diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 000000000..4d2a55e7c
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,16 @@
+# EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs
+# Docs: http://editorconfig.org
+
+# For Atom: https://atom.io/packages/editorconfig
+# For Sublime: https://github.com/sindresorhus/editorconfig-sublime
+# For WebStorm: Natively supported
+
+root = true
+
+[*]
+indent_style = tab
+indent_size = 2
+trim_trailing_whitespace = true
+insert_final_newline = true
+end_of_line = lf
+charset = utf-8
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 000000000..f0bae429e
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,38 @@
+# Force all line endings to be \n
+* text eol=lf
+
+############################################################
+# git can corrupt binary files if they're not set to binary.
+############################################################
+
+# Image files
+*.png binary
+*.jpg binary
+*.jpeg binary
+*.gif binary
+*.webp binary
+*.ico binary
+
+# Movie and audio files
+*.mov binary
+*.mp4 binary
+*.mp3 binary
+*.flv binary
+*.ogg binary
+
+# Compression formats
+*.gz binary
+*.bz2 binary
+*.7z binary
+*.zip binary
+
+# Web fonts
+*.ttf binary
+*.eot binary
+*.woff binary
+*.otf binary
+
+# Other
+*.fla binary
+*.swf binary
+*.pdf binary
diff --git a/.gitignore b/.gitignore
index 9dba5d8f9..6d852fa26 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,17 +1,27 @@
-.DS_Store
-build/output/
-build/tmp/
-tests/_SpecRunner.html
-tests/.grunt/
-docs/**/
-*TMP*
+# Packages
node_modules/
+
+# JetBrains
.idea/
+
+# Sublime Text
*.sublime-project
*.sublime-workspace
-config.local.json
-*[\<\>\:\"\/\\\|\?\*]*
-npm-debug.log
-build/.sass-cache
-main.css
+# Atom
+.atom/
+
+# VSCode
+.vscode/
+
+# OS
+.DS_Store
+Thumbs.db
+
+# Generated
+docs/
+tests/coverage/
+tests/debug/
+
+# Other
+*.log
diff --git a/.npmignore b/.npmignore
new file mode 100644
index 000000000..ef94d1ab4
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1,29 @@
+# JetBrains
+.idea/
+
+# Sublime Text
+*.sublime-project
+*.sublime-workspace
+
+# Atom
+.atom/
+
+# VSCode
+.vscode/
+
+# OS
+.DS_Store
+Thumbs.db
+
+# Other
+*.log
+
+# Project
+assets/
+docs/
+examples/
+extras/
+tests/
+tutorials/
+.editorconfig
+CONTRIBUTING.md
diff --git a/VERSIONS.txt b/CHANGELOG.md
similarity index 98%
rename from VERSIONS.txt
rename to CHANGELOG.md
index d35fbf751..ea64f239b 100644
--- a/VERSIONS.txt
+++ b/CHANGELOG.md
@@ -1,505 +1,513 @@
-Version NEXT [Not Released]
-****************************************************************************************************
-
-
-Version 0.8.2 [November 26, 2015]
-****************************************************************************************************
-CRITICAL (may break existing content):
-- MovieClip has been added to the minified EaselJS source. The movieclip minified script has been removed.
-
-*****
-OTHER:
-- fixed compositeOperation value in DisplayProps.setValues (thanks @fumio)
-- documentation updates
-- upgraded tutorials to the latest EaselJS version, including content updates
-- fixed the SpriteSheetBuilder to support both SpriteSheet framerate and speed (instead of frequency)
-- fixed ignoreScale support in Graphic StrokeStyle command
-- bower updates: Removed bower.json from excludes
-- updated ScaleBitmap extra to the new extend/promote approach
-- changed SpriteSheet Array checks from instanceof to Array.isArray()
-- added StrokeDash support to SVGExporter
-- fixed issue with SVGExporter when the first lineTo has a zero-value for x or y
-- added image error handling to SpriteSheet
-- Grunt updates: Added shortcut "next" task
-
-
-Version 0.8.1 [May 21, 2015]
-****************************************************************************************************
-CRITICAL (may break existing content):
-- Graphics.command now returns null after empty fill / stroke calls.
-- dispatchEvent now returns false instead of true to indicate an event had preventDefault called (DOM level 2 compatibility)
-- cursor is now inherited properly (cursors on children override parents)
-
-*****
-OTHER:
-- added Graphics.StrokeDash and Graphics.setStrokeDash()
-- Graphics no longer appends redundant StrokeStyle commands
-- fixed an issue with preventDefault not working with drawstart and tickstart events
-- added bubbles and cancelable params to EventDispatcher.dispatchEvent()
-- reintroduced Sprite.initialize() for now, to support FlashCC spritesheet export
-- fixed an issue with stroke dash not being reset properly on Graphics.clear()
-- bitmap fills no longer throw RTEs when targeting an unloaded image
-- Sprite constructor now accepts 0 as frameOrAnimation param
-- added MouseEvent.relatedTarget
-- improved handling of Bitmap load errors
-- fixed Rectangle.pad
-- fixed issues with buttons playing on reset
-- added totalframes property and getDuration method to MovieClip
-
-
-Version 0.8.0 [December 12, 2014]
-****************************************************************************************************
-CRITICAL (may break existing content):
-- modified behaviour of SpriteSheetBuilder.addFrame setupFunction, setupParams & setupScope params
-- removed the deprecated mousemove & mouseup events on MouseEvent
-- removed Graphics.inject() in favour of Graphics.append()
-- Sprite now properly displays the first frame of animations after calling gotoAndPlay() (thanks MannyC)
-- Moved Ticker into the "createjs" package since it will be included with TweenJS in future releases.
-- re-architected the class and inheritance model
- - initialize methods removed, use MySuperClass_constructor instead
- - helper methods: extend & promote (see the "Utility Methods" docs)
- - property definitions are now instance level, and in the constructor (performance gains)
- - the .constructor is now set correctly on all classes (thanks kaesve)
-- renamed initialize on geom classes to "setValues()"
-- removed secondary properties (visible, alpha, compositeOperation, shadow) and related functionality from Matrix2D
- - added DisplayProps to hold these properties + a matrix instance
-- Matrix2D was updated to be internally consistent with regards to matrix orientation
- - Matrix2D transform methods (ex. translate, rotate) now behave as append instead of prepend operations
-- renamed ColorMatrix.copyMatrix() to .copy() to reflect geom classes
-
-*****
-DEPRECATED (will be removed in a future version):
-- Container.getNumChildren() in favour of Container.numChildren
-- DisplayObject.getStage() in favour of DisplayObject.stage
-- Graphics.getInstructions() in favour of Graphics.instructions
-- MovieClip.getLabels() in favour of MovieClip.labels
-- MovieClip.getCurrentLabel() in favour of MovieClip.currentLabel
-- SpriteSheet.getAnimations() in favour of SpriteSheet.animations
-- Ticker.getInterval() in favour of Ticker.interval
-- Ticker.getFPS() in favour of Ticker.framerate
-- Ticker.getPaused() / setPaused() in favour of Ticker.paused
-
-***********
-PERFORMANCE:
-- added performance tests to extras
-- significant performance improvements:
- - vector graphics (especially in Graphics instances with large numbers of instructions)
- - filters (thanks pfirpfel & quasimondo) (~2-4x faster)
- - overall display list performance (~2x faster)
- - display object property access (~2x faster)
- - tick event propagation (~3x faster)
-
-*****
-OTHER:
-- replaced a number of get/set methods with getter / setters. See the DEPRECATED section above for a list.
-- added setupFunction, setupData, labelFunction to SpriteSheetBuilder.addMovieClip
-- added SpriteStage & SpriteContainer for WebGL rendering
-- changes to how BitmapText works to support WebGL
-- added WebGL examples
-- added .visible to Matrix2D for use by DOMElement
-- updates to how DisplayObject.snapToPixel & Stage.snapToPixelEnabled interact
-- major improvements to Stage.nextStage to better handle layered canvases
-- ButtonHelper now sets mouseChildren to false, and reverts to default cursor when disabled
-- fixed issue introduced in 0.7.1 where getObjectsUnderPoint ignore elements without mouse listeners
-- doc updates
-- fixed example formatting in docs
-- simplified handling of custom data passed into Stage.update()
-- display object tick events will now include delta, time, paused, and runTime properties if a Ticker tick event object is passed as the first param to Stage.update()
-- added Stage.tick()
-- added Event.set()
-- added MovieClip.framerate and support for time based movieclips
-- Added Bower support, including grunt task for automatically updating bower.json
-- fixed an issue with Ticker.reset()
-- Ticker.getTime()/getEventTime() now return -1 if the Ticker has not been initialized
-- preventDefault support added to the tickstart and drawstart events
-- added Stage.drawRect to support selective rendering
-- major rewrite of Graphics to use specific command objects
-- added Graphics.getInstructions()
-- added Text.getMetrics()
-- fix for Text.getMeasuredWidth() when no font or an invalid font is specified
-- fix for spritesheets that included 0 width/height frames
-- the CreateJS CDN now supports https / SSL
-- improved how Sprite handles sequencing between animations with different speed values
-- added "change" event to Sprite
-- added "added" and "removed" events to DisplayObject
-- added the extras folder, with: SVGExport, Context2DLog, and PerformanceTests
-- added Graphics.store() / unstore()
-- examples now all use the combined lib
-- SpriteSheet.getNumFrames() now returns 0 instead of null if images are not loaded.
-- added some initial unit tests for the library
-- added helper methods to Rectangle: union, intersects, extend, intersection, pad, isEmpty, & contains.
-- updated clone() method for all classes
-- added Matrix2D.equals() method
-- added DisplayObject.transformMatrix
-- mouse interactions and getObjectsUnderPoint now respect masks
-- added a mode param to getObjectsUnderPoint() to respect mouseEnabled/mouseChildren and event listeners
-- added Stage.preventSelection to block accidental selection of document elements
-- added `pt` param to DisplayObject.localToGlobal, globalToLocal, and localToLocal methods
-- BlurFilter provides higher quality results (thanks quasimondo)
-- added MouseEvent.isTouch
-- added support for margin and spacing in sprite sheet data (thanks renatopp)
-
-
-Version 0.7.1 [December 12, 2013]
-****************************************************************************************************
-- fixed issue with mouseChildren not working with nested Containers
-- fixed issue where first call to Ticker.addEventListener() did not return the listener
-- added DisplayObject.tickEnabled & Container.tickChildren
-- fixed an issue related to modal dialogs and pointer position for mouse down
-- fixed an issue when calling gotoAndStop(animation) in the animationend event stack for the same animation
-- ColorMatrix no longer extends Array
-- fixed ColorMatrix.toArray(), .concat(), and .clone()
-- changed dblclick to use a canvas listener instead of global listener
-- added MouseEvent.localX/Y
-- fixed touch/multitouch in IE11
-- fixed issue with -1 mouse pointers (thanks cubica)
-- fixed issue with AlphaMapFilter (thanks Dave)
-- added willTrigger() to EventDispatcher
-- modified mouse event flow so items with no listeners are not checked for a hitTest.
- - avoids unnecessary cross-domain issues introduced in EaselJS 0.7.0, when loaded images don't have any mouse listeners on them.
-- getObjectsUnderPoint() and getObjectUnderPoint() now account for hitAreas
-
-
-Version 0.7.0 [September 25, 2013]
-****************************************************************************************************
-CRITICAL (may break existing content):
-- removed all onEvent handlers (ex. onClick, onTick, onAnimationEnd, etc)
-- removed Ticker.addListener and .removeListener
-- most mouse events now bubble
-- BitmapAnimation renamed to Sprite
-- MouseEvent now inherits from new Event class
-- sprite sheet data's animation .frequency property removed in favour of .speed
-- removed "target" from MouseEvent's param list
-- returning false from an event handler no longer causes dispatchEvent to return false, see Event.preventDefault
-- Added "use strict"; to everything.
-- renamed BoxBlurFilter to BlurFilter
-
-*****
-DEPRECATED (will be removed in a future version):
-- MouseEvent mousemove/mouseup events, see DisplayObject pressmove/pressup
-- SpriteSheetUtils.flip()
-- SpriteSheetUtils.mergeAlpha()
-
-*****
-OTHER:
-- implemented createjs Utils
-- implemented "use strict" mode
-- BitmapAnimation renamed to Sprite
-- renamed the "frequency" property in sprite sheet data to "speed" and changed functionality:
- * support for non-integer values
- * inverted outcome vs frequency. Ex. a "speed" value of 2 doubles playback speed, 0.5 halves it
-- added Sprite.framerate and SpriteSheet.framerate
-- added frameOrAnimation param to Sprite constructor
-- deprecated Sprite.offset (no longer functional)
-- added Ticker.timingMode and deprecated Ticker.useRAF
- * added Ticker.TIMEOUT, Ticker.RAF, Ticker.RAF_SYNCHED timing mode constants
-- added Ticker.getMeasuredTickTime()
-- Ticker now does not automatically init until a listener is added to it
-- added Ticker.reset()
-- added Stage.nextStage to relay interaction events
-- added Graphics.inject()
-- added Text.getMeasuredHeight()
-- fixes and improvements to Touch support
-- fixed setChildIndex when adding to an index lower than the item exists at already.
-- added Graphics.Command
-- merged lots of doc updates (thanks @peteshand)
-- lots of doc, example, & tutorial updates
-- included MouseEvent.nativeEvent for mouseover/out events
-- added rollover / rollout events to DisplayObject
-- prevented mouseover/out and rollover/out events from triggering if the mouse is not over the canvas
- * ex. within a scrolling div or DOM element layered over top
-- added pressmove / pressup events to DisplayObject
-- added Matrix2D.transformPoint() method
-- fixed an issue when adding the same listener to an event twice
-- added Event class, used by all events
-- MouseEvent inherits from new Event class
-- added .on and .off methods to EventDispatcher
-- fixed an issue with extending EventDispatcher
-- DisplayObject, SpriteSheet, and SpriteSheetBuilder now inherit from EventDispatcher
-- fixed an issue with the tick event's time value being epoch time instead of Timer time
-- added Ticker.getEventTime()
-- added Ticker.maxDelta
-- the initialize methods for Point, Rectangle, and Matrix2D are now public
-- added .copy() to Point, Rectangle, and Matrix2D
-- fixed an issue that could occur when reinitializing Matrix2D
-- added MovieClip.frameBounds
-- fixed errors when the lib was loaded in a browser with no canvas support (ex. IE8)
-- added support for .next on single frame spritesheet animations
-- added the BitmapText class
-- improved DOMElement redraw handling to avoid flicker and layout costs
-- added Stage mouseleave and mouseenter events
-- added tickstart, tickend, drawstart, and drawend events to Stage
-- added getBounds() functionality for all display objects
-- added MovieClip.getLabels() & getCurrentLabel()
-- Filter.getBounds() now returns null as its default value
-- bounds for cache() are now automatically adjusted for filters
-- improved BlurFilter performance and results (thanks to Mario Klingemann)
-- objects added to a MovieClip via addChild will now display over objects managed by the MovieClip
-- Fixed clone on AlphaMapFilter
-- Updated the build process to use NodeJS & Grunt.js. Please refer to the README in the build folder.
-
-
-Version 0.6.1 [May 14, 2013]
-****************************************************************************************************
-- Updated demos:
- * propagate the tick event to the stage. This is a best practice.
- * Added AlphaMaskFilter demo.
- * Added a "Graphics Winding" demo
- * Added Safari note to the Cache demo
-- Updated documentation:
- * Added lots more examples.
- * Matrix2D.rotate
- * Matrix2D.tx named incorrectly
- * Stage.stagemousedown event (stagemouseup was doc'd twice)
- * DisplayObject.dblclick (case incorrect)
- * Fixed example in Stage documentation (incorrect)
- * Fixed example in Text documentation (missing quote)
- * Fixed updateContext method name in docs (was incorrectly set to "setupContext")
- * Added sample code to MovieClip documentation, and a MovieClip example.
- * Added optional parameters to MovieClip constructor
- * Updated description of DisplayObject.mouseEnabled
- * Fixed setPaused/getPaused descriptions in Ticker, and added some better descriptions, a few examples, and updated
- documentation throughout.
- * Updated SpriteSheetUtils/extractFrame documentation to mention Bitmap/sourceRect and security concerns
- * Updated Bitmap/cache methods to clarify caching usage for Bitmaps
- * Updated optional parameter for DisplayObject/cache
- * Added initial example in EaselJS to show interaction
-- Modified EventDispatcher to avoid unnecessary instanceof and apply
-- Replaced the width=0 hack (for clearing canvases) with a setTransform/clearRect in DisplayObject,
- Container, and SpriteSheetUtils.
-- Updated clearRect usages to use +1 on width and height to prevent crashes on Android (thanks mikelito)
-- Fixed Matrix2D.scale method to properly apply scale when rotated (thanks fumio)
-- Fixed bug with mouse and touch events in iOS's UIWebView (thanks cubica)
-
-
-Version 0.6.0 [Feb 12, 2013]
-****************************************************************************************************
-- added new event model with EventDispatcher class
-- added DisplayObject.cursor property
-- added Container.getChildByName() method
-- added ButtonHelper class
-- fixed error with AlphaMaskFilter
-- hitArea position now ignores the regX/Y of the target instance
-- added Log class to provide verbose errors while debugging
-- simplified & updated MovieClipPlugin to work with revised TweenJS plugin model
-- added DisplayObject.set() shortcut method
-- added MovieClip.autoReset property
-- added Graphics.isEmpty() method
-- improved support for empty masks
-- added SpriteSheetBuilder.progress
-- added SpriteSheetBuilder.timeSlice
-- removed the callback param on SpriteSheetBuilder.buildAsync, replaced with .onComplete
-- added SpriteSheetBuilder.onComplete and .onProgress
-- fixes for various MovieClip bugs
-- SpriteSheetBuilder now works correctly when adding more than one MovieClip
-- fixed an issue with SpriteSheetBuilder defining frames that exceeded the image bounds
-- added SpriteSheet.getFrameBounds()
-- added BitmapAnimation.getBounds()
-- added closePath support to Graphics.decodePath()
-- changed how animationEnd events are fired, to support calling stop() in the handler
-- animationEnd events now include a "next" value with the name of the next animation
-- event types for MouseEvents now follow DOM standards (mousedown, click, dblclick etc)
-- improved hitArea handling
-- added version.js
-- added MovieClip.currentFrame
-- documentation updates
-- new and improved build process, tools & documentation format
-- added Stage.enableDOMEvents() method
-- added default Stage.handleEvent() for integration with Ticker and new event model
-- deprecated Stage.snapToPixel API
-- added Graphics.ignoreScale API
-- added a matrix parameter to Graphics.beginBitmapFill
-
-
-Version 0.5.0 [Aug 24, 2012]
-****************************************************************************************************
-- moved all classes into a configurable createjs namespace
-- added support for multitouch
-- complete rewrite of drawing model to use a hybrid approach (save/restore & matrix)
-- added DisplayObject.mask
-- added Graphics.drawAsPath(ctx)
-- added Text.getMeasuredHeight()
-- added DisplayObject.updateContext(ctx)
-- added DisplayObject.getMatrix(matrix)
-- added DisplayObject.hitArea
-- fixed issue with Text not displaying if .text is 0 or false
-- fix for setChildIndex
-- fix for addChildAt with multiple params
-- added SpriteSheetBuilder
-- added MovieClip.actionsEnabled
-- updates to Ticker to improve support for requestAnimationFrame
-- better support for negative corner values on .drawRoundRectComplex
-- added stage.mouseMoveOutside & mouseEvent.rawX/Y
-- added "createjs.createCanvas()" to support for alternative canvases (ex. exCanvas)
-- added "scale" parameter to cache() and cleaned up the implementation
-- fix for DOMElement with Opera
-- various bug fixes and doc updates
-- changed setTransform to return the instance for use in chaining
-- started adding tutorials to address common questions and make it easier to get started
-- stage.mouseX/Y now defaults to 0 instead of null
-- text.textBaseline now defaults to "top" instead of null (resolved to "alphabetic")
-- text.textAlign now defaults to "left" instead of null
-- text.color now defaults to "#000" instead of null
-- parameters passed to Stage.update are now passed on to onTick handlers
- - for example, Ticker elapsedTime and paused params
-- correctly resolves mouse positions for CSS scaled canvases & canvases with borders/padding
-- added AlphaMapFilter & AlphaMaskFilter
-- added Touch.disable(stage)
-
-
-Version 0.4.2 [Apr 18, 2012]
-****************************************************************************************************
-- hot fix for issues with Ticker that caused reduced frame rates.
-- NO API CHANGES
-
-
-Version 0.4.1 [Apr 14, 2012]
-****************************************************************************************************
-- DisplayObject.tick has been renamed to onTick
-- fixed a problem with preloading sprite sheet images when using tile based sheets
-- worked around a bug in Safari with addFlippedFrames
-- added setChildIndex(), swapChildrenAt(), and swapChildren() to Container
-- made frequency param on enableMouseOver optional
-- worked around a Chrome 17 bug that would prevent text w/o maxwidth from rendering
-- additional fixes for video as a Bitmap source
-- rewrite of Ticker to simplify implementation and solve issues with useRAF in Safari
-- animations in BitmapAnimation now default to looping
-- added BitmapAnimation.play/stop()
-- added Bitmap.sourceRect
-- Ticker now supports an object with a tick method, or a function as a listener
-- renamed DisplayObject.tick to .onTick
-- added MovieClip class
-- added onComplete to SpriteSheet
-- added ColorMatrix class
-- added Graphics.decodePath for compressed vector paths
-- support for passing a canvas string id to the Stage constructor
-- various bug fixes and doc updates
-- updateCache now clears the cacheCanvas correctly
-
-
-Version 0.4 [Nov 30, 2011]
-****************************************************************************************************
-- completely rewrote BitmapSequence (now BitmapAnimation) & SpriteSheet including data format
- - BitmapSequence was renamed BitmapAnimation
- - SpriteSheet now handles calculating frame rects
- - support for multi-image sprite sheets
- - support for variable frame sizes
- - support for frame reuse (non-linear frame order)
- - support for frame registration points
- - SpriteSheet supports URIs as sources (and will handle preloading)
-- rewrote SpriteSheetUtils to support SpriteSheet changes
- - renamed .flip() to .addFlippedFrames() and changed functionality significantly
- - removed .frameDataToString()
-- fixed support for video sources in Bitmap
-- added support for null canvas for Stage
-- added DOMElement, an experimental display object for including DOM elements in the display list
-- separated tick and draw into separate phases to fix possible race conditions
-- added Matrix2D.isIdentity()
-- support for double click events (thanks to rbarazi)
-- added MouseEvent.nativeEvent and MouseEvent.target properties
-- fixes to Ticker, added second "paused" param when it calls tick
-- added experimental support for requestAnimationFrame to Ticker
-- fixed a problem with caching Container instances
-- fixed an issue with .parent not being assigned on children of cloned Containers
-- added filter support via DisplayObject.filters and Filter objects
- - added sample filters: ColorFilter, ColorMatrixFilter, and BoxBlurFilter
-- added DisplayObject.setTransform()
-- added DisplayObject.onDoubleClick handler (thanks to rbarazi)
-- added DisplayObject.cacheID and DisplayObject.getCacheDataURL()
-- performance optimization for DisplayObject drawing (6910e6849856bd0740f8)
-- added support for touch input (single point) via the Touch class
-- added support for passing an image URI to the Bitmap constructor
-- fixes to Shadow
-- optimizations
-- documentation updates
-
-
-Version 0.3.2 [Mar 2, 2011]
-****************************************************************************************************
-- added stage.mouseInBounds
-- added DisplayObject.onMouseOver and onMouseOut callbacks
-- added stage.enableMouseOver(freq)
-- improved support for calculating mouseX/Y in divs with relative positioning
-- fixed Graphics.clone()
-- fixed an issue with shadows not being reset properly
-- migrated to use YUIDocs instead of JSDocs
-- fixed an issue that prevented BitmapSequence instances with frameData from working with gotoAndPlay(frameNumber)
-
-
-Version 0.3.1 [Feb 13, 2011]
-****************************************************************************************************
-- fixed issues with hitTest and mouse event callbacks on Container instances.
-- added recursive clone option to Container and Shape
-- fix for snapToPixel
-- added cache, updateCache, and HelloWorld demos
-- extensive code cleanup, including improved support for jsdoc
-
-
-Version 0.3 [Feb 8, 2011]
-****************************************************************************************************
-- renamed Tick to Ticker
-- adding a listener to Ticker twice will now move it to the end of the listener list
-- added Ticker.getMeasuredFPS()
-- added Ticker.setFPS()
-- renamed Stage.tick to Stage.update and made Stage.tick point to Stage.update
-- made the pauseable param "true" by default on Ticker.addListener()
-- added Stage.toDataURL(backgroundColor, mimeType)
-- renamed Rectangle.w/h to width/height
-- improvements to commenting and documentation
-- formalized inheritance model to make code more readable
-- changed color to null instead of 0 in Shadow.IDENTITY
-- fixed an error with simple sprite sheets that weren't set to loop
-- implemented "tiny" instructions for Graphics. (ex. myGraphics.f("#0FF").c(x,y,r) )
-- fixed problems with Graphics.clone()
-- fixed bug with passing instructions to a Graphics object constructor
-- complete rewrite of the render engine to be cleaner and more flexible
-- added .decompose() method to Matrix2D
-- added .skew() method to Matrix2D
-- added .skewX/Y on DisplayObject
-- added SpriteSheetUtils.extractFrame(spriteSheet,frame) method
-- added basic multi-line support for Text
-- added DisplayObject.suppressCrossDomainErrors property
-- complete rewrite of the hit testing system to be cleaner and run 5-10x faster
-- improved the interaction model:
- - added .onPress, .onClick callbacks on DisplayObject
- - removed .mouseChildren from Container
- - made .mouseEnabled true by default
- - added .onMouseDown, .onMouseUp, and .onMouseMove callbacks on Stage
- - added MouseEvent
-- Stage.getObjectsUnderPoint() has been moved to Container
-- added Container.contains(child) method
-- added DisplayObject.compositeOperation
-- added appendProperties() and prependProperties methods to Matrix2D
-- added DisplayObject.hitTest() method
-- added stage.snapToPixelEnabled and displayObject.snapToPixel
-- added DisplayObject.updateCache()
-- renamed minified file from easeljs.js to easel.js
-- Re-factored directory layout
-
-
-Version 0.2.1 [Jan 12, 2011]
-****************************************************************************************************
-- optimized Graphics: reduced overhead by 80-90%
-- added drawPolyStar method to Graphics
-- fixed bug with using canvas as an image source for Bitmap
-- made mouseChildren true by default for stage
-- fixed major bug with Ticker.getTime()
-
-
-Version 0.2 [Jan 6, 2011]
-****************************************************************************************************
-Focus on vector graphics and text.
-- repackaged all class files to "easeljs" instead of "com.gskinner"
-- added Graphics API, and revised Shape to use a Graphics instance
-- added Text class
-- added Point class and updated CoordTransform to use it
-- added Rectangle class
-- fixed minor issue with Ticker
-- added initial implementation of Stage.mouseX/Y (likely to change)
-- added new examples, updated others to work with revised APIs
-- minor tweaks, fixes to code and documentation
-- added support for multiple params on Container.addChild, addChildAt, removeChild & removeChildAt
-
-Version 0.1 [Dec 17, 2010]
-****************************************************************************************************
-Initial release.
+Version NEXT [Not Released]
+****************************************************************************************************
+CRITICAL (may break existing content):
+- Codebase ported to ES6 and transpiled to ES5 with Babel. Multiple build formats are provided (global, CommonJS, ES6).
+
+*****
+OTHER:
+- Build process converted from Grunt to Gulp
+- Build process and shared files (Event, EventDispatcher, Ticker) moved to external repository which is a devDependency of this one.
+- WebGL is no longer a plugin, it has been fully integrated. WebGL will be leveraged by BitmapCache if support is found.
+
+
+Version 0.8.2 [November 26, 2015]
+****************************************************************************************************
+CRITICAL (may break existing content):
+- MovieClip has been added to the minified EaselJS source. The movieclip minified script has been removed.
+
+*****
+OTHER:
+- fixed compositeOperation value in DisplayProps.setValues (thanks @fumio)
+- documentation updates
+- upgraded tutorials to the latest EaselJS version, including content updates
+- fixed the SpriteSheetBuilder to support both SpriteSheet framerate and speed (instead of frequency)
+- fixed ignoreScale support in Graphic StrokeStyle command
+- bower updates: Removed bower.json from excludes
+- updated ScaleBitmap extra to the new extend/promote approach
+- changed SpriteSheet Array checks from instanceof to Array.isArray()
+- added StrokeDash support to SVGExporter
+- fixed issue with SVGExporter when the first lineTo has a zero-value for x or y
+- added image error handling to SpriteSheet
+- Grunt updates: Added shortcut "next" task
+
+
+Version 0.8.1 [May 21, 2015]
+****************************************************************************************************
+CRITICAL (may break existing content):
+- Graphics.command now returns null after empty fill / stroke calls.
+- dispatchEvent now returns false instead of true to indicate an event had preventDefault called (DOM level 2 compatibility)
+- cursor is now inherited properly (cursors on children override parents)
+
+*****
+OTHER:
+- added Graphics.StrokeDash and Graphics.setStrokeDash()
+- Graphics no longer appends redundant StrokeStyle commands
+- fixed an issue with preventDefault not working with drawstart and tickstart events
+- added bubbles and cancelable params to EventDispatcher.dispatchEvent()
+- reintroduced Sprite.initialize() for now, to support FlashCC spritesheet export
+- fixed an issue with stroke dash not being reset properly on Graphics.clear()
+- bitmap fills no longer throw RTEs when targeting an unloaded image
+- Sprite constructor now accepts 0 as frameOrAnimation param
+- added MouseEvent.relatedTarget
+- improved handling of Bitmap load errors
+- fixed Rectangle.pad
+- fixed issues with buttons playing on reset
+- added totalframes property and getDuration method to MovieClip
+
+
+Version 0.8.0 [December 12, 2014]
+****************************************************************************************************
+CRITICAL (may break existing content):
+- modified behaviour of SpriteSheetBuilder.addFrame setupFunction, setupParams & setupScope params
+- removed the deprecated mousemove & mouseup events on MouseEvent
+- removed Graphics.inject() in favour of Graphics.append()
+- Sprite now properly displays the first frame of animations after calling gotoAndPlay() (thanks MannyC)
+- Moved Ticker into the "createjs" package since it will be included with TweenJS in future releases.
+- re-architected the class and inheritance model
+ - initialize methods removed, use MySuperClass_constructor instead
+ - helper methods: extend & promote (see the "Utility Methods" docs)
+ - property definitions are now instance level, and in the constructor (performance gains)
+ - the .constructor is now set correctly on all classes (thanks kaesve)
+- renamed initialize on geom classes to "setValues()"
+- removed secondary properties (visible, alpha, compositeOperation, shadow) and related functionality from Matrix2D
+ - added DisplayProps to hold these properties + a matrix instance
+- Matrix2D was updated to be internally consistent with regards to matrix orientation
+ - Matrix2D transform methods (ex. translate, rotate) now behave as append instead of prepend operations
+- renamed ColorMatrix.copyMatrix() to .copy() to reflect geom classes
+
+*****
+DEPRECATED (will be removed in a future version):
+- Container.getNumChildren() in favour of Container.numChildren
+- DisplayObject.getStage() in favour of DisplayObject.stage
+- Graphics.getInstructions() in favour of Graphics.instructions
+- MovieClip.getLabels() in favour of MovieClip.labels
+- MovieClip.getCurrentLabel() in favour of MovieClip.currentLabel
+- SpriteSheet.getAnimations() in favour of SpriteSheet.animations
+- Ticker.getInterval() in favour of Ticker.interval
+- Ticker.getFPS() in favour of Ticker.framerate
+- Ticker.getPaused() / setPaused() in favour of Ticker.paused
+
+***********
+PERFORMANCE:
+- added performance tests to extras
+- significant performance improvements:
+ - vector graphics (especially in Graphics instances with large numbers of instructions)
+ - filters (thanks pfirpfel & quasimondo) (~2-4x faster)
+ - overall display list performance (~2x faster)
+ - display object property access (~2x faster)
+ - tick event propagation (~3x faster)
+
+*****
+OTHER:
+- replaced a number of get/set methods with getter / setters. See the DEPRECATED section above for a list.
+- added setupFunction, setupData, labelFunction to SpriteSheetBuilder.addMovieClip
+- added SpriteStage & SpriteContainer for WebGL rendering
+- changes to how BitmapText works to support WebGL
+- added WebGL examples
+- added .visible to Matrix2D for use by DOMElement
+- updates to how DisplayObject.snapToPixel & Stage.snapToPixelEnabled interact
+- major improvements to Stage.nextStage to better handle layered canvases
+- ButtonHelper now sets mouseChildren to false, and reverts to default cursor when disabled
+- fixed issue introduced in 0.7.1 where getObjectsUnderPoint ignore elements without mouse listeners
+- doc updates
+- fixed example formatting in docs
+- simplified handling of custom data passed into Stage.update()
+- display object tick events will now include delta, time, paused, and runTime properties if a Ticker tick event object is passed as the first param to Stage.update()
+- added Stage.tick()
+- added Event.set()
+- added MovieClip.framerate and support for time based movieclips
+- Added Bower support, including grunt task for automatically updating bower.json
+- fixed an issue with Ticker.reset()
+- Ticker.getTime()/getEventTime() now return -1 if the Ticker has not been initialized
+- preventDefault support added to the tickstart and drawstart events
+- added Stage.drawRect to support selective rendering
+- major rewrite of Graphics to use specific command objects
+- added Graphics.getInstructions()
+- added Text.getMetrics()
+- fix for Text.getMeasuredWidth() when no font or an invalid font is specified
+- fix for spritesheets that included 0 width/height frames
+- the CreateJS CDN now supports https / SSL
+- improved how Sprite handles sequencing between animations with different speed values
+- added "change" event to Sprite
+- added "added" and "removed" events to DisplayObject
+- added the extras folder, with: SVGExport, Context2DLog, and PerformanceTests
+- added Graphics.store() / unstore()
+- examples now all use the combined lib
+- SpriteSheet.getNumFrames() now returns 0 instead of null if images are not loaded.
+- added some initial unit tests for the library
+- added helper methods to Rectangle: union, intersects, extend, intersection, pad, isEmpty, & contains.
+- updated clone() method for all classes
+- added Matrix2D.equals() method
+- added DisplayObject.transformMatrix
+- mouse interactions and getObjectsUnderPoint now respect masks
+- added a mode param to getObjectsUnderPoint() to respect mouseEnabled/mouseChildren and event listeners
+- added Stage.preventSelection to block accidental selection of document elements
+- added `pt` param to DisplayObject.localToGlobal, globalToLocal, and localToLocal methods
+- BlurFilter provides higher quality results (thanks quasimondo)
+- added MouseEvent.isTouch
+- added support for margin and spacing in sprite sheet data (thanks renatopp)
+
+
+Version 0.7.1 [December 12, 2013]
+****************************************************************************************************
+- fixed issue with mouseChildren not working with nested Containers
+- fixed issue where first call to Ticker.addEventListener() did not return the listener
+- added DisplayObject.tickEnabled & Container.tickChildren
+- fixed an issue related to modal dialogs and pointer position for mouse down
+- fixed an issue when calling gotoAndStop(animation) in the animationend event stack for the same animation
+- ColorMatrix no longer extends Array
+- fixed ColorMatrix.toArray(), .concat(), and .clone()
+- changed dblclick to use a canvas listener instead of global listener
+- added MouseEvent.localX/Y
+- fixed touch/multitouch in IE11
+- fixed issue with -1 mouse pointers (thanks cubica)
+- fixed issue with AlphaMapFilter (thanks Dave)
+- added willTrigger() to EventDispatcher
+- modified mouse event flow so items with no listeners are not checked for a hitTest.
+ - avoids unnecessary cross-domain issues introduced in EaselJS 0.7.0, when loaded images don't have any mouse listeners on them.
+- getObjectsUnderPoint() and getObjectUnderPoint() now account for hitAreas
+
+
+Version 0.7.0 [September 25, 2013]
+****************************************************************************************************
+CRITICAL (may break existing content):
+- removed all onEvent handlers (ex. onClick, onTick, onAnimationEnd, etc)
+- removed Ticker.addListener and .removeListener
+- most mouse events now bubble
+- BitmapAnimation renamed to Sprite
+- MouseEvent now inherits from new Event class
+- sprite sheet data's animation .frequency property removed in favour of .speed
+- removed "target" from MouseEvent's param list
+- returning false from an event handler no longer causes dispatchEvent to return false, see Event.preventDefault
+- Added "use strict"; to everything.
+- renamed BoxBlurFilter to BlurFilter
+
+*****
+DEPRECATED (will be removed in a future version):
+- MouseEvent mousemove/mouseup events, see DisplayObject pressmove/pressup
+- SpriteSheetUtils.flip()
+- SpriteSheetUtils.mergeAlpha()
+
+*****
+OTHER:
+- implemented createjs Utils
+- implemented "use strict" mode
+- BitmapAnimation renamed to Sprite
+- renamed the "frequency" property in sprite sheet data to "speed" and changed functionality:
+ * support for non-integer values
+ * inverted outcome vs frequency. Ex. a "speed" value of 2 doubles playback speed, 0.5 halves it
+- added Sprite.framerate and SpriteSheet.framerate
+- added frameOrAnimation param to Sprite constructor
+- deprecated Sprite.offset (no longer functional)
+- added Ticker.timingMode and deprecated Ticker.useRAF
+ * added Ticker.TIMEOUT, Ticker.RAF, Ticker.RAF_SYNCHED timing mode constants
+- added Ticker.getMeasuredTickTime()
+- Ticker now does not automatically init until a listener is added to it
+- added Ticker.reset()
+- added Stage.nextStage to relay interaction events
+- added Graphics.inject()
+- added Text.getMeasuredHeight()
+- fixes and improvements to Touch support
+- fixed setChildIndex when adding to an index lower than the item exists at already.
+- added Graphics.Command
+- merged lots of doc updates (thanks @peteshand)
+- lots of doc, example, & tutorial updates
+- included MouseEvent.nativeEvent for mouseover/out events
+- added rollover / rollout events to DisplayObject
+- prevented mouseover/out and rollover/out events from triggering if the mouse is not over the canvas
+ * ex. within a scrolling div or DOM element layered over top
+- added pressmove / pressup events to DisplayObject
+- added Matrix2D.transformPoint() method
+- fixed an issue when adding the same listener to an event twice
+- added Event class, used by all events
+- MouseEvent inherits from new Event class
+- added .on and .off methods to EventDispatcher
+- fixed an issue with extending EventDispatcher
+- DisplayObject, SpriteSheet, and SpriteSheetBuilder now inherit from EventDispatcher
+- fixed an issue with the tick event's time value being epoch time instead of Timer time
+- added Ticker.getEventTime()
+- added Ticker.maxDelta
+- the initialize methods for Point, Rectangle, and Matrix2D are now public
+- added .copy() to Point, Rectangle, and Matrix2D
+- fixed an issue that could occur when reinitializing Matrix2D
+- added MovieClip.frameBounds
+- fixed errors when the lib was loaded in a browser with no canvas support (ex. IE8)
+- added support for .next on single frame spritesheet animations
+- added the BitmapText class
+- improved DOMElement redraw handling to avoid flicker and layout costs
+- added Stage mouseleave and mouseenter events
+- added tickstart, tickend, drawstart, and drawend events to Stage
+- added getBounds() functionality for all display objects
+- added MovieClip.getLabels() & getCurrentLabel()
+- Filter.getBounds() now returns null as its default value
+- bounds for cache() are now automatically adjusted for filters
+- improved BlurFilter performance and results (thanks to Mario Klingemann)
+- objects added to a MovieClip via addChild will now display over objects managed by the MovieClip
+- Fixed clone on AlphaMapFilter
+- Updated the build process to use NodeJS & Grunt.js. Please refer to the README in the build folder.
+
+
+Version 0.6.1 [May 14, 2013]
+****************************************************************************************************
+- Updated demos:
+ * propagate the tick event to the stage. This is a best practice.
+ * Added AlphaMaskFilter demo.
+ * Added a "Graphics Winding" demo
+ * Added Safari note to the Cache demo
+- Updated documentation:
+ * Added lots more examples.
+ * Matrix2D.rotate
+ * Matrix2D.tx named incorrectly
+ * Stage.stagemousedown event (stagemouseup was doc'd twice)
+ * DisplayObject.dblclick (case incorrect)
+ * Fixed example in Stage documentation (incorrect)
+ * Fixed example in Text documentation (missing quote)
+ * Fixed updateContext method name in docs (was incorrectly set to "setupContext")
+ * Added sample code to MovieClip documentation, and a MovieClip example.
+ * Added optional parameters to MovieClip constructor
+ * Updated description of DisplayObject.mouseEnabled
+ * Fixed setPaused/getPaused descriptions in Ticker, and added some better descriptions, a few examples, and updated
+ documentation throughout.
+ * Updated SpriteSheetUtils/extractFrame documentation to mention Bitmap/sourceRect and security concerns
+ * Updated Bitmap/cache methods to clarify caching usage for Bitmaps
+ * Updated optional parameter for DisplayObject/cache
+ * Added initial example in EaselJS to show interaction
+- Modified EventDispatcher to avoid unnecessary instanceof and apply
+- Replaced the width=0 hack (for clearing canvases) with a setTransform/clearRect in DisplayObject,
+ Container, and SpriteSheetUtils.
+- Updated clearRect usages to use +1 on width and height to prevent crashes on Android (thanks mikelito)
+- Fixed Matrix2D.scale method to properly apply scale when rotated (thanks fumio)
+- Fixed bug with mouse and touch events in iOS's UIWebView (thanks cubica)
+
+
+Version 0.6.0 [Feb 12, 2013]
+****************************************************************************************************
+- added new event model with EventDispatcher class
+- added DisplayObject.cursor property
+- added Container.getChildByName() method
+- added ButtonHelper class
+- fixed error with AlphaMaskFilter
+- hitArea position now ignores the regX/Y of the target instance
+- added Log class to provide verbose errors while debugging
+- simplified & updated MovieClipPlugin to work with revised TweenJS plugin model
+- added DisplayObject.set() shortcut method
+- added MovieClip.autoReset property
+- added Graphics.isEmpty() method
+- improved support for empty masks
+- added SpriteSheetBuilder.progress
+- added SpriteSheetBuilder.timeSlice
+- removed the callback param on SpriteSheetBuilder.buildAsync, replaced with .onComplete
+- added SpriteSheetBuilder.onComplete and .onProgress
+- fixes for various MovieClip bugs
+- SpriteSheetBuilder now works correctly when adding more than one MovieClip
+- fixed an issue with SpriteSheetBuilder defining frames that exceeded the image bounds
+- added SpriteSheet.getFrameBounds()
+- added BitmapAnimation.getBounds()
+- added closePath support to Graphics.decodePath()
+- changed how animationEnd events are fired, to support calling stop() in the handler
+- animationEnd events now include a "next" value with the name of the next animation
+- event types for MouseEvents now follow DOM standards (mousedown, click, dblclick etc)
+- improved hitArea handling
+- added version.js
+- added MovieClip.currentFrame
+- documentation updates
+- new and improved build process, tools & documentation format
+- added Stage.enableDOMEvents() method
+- added default Stage.handleEvent() for integration with Ticker and new event model
+- deprecated Stage.snapToPixel API
+- added Graphics.ignoreScale API
+- added a matrix parameter to Graphics.beginBitmapFill
+
+
+Version 0.5.0 [Aug 24, 2012]
+****************************************************************************************************
+- moved all classes into a configurable createjs namespace
+- added support for multitouch
+- complete rewrite of drawing model to use a hybrid approach (save/restore & matrix)
+- added DisplayObject.mask
+- added Graphics.drawAsPath(ctx)
+- added Text.getMeasuredHeight()
+- added DisplayObject.updateContext(ctx)
+- added DisplayObject.getMatrix(matrix)
+- added DisplayObject.hitArea
+- fixed issue with Text not displaying if .text is 0 or false
+- fix for setChildIndex
+- fix for addChildAt with multiple params
+- added SpriteSheetBuilder
+- added MovieClip.actionsEnabled
+- updates to Ticker to improve support for requestAnimationFrame
+- better support for negative corner values on .drawRoundRectComplex
+- added stage.mouseMoveOutside & mouseEvent.rawX/Y
+- added "createjs.createCanvas()" to support for alternative canvases (ex. exCanvas)
+- added "scale" parameter to cache() and cleaned up the implementation
+- fix for DOMElement with Opera
+- various bug fixes and doc updates
+- changed setTransform to return the instance for use in chaining
+- started adding tutorials to address common questions and make it easier to get started
+- stage.mouseX/Y now defaults to 0 instead of null
+- text.textBaseline now defaults to "top" instead of null (resolved to "alphabetic")
+- text.textAlign now defaults to "left" instead of null
+- text.color now defaults to "#000" instead of null
+- parameters passed to Stage.update are now passed on to onTick handlers
+ - for example, Ticker elapsedTime and paused params
+- correctly resolves mouse positions for CSS scaled canvases & canvases with borders/padding
+- added AlphaMapFilter & AlphaMaskFilter
+- added Touch.disable(stage)
+
+
+Version 0.4.2 [Apr 18, 2012]
+****************************************************************************************************
+- hot fix for issues with Ticker that caused reduced frame rates.
+- NO API CHANGES
+
+
+Version 0.4.1 [Apr 14, 2012]
+****************************************************************************************************
+- DisplayObject.tick has been renamed to onTick
+- fixed a problem with preloading sprite sheet images when using tile based sheets
+- worked around a bug in Safari with addFlippedFrames
+- added setChildIndex(), swapChildrenAt(), and swapChildren() to Container
+- made frequency param on enableMouseOver optional
+- worked around a Chrome 17 bug that would prevent text w/o maxwidth from rendering
+- additional fixes for video as a Bitmap source
+- rewrite of Ticker to simplify implementation and solve issues with useRAF in Safari
+- animations in BitmapAnimation now default to looping
+- added BitmapAnimation.play/stop()
+- added Bitmap.sourceRect
+- Ticker now supports an object with a tick method, or a function as a listener
+- renamed DisplayObject.tick to .onTick
+- added MovieClip class
+- added onComplete to SpriteSheet
+- added ColorMatrix class
+- added Graphics.decodePath for compressed vector paths
+- support for passing a canvas string id to the Stage constructor
+- various bug fixes and doc updates
+- updateCache now clears the cacheCanvas correctly
+
+
+Version 0.4 [Nov 30, 2011]
+****************************************************************************************************
+- completely rewrote BitmapSequence (now BitmapAnimation) & SpriteSheet including data format
+ - BitmapSequence was renamed BitmapAnimation
+ - SpriteSheet now handles calculating frame rects
+ - support for multi-image sprite sheets
+ - support for variable frame sizes
+ - support for frame reuse (non-linear frame order)
+ - support for frame registration points
+ - SpriteSheet supports URIs as sources (and will handle preloading)
+- rewrote SpriteSheetUtils to support SpriteSheet changes
+ - renamed .flip() to .addFlippedFrames() and changed functionality significantly
+ - removed .frameDataToString()
+- fixed support for video sources in Bitmap
+- added support for null canvas for Stage
+- added DOMElement, an experimental display object for including DOM elements in the display list
+- separated tick and draw into separate phases to fix possible race conditions
+- added Matrix2D.isIdentity()
+- support for double click events (thanks to rbarazi)
+- added MouseEvent.nativeEvent and MouseEvent.target properties
+- fixes to Ticker, added second "paused" param when it calls tick
+- added experimental support for requestAnimationFrame to Ticker
+- fixed a problem with caching Container instances
+- fixed an issue with .parent not being assigned on children of cloned Containers
+- added filter support via DisplayObject.filters and Filter objects
+ - added sample filters: ColorFilter, ColorMatrixFilter, and BoxBlurFilter
+- added DisplayObject.setTransform()
+- added DisplayObject.onDoubleClick handler (thanks to rbarazi)
+- added DisplayObject.cacheID and DisplayObject.getCacheDataURL()
+- performance optimization for DisplayObject drawing (6910e6849856bd0740f8)
+- added support for touch input (single point) via the Touch class
+- added support for passing an image URI to the Bitmap constructor
+- fixes to Shadow
+- optimizations
+- documentation updates
+
+
+Version 0.3.2 [Mar 2, 2011]
+****************************************************************************************************
+- added stage.mouseInBounds
+- added DisplayObject.onMouseOver and onMouseOut callbacks
+- added stage.enableMouseOver(freq)
+- improved support for calculating mouseX/Y in divs with relative positioning
+- fixed Graphics.clone()
+- fixed an issue with shadows not being reset properly
+- migrated to use YUIDocs instead of JSDocs
+- fixed an issue that prevented BitmapSequence instances with frameData from working with gotoAndPlay(frameNumber)
+
+
+Version 0.3.1 [Feb 13, 2011]
+****************************************************************************************************
+- fixed issues with hitTest and mouse event callbacks on Container instances.
+- added recursive clone option to Container and Shape
+- fix for snapToPixel
+- added cache, updateCache, and HelloWorld demos
+- extensive code cleanup, including improved support for jsdoc
+
+
+Version 0.3 [Feb 8, 2011]
+****************************************************************************************************
+- renamed Tick to Ticker
+- adding a listener to Ticker twice will now move it to the end of the listener list
+- added Ticker.getMeasuredFPS()
+- added Ticker.setFPS()
+- renamed Stage.tick to Stage.update and made Stage.tick point to Stage.update
+- made the pauseable param "true" by default on Ticker.addListener()
+- added Stage.toDataURL(backgroundColor, mimeType)
+- renamed Rectangle.w/h to width/height
+- improvements to commenting and documentation
+- formalized inheritance model to make code more readable
+- changed color to null instead of 0 in Shadow.IDENTITY
+- fixed an error with simple sprite sheets that weren't set to loop
+- implemented "tiny" instructions for Graphics. (ex. myGraphics.f("#0FF").c(x,y,r) )
+- fixed problems with Graphics.clone()
+- fixed bug with passing instructions to a Graphics object constructor
+- complete rewrite of the render engine to be cleaner and more flexible
+- added .decompose() method to Matrix2D
+- added .skew() method to Matrix2D
+- added .skewX/Y on DisplayObject
+- added SpriteSheetUtils.extractFrame(spriteSheet,frame) method
+- added basic multi-line support for Text
+- added DisplayObject.suppressCrossDomainErrors property
+- complete rewrite of the hit testing system to be cleaner and run 5-10x faster
+- improved the interaction model:
+ - added .onPress, .onClick callbacks on DisplayObject
+ - removed .mouseChildren from Container
+ - made .mouseEnabled true by default
+ - added .onMouseDown, .onMouseUp, and .onMouseMove callbacks on Stage
+ - added MouseEvent
+- Stage.getObjectsUnderPoint() has been moved to Container
+- added Container.contains(child) method
+- added DisplayObject.compositeOperation
+- added appendProperties() and prependProperties methods to Matrix2D
+- added DisplayObject.hitTest() method
+- added stage.snapToPixelEnabled and displayObject.snapToPixel
+- added DisplayObject.updateCache()
+- renamed minified file from easeljs.js to easel.js
+- Re-factored directory layout
+
+
+Version 0.2.1 [Jan 12, 2011]
+****************************************************************************************************
+- optimized Graphics: reduced overhead by 80-90%
+- added drawPolyStar method to Graphics
+- fixed bug with using canvas as an image source for Bitmap
+- made mouseChildren true by default for stage
+- fixed major bug with Ticker.getTime()
+
+
+Version 0.2 [Jan 6, 2011]
+****************************************************************************************************
+Focus on vector graphics and text.
+- repackaged all class files to "easeljs" instead of "com.gskinner"
+- added Graphics API, and revised Shape to use a Graphics instance
+- added Text class
+- added Point class and updated CoordTransform to use it
+- added Rectangle class
+- fixed minor issue with Ticker
+- added initial implementation of Stage.mouseX/Y (likely to change)
+- added new examples, updated others to work with revised APIs
+- minor tweaks, fixes to code and documentation
+- added support for multiple params on Container.addChild, addChildAt, removeChild & removeChildAt
+
+Version 0.1 [Dec 17, 2010]
+****************************************************************************************************
+Initial release.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 000000000..67936d047
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,21 @@
+# Contributing
+
+We welcome pull requests on fixes, documentation updates, and even features. Ideally changes are discrete, documented inline with current standards, and don't contain superficial changes like tab formatting an entire file (hard to accept a PR that has 1000 changes). Don't commit updates to the `dist/` folder, as those will be done by the maintainers at our discretion.
+
+### Pull Requests
+
+Our continuous integration processes will lint and test all pull requests. To save time, please lint and test your changes locally, prior to committing.
+
+Please reference any issues that your PR addresses.
+
+### Local Development
+
+```
+# clone repo
+git clone https://github.com:createjs/easeljs.git
+cd path/to/easeljs
+# install dependencies
+npm install
+```
+
+Documentation for compiling and testing the source can be found in the [build repository README](https://github.com/createjs/build/blob/master/README.md).
diff --git a/LICENSE.txt b/LICENSE.md
similarity index 100%
rename from LICENSE.txt
rename to LICENSE.md
diff --git a/README.md b/README.md
index f8a45503f..b990b3fc1 100644
--- a/README.md
+++ b/README.md
@@ -1,139 +1,80 @@
-# EaselJS
+### 2.0 BETA
-EaselJS is a library for building high-performance interactive 2D content in HTML5. It provides a feature-rich display
-list to allow you to manipulate and animate graphics. It also provides a robust interactive model for mouse and touch
+**This branch is in beta. Reporting issues is appreciated, please mention that it is for 2.0 in the issue body.**
+
+The `StageGL` class went under a heavy rewrite in 1.1 which has not been ported to ES2015 syntax. We have excluded it from this branch for the time being. It will be added back when the class is finalized.
+
+Canvas-based image comparison unit tests are known to be failing, please don't report issues for this.
+
+
+
+EaselJS is a library for building high-performance interactive 2D content in HTML5. It provides a feature-rich display
+list to allow you to manipulate and animate graphics. It also provides a robust interactive model for mouse and touch
interactions.
-It is excellent for building games, generative art, ads, data visualization, and other highly graphical experiences. It
-works well alone, or with the rest of the [CreateJS](http://createjs.com/) suite: [SoundJS](http://createjs.com/soundjs),
-[PreloadJS](http://createjs.com/preloadjs), and [TweenJS](http://createjs.com/tweenjs).
+It is excellent for building games, generative art, ads, data visualization, and other highly graphical experiences. It
+works well alone, or with the rest of the [CreateJS](https://createjs.com/) suite: [SoundJS](https://github.com/createjs/soundjs),
+[PreloadJS](https://github.com/createjs/preloadjs), and [TweenJS](https://github.com/createjs/tweenjs).
It has no external dependencies, and should be compatible with virtually any framework you enjoy using.
+## Installation
+
+#### NPM
+
+`npm install @createjs/easeljs --save`
+
+#### CDN
+
+``
+
## Simple Example
```javascript
-//Draw a square on screen.
-var stage = new createjs.Stage('myCanvas');
-var shape = new createjs.Shape();
-shape.graphics.beginFill('red').drawRect(0, 0, 120, 120);
+// Draw a square on screen.
+import { Stage, Shape } from "@createjs/easeljs";
+let stage = new Stage("myCanvas");
+let shape = new Shape();
+shape.graphics.beginFill("red").drawRect(0, 0, 120, 120);
stage.addChild(shape);
stage.update();
```
## Sprite Animation Example
```javascript
-var ss = new createjs.SpriteSheet({
- frames: {
- width: 32,
- height: 64,
- numFrames: 19
- },
- animations: {run: [0, 25], jump: [26, 63, "run"]},
- images: ["./assets/runningGrant.png"]
+import { Sprite, SpriteSheet, Ticker } from "@createjs/easeljs";
+let ss = new SpriteSheet({
+ frames: {
+ width: 32,
+ height: 64,
+ numFrames: 19
+ },
+ animations: {run: [0, 25], jump: [26, 63, "run"]},
+ images: ["./assets/runningGrant.png"]
});
-
-var sprite = new createjs.Sprite(ss, "run");
+
+let sprite = new Sprite(ss, "run");
sprite.scaleY = sprite.scaleX = 0.4;
stage.addChild(sprite);
-
-sprite.on("click", function() { sprite.gotoAndPlay("jump"); });
-
-createjs.Ticker.on("tick", stage);
+
+sprite.on("click", evt => sprite.gotoAndPlay("jump"));
+
+Ticker.on("tick", stage);
```
## Support and Resources
-* Find examples and more information at the [EaselJS web site](http://easeljs.com/).
-* Read the [documentation](http://createjs.com/docs/easeljs).
-* Discuss, share projects, and interact with other users on [reddit](http://www.reddit.com/r/createjs/).
-* Ask technical questions on [Stack Overflow](http://stackoverflow.com/questions/tagged/easeljs).
-* File verified bugs or formal feature requests using Issues on [GitHub](https://github.com/createjs/EaselJS/issues).
-* There is a [Google Group](http://groups.google.com/group/createjs-discussion) for discussions and support.
-* Have a look at the included [examples](https://github.com/CreateJS/EaselJS/tree/master/examples) and
-[API documentation](http://createjs.com/docs/easeljs/) for more in-depth information.
+- Find examples and more information at the [EaselJS web site](http://createjs.com/easeljs).
+- Read the [documentation](http://createjs.com/easeljs/docs).
+- Discuss, share projects, and interact with other users on [reddit](http://www.reddit.com/r/createjs/).
+- Ask technical questions on [Stack Overflow](http://stackoverflow.com/questions/tagged/easeljs).
+- File verified bugs or formal feature requests using Issues on [GitHub](https://github.com/createjs/easeljs/issues).
+- There is a [Google Group](http://groups.google.com/group/createjs-discussion) for discussions and support.
+- Have a look at the included [examples](https://github.com/createjs/easeljs/tree/master/examples) for more in-depth instructions.
It was built by [gskinner.com](http://www.gskinner.com), and is released for free under the MIT license, which means you
-can use it for almost any purpose (including commercial projects). We appreciate credit where possible, but it is not a
+can use it for almost any purpose (including commercial projects). We appreciate credit where possible, but it is not a
requirement.
-
-
-## Classes
-
-The API is inspired in part by Flash's display list, and should be easy to pick up for both JS and AS3 developers. Check
-out the [docs](http://createjs.com/docs/easeljs/) for more information.
-
-**DisplayObject**
-Abstract base class for all display elements in EaselJS. Exposes all of the display properties (ex. x, y, rotation,
-scaleX, scaleY, skewX, skewY, alpha, shadow, etc) that are common to all display objects.
-
-**Stage**
-The root level display container for display elements. Each time tick() is called on Stage, it will update and render
-the display list to its associated canvas.
-
-**Container**
-A nestable display container, which lets you aggregate display objects and manipulate them as a group.
-
-**Bitmap**
-Draws an image, video or canvas to the canvas according to its display properties.
-
-**Sprite**
-Displays single frames or animations from sprite sheets, and provides APIs for managing playback and sequencing.
-
-**Shape**
-Renders a Graphics object within the context of the display list.
-
-**Graphics**
-Provides an easy to use API for drawing vector data. Can be used with Shape, or completely stand alone.
-
-**Text**
-Renders a single line of text to the stage.
-
-**BitmapText**
-Renders text using a SpriteSheet of letter.
-
-**DOMElement**
-An experimental display object that allows you to manage an HTML element as a part of the display list.
-
-**Filter**
-The base filter class that other filters (ex. BlurFilter, ColorMatrixFilter, etc) extend.
-
-
-There are also a few helper classes included:
-
-**Shadow**
-Defines all of the properties needed to display a shadow on a display object.
-
-**Ticker**
-Provides a pausable centralized tick manager for ticking Stage instances or other time based code.
-
-**UID**
-Very simple class that provides global, incremental unique numeric IDs.
-
-**SpriteSheet**
-Encapsulates all the data associated with a sprite sheet to be used with Sprite.
-
-**SpriteSheetUtils**
-Contains utility methods for extending existing sprite sheets with flipped frames and extracting individual frames.
-
-**SpriteSheetBuilder**
-Build a bitmap SpriteSheet from vector graphics at run time. Get the filesize savings of vector, with the performance
-of a SpriteSheet.
-
-**Matrix2D**
-Represents a 3x3 affine transformation matrix. Used internally for calculating concatenated transformations.
-
-**Rectangle**
-Represents a rectangle as defined by the points (x, y) and (x+width, y+height).
-
-**Point**
-Represents a point on a 2 dimensional x / y coordinate system.
-
-A WebGL implementation currently exists, but is limited.
-
-**SpriteContainer**
-A container that accepts a SpriteSheet, and uses a WebGL stage (SpriteStage) for WebGL-accelerated content.
-
-**SpriteStage**
-A Stage class that uses a WebGL context. Currently, can only have children that are SpriteContainers.
-
-A new WebGL implementation is in the works, which removes these limitations.
diff --git a/README_SECURITY_ERROR.txt b/README_SECURITY_ERROR.txt
deleted file mode 100644
index 3d20ae4aa..000000000
--- a/README_SECURITY_ERROR.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-When working with loaded images and canvas on your local file system, some browsers
-will throw security errors. This may occur when using SpriteSheetUtils or getObjectsUnderPoint,
-and lead to a number of other repeating errors.
-
-To avoid this, test on a web server (a local web server should work fine), or test with a browser
-that doesn't throw these errors (Safari seems to work).
-
-If you have python installed on your system you can enable a simple web server that's fine for
-local testing by navigating to the directory where your project resides typing the following
-at your command line:
-
-python -m SimpleHTTPServer
-
-Your project is now available at:
-
-http://localhost:8000/
\ No newline at end of file
diff --git a/_assets/README.md b/_assets/README.md
deleted file mode 100644
index bea1b3942..000000000
--- a/_assets/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# _shared folder
-
-Contains assets that are shared by examples, tutorials, and tests to prevent duplication, and simplify referencing.
\ No newline at end of file
diff --git a/_assets/art/loading.gif b/_assets/art/loading.gif
deleted file mode 100644
index c02e626a9..000000000
Binary files a/_assets/art/loading.gif and /dev/null differ
diff --git a/_assets/art/logo_createjs.svg b/_assets/art/logo_createjs.svg
deleted file mode 100644
index 6c7340017..000000000
--- a/_assets/art/logo_createjs.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/_assets/css/examples.css b/_assets/css/examples.css
deleted file mode 100755
index 1d3bdfe4b..000000000
--- a/_assets/css/examples.css
+++ /dev/null
@@ -1,68 +0,0 @@
-body {
- width: 960px;
-}
-
-header {
- margin-bottom: 1rem;
-}
-
-h1 {
- font-weight: 200;
- margin-bottom: 1rem;
-}
-
-h1:before {
- content:"EASELJS ";
- font-weight: bold;
-}
-
-header p {
- margin: 0;
- padding: 1em;
- background: rgba(250, 252, 255, 0.7);
-}
-
-.content, canvas {
- background: white;
-}
-
-.content {
- width: 960px;
- height: 400px;
- overflow: hidden;
-}
-
-.loading {
- position: relative;
-}
-
-.loading:after {
- content: url("../art/loading.gif");
- position: absolute;
- left: 50%;
- top: 50%;
- margin: -13px 0 0 -51px;
- opacity: 0.8;
-}
-
-#error {
- display:none;
- width: 960px;
- text-align: left;
- padding: 10px;
-}
-
-#mobile {
- display:none;
- width: 960px;
- text-align: left;
- padding: 10px;
-}
-
-body.embedded header {
- display: none;
-}
-
-body.embedded {
- margin: 0;
-}
diff --git a/_assets/css/shared.css b/_assets/css/shared.css
deleted file mode 100644
index 479e119f4..000000000
--- a/_assets/css/shared.css
+++ /dev/null
@@ -1,95 +0,0 @@
-body {
- margin: 3em auto;
- padding: 0;
- background-color: #eaebee;
- font-family: Arial, Verdana, sans-serif;
- font-size: 14px;
- font-weight: normal;
- color: #333;
- line-height: 1.4em;
-}
-
-a:link, a:visited {
- color: #39f;
- text-decoration: none;
-}
-
-a:hover {
- text-decoration: underline;
-}
-
-h1, h2 {
- color: #FFF;
- font-size: 1.6em;
- margin-bottom: 0;
- padding: 1.5em;
- padding-bottom: 1.2em;
- background: #374252;
- text-transform: uppercase;
-}
-
-h1::after {
- display: block;
- content: "";
- background: url('../art/logo_createjs.svg') no-repeat;
- height:1.5em;
- width: 6em;
- margin-top: -0.3em;
- float: right;
-}
-
-h1 em {
- font-weight: 200;
- font-style: normal;
-}
-
-h2 {
- font-size: 1.3em;
- padding: 1em;
- padding-bottom: 0.8em;
-}
-
-h3 {
- background: #e0e1e5;
- color: #374252;
- font-size: 1.25em;
- padding: 0.5em;
- margin-top: 1.25em;
- margin-bottom: -0.5em;
- position: relative;
-}
-
-code {
- color: black;
- background-color: rgba(255, 230, 0, 0.33);
- padding: 1px 3px;
- font-family: Courier New, Courier, serif;
- font-weight: bold;
-}
-
-/**
- * For modern browsers
- * 1. The space content is one way to avoid an Opera bug when the
- * contenteditable attribute is included anywhere else in the document.
- * Otherwise it causes space to appear at the top and bottom of elements
- * that are clearfixed.
- * 2. The use of `table` rather than `block` is only necessary if using
- * `:before` to contain the top-margins of child elements.
- */
-.cf:before,
-.cf:after {
- content: " "; /* 1 */
- display: table; /* 2 */
-}
-
-.cf:after {
- clear: both;
-}
-
-/**
- * For IE 6/7 only
- * Include this rule to trigger hasLayout and contain floats.
- */
-.cf {
- *zoom: 1;
-}
\ No newline at end of file
diff --git a/_assets/js/Slider.js b/_assets/js/Slider.js
deleted file mode 100644
index 2f98267ff..000000000
--- a/_assets/js/Slider.js
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
-* Slider
-* 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.
-*/
-
-(function() {
-
- /**
- * Simple slider control for EaselJS examples.
- **/
- function Slider(min, max, width, height) {
- this.Shape_constructor();
-
- // public properties:
- this.min = this.value = min||0;
- this.max = max||100;
-
- this.width = width||100;
- this.height = height||20;
-
- this.values = {};
-
- this.trackColor = "#EEE";
- this.thumbColor = "#666";
-
- this.cursor = "pointer";
- this.on("mousedown", this._handleInput, this);
- this.on("pressmove", this._handleInput, this);
- }
- var p = createjs.extend(Slider, createjs.Shape);
-
-
-// public methods:
- p.isVisible = function() { return true; };
-
- p.draw = function(ctx, ignoreCache) {
- if (this._checkChange()) {
- var x = (this.width-this.height) * Math.max(0,Math.min(1,(this.value-this.min) / (this.max-this.min)));
- this.graphics.clear()
- .beginFill(this.trackColor).drawRect(0,0,this.width,this.height)
- .beginFill(this.thumbColor).drawRect(x,0,this.height, this.height);
- }
- this.Shape_draw(ctx, true);
- };
-
-
-// private methods:
- p._checkChange = function() {
- var a = this, b = a.values;
- if (a.value !== b.value || a.min !== b.min || a.max !== b.max || a.width !== b.width || a.height !== b.height) {
- b.min = a.min;
- b.max = a.max;
- b.value = a.value;
- b.width = a.width;
- b.height = a.height;
- return true;
- }
- return false;
- };
-
- p._handleInput = function(evt) {
- var val = (evt.localX-this.height/2)/(this.width-this.height)*(this.max-this.min)+this.min;
- val = Math.max(this.min, Math.min(this.max, val));
- if (val == this.value) { return; }
- this.value = val;
- this.dispatchEvent("change");
- };
-
-
- window.Slider = createjs.promote(Slider, "Shape");
-}());
\ No newline at end of file
diff --git a/_assets/js/examples.js b/_assets/js/examples.js
deleted file mode 100644
index fd0618871..000000000
--- a/_assets/js/examples.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * Very minimal shared code for examples.
- */
-
-(function() {
- if (document.body) { setupEmbed(); }
- else { document.addEventListener("DOMContentLoaded", setupEmbed); }
-
- function setupEmbed() {
- if (window.top != window) {
- document.body.className += " embedded";
- }
- }
-
- var o = window.examples = {};
- o.showDistractor = function(id) {
- var div = id ? document.getElementById(id) : document.querySelector("div canvas").parentNode;
- div.className += " loading";
- };
-
- o.hideDistractor = function() {
- var div = document.querySelector(".loading");
- div.className = div.className.replace(/\bloading\b/);
- };
-})();
\ No newline at end of file
diff --git a/_assets/libs/preloadjs-NEXT.min.js b/_assets/libs/preloadjs-NEXT.min.js
deleted file mode 100644
index 2d16bf3ff..000000000
--- a/_assets/libs/preloadjs-NEXT.min.js
+++ /dev/null
@@ -1,13 +0,0 @@
-/*!
-* @license PreloadJS
-* Visit http://createjs.com/ for documentation, updates and examples.
-*
-* Copyright (c) 2011-2015 gskinner.com, inc.
-*
-* Distributed under the terms of the MIT license.
-* http://www.opensource.org/licenses/mit-license.html
-*
-* This notice shall be included in all copies or substantial portions of the Software.
-*/
-this.createjs=this.createjs||{},function(){"use strict";var a=createjs.PreloadJS=createjs.PreloadJS||{};a.version="NEXT",a.buildDate="Thu, 26 Nov 2015 20:40:05 GMT"}(),this.createjs=this.createjs||{},createjs.extend=function(a,b){"use strict";function c(){this.constructor=a}return c.prototype=b.prototype,a.prototype=new c},this.createjs=this.createjs||{},createjs.promote=function(a,b){"use strict";var c=a.prototype,d=Object.getPrototypeOf&&Object.getPrototypeOf(c)||c.__proto__;if(d){c[(b+="_")+"constructor"]=d.constructor;for(var e in d)c.hasOwnProperty(e)&&"function"==typeof d[e]&&(c[b+e]=d[e])}return a},this.createjs=this.createjs||{},createjs.indexOf=function(a,b){"use strict";for(var c=0,d=a.length;d>c;c++)if(b===a[c])return c;return-1},this.createjs=this.createjs||{},function(){"use strict";createjs.proxy=function(a,b){var c=Array.prototype.slice.call(arguments,2);return function(){return a.apply(b,Array.prototype.slice.call(arguments,0).concat(c))}}}(),this.createjs=this.createjs||{},function(){"use strict";function Event(a,b,c){this.type=a,this.target=null,this.currentTarget=null,this.eventPhase=0,this.bubbles=!!b,this.cancelable=!!c,this.timeStamp=(new Date).getTime(),this.defaultPrevented=!1,this.propagationStopped=!1,this.immediatePropagationStopped=!1,this.removed=!1}var a=Event.prototype;a.preventDefault=function(){this.defaultPrevented=this.cancelable&&!0},a.stopPropagation=function(){this.propagationStopped=!0},a.stopImmediatePropagation=function(){this.immediatePropagationStopped=this.propagationStopped=!0},a.remove=function(){this.removed=!0},a.clone=function(){return new Event(this.type,this.bubbles,this.cancelable)},a.set=function(a){for(var b in a)this[b]=a[b];return this},a.toString=function(){return"[Event (type="+this.type+")]"},createjs.Event=Event}(),this.createjs=this.createjs||{},function(){"use strict";function ErrorEvent(a,b,c){this.Event_constructor("error"),this.title=a,this.message=b,this.data=c}var a=createjs.extend(ErrorEvent,createjs.Event);a.clone=function(){return new createjs.ErrorEvent(this.title,this.message,this.data)},createjs.ErrorEvent=createjs.promote(ErrorEvent,"Event")}(),this.createjs=this.createjs||{},function(){"use strict";function EventDispatcher(){this._listeners=null,this._captureListeners=null}var a=EventDispatcher.prototype;EventDispatcher.initialize=function(b){b.addEventListener=a.addEventListener,b.on=a.on,b.removeEventListener=b.off=a.removeEventListener,b.removeAllEventListeners=a.removeAllEventListeners,b.hasEventListener=a.hasEventListener,b.dispatchEvent=a.dispatchEvent,b._dispatchEvent=a._dispatchEvent,b.willTrigger=a.willTrigger},a.addEventListener=function(a,b,c){var d;d=c?this._captureListeners=this._captureListeners||{}:this._listeners=this._listeners||{};var e=d[a];return e&&this.removeEventListener(a,b,c),e=d[a],e?e.push(b):d[a]=[b],b},a.on=function(a,b,c,d,e,f){return b.handleEvent&&(c=c||b,b=b.handleEvent),c=c||this,this.addEventListener(a,function(a){b.call(c,a,e),d&&a.remove()},f)},a.removeEventListener=function(a,b,c){var d=c?this._captureListeners:this._listeners;if(d){var e=d[a];if(e)for(var f=0,g=e.length;g>f;f++)if(e[f]==b){1==g?delete d[a]:e.splice(f,1);break}}},a.off=a.removeEventListener,a.removeAllEventListeners=function(a){a?(this._listeners&&delete this._listeners[a],this._captureListeners&&delete this._captureListeners[a]):this._listeners=this._captureListeners=null},a.dispatchEvent=function(a,b,c){if("string"==typeof a){var d=this._listeners;if(!(b||d&&d[a]))return!0;a=new createjs.Event(a,b,c)}else a.target&&a.clone&&(a=a.clone());try{a.target=this}catch(e){}if(a.bubbles&&this.parent){for(var f=this,g=[f];f.parent;)g.push(f=f.parent);var h,i=g.length;for(h=i-1;h>=0&&!a.propagationStopped;h--)g[h]._dispatchEvent(a,1+(0==h));for(h=1;i>h&&!a.propagationStopped;h++)g[h]._dispatchEvent(a,3)}else this._dispatchEvent(a,2);return!a.defaultPrevented},a.hasEventListener=function(a){var b=this._listeners,c=this._captureListeners;return!!(b&&b[a]||c&&c[a])},a.willTrigger=function(a){for(var b=this;b;){if(b.hasEventListener(a))return!0;b=b.parent}return!1},a.toString=function(){return"[EventDispatcher]"},a._dispatchEvent=function(a,b){var c,d=1==b?this._captureListeners:this._listeners;if(a&&d){var e=d[a.type];if(!e||!(c=e.length))return;try{a.currentTarget=this}catch(f){}try{a.eventPhase=b}catch(f){}a.removed=!1,e=e.slice();for(var g=0;c>g&&!a.immediatePropagationStopped;g++){var h=e[g];h.handleEvent?h.handleEvent(a):h(a),a.removed&&(this.off(a.type,h,1==b),a.removed=!1)}}},createjs.EventDispatcher=EventDispatcher}(),this.createjs=this.createjs||{},function(){"use strict";function ProgressEvent(a,b){this.Event_constructor("progress"),this.loaded=a,this.total=null==b?1:b,this.progress=0==b?0:this.loaded/this.total}var a=createjs.extend(ProgressEvent,createjs.Event);a.clone=function(){return new createjs.ProgressEvent(this.loaded,this.total)},createjs.ProgressEvent=createjs.promote(ProgressEvent,"Event")}(window),function(){function a(b,d){function f(a){if(f[a]!==q)return f[a];var b;if("bug-string-char-index"==a)b="a"!="a"[0];else if("json"==a)b=f("json-stringify")&&f("json-parse");else{var c,e='{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';if("json-stringify"==a){var i=d.stringify,k="function"==typeof i&&t;if(k){(c=function(){return 1}).toJSON=c;try{k="0"===i(0)&&"0"===i(new g)&&'""'==i(new h)&&i(s)===q&&i(q)===q&&i()===q&&"1"===i(c)&&"[1]"==i([c])&&"[null]"==i([q])&&"null"==i(null)&&"[null,null,null]"==i([q,s,null])&&i({a:[c,!0,!1,null,"\x00\b\n\f\r "]})==e&&"1"===i(null,c)&&"[\n 1,\n 2\n]"==i([1,2],null,1)&&'"-271821-04-20T00:00:00.000Z"'==i(new j(-864e13))&&'"+275760-09-13T00:00:00.000Z"'==i(new j(864e13))&&'"-000001-01-01T00:00:00.000Z"'==i(new j(-621987552e5))&&'"1969-12-31T23:59:59.999Z"'==i(new j(-1))}catch(l){k=!1}}b=k}if("json-parse"==a){var m=d.parse;if("function"==typeof m)try{if(0===m("0")&&!m(!1)){c=m(e);var n=5==c.a.length&&1===c.a[0];if(n){try{n=!m('" "')}catch(l){}if(n)try{n=1!==m("01")}catch(l){}if(n)try{n=1!==m("1.")}catch(l){}}}}catch(l){n=!1}b=n}}return f[a]=!!b}b||(b=e.Object()),d||(d=e.Object());var g=b.Number||e.Number,h=b.String||e.String,i=b.Object||e.Object,j=b.Date||e.Date,k=b.SyntaxError||e.SyntaxError,l=b.TypeError||e.TypeError,m=b.Math||e.Math,n=b.JSON||e.JSON;"object"==typeof n&&n&&(d.stringify=n.stringify,d.parse=n.parse);var o,p,q,r=i.prototype,s=r.toString,t=new j(-0xc782b5b800cec);try{t=-109252==t.getUTCFullYear()&&0===t.getUTCMonth()&&1===t.getUTCDate()&&10==t.getUTCHours()&&37==t.getUTCMinutes()&&6==t.getUTCSeconds()&&708==t.getUTCMilliseconds()}catch(u){}if(!f("json")){var v="[object Function]",w="[object Date]",x="[object Number]",y="[object String]",z="[object Array]",A="[object Boolean]",B=f("bug-string-char-index");if(!t)var C=m.floor,D=[0,31,59,90,120,151,181,212,243,273,304,334],E=function(a,b){return D[b]+365*(a-1970)+C((a-1969+(b=+(b>1)))/4)-C((a-1901+b)/100)+C((a-1601+b)/400)};if((o=r.hasOwnProperty)||(o=function(a){var b,c={};return(c.__proto__=null,c.__proto__={toString:1},c).toString!=s?o=function(a){var b=this.__proto__,c=a in(this.__proto__=null,this);return this.__proto__=b,c}:(b=c.constructor,o=function(a){var c=(this.constructor||b).prototype;return a in this&&!(a in c&&this[a]===c[a])}),c=null,o.call(this,a)}),p=function(a,b){var d,e,f,g=0;(d=function(){this.valueOf=0}).prototype.valueOf=0,e=new d;for(f in e)o.call(e,f)&&g++;return d=e=null,g?p=2==g?function(a,b){var c,d={},e=s.call(a)==v;for(c in a)e&&"prototype"==c||o.call(d,c)||!(d[c]=1)||!o.call(a,c)||b(c)}:function(a,b){var c,d,e=s.call(a)==v;for(c in a)e&&"prototype"==c||!o.call(a,c)||(d="constructor"===c)||b(c);(d||o.call(a,c="constructor"))&&b(c)}:(e=["valueOf","toString","toLocaleString","propertyIsEnumerable","isPrototypeOf","hasOwnProperty","constructor"],p=function(a,b){var d,f,g=s.call(a)==v,h=!g&&"function"!=typeof a.constructor&&c[typeof a.hasOwnProperty]&&a.hasOwnProperty||o;for(d in a)g&&"prototype"==d||!h.call(a,d)||b(d);for(f=e.length;d=e[--f];h.call(a,d)&&b(d));}),p(a,b)},!f("json-stringify")){var F={92:"\\\\",34:'\\"',8:"\\b",12:"\\f",10:"\\n",13:"\\r",9:"\\t"},G="000000",H=function(a,b){return(G+(b||0)).slice(-a)},I="\\u00",J=function(a){for(var b='"',c=0,d=a.length,e=!B||d>10,f=e&&(B?a.split(""):a);d>c;c++){var g=a.charCodeAt(c);switch(g){case 8:case 9:case 10:case 12:case 13:case 34:case 92:b+=F[g];break;default:if(32>g){b+=I+H(2,g.toString(16));break}b+=e?f[c]:a.charAt(c)}}return b+'"'},K=function(a,b,c,d,e,f,g){var h,i,j,k,m,n,r,t,u,v,B,D,F,G,I,L;try{h=b[a]}catch(M){}if("object"==typeof h&&h)if(i=s.call(h),i!=w||o.call(h,"toJSON"))"function"==typeof h.toJSON&&(i!=x&&i!=y&&i!=z||o.call(h,"toJSON"))&&(h=h.toJSON(a));else if(h>-1/0&&1/0>h){if(E){for(m=C(h/864e5),j=C(m/365.2425)+1970-1;E(j+1,0)<=m;j++);for(k=C((m-E(j,0))/30.42);E(j,k+1)<=m;k++);m=1+m-E(j,k),n=(h%864e5+864e5)%864e5,r=C(n/36e5)%24,t=C(n/6e4)%60,u=C(n/1e3)%60,v=n%1e3}else j=h.getUTCFullYear(),k=h.getUTCMonth(),m=h.getUTCDate(),r=h.getUTCHours(),t=h.getUTCMinutes(),u=h.getUTCSeconds(),v=h.getUTCMilliseconds();h=(0>=j||j>=1e4?(0>j?"-":"+")+H(6,0>j?-j:j):H(4,j))+"-"+H(2,k+1)+"-"+H(2,m)+"T"+H(2,r)+":"+H(2,t)+":"+H(2,u)+"."+H(3,v)+"Z"}else h=null;if(c&&(h=c.call(b,a,h)),null===h)return"null";if(i=s.call(h),i==A)return""+h;if(i==x)return h>-1/0&&1/0>h?""+h:"null";if(i==y)return J(""+h);if("object"==typeof h){for(G=g.length;G--;)if(g[G]===h)throw l();if(g.push(h),B=[],I=f,f+=e,i==z){for(F=0,G=h.length;G>F;F++)D=K(F,h,c,d,e,f,g),B.push(D===q?"null":D);L=B.length?e?"[\n"+f+B.join(",\n"+f)+"\n"+I+"]":"["+B.join(",")+"]":"[]"}else p(d||h,function(a){var b=K(a,h,c,d,e,f,g);b!==q&&B.push(J(a)+":"+(e?" ":"")+b)}),L=B.length?e?"{\n"+f+B.join(",\n"+f)+"\n"+I+"}":"{"+B.join(",")+"}":"{}";return g.pop(),L}};d.stringify=function(a,b,d){var e,f,g,h;if(c[typeof b]&&b)if((h=s.call(b))==v)f=b;else if(h==z){g={};for(var i,j=0,k=b.length;k>j;i=b[j++],h=s.call(i),(h==y||h==x)&&(g[i]=1));}if(d)if((h=s.call(d))==x){if((d-=d%1)>0)for(e="",d>10&&(d=10);e.lengthL;)switch(e=f.charCodeAt(L)){case 9:case 10:case 13:case 32:L++;break;case 123:case 125:case 91:case 93:case 58:case 44:return a=B?f.charAt(L):f[L],L++,a;case 34:for(a="@",L++;g>L;)if(e=f.charCodeAt(L),32>e)P();else if(92==e)switch(e=f.charCodeAt(++L)){case 92:case 34:case 47:case 98:case 116:case 110:case 102:case 114:a+=O[e],L++;break;case 117:for(b=++L,c=L+4;c>L;L++)e=f.charCodeAt(L),e>=48&&57>=e||e>=97&&102>=e||e>=65&&70>=e||P();a+=N("0x"+f.slice(b,L));break;default:P()}else{if(34==e)break;for(e=f.charCodeAt(L),b=L;e>=32&&92!=e&&34!=e;)e=f.charCodeAt(++L);a+=f.slice(b,L)}if(34==f.charCodeAt(L))return L++,a;P();default:if(b=L,45==e&&(d=!0,e=f.charCodeAt(++L)),e>=48&&57>=e){for(48==e&&(e=f.charCodeAt(L+1),e>=48&&57>=e)&&P(),d=!1;g>L&&(e=f.charCodeAt(L),e>=48&&57>=e);L++);if(46==f.charCodeAt(L)){for(c=++L;g>c&&(e=f.charCodeAt(c),e>=48&&57>=e);c++);c==L&&P(),L=c}if(e=f.charCodeAt(L),101==e||69==e){for(e=f.charCodeAt(++L),(43==e||45==e)&&L++,c=L;g>c&&(e=f.charCodeAt(c),e>=48&&57>=e);c++);c==L&&P(),L=c}return+f.slice(b,L)}if(d&&P(),"true"==f.slice(L,L+4))return L+=4,!0;if("false"==f.slice(L,L+5))return L+=5,!1;if("null"==f.slice(L,L+4))return L+=4,null;P()}return"$"},R=function(a){var b,c;if("$"==a&&P(),"string"==typeof a){if("@"==(B?a.charAt(0):a[0]))return a.slice(1);if("["==a){for(b=[];a=Q(),"]"!=a;c||(c=!0))c&&(","==a?(a=Q(),"]"==a&&P()):P()),","==a&&P(),b.push(R(a));return b}if("{"==a){for(b={};a=Q(),"}"!=a;c||(c=!0))c&&(","==a?(a=Q(),"}"==a&&P()):P()),(","==a||"string"!=typeof a||"@"!=(B?a.charAt(0):a[0])||":"!=Q())&&P(),b[a.slice(1)]=R(Q());return b}P()}return a},S=function(a,b,c){var d=T(a,b,c);d===q?delete a[b]:a[b]=d},T=function(a,b,c){var d,e=a[b];if("object"==typeof e&&e)if(s.call(e)==z)for(d=e.length;d--;)S(e,d,c);else p(e,function(a){S(e,a,c)});return c.call(a,b,e)};d.parse=function(a,b){var c,d;return L=0,M=""+a,c=R(Q()),"$"!=Q()&&P(),L=M=null,b&&s.call(b)==v?T((d={},d[""]=c,d),"",b):c}}}return d.runInContext=a,d}var b="function"==typeof define&&define.amd,c={"function":!0,object:!0},d=c[typeof exports]&&exports&&!exports.nodeType&&exports,e=c[typeof window]&&window||this,f=d&&c[typeof module]&&module&&!module.nodeType&&"object"==typeof global&&global;if(!f||f.global!==f&&f.window!==f&&f.self!==f||(e=f),d&&!b)a(e,d);else{var g=e.JSON,h=e.JSON3,i=!1,j=a(e,e.JSON3={noConflict:function(){return i||(i=!0,e.JSON=g,e.JSON3=h,g=h=null),j}});e.JSON={parse:j.parse,stringify:j.stringify}}b&&define(function(){return j})}.call(this),function(){var a={};a.appendToHead=function(b){a.getHead().appendChild(b)},a.getHead=function(){return document.head||document.getElementsByTagName("head")[0]},a.getBody=function(){return document.body||document.getElementsByTagName("body")[0]},createjs.DomUtils=a}(),function(){var a={};a.parseXML=function(a,b){var c=null;try{if(window.DOMParser){var d=new DOMParser;c=d.parseFromString(a,b)}}catch(e){}if(!c)try{c=new ActiveXObject("Microsoft.XMLDOM"),c.async=!1,c.loadXML(a)}catch(e){c=null}return c},a.parseJSON=function(a){if(null==a)return null;try{return JSON.parse(a)}catch(b){throw b}},createjs.DataUtils=a}(),this.createjs=this.createjs||{},function(){"use strict";function LoadItem(){this.src=null,this.type=null,this.id=null,this.maintainOrder=!1,this.callback=null,this.data=null,this.method=createjs.LoadItem.GET,this.values=null,this.headers=null,this.withCredentials=!1,this.mimeType=null,this.crossOrigin=null,this.loadTimeout=b.LOAD_TIMEOUT_DEFAULT}var a=LoadItem.prototype={},b=LoadItem;b.LOAD_TIMEOUT_DEFAULT=8e3,b.create=function(a){if("string"==typeof a){var c=new LoadItem;return c.src=a,c}if(a instanceof b)return a;if(a instanceof Object&&a.src)return null==a.loadTimeout&&(a.loadTimeout=b.LOAD_TIMEOUT_DEFAULT),a;throw new Error("Type not recognized.")},a.set=function(a){for(var b in a)this[b]=a[b];return this},createjs.LoadItem=b}(),function(){var a={};a.ABSOLUTE_PATT=/^(?:\w+:)?\/{2}/i,a.RELATIVE_PATT=/^[.\/]*?\//i,a.EXTENSION_PATT=/\/?[^\/]+\.(\w{1,5})$/i,a.parseURI=function(b){var c={absolute:!1,relative:!1};if(null==b)return c;var d=b.indexOf("?");d>-1&&(b=b.substr(0,d));var e;return a.ABSOLUTE_PATT.test(b)?c.absolute=!0:a.RELATIVE_PATT.test(b)&&(c.relative=!0),(e=b.match(a.EXTENSION_PATT))&&(c.extension=e[1].toLowerCase()),c},a.formatQueryString=function(a,b){if(null==a)throw new Error("You must specify data.");var c=[];for(var d in a)c.push(d+"="+escape(a[d]));return b&&(c=c.concat(b)),c.join("&")},a.buildPath=function(a,b){if(null==b)return a;var c=[],d=a.indexOf("?");if(-1!=d){var e=a.slice(d+1);c=c.concat(e.split("&"))}return-1!=d?a.slice(0,d)+"?"+this.formatQueryString(b,c):a+"?"+this.formatQueryString(b,c)},a.isCrossDomain=function(a){var b=document.createElement("a");b.href=a.src;var c=document.createElement("a");c.href=location.href;var d=""!=b.hostname&&(b.port!=c.port||b.protocol!=c.protocol||b.hostname!=c.hostname);return d},a.isLocal=function(a){var b=document.createElement("a");return b.href=a.src,""==b.hostname&&"file:"==b.protocol},a.isBinary=function(a){switch(a){case createjs.AbstractLoader.IMAGE:case createjs.AbstractLoader.BINARY:return!0;default:return!1}},a.isImageTag=function(a){return a instanceof HTMLImageElement},a.isAudioTag=function(a){return window.HTMLAudioElement?a instanceof HTMLAudioElement:!1},a.isVideoTag=function(a){return window.HTMLVideoElement?a instanceof HTMLVideoElement:!1},a.isText=function(a){switch(a){case createjs.AbstractLoader.TEXT:case createjs.AbstractLoader.JSON:case createjs.AbstractLoader.MANIFEST:case createjs.AbstractLoader.XML:case createjs.AbstractLoader.CSS:case createjs.AbstractLoader.SVG:case createjs.AbstractLoader.JAVASCRIPT:case createjs.AbstractLoader.SPRITESHEET:return!0;default:return!1}},a.getTypeByExtension=function(a){if(null==a)return createjs.AbstractLoader.TEXT;switch(a.toLowerCase()){case"jpeg":case"jpg":case"gif":case"png":case"webp":case"bmp":return createjs.AbstractLoader.IMAGE;case"ogg":case"mp3":case"webm":return createjs.AbstractLoader.SOUND;case"mp4":case"webm":case"ts":return createjs.AbstractLoader.VIDEO;case"json":return createjs.AbstractLoader.JSON;case"xml":return createjs.AbstractLoader.XML;case"css":return createjs.AbstractLoader.CSS;case"js":return createjs.AbstractLoader.JAVASCRIPT;case"svg":return createjs.AbstractLoader.SVG;default:return createjs.AbstractLoader.TEXT}},createjs.RequestUtils=a}(),this.createjs=this.createjs||{},function(){"use strict";function AbstractLoader(a,b,c){this.EventDispatcher_constructor(),this.loaded=!1,this.canceled=!1,this.progress=0,this.type=c,this.resultFormatter=null,this._item=a?createjs.LoadItem.create(a):null,this._preferXHR=b,this._result=null,this._rawResult=null,this._loadedItems=null,this._tagSrcAttribute=null,this._tag=null}var a=createjs.extend(AbstractLoader,createjs.EventDispatcher),b=AbstractLoader;b.POST="POST",b.GET="GET",b.BINARY="binary",b.CSS="css",b.IMAGE="image",b.JAVASCRIPT="javascript",b.JSON="json",b.JSONP="jsonp",b.MANIFEST="manifest",b.SOUND="sound",b.VIDEO="video",b.SPRITESHEET="spritesheet",b.SVG="svg",b.TEXT="text",b.XML="xml",a.getItem=function(){return this._item},a.getResult=function(a){return a?this._rawResult:this._result},a.getTag=function(){return this._tag},a.setTag=function(a){this._tag=a},a.load=function(){this._createRequest(),this._request.on("complete",this,this),this._request.on("progress",this,this),this._request.on("loadStart",this,this),this._request.on("abort",this,this),this._request.on("timeout",this,this),this._request.on("error",this,this);var a=new createjs.Event("initialize");a.loader=this._request,this.dispatchEvent(a),this._request.load()},a.cancel=function(){this.canceled=!0,this.destroy()},a.destroy=function(){this._request&&(this._request.removeAllEventListeners(),this._request.destroy()),this._request=null,this._item=null,this._rawResult=null,this._result=null,this._loadItems=null,this.removeAllEventListeners()},a.getLoadedItems=function(){return this._loadedItems},a._createRequest=function(){this._request=this._preferXHR?new createjs.XHRRequest(this._item):new createjs.TagRequest(this._item,this._tag||this._createTag(),this._tagSrcAttribute)},a._createTag=function(){return null},a._sendLoadStart=function(){this._isCanceled()||this.dispatchEvent("loadstart")},a._sendProgress=function(a){if(!this._isCanceled()){var b=null;"number"==typeof a?(this.progress=a,b=new createjs.ProgressEvent(this.progress)):(b=a,this.progress=a.loaded/a.total,b.progress=this.progress,(isNaN(this.progress)||1/0==this.progress)&&(this.progress=0)),this.hasEventListener("progress")&&this.dispatchEvent(b)}},a._sendComplete=function(){if(!this._isCanceled()){this.loaded=!0;var a=new createjs.Event("complete");a.rawResult=this._rawResult,null!=this._result&&(a.result=this._result),this.dispatchEvent(a)}},a._sendError=function(a){!this._isCanceled()&&this.hasEventListener("error")&&(null==a&&(a=new createjs.ErrorEvent("PRELOAD_ERROR_EMPTY")),this.dispatchEvent(a))},a._isCanceled=function(){return null==window.createjs||this.canceled?!0:!1},a.resultFormatter=null,a.handleEvent=function(a){switch(a.type){case"complete":this._rawResult=a.target._response;var b=this.resultFormatter&&this.resultFormatter(this);b instanceof Function?b.call(this,createjs.proxy(this._resultFormatSuccess,this),createjs.proxy(this._resultFormatFailed,this)):(this._result=b||this._rawResult,this._sendComplete());break;case"progress":this._sendProgress(a);break;case"error":this._sendError(a);break;case"loadstart":this._sendLoadStart();break;case"abort":case"timeout":this._isCanceled()||this.dispatchEvent(new createjs.ErrorEvent("PRELOAD_"+a.type.toUpperCase()+"_ERROR"))}},a._resultFormatSuccess=function(a){this._result=a,this._sendComplete()},a._resultFormatFailed=function(a){this._sendError(a)},a.buildPath=function(a,b){return createjs.RequestUtils.buildPath(a,b)},a.toString=function(){return"[PreloadJS AbstractLoader]"},createjs.AbstractLoader=createjs.promote(AbstractLoader,"EventDispatcher")}(),this.createjs=this.createjs||{},function(){"use strict";function AbstractMediaLoader(a,b,c){this.AbstractLoader_constructor(a,b,c),this.resultFormatter=this._formatResult,this._tagSrcAttribute="src",this.on("initialize",this._updateXHR,this)}var a=createjs.extend(AbstractMediaLoader,createjs.AbstractLoader);a.load=function(){this._tag||(this._tag=this._createTag(this._item.src)),this._tag.preload="auto",this._tag.load(),this.AbstractLoader_load()},a._createTag=function(){},a._createRequest=function(){this._request=this._preferXHR?new createjs.XHRRequest(this._item):new createjs.MediaTagRequest(this._item,this._tag||this._createTag(),this._tagSrcAttribute)},a._updateXHR=function(a){a.loader.setResponseType&&a.loader.setResponseType("blob")},a._formatResult=function(a){if(this._tag.removeEventListener&&this._tag.removeEventListener("canplaythrough",this._loadedHandler),this._tag.onstalled=null,this._preferXHR){var b=window.URL||window.webkitURL,c=a.getResult(!0);a.getTag().src=b.createObjectURL(c)}return a.getTag()},createjs.AbstractMediaLoader=createjs.promote(AbstractMediaLoader,"AbstractLoader")}(),this.createjs=this.createjs||{},function(){"use strict";var AbstractRequest=function(a){this._item=a},a=createjs.extend(AbstractRequest,createjs.EventDispatcher);a.load=function(){},a.destroy=function(){},a.cancel=function(){},createjs.AbstractRequest=createjs.promote(AbstractRequest,"EventDispatcher")}(),this.createjs=this.createjs||{},function(){"use strict";function TagRequest(a,b,c){this.AbstractRequest_constructor(a),this._tag=b,this._tagSrcAttribute=c,this._loadedHandler=createjs.proxy(this._handleTagComplete,this),this._addedToDOM=!1,this._startTagDisplay=null}var a=createjs.extend(TagRequest,createjs.AbstractRequest);a.load=function(){this._tag.onload=createjs.proxy(this._handleTagComplete,this),this._tag.onreadystatechange=createjs.proxy(this._handleReadyStateChange,this),this._tag.onerror=createjs.proxy(this._handleError,this);var a=new createjs.Event("initialize");a.loader=this._tag,this.dispatchEvent(a),this._hideTag(),this._loadTimeout=setTimeout(createjs.proxy(this._handleTimeout,this),this._item.loadTimeout),this._tag[this._tagSrcAttribute]=this._item.src,null==this._tag.parentNode&&(window.document.body.appendChild(this._tag),this._addedToDOM=!0)},a.destroy=function(){this._clean(),this._tag=null,this.AbstractRequest_destroy()},a._handleReadyStateChange=function(){clearTimeout(this._loadTimeout);var a=this._tag;("loaded"==a.readyState||"complete"==a.readyState)&&this._handleTagComplete()},a._handleError=function(){this._clean(),this.dispatchEvent("error")},a._handleTagComplete=function(){this._rawResult=this._tag,this._result=this.resultFormatter&&this.resultFormatter(this)||this._rawResult,this._clean(),this._showTag(),this.dispatchEvent("complete")},a._handleTimeout=function(){this._clean(),this.dispatchEvent(new createjs.Event("timeout"))},a._clean=function(){this._tag.onload=null,this._tag.onreadystatechange=null,this._tag.onerror=null,this._addedToDOM&&null!=this._tag.parentNode&&this._tag.parentNode.removeChild(this._tag),clearTimeout(this._loadTimeout)},a._hideTag=function(){this._startTagDisplay=this._tag.style.display,this._tag.style.display="none"},a._showTag=function(){this._tag.style.display=this._startTagDisplay},a._handleStalled=function(){},createjs.TagRequest=createjs.promote(TagRequest,"AbstractRequest")}(),this.createjs=this.createjs||{},function(){"use strict";function MediaTagRequest(a,b,c){this.AbstractRequest_constructor(a),this._tag=b,this._tagSrcAttribute=c,this._loadedHandler=createjs.proxy(this._handleTagComplete,this)}var a=createjs.extend(MediaTagRequest,createjs.TagRequest);a.load=function(){var a=createjs.proxy(this._handleStalled,this);this._stalledCallback=a;var b=createjs.proxy(this._handleProgress,this);this._handleProgress=b,this._tag.addEventListener("stalled",a),this._tag.addEventListener("progress",b),this._tag.addEventListener&&this._tag.addEventListener("canplaythrough",this._loadedHandler,!1),this.TagRequest_load()},a._handleReadyStateChange=function(){clearTimeout(this._loadTimeout);var a=this._tag;("loaded"==a.readyState||"complete"==a.readyState)&&this._handleTagComplete()},a._handleStalled=function(){},a._handleProgress=function(a){if(a&&!(a.loaded>0&&0==a.total)){var b=new createjs.ProgressEvent(a.loaded,a.total);this.dispatchEvent(b)}},a._clean=function(){this._tag.removeEventListener&&this._tag.removeEventListener("canplaythrough",this._loadedHandler),this._tag.removeEventListener("stalled",this._stalledCallback),this._tag.removeEventListener("progress",this._progressCallback),this.TagRequest__clean()},createjs.MediaTagRequest=createjs.promote(MediaTagRequest,"TagRequest")}(),this.createjs=this.createjs||{},function(){"use strict";function XHRRequest(a){this.AbstractRequest_constructor(a),this._request=null,this._loadTimeout=null,this._xhrLevel=1,this._response=null,this._rawResponse=null,this._canceled=!1,this._handleLoadStartProxy=createjs.proxy(this._handleLoadStart,this),this._handleProgressProxy=createjs.proxy(this._handleProgress,this),this._handleAbortProxy=createjs.proxy(this._handleAbort,this),this._handleErrorProxy=createjs.proxy(this._handleError,this),this._handleTimeoutProxy=createjs.proxy(this._handleTimeout,this),this._handleLoadProxy=createjs.proxy(this._handleLoad,this),this._handleReadyStateChangeProxy=createjs.proxy(this._handleReadyStateChange,this),!this._createXHR(a)}var a=createjs.extend(XHRRequest,createjs.AbstractRequest);XHRRequest.ACTIVEX_VERSIONS=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],a.getResult=function(a){return a&&this._rawResponse?this._rawResponse:this._response},a.cancel=function(){this.canceled=!0,this._clean(),this._request.abort()},a.load=function(){if(null==this._request)return void this._handleError();null!=this._request.addEventListener?(this._request.addEventListener("loadstart",this._handleLoadStartProxy,!1),this._request.addEventListener("progress",this._handleProgressProxy,!1),this._request.addEventListener("abort",this._handleAbortProxy,!1),this._request.addEventListener("error",this._handleErrorProxy,!1),this._request.addEventListener("timeout",this._handleTimeoutProxy,!1),this._request.addEventListener("load",this._handleLoadProxy,!1),this._request.addEventListener("readystatechange",this._handleReadyStateChangeProxy,!1)):(this._request.onloadstart=this._handleLoadStartProxy,this._request.onprogress=this._handleProgressProxy,this._request.onabort=this._handleAbortProxy,this._request.onerror=this._handleErrorProxy,this._request.ontimeout=this._handleTimeoutProxy,this._request.onload=this._handleLoadProxy,this._request.onreadystatechange=this._handleReadyStateChangeProxy),1==this._xhrLevel&&(this._loadTimeout=setTimeout(createjs.proxy(this._handleTimeout,this),this._item.loadTimeout));try{this._item.values&&this._item.method!=createjs.AbstractLoader.GET?this._item.method==createjs.AbstractLoader.POST&&this._request.send(createjs.RequestUtils.formatQueryString(this._item.values)):this._request.send()}catch(a){this.dispatchEvent(new createjs.ErrorEvent("XHR_SEND",null,a))}},a.setResponseType=function(a){"blob"===a&&(a=window.URL?"blob":"arraybuffer",this._responseType=a),this._request.responseType=a},a.getAllResponseHeaders=function(){return this._request.getAllResponseHeaders instanceof Function?this._request.getAllResponseHeaders():null},a.getResponseHeader=function(a){return this._request.getResponseHeader instanceof Function?this._request.getResponseHeader(a):null},a._handleProgress=function(a){if(a&&!(a.loaded>0&&0==a.total)){var b=new createjs.ProgressEvent(a.loaded,a.total);this.dispatchEvent(b)}},a._handleLoadStart=function(){clearTimeout(this._loadTimeout),this.dispatchEvent("loadstart")},a._handleAbort=function(a){this._clean(),this.dispatchEvent(new createjs.ErrorEvent("XHR_ABORTED",null,a))},a._handleError=function(a){this._clean(),this.dispatchEvent(new createjs.ErrorEvent(a.message))},a._handleReadyStateChange=function(){4==this._request.readyState&&this._handleLoad()},a._handleLoad=function(){if(!this.loaded){this.loaded=!0;var a=this._checkError();if(a)return void this._handleError(a);if(this._response=this._getResponse(),"arraybuffer"===this._responseType)try{this._response=new Blob([this._response])}catch(b){if(window.BlobBuilder=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder,"TypeError"===b.name&&window.BlobBuilder){var c=new BlobBuilder;c.append(this._response),this._response=c.getBlob()}}this._clean(),this.dispatchEvent(new createjs.Event("complete"))}},a._handleTimeout=function(a){this._clean(),this.dispatchEvent(new createjs.ErrorEvent("PRELOAD_TIMEOUT",null,a))},a._checkError=function(){var a=parseInt(this._request.status);switch(a){case 404:case 0:return new Error(a)}return null},a._getResponse=function(){if(null!=this._response)return this._response;if(null!=this._request.response)return this._request.response;try{if(null!=this._request.responseText)return this._request.responseText}catch(a){}try{if(null!=this._request.responseXML)return this._request.responseXML}catch(a){}return null},a._createXHR=function(a){var b=createjs.RequestUtils.isCrossDomain(a),c={},d=null;if(window.XMLHttpRequest)d=new XMLHttpRequest,b&&void 0===d.withCredentials&&window.XDomainRequest&&(d=new XDomainRequest);else{for(var e=0,f=s.ACTIVEX_VERSIONS.length;f>e;e++){var g=s.ACTIVEX_VERSIONS[e];try{d=new ActiveXObject(g);break}catch(h){}}if(null==d)return!1}null==a.mimeType&&createjs.RequestUtils.isText(a.type)&&(a.mimeType="text/plain; charset=utf-8"),a.mimeType&&d.overrideMimeType&&d.overrideMimeType(a.mimeType),this._xhrLevel="string"==typeof d.responseType?2:1;var i=null;if(i=a.method==createjs.AbstractLoader.GET?createjs.RequestUtils.buildPath(a.src,a.values):a.src,d.open(a.method||createjs.AbstractLoader.GET,i,!0),b&&d instanceof XMLHttpRequest&&1==this._xhrLevel&&(c.Origin=location.origin),a.values&&a.method==createjs.AbstractLoader.POST&&(c["Content-Type"]="application/x-www-form-urlencoded"),b||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest"),a.headers)for(var j in a.headers)c[j]=a.headers[j];for(j in c)d.setRequestHeader(j,c[j]);return d instanceof XMLHttpRequest&&void 0!==a.withCredentials&&(d.withCredentials=a.withCredentials),this._request=d,!0},a._clean=function(){clearTimeout(this._loadTimeout),null!=this._request.removeEventListener?(this._request.removeEventListener("loadstart",this._handleLoadStartProxy),this._request.removeEventListener("progress",this._handleProgressProxy),this._request.removeEventListener("abort",this._handleAbortProxy),this._request.removeEventListener("error",this._handleErrorProxy),this._request.removeEventListener("timeout",this._handleTimeoutProxy),this._request.removeEventListener("load",this._handleLoadProxy),this._request.removeEventListener("readystatechange",this._handleReadyStateChangeProxy)):(this._request.onloadstart=null,this._request.onprogress=null,this._request.onabort=null,this._request.onerror=null,this._request.ontimeout=null,this._request.onload=null,this._request.onreadystatechange=null)},a.toString=function(){return"[PreloadJS XHRRequest]"},createjs.XHRRequest=createjs.promote(XHRRequest,"AbstractRequest")}(),this.createjs=this.createjs||{},function(){"use strict";function LoadQueue(a,b,c){this.AbstractLoader_constructor(),this._plugins=[],this._typeCallbacks={},this._extensionCallbacks={},this.next=null,this.maintainScriptOrder=!0,this.stopOnError=!1,this._maxConnections=1,this._availableLoaders=[createjs.ImageLoader,createjs.JavaScriptLoader,createjs.CSSLoader,createjs.JSONLoader,createjs.JSONPLoader,createjs.SoundLoader,createjs.ManifestLoader,createjs.SpriteSheetLoader,createjs.XMLLoader,createjs.SVGLoader,createjs.BinaryLoader,createjs.VideoLoader,createjs.TextLoader],this._defaultLoaderLength=this._availableLoaders.length,this.init(a,b,c)
-}var a=createjs.extend(LoadQueue,createjs.AbstractLoader),b=LoadQueue;a.init=function(a,b,c){this.useXHR=!0,this.preferXHR=!0,this._preferXHR=!0,this.setPreferXHR(a),this._paused=!1,this._basePath=b,this._crossOrigin=c,this._loadStartWasDispatched=!1,this._currentlyLoadingScript=null,this._currentLoads=[],this._loadQueue=[],this._loadQueueBackup=[],this._loadItemsById={},this._loadItemsBySrc={},this._loadedResults={},this._loadedRawResults={},this._numItems=0,this._numItemsLoaded=0,this._scriptOrder=[],this._loadedScripts=[],this._lastProgress=0/0},b.loadTimeout=8e3,b.LOAD_TIMEOUT=0,b.BINARY=createjs.AbstractLoader.BINARY,b.CSS=createjs.AbstractLoader.CSS,b.IMAGE=createjs.AbstractLoader.IMAGE,b.JAVASCRIPT=createjs.AbstractLoader.JAVASCRIPT,b.JSON=createjs.AbstractLoader.JSON,b.JSONP=createjs.AbstractLoader.JSONP,b.MANIFEST=createjs.AbstractLoader.MANIFEST,b.SOUND=createjs.AbstractLoader.SOUND,b.VIDEO=createjs.AbstractLoader.VIDEO,b.SVG=createjs.AbstractLoader.SVG,b.TEXT=createjs.AbstractLoader.TEXT,b.XML=createjs.AbstractLoader.XML,b.POST=createjs.AbstractLoader.POST,b.GET=createjs.AbstractLoader.GET,a.registerLoader=function(a){if(!a||!a.canLoadItem)throw new Error("loader is of an incorrect type.");if(-1!=this._availableLoaders.indexOf(a))throw new Error("loader already exists.");this._availableLoaders.unshift(a)},a.unregisterLoader=function(a){var b=this._availableLoaders.indexOf(a);-1!=b&&b0)return;var c=!1;if(b){for(;b.length;){var d=b.pop(),e=this.getResult(d);for(f=this._loadQueue.length-1;f>=0;f--)if(g=this._loadQueue[f].getItem(),g.id==d||g.src==d){this._loadQueue.splice(f,1)[0].cancel();break}for(f=this._loadQueueBackup.length-1;f>=0;f--)if(g=this._loadQueueBackup[f].getItem(),g.id==d||g.src==d){this._loadQueueBackup.splice(f,1)[0].cancel();break}if(e)this._disposeItem(this.getItem(d));else for(var f=this._currentLoads.length-1;f>=0;f--){var g=this._currentLoads[f].getItem();if(g.id==d||g.src==d){this._currentLoads.splice(f,1)[0].cancel(),c=!0;break}}}c&&this._loadNext()}else{this.close();for(var h in this._loadItemsById)this._disposeItem(this._loadItemsById[h]);this.init(this.preferXHR,this._basePath)}},a.reset=function(){this.close();for(var a in this._loadItemsById)this._disposeItem(this._loadItemsById[a]);for(var b=[],c=0,d=this._loadQueueBackup.length;d>c;c++)b.push(this._loadQueueBackup[c].getItem());this.loadManifest(b,!1)},a.installPlugin=function(a){if(null!=a&&null!=a.getPreloadHandlers){this._plugins.push(a);var b=a.getPreloadHandlers();if(b.scope=a,null!=b.types)for(var c=0,d=b.types.length;d>c;c++)this._typeCallbacks[b.types[c]]=b;if(null!=b.extensions)for(c=0,d=b.extensions.length;d>c;c++)this._extensionCallbacks[b.extensions[c]]=b}},a.setMaxConnections=function(a){this._maxConnections=a,!this._paused&&this._loadQueue.length>0&&this._loadNext()},a.loadFile=function(a,b,c){if(null==a){var d=new createjs.ErrorEvent("PRELOAD_NO_FILE");return void this._sendError(d)}this._addItem(a,null,c),this.setPaused(b!==!1?!1:!0)},a.loadManifest=function(a,c,d){var e=null,f=null;if(Array.isArray(a)){if(0==a.length){var g=new createjs.ErrorEvent("PRELOAD_MANIFEST_EMPTY");return void this._sendError(g)}e=a}else if("string"==typeof a)e=[{src:a,type:b.MANIFEST}];else{if("object"!=typeof a){var g=new createjs.ErrorEvent("PRELOAD_MANIFEST_NULL");return void this._sendError(g)}if(void 0!==a.src){if(null==a.type)a.type=b.MANIFEST;else if(a.type!=b.MANIFEST){var g=new createjs.ErrorEvent("PRELOAD_MANIFEST_TYPE");this._sendError(g)}e=[a]}else void 0!==a.manifest&&(e=a.manifest,f=a.path)}for(var h=0,i=e.length;i>h;h++)this._addItem(e[h],f,d);this.setPaused(c!==!1?!1:!0)},a.load=function(){this.setPaused(!1)},a.getItem=function(a){return this._loadItemsById[a]||this._loadItemsBySrc[a]},a.getResult=function(a,b){var c=this._loadItemsById[a]||this._loadItemsBySrc[a];if(null==c)return null;var d=c.id;return b&&this._loadedRawResults[d]?this._loadedRawResults[d]:this._loadedResults[d]},a.getItems=function(a){var b=[];for(var c in this._loadItemsById){var d=this._loadItemsById[c],e=this.getResult(c);(a!==!0||null!=e)&&b.push({item:d,result:e,rawResult:this.getResult(c,!0)})}return b},a.setPaused=function(a){this._paused=a,this._paused||this._loadNext()},a.close=function(){for(;this._currentLoads.length;)this._currentLoads.pop().cancel();this._scriptOrder.length=0,this._loadedScripts.length=0,this.loadStartWasDispatched=!1,this._itemCount=0,this._lastProgress=0/0},a._addItem=function(a,b,c){var d=this._createLoadItem(a,b,c);if(null!=d){var e=this._createLoader(d);null!=e&&("plugins"in e&&(e.plugins=this._plugins),d._loader=e,this._loadQueue.push(e),this._loadQueueBackup.push(e),this._numItems++,this._updateProgress(),(this.maintainScriptOrder&&d.type==createjs.LoadQueue.JAVASCRIPT||d.maintainOrder===!0)&&(this._scriptOrder.push(d),this._loadedScripts.push(null)))}},a._createLoadItem=function(a,b,c){var d=createjs.LoadItem.create(a);if(null==d)return null;var e="",f=c||this._basePath;if(d.src instanceof Object){if(!d.type)return null;if(b){e=b;var g=createjs.RequestUtils.parseURI(b);null==f||g.absolute||g.relative||(e=f+e)}else null!=f&&(e=f)}else{var h=createjs.RequestUtils.parseURI(d.src);h.extension&&(d.ext=h.extension),null==d.type&&(d.type=createjs.RequestUtils.getTypeByExtension(d.ext));var i=d.src;if(!h.absolute&&!h.relative)if(b){e=b;var g=createjs.RequestUtils.parseURI(b);i=b+i,null==f||g.absolute||g.relative||(e=f+e)}else null!=f&&(e=f);d.src=e+d.src}d.path=e,(void 0===d.id||null===d.id||""===d.id)&&(d.id=i);var j=this._typeCallbacks[d.type]||this._extensionCallbacks[d.ext];if(j){var k=j.callback.call(j.scope,d,this);if(k===!1)return null;k===!0||null!=k&&(d._loader=k),h=createjs.RequestUtils.parseURI(d.src),null!=h.extension&&(d.ext=h.extension)}return this._loadItemsById[d.id]=d,this._loadItemsBySrc[d.src]=d,null==d.crossOrigin&&(d.crossOrigin=this._crossOrigin),d},a._createLoader=function(a){if(null!=a._loader)return a._loader;for(var b=this.preferXHR,c=0;c=this._maxConnections);a++){var b=this._loadQueue[a];this._canStartLoad(b)&&(this._loadQueue.splice(a,1),a--,this._loadItem(b))}}},a._loadItem=function(a){a.on("fileload",this._handleFileLoad,this),a.on("progress",this._handleProgress,this),a.on("complete",this._handleFileComplete,this),a.on("error",this._handleError,this),a.on("fileerror",this._handleFileError,this),this._currentLoads.push(a),this._sendFileStart(a.getItem()),a.load()},a._handleFileLoad=function(a){a.target=null,this.dispatchEvent(a)},a._handleFileError=function(a){var b=new createjs.ErrorEvent("FILE_LOAD_ERROR",null,a.item);this._sendError(b)},a._handleError=function(a){var b=a.target;this._numItemsLoaded++,this._finishOrderedItem(b,!0),this._updateProgress();var c=new createjs.ErrorEvent("FILE_LOAD_ERROR",null,b.getItem());this._sendError(c),this.stopOnError?this.setPaused(!0):(this._removeLoadItem(b),this._cleanLoadItem(b),this._loadNext())},a._handleFileComplete=function(a){var b=a.target,c=b.getItem(),d=b.getResult();this._loadedResults[c.id]=d;var e=b.getResult(!0);null!=e&&e!==d&&(this._loadedRawResults[c.id]=e),this._saveLoadedItems(b),this._removeLoadItem(b),this._finishOrderedItem(b)||this._processFinishedLoad(c,b),this._cleanLoadItem(b)},a._saveLoadedItems=function(a){var b=a.getLoadedItems();if(null!==b)for(var c=0;cb;b++){var c=this._loadedScripts[b];if(null===c)break;if(c!==!0){var d=this._loadedResults[c.id];c.type==createjs.LoadQueue.JAVASCRIPT&&createjs.DomUtils.appendToHead(d);var e=c._loader;this._processFinishedLoad(c,e),this._loadedScripts[b]=!0}}},a._processFinishedLoad=function(a,b){if(this._numItemsLoaded++,!this.maintainScriptOrder&&a.type==createjs.LoadQueue.JAVASCRIPT){var c=b.getTag();createjs.DomUtils.appendToHead(c)}this._updateProgress(),this._sendFileComplete(a,b),this._loadNext()},a._canStartLoad=function(a){if(!this.maintainScriptOrder||a.preferXHR)return!0;var b=a.getItem();if(b.type!=createjs.LoadQueue.JAVASCRIPT)return!0;if(this._currentlyLoadingScript)return!1;for(var c=this._scriptOrder.indexOf(b),d=0;c>d;){var e=this._loadedScripts[d];if(null==e)return!1;d++}return this._currentlyLoadingScript=!0,!0},a._removeLoadItem=function(a){for(var b=this._currentLoads.length,c=0;b>c;c++)if(this._currentLoads[c]==a){this._currentLoads.splice(c,1);break}},a._cleanLoadItem=function(a){var b=a.getItem();b&&delete b._loader},a._handleProgress=function(a){var b=a.target;this._sendFileProgress(b.getItem(),b.progress),this._updateProgress()},a._updateProgress=function(){var a=this._numItemsLoaded/this._numItems,b=this._numItems-this._numItemsLoaded;if(b>0){for(var c=0,d=0,e=this._currentLoads.length;e>d;d++)c+=this._currentLoads[d].progress;a+=c/b*(b/this._numItems)}this._lastProgress!=a&&(this._sendProgress(a),this._lastProgress=a)},a._disposeItem=function(a){delete this._loadedResults[a.id],delete this._loadedRawResults[a.id],delete this._loadItemsById[a.id],delete this._loadItemsBySrc[a.src]},a._sendFileProgress=function(a,b){if(!this._isCanceled()&&!this._paused&&this.hasEventListener("fileprogress")){var c=new createjs.Event("fileprogress");c.progress=b,c.loaded=b,c.total=1,c.item=a,this.dispatchEvent(c)}},a._sendFileComplete=function(a,b){if(!this._isCanceled()&&!this._paused){var c=new createjs.Event("fileload");c.loader=b,c.item=a,c.result=this._loadedResults[a.id],c.rawResult=this._loadedRawResults[a.id],a.completeHandler&&a.completeHandler(c),this.hasEventListener("fileload")&&this.dispatchEvent(c)}},a._sendFileStart=function(a){var b=new createjs.Event("filestart");b.item=a,this.hasEventListener("filestart")&&this.dispatchEvent(b)},a.toString=function(){return"[PreloadJS LoadQueue]"},createjs.LoadQueue=createjs.promote(LoadQueue,"AbstractLoader")}(),this.createjs=this.createjs||{},function(){"use strict";function TextLoader(a){this.AbstractLoader_constructor(a,!0,createjs.AbstractLoader.TEXT)}var a=(createjs.extend(TextLoader,createjs.AbstractLoader),TextLoader);a.canLoadItem=function(a){return a.type==createjs.AbstractLoader.TEXT},createjs.TextLoader=createjs.promote(TextLoader,"AbstractLoader")}(),this.createjs=this.createjs||{},function(){"use strict";function BinaryLoader(a){this.AbstractLoader_constructor(a,!0,createjs.AbstractLoader.BINARY),this.on("initialize",this._updateXHR,this)}var a=createjs.extend(BinaryLoader,createjs.AbstractLoader),b=BinaryLoader;b.canLoadItem=function(a){return a.type==createjs.AbstractLoader.BINARY},a._updateXHR=function(a){a.loader.setResponseType("arraybuffer")},createjs.BinaryLoader=createjs.promote(BinaryLoader,"AbstractLoader")}(),this.createjs=this.createjs||{},function(){"use strict";function CSSLoader(a,b){this.AbstractLoader_constructor(a,b,createjs.AbstractLoader.CSS),this.resultFormatter=this._formatResult,this._tagSrcAttribute="href",this._tag=document.createElement(b?"style":"link"),this._tag.rel="stylesheet",this._tag.type="text/css"}var a=createjs.extend(CSSLoader,createjs.AbstractLoader),b=CSSLoader;b.canLoadItem=function(a){return a.type==createjs.AbstractLoader.CSS},a._formatResult=function(a){if(this._preferXHR){var b=a.getTag();if(b.styleSheet)b.styleSheet.cssText=a.getResult(!0);else{var c=document.createTextNode(a.getResult(!0));b.appendChild(c)}}else b=this._tag;return createjs.DomUtils.appendToHead(b),b},createjs.CSSLoader=createjs.promote(CSSLoader,"AbstractLoader")}(),this.createjs=this.createjs||{},function(){"use strict";function ImageLoader(a,b){this.AbstractLoader_constructor(a,b,createjs.AbstractLoader.IMAGE),this.resultFormatter=this._formatResult,this._tagSrcAttribute="src",createjs.RequestUtils.isImageTag(a)?this._tag=a:createjs.RequestUtils.isImageTag(a.src)?this._tag=a.src:createjs.RequestUtils.isImageTag(a.tag)&&(this._tag=a.tag),null!=this._tag?this._preferXHR=!1:this._tag=document.createElement("img"),this.on("initialize",this._updateXHR,this)}var a=createjs.extend(ImageLoader,createjs.AbstractLoader),b=ImageLoader;b.canLoadItem=function(a){return a.type==createjs.AbstractLoader.IMAGE},a.load=function(){if(""!=this._tag.src&&this._tag.complete)return void this._sendComplete();var a=this._item.crossOrigin;1==a&&(a="Anonymous"),null==a||createjs.RequestUtils.isLocal(this._item.src)||(this._tag.crossOrigin=a),this.AbstractLoader_load()},a._updateXHR=function(a){a.loader.mimeType="text/plain; charset=x-user-defined-binary",a.loader.setResponseType&&a.loader.setResponseType("blob")},a._formatResult=function(){return this._formatImage},a._formatImage=function(a,b){var c=this._tag,d=window.URL||window.webkitURL;if(this._preferXHR)if(d){var e=d.createObjectURL(this.getResult(!0));c.src=e,c.addEventListener("load",this._cleanUpURL,!1),c.addEventListener("error",this._cleanUpURL,!1)}else c.src=loader.getItem().src;else;c.complete?a(c):(c.addEventListener("load",createjs.proxy(function(){a(this._tag)},this),!1),c.addEventListener("error",createjs.proxy(function(){b(this._tag)},this),!1))},a._cleanUpURL=function(a){var b=window.URL||window.webkitURL;b.revokeObjectURL(a.target.src)},createjs.ImageLoader=createjs.promote(ImageLoader,"AbstractLoader")}(),this.createjs=this.createjs||{},function(){"use strict";function JavaScriptLoader(a,b){this.AbstractLoader_constructor(a,b,createjs.AbstractLoader.JAVASCRIPT),this.resultFormatter=this._formatResult,this._tagSrcAttribute="src",this.setTag(document.createElement("script"))}var a=createjs.extend(JavaScriptLoader,createjs.AbstractLoader),b=JavaScriptLoader;b.canLoadItem=function(a){return a.type==createjs.AbstractLoader.JAVASCRIPT},a._formatResult=function(a){var b=a.getTag();return this._preferXHR&&(b.text=a.getResult(!0)),b},createjs.JavaScriptLoader=createjs.promote(JavaScriptLoader,"AbstractLoader")}(),this.createjs=this.createjs||{},function(){"use strict";function JSONLoader(a){this.AbstractLoader_constructor(a,!0,createjs.AbstractLoader.JSON),this.resultFormatter=this._formatResult}var a=createjs.extend(JSONLoader,createjs.AbstractLoader),b=JSONLoader;b.canLoadItem=function(a){return a.type==createjs.AbstractLoader.JSON},a._formatResult=function(a){var b=null;try{b=createjs.DataUtils.parseJSON(a.getResult(!0))}catch(c){var d=new createjs.ErrorEvent("JSON_FORMAT",null,c);return this._sendError(d),c}return b},createjs.JSONLoader=createjs.promote(JSONLoader,"AbstractLoader")}(),this.createjs=this.createjs||{},function(){"use strict";function JSONPLoader(a){this.AbstractLoader_constructor(a,!1,createjs.AbstractLoader.JSONP),this.setTag(document.createElement("script")),this.getTag().type="text/javascript"}var a=createjs.extend(JSONPLoader,createjs.AbstractLoader),b=JSONPLoader;b.canLoadItem=function(a){return a.type==createjs.AbstractLoader.JSONP},a.cancel=function(){this.AbstractLoader_cancel(),this._dispose()},a.load=function(){if(null==this._item.callback)throw new Error("callback is required for loading JSONP requests.");if(null!=window[this._item.callback])throw new Error("JSONP callback '"+this._item.callback+"' already exists on window. You need to specify a different callback or re-name the current one.");window[this._item.callback]=createjs.proxy(this._handleLoad,this),window.document.body.appendChild(this._tag),this._loadTimeout=setTimeout(createjs.proxy(this._handleTimeout,this),this._item.loadTimeout),this._tag.src=this._item.src},a._handleLoad=function(a){this._result=this._rawResult=a,this._sendComplete(),this._dispose()},a._handleTimeout=function(){this._dispose(),this.dispatchEvent(new createjs.ErrorEvent("timeout"))},a._dispose=function(){window.document.body.removeChild(this._tag),delete window[this._item.callback],clearTimeout(this._loadTimeout)},createjs.JSONPLoader=createjs.promote(JSONPLoader,"AbstractLoader")}(),this.createjs=this.createjs||{},function(){"use strict";function ManifestLoader(a){this.AbstractLoader_constructor(a,null,createjs.AbstractLoader.MANIFEST),this.plugins=null,this._manifestQueue=null}var a=createjs.extend(ManifestLoader,createjs.AbstractLoader),b=ManifestLoader;b.MANIFEST_PROGRESS=.25,b.canLoadItem=function(a){return a.type==createjs.AbstractLoader.MANIFEST},a.load=function(){this.AbstractLoader_load()},a._createRequest=function(){var a=this._item.callback;this._request=null!=a?new createjs.JSONPLoader(this._item):new createjs.JSONLoader(this._item)},a.handleEvent=function(a){switch(a.type){case"complete":return this._rawResult=a.target.getResult(!0),this._result=a.target.getResult(),this._sendProgress(b.MANIFEST_PROGRESS),void this._loadManifest(this._result);case"progress":return a.loaded*=b.MANIFEST_PROGRESS,this.progress=a.loaded/a.total,(isNaN(this.progress)||1/0==this.progress)&&(this.progress=0),void this._sendProgress(a)}this.AbstractLoader_handleEvent(a)},a.destroy=function(){this.AbstractLoader_destroy(),this._manifestQueue.close()},a._loadManifest=function(a){if(a&&a.manifest){var b=this._manifestQueue=new createjs.LoadQueue;b.on("fileload",this._handleManifestFileLoad,this),b.on("progress",this._handleManifestProgress,this),b.on("complete",this._handleManifestComplete,this,!0),b.on("error",this._handleManifestError,this,!0);for(var c=0,d=this.plugins.length;d>c;c++)b.installPlugin(this.plugins[c]);b.loadManifest(a)}else this._sendComplete()},a._handleManifestFileLoad=function(a){a.target=null,this.dispatchEvent(a)},a._handleManifestComplete=function(){this._loadedItems=this._manifestQueue.getItems(!0),this._sendComplete()},a._handleManifestProgress=function(a){this.progress=a.progress*(1-b.MANIFEST_PROGRESS)+b.MANIFEST_PROGRESS,this._sendProgress(this.progress)},a._handleManifestError=function(a){var b=new createjs.Event("fileerror");b.item=a.data,this.dispatchEvent(b)},createjs.ManifestLoader=createjs.promote(ManifestLoader,"AbstractLoader")}(),this.createjs=this.createjs||{},function(){"use strict";function SoundLoader(a,b){this.AbstractMediaLoader_constructor(a,b,createjs.AbstractLoader.SOUND),createjs.RequestUtils.isAudioTag(a)?this._tag=a:createjs.RequestUtils.isAudioTag(a.src)?this._tag=a:createjs.RequestUtils.isAudioTag(a.tag)&&(this._tag=createjs.RequestUtils.isAudioTag(a)?a:a.src),null!=this._tag&&(this._preferXHR=!1)}var a=createjs.extend(SoundLoader,createjs.AbstractMediaLoader),b=SoundLoader;b.canLoadItem=function(a){return a.type==createjs.AbstractLoader.SOUND},a._createTag=function(a){var b=document.createElement("audio");return b.autoplay=!1,b.preload="none",b.src=a,b},createjs.SoundLoader=createjs.promote(SoundLoader,"AbstractMediaLoader")}(),this.createjs=this.createjs||{},function(){"use strict";function VideoLoader(a,b){this.AbstractMediaLoader_constructor(a,b,createjs.AbstractLoader.VIDEO),createjs.RequestUtils.isVideoTag(a)||createjs.RequestUtils.isVideoTag(a.src)?(this.setTag(createjs.RequestUtils.isVideoTag(a)?a:a.src),this._preferXHR=!1):this.setTag(this._createTag())}var a=createjs.extend(VideoLoader,createjs.AbstractMediaLoader),b=VideoLoader;a._createTag=function(){return document.createElement("video")},b.canLoadItem=function(a){return a.type==createjs.AbstractLoader.VIDEO},createjs.VideoLoader=createjs.promote(VideoLoader,"AbstractMediaLoader")}(),this.createjs=this.createjs||{},function(){"use strict";function SpriteSheetLoader(a,b){this.AbstractLoader_constructor(a,b,createjs.AbstractLoader.SPRITESHEET),this._manifestQueue=null}var a=createjs.extend(SpriteSheetLoader,createjs.AbstractLoader),b=SpriteSheetLoader;b.SPRITESHEET_PROGRESS=.25,b.canLoadItem=function(a){return a.type==createjs.AbstractLoader.SPRITESHEET},a.destroy=function(){this.AbstractLoader_destroy,this._manifestQueue.close()},a._createRequest=function(){var a=this._item.callback;this._request=null!=a?new createjs.JSONPLoader(this._item):new createjs.JSONLoader(this._item)},a.handleEvent=function(a){switch(a.type){case"complete":return this._rawResult=a.target.getResult(!0),this._result=a.target.getResult(),this._sendProgress(b.SPRITESHEET_PROGRESS),void this._loadManifest(this._result);case"progress":return a.loaded*=b.SPRITESHEET_PROGRESS,this.progress=a.loaded/a.total,(isNaN(this.progress)||1/0==this.progress)&&(this.progress=0),void this._sendProgress(a)}this.AbstractLoader_handleEvent(a)},a._loadManifest=function(a){if(a&&a.images){var b=this._manifestQueue=new createjs.LoadQueue(this._preferXHR,this._item.path,this._item.crossOrigin);b.on("complete",this._handleManifestComplete,this,!0),b.on("fileload",this._handleManifestFileLoad,this),b.on("progress",this._handleManifestProgress,this),b.on("error",this._handleManifestError,this,!0),b.loadManifest(a.images)}},a._handleManifestFileLoad=function(a){var b=a.result;if(null!=b){var c=this.getResult().images,d=c.indexOf(a.item.src);c[d]=b}},a._handleManifestComplete=function(){this._result=new createjs.SpriteSheet(this._result),this._loadedItems=this._manifestQueue.getItems(!0),this._sendComplete()},a._handleManifestProgress=function(a){this.progress=a.progress*(1-b.SPRITESHEET_PROGRESS)+b.SPRITESHEET_PROGRESS,this._sendProgress(this.progress)},a._handleManifestError=function(a){var b=new createjs.Event("fileerror");b.item=a.data,this.dispatchEvent(b)},createjs.SpriteSheetLoader=createjs.promote(SpriteSheetLoader,"AbstractLoader")}(),this.createjs=this.createjs||{},function(){"use strict";function SVGLoader(a,b){this.AbstractLoader_constructor(a,b,createjs.AbstractLoader.SVG),this.resultFormatter=this._formatResult,this._tagSrcAttribute="data",b?this.setTag(document.createElement("svg")):(this.setTag(document.createElement("object")),this.getTag().type="image/svg+xml")}var a=createjs.extend(SVGLoader,createjs.AbstractLoader),b=SVGLoader;b.canLoadItem=function(a){return a.type==createjs.AbstractLoader.SVG},a._formatResult=function(a){var b=createjs.DataUtils.parseXML(a.getResult(!0),"text/xml"),c=a.getTag();return!this._preferXHR&&document.body.contains(c)&&document.body.removeChild(c),null!=b.documentElement?(c.appendChild(b.documentElement),c.style.visibility="visible",c):b},createjs.SVGLoader=createjs.promote(SVGLoader,"AbstractLoader")}(),this.createjs=this.createjs||{},function(){"use strict";function XMLLoader(a){this.AbstractLoader_constructor(a,!0,createjs.AbstractLoader.XML),this.resultFormatter=this._formatResult}var a=createjs.extend(XMLLoader,createjs.AbstractLoader),b=XMLLoader;b.canLoadItem=function(a){return a.type==createjs.AbstractLoader.XML},a._formatResult=function(a){return createjs.DataUtils.parseXML(a.getResult(!0),"text/xml")},createjs.XMLLoader=createjs.promote(XMLLoader,"AbstractLoader")}();
\ No newline at end of file
diff --git a/_assets/libs/soundjs-NEXT.min.js b/_assets/libs/soundjs-NEXT.min.js
deleted file mode 100644
index bbfc84245..000000000
--- a/_assets/libs/soundjs-NEXT.min.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/*!
-* @license SoundJS
-* Visit http://createjs.com/ for documentation, updates and examples.
-*
-* Copyright (c) 2011-2015 gskinner.com, inc.
-*
-* Distributed under the terms of the MIT license.
-* http://www.opensource.org/licenses/mit-license.html
-*
-* This notice shall be included in all copies or substantial portions of the Software.
-*/
-
-/**!
- * SoundJS FlashAudioPlugin also includes swfobject (http://code.google.com/p/swfobject/)
- */
-
-this.createjs=this.createjs||{},function(){var a=createjs.SoundJS=createjs.SoundJS||{};a.version="NEXT",a.buildDate="Wed, 25 Nov 2015 19:26:51 GMT"}(),this.createjs=this.createjs||{},createjs.extend=function(a,b){"use strict";function c(){this.constructor=a}return c.prototype=b.prototype,a.prototype=new c},this.createjs=this.createjs||{},createjs.promote=function(a,b){"use strict";var c=a.prototype,d=Object.getPrototypeOf&&Object.getPrototypeOf(c)||c.__proto__;if(d){c[(b+="_")+"constructor"]=d.constructor;for(var e in d)c.hasOwnProperty(e)&&"function"==typeof d[e]&&(c[b+e]=d[e])}return a},this.createjs=this.createjs||{},createjs.indexOf=function(a,b){"use strict";for(var c=0,d=a.length;d>c;c++)if(b===a[c])return c;return-1},this.createjs=this.createjs||{},function(){"use strict";createjs.proxy=function(a,b){var c=Array.prototype.slice.call(arguments,2);return function(){return a.apply(b,Array.prototype.slice.call(arguments,0).concat(c))}}}(),this.createjs=this.createjs||{},function(){"use strict";function BrowserDetect(){throw"BrowserDetect cannot be instantiated"}var a=BrowserDetect.agent=window.navigator.userAgent;BrowserDetect.isWindowPhone=a.indexOf("IEMobile")>-1||a.indexOf("Windows Phone")>-1,BrowserDetect.isFirefox=a.indexOf("Firefox")>-1,BrowserDetect.isOpera=null!=window.opera,BrowserDetect.isChrome=a.indexOf("Chrome")>-1,BrowserDetect.isIOS=(a.indexOf("iPod")>-1||a.indexOf("iPhone")>-1||a.indexOf("iPad")>-1)&&!BrowserDetect.isWindowPhone,BrowserDetect.isAndroid=a.indexOf("Android")>-1&&!BrowserDetect.isWindowPhone,BrowserDetect.isBlackberry=a.indexOf("Blackberry")>-1,createjs.BrowserDetect=BrowserDetect}(),this.createjs=this.createjs||{},function(){"use strict";function EventDispatcher(){this._listeners=null,this._captureListeners=null}var a=EventDispatcher.prototype;EventDispatcher.initialize=function(b){b.addEventListener=a.addEventListener,b.on=a.on,b.removeEventListener=b.off=a.removeEventListener,b.removeAllEventListeners=a.removeAllEventListeners,b.hasEventListener=a.hasEventListener,b.dispatchEvent=a.dispatchEvent,b._dispatchEvent=a._dispatchEvent,b.willTrigger=a.willTrigger},a.addEventListener=function(a,b,c){var d;d=c?this._captureListeners=this._captureListeners||{}:this._listeners=this._listeners||{};var e=d[a];return e&&this.removeEventListener(a,b,c),e=d[a],e?e.push(b):d[a]=[b],b},a.on=function(a,b,c,d,e,f){return b.handleEvent&&(c=c||b,b=b.handleEvent),c=c||this,this.addEventListener(a,function(a){b.call(c,a,e),d&&a.remove()},f)},a.removeEventListener=function(a,b,c){var d=c?this._captureListeners:this._listeners;if(d){var e=d[a];if(e)for(var f=0,g=e.length;g>f;f++)if(e[f]==b){1==g?delete d[a]:e.splice(f,1);break}}},a.off=a.removeEventListener,a.removeAllEventListeners=function(a){a?(this._listeners&&delete this._listeners[a],this._captureListeners&&delete this._captureListeners[a]):this._listeners=this._captureListeners=null},a.dispatchEvent=function(a,b,c){if("string"==typeof a){var d=this._listeners;if(!(b||d&&d[a]))return!0;a=new createjs.Event(a,b,c)}else a.target&&a.clone&&(a=a.clone());try{a.target=this}catch(e){}if(a.bubbles&&this.parent){for(var f=this,g=[f];f.parent;)g.push(f=f.parent);var h,i=g.length;for(h=i-1;h>=0&&!a.propagationStopped;h--)g[h]._dispatchEvent(a,1+(0==h));for(h=1;i>h&&!a.propagationStopped;h++)g[h]._dispatchEvent(a,3)}else this._dispatchEvent(a,2);return!a.defaultPrevented},a.hasEventListener=function(a){var b=this._listeners,c=this._captureListeners;return!!(b&&b[a]||c&&c[a])},a.willTrigger=function(a){for(var b=this;b;){if(b.hasEventListener(a))return!0;b=b.parent}return!1},a.toString=function(){return"[EventDispatcher]"},a._dispatchEvent=function(a,b){var c,d=1==b?this._captureListeners:this._listeners;if(a&&d){var e=d[a.type];if(!e||!(c=e.length))return;try{a.currentTarget=this}catch(f){}try{a.eventPhase=b}catch(f){}a.removed=!1,e=e.slice();for(var g=0;c>g&&!a.immediatePropagationStopped;g++){var h=e[g];h.handleEvent?h.handleEvent(a):h(a),a.removed&&(this.off(a.type,h,1==b),a.removed=!1)}}},createjs.EventDispatcher=EventDispatcher}(),this.createjs=this.createjs||{},function(){"use strict";function Event(a,b,c){this.type=a,this.target=null,this.currentTarget=null,this.eventPhase=0,this.bubbles=!!b,this.cancelable=!!c,this.timeStamp=(new Date).getTime(),this.defaultPrevented=!1,this.propagationStopped=!1,this.immediatePropagationStopped=!1,this.removed=!1}var a=Event.prototype;a.preventDefault=function(){this.defaultPrevented=this.cancelable&&!0},a.stopPropagation=function(){this.propagationStopped=!0},a.stopImmediatePropagation=function(){this.immediatePropagationStopped=this.propagationStopped=!0},a.remove=function(){this.removed=!0},a.clone=function(){return new Event(this.type,this.bubbles,this.cancelable)},a.set=function(a){for(var b in a)this[b]=a[b];return this},a.toString=function(){return"[Event (type="+this.type+")]"},createjs.Event=Event}(),this.createjs=this.createjs||{},function(){"use strict";function ErrorEvent(a,b,c){this.Event_constructor("error"),this.title=a,this.message=b,this.data=c}var a=createjs.extend(ErrorEvent,createjs.Event);a.clone=function(){return new createjs.ErrorEvent(this.title,this.message,this.data)},createjs.ErrorEvent=createjs.promote(ErrorEvent,"Event")}(),this.createjs=this.createjs||{},function(){"use strict";function ProgressEvent(a,b){this.Event_constructor("progress"),this.loaded=a,this.total=null==b?1:b,this.progress=0==b?0:this.loaded/this.total}var a=createjs.extend(ProgressEvent,createjs.Event);a.clone=function(){return new createjs.ProgressEvent(this.loaded,this.total)},createjs.ProgressEvent=createjs.promote(ProgressEvent,"Event")}(window),this.createjs=this.createjs||{},function(){"use strict";function LoadItem(){this.src=null,this.type=null,this.id=null,this.maintainOrder=!1,this.callback=null,this.data=null,this.method=createjs.LoadItem.GET,this.values=null,this.headers=null,this.withCredentials=!1,this.mimeType=null,this.crossOrigin=null,this.loadTimeout=b.LOAD_TIMEOUT_DEFAULT}var a=LoadItem.prototype={},b=LoadItem;b.LOAD_TIMEOUT_DEFAULT=8e3,b.create=function(a){if("string"==typeof a){var c=new LoadItem;return c.src=a,c}if(a instanceof b)return a;if(a instanceof Object&&a.src)return null==a.loadTimeout&&(a.loadTimeout=b.LOAD_TIMEOUT_DEFAULT),a;throw new Error("Type not recognized.")},a.set=function(a){for(var b in a)this[b]=a[b];return this},createjs.LoadItem=b}(),function(){var a={};a.ABSOLUTE_PATT=/^(?:\w+:)?\/{2}/i,a.RELATIVE_PATT=/^[.\/]*?\//i,a.EXTENSION_PATT=/\/?[^\/]+\.(\w{1,5})$/i,a.parseURI=function(b){var c={absolute:!1,relative:!1};if(null==b)return c;var d=b.indexOf("?");d>-1&&(b=b.substr(0,d));var e;return a.ABSOLUTE_PATT.test(b)?c.absolute=!0:a.RELATIVE_PATT.test(b)&&(c.relative=!0),(e=b.match(a.EXTENSION_PATT))&&(c.extension=e[1].toLowerCase()),c},a.formatQueryString=function(a,b){if(null==a)throw new Error("You must specify data.");var c=[];for(var d in a)c.push(d+"="+escape(a[d]));return b&&(c=c.concat(b)),c.join("&")},a.buildPath=function(a,b){if(null==b)return a;var c=[],d=a.indexOf("?");if(-1!=d){var e=a.slice(d+1);c=c.concat(e.split("&"))}return-1!=d?a.slice(0,d)+"?"+this._formatQueryString(b,c):a+"?"+this._formatQueryString(b,c)},a.isCrossDomain=function(a){var b=document.createElement("a");b.href=a.src;var c=document.createElement("a");c.href=location.href;var d=""!=b.hostname&&(b.port!=c.port||b.protocol!=c.protocol||b.hostname!=c.hostname);return d},a.isLocal=function(a){var b=document.createElement("a");return b.href=a.src,""==b.hostname&&"file:"==b.protocol},a.isBinary=function(a){switch(a){case createjs.AbstractLoader.IMAGE:case createjs.AbstractLoader.BINARY:return!0;default:return!1}},a.isImageTag=function(a){return a instanceof HTMLImageElement},a.isAudioTag=function(a){return window.HTMLAudioElement?a instanceof HTMLAudioElement:!1},a.isVideoTag=function(a){return window.HTMLVideoElement?a instanceof HTMLVideoElement:!1},a.isText=function(a){switch(a){case createjs.AbstractLoader.TEXT:case createjs.AbstractLoader.JSON:case createjs.AbstractLoader.MANIFEST:case createjs.AbstractLoader.XML:case createjs.AbstractLoader.CSS:case createjs.AbstractLoader.SVG:case createjs.AbstractLoader.JAVASCRIPT:case createjs.AbstractLoader.SPRITESHEET:return!0;default:return!1}},a.getTypeByExtension=function(a){if(null==a)return createjs.AbstractLoader.TEXT;switch(a.toLowerCase()){case"jpeg":case"jpg":case"gif":case"png":case"webp":case"bmp":return createjs.AbstractLoader.IMAGE;case"ogg":case"mp3":case"webm":return createjs.AbstractLoader.SOUND;case"mp4":case"webm":case"ts":return createjs.AbstractLoader.VIDEO;case"json":return createjs.AbstractLoader.JSON;case"xml":return createjs.AbstractLoader.XML;case"css":return createjs.AbstractLoader.CSS;case"js":return createjs.AbstractLoader.JAVASCRIPT;case"svg":return createjs.AbstractLoader.SVG;default:return createjs.AbstractLoader.TEXT}},createjs.RequestUtils=a}(),this.createjs=this.createjs||{},function(){"use strict";function AbstractLoader(a,b,c){this.EventDispatcher_constructor(),this.loaded=!1,this.canceled=!1,this.progress=0,this.type=c,this.resultFormatter=null,this._item=a?createjs.LoadItem.create(a):null,this._preferXHR=b,this._result=null,this._rawResult=null,this._loadedItems=null,this._tagSrcAttribute=null,this._tag=null}var a=createjs.extend(AbstractLoader,createjs.EventDispatcher),b=AbstractLoader;b.POST="POST",b.GET="GET",b.BINARY="binary",b.CSS="css",b.IMAGE="image",b.JAVASCRIPT="javascript",b.JSON="json",b.JSONP="jsonp",b.MANIFEST="manifest",b.SOUND="sound",b.VIDEO="video",b.SPRITESHEET="spritesheet",b.SVG="svg",b.TEXT="text",b.XML="xml",a.getItem=function(){return this._item},a.getResult=function(a){return a?this._rawResult:this._result},a.getTag=function(){return this._tag},a.setTag=function(a){this._tag=a},a.load=function(){this._createRequest(),this._request.on("complete",this,this),this._request.on("progress",this,this),this._request.on("loadStart",this,this),this._request.on("abort",this,this),this._request.on("timeout",this,this),this._request.on("error",this,this);var a=new createjs.Event("initialize");a.loader=this._request,this.dispatchEvent(a),this._request.load()},a.cancel=function(){this.canceled=!0,this.destroy()},a.destroy=function(){this._request&&(this._request.removeAllEventListeners(),this._request.destroy()),this._request=null,this._item=null,this._rawResult=null,this._result=null,this._loadItems=null,this.removeAllEventListeners()},a.getLoadedItems=function(){return this._loadedItems},a._createRequest=function(){this._request=this._preferXHR?new createjs.XHRRequest(this._item):new createjs.TagRequest(this._item,this._tag||this._createTag(),this._tagSrcAttribute)},a._createTag=function(){return null},a._sendLoadStart=function(){this._isCanceled()||this.dispatchEvent("loadstart")},a._sendProgress=function(a){if(!this._isCanceled()){var b=null;"number"==typeof a?(this.progress=a,b=new createjs.ProgressEvent(this.progress)):(b=a,this.progress=a.loaded/a.total,b.progress=this.progress,(isNaN(this.progress)||1/0==this.progress)&&(this.progress=0)),this.hasEventListener("progress")&&this.dispatchEvent(b)}},a._sendComplete=function(){if(!this._isCanceled()){this.loaded=!0;var a=new createjs.Event("complete");a.rawResult=this._rawResult,null!=this._result&&(a.result=this._result),this.dispatchEvent(a)}},a._sendError=function(a){!this._isCanceled()&&this.hasEventListener("error")&&(null==a&&(a=new createjs.ErrorEvent("PRELOAD_ERROR_EMPTY")),this.dispatchEvent(a))},a._isCanceled=function(){return null==window.createjs||this.canceled?!0:!1},a.resultFormatter=null,a.handleEvent=function(a){switch(a.type){case"complete":this._rawResult=a.target._response;var b=this.resultFormatter&&this.resultFormatter(this);b instanceof Function?b.call(this,createjs.proxy(this._resultFormatSuccess,this),createjs.proxy(this._resultFormatFailed,this)):(this._result=b||this._rawResult,this._sendComplete());break;case"progress":this._sendProgress(a);break;case"error":this._sendError(a);break;case"loadstart":this._sendLoadStart();break;case"abort":case"timeout":this._isCanceled()||this.dispatchEvent(new createjs.ErrorEvent("PRELOAD_"+a.type.toUpperCase()+"_ERROR"))}},a._resultFormatSuccess=function(a){this._result=a,this._sendComplete()},a._resultFormatFailed=function(a){this._sendError(a)},a.buildPath=function(a,b){return createjs.RequestUtils.buildPath(a,b)},a.toString=function(){return"[PreloadJS AbstractLoader]"},createjs.AbstractLoader=createjs.promote(AbstractLoader,"EventDispatcher")}(),this.createjs=this.createjs||{},function(){"use strict";function AbstractMediaLoader(a,b,c){this.AbstractLoader_constructor(a,b,c),this.resultFormatter=this._formatResult,this._tagSrcAttribute="src",this.on("initialize",this._updateXHR,this)}var a=createjs.extend(AbstractMediaLoader,createjs.AbstractLoader);a.load=function(){this._tag||(this._tag=this._createTag(this._item.src)),this._tag.preload="auto",this._tag.load(),this.AbstractLoader_load()},a._createTag=function(){},a._createRequest=function(){this._request=this._preferXHR?new createjs.XHRRequest(this._item):new createjs.MediaTagRequest(this._item,this._tag||this._createTag(),this._tagSrcAttribute)},a._updateXHR=function(a){a.loader.setResponseType&&a.loader.setResponseType("blob")},a._formatResult=function(a){if(this._tag.removeEventListener&&this._tag.removeEventListener("canplaythrough",this._loadedHandler),this._tag.onstalled=null,this._preferXHR){var b=window.URL||window.webkitURL,c=a.getResult(!0);a.getTag().src=b.createObjectURL(c)}return a.getTag()},createjs.AbstractMediaLoader=createjs.promote(AbstractMediaLoader,"AbstractLoader")}(),this.createjs=this.createjs||{},function(){"use strict";var AbstractRequest=function(a){this._item=a},a=createjs.extend(AbstractRequest,createjs.EventDispatcher);a.load=function(){},a.destroy=function(){},a.cancel=function(){},createjs.AbstractRequest=createjs.promote(AbstractRequest,"EventDispatcher")}(),this.createjs=this.createjs||{},function(){"use strict";function TagRequest(a,b,c){this.AbstractRequest_constructor(a),this._tag=b,this._tagSrcAttribute=c,this._loadedHandler=createjs.proxy(this._handleTagComplete,this),this._addedToDOM=!1,this._startTagVisibility=null}var a=createjs.extend(TagRequest,createjs.AbstractRequest);a.load=function(){this._tag.onload=createjs.proxy(this._handleTagComplete,this),this._tag.onreadystatechange=createjs.proxy(this._handleReadyStateChange,this),this._tag.onerror=createjs.proxy(this._handleError,this);var a=new createjs.Event("initialize");a.loader=this._tag,this.dispatchEvent(a),this._hideTag(),this._loadTimeout=setTimeout(createjs.proxy(this._handleTimeout,this),this._item.loadTimeout),this._tag[this._tagSrcAttribute]=this._item.src,null==this._tag.parentNode&&(window.document.body.appendChild(this._tag),this._addedToDOM=!0)},a.destroy=function(){this._clean(),this._tag=null,this.AbstractRequest_destroy()},a._handleReadyStateChange=function(){clearTimeout(this._loadTimeout);var a=this._tag;("loaded"==a.readyState||"complete"==a.readyState)&&this._handleTagComplete()},a._handleError=function(){this._clean(),this.dispatchEvent("error")},a._handleTagComplete=function(){this._rawResult=this._tag,this._result=this.resultFormatter&&this.resultFormatter(this)||this._rawResult,this._clean(),this._showTag(),this.dispatchEvent("complete")},a._handleTimeout=function(){this._clean(),this.dispatchEvent(new createjs.Event("timeout"))},a._clean=function(){this._tag.onload=null,this._tag.onreadystatechange=null,this._tag.onerror=null,this._addedToDOM&&null!=this._tag.parentNode&&this._tag.parentNode.removeChild(this._tag),clearTimeout(this._loadTimeout)},a._hideTag=function(){this._startTagVisibility=this._tag.style.visibility,this._tag.style.visibility="hidden"},a._showTag=function(){this._tag.style.visibility=this._startTagVisibility},a._handleStalled=function(){},createjs.TagRequest=createjs.promote(TagRequest,"AbstractRequest")}(),this.createjs=this.createjs||{},function(){"use strict";function MediaTagRequest(a,b,c){this.AbstractRequest_constructor(a),this._tag=b,this._tagSrcAttribute=c,this._loadedHandler=createjs.proxy(this._handleTagComplete,this)}var a=createjs.extend(MediaTagRequest,createjs.TagRequest);a.load=function(){var a=createjs.proxy(this._handleStalled,this);this._stalledCallback=a;var b=createjs.proxy(this._handleProgress,this);this._handleProgress=b,this._tag.addEventListener("stalled",a),this._tag.addEventListener("progress",b),this._tag.addEventListener&&this._tag.addEventListener("canplaythrough",this._loadedHandler,!1),this.TagRequest_load()},a._handleReadyStateChange=function(){clearTimeout(this._loadTimeout);var a=this._tag;("loaded"==a.readyState||"complete"==a.readyState)&&this._handleTagComplete()},a._handleStalled=function(){},a._handleProgress=function(a){if(a&&!(a.loaded>0&&0==a.total)){var b=new createjs.ProgressEvent(a.loaded,a.total);this.dispatchEvent(b)}},a._clean=function(){this._tag.removeEventListener&&this._tag.removeEventListener("canplaythrough",this._loadedHandler),this._tag.removeEventListener("stalled",this._stalledCallback),this._tag.removeEventListener("progress",this._progressCallback),this.TagRequest__clean()},createjs.MediaTagRequest=createjs.promote(MediaTagRequest,"TagRequest")}(),this.createjs=this.createjs||{},function(){"use strict";function XHRRequest(a){this.AbstractRequest_constructor(a),this._request=null,this._loadTimeout=null,this._xhrLevel=1,this._response=null,this._rawResponse=null,this._canceled=!1,this._handleLoadStartProxy=createjs.proxy(this._handleLoadStart,this),this._handleProgressProxy=createjs.proxy(this._handleProgress,this),this._handleAbortProxy=createjs.proxy(this._handleAbort,this),this._handleErrorProxy=createjs.proxy(this._handleError,this),this._handleTimeoutProxy=createjs.proxy(this._handleTimeout,this),this._handleLoadProxy=createjs.proxy(this._handleLoad,this),this._handleReadyStateChangeProxy=createjs.proxy(this._handleReadyStateChange,this),!this._createXHR(a)}var a=createjs.extend(XHRRequest,createjs.AbstractRequest);XHRRequest.ACTIVEX_VERSIONS=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],a.getResult=function(a){return a&&this._rawResponse?this._rawResponse:this._response},a.cancel=function(){this.canceled=!0,this._clean(),this._request.abort()},a.load=function(){if(null==this._request)return void this._handleError();null!=this._request.addEventListener?(this._request.addEventListener("loadstart",this._handleLoadStartProxy,!1),this._request.addEventListener("progress",this._handleProgressProxy,!1),this._request.addEventListener("abort",this._handleAbortProxy,!1),this._request.addEventListener("error",this._handleErrorProxy,!1),this._request.addEventListener("timeout",this._handleTimeoutProxy,!1),this._request.addEventListener("load",this._handleLoadProxy,!1),this._request.addEventListener("readystatechange",this._handleReadyStateChangeProxy,!1)):(this._request.onloadstart=this._handleLoadStartProxy,this._request.onprogress=this._handleProgressProxy,this._request.onabort=this._handleAbortProxy,this._request.onerror=this._handleErrorProxy,this._request.ontimeout=this._handleTimeoutProxy,this._request.onload=this._handleLoadProxy,this._request.onreadystatechange=this._handleReadyStateChangeProxy),1==this._xhrLevel&&(this._loadTimeout=setTimeout(createjs.proxy(this._handleTimeout,this),this._item.loadTimeout));try{this._item.values&&this._item.method!=createjs.AbstractLoader.GET?this._item.method==createjs.AbstractLoader.POST&&this._request.send(createjs.RequestUtils.formatQueryString(this._item.values)):this._request.send()}catch(a){this.dispatchEvent(new createjs.ErrorEvent("XHR_SEND",null,a))}},a.setResponseType=function(a){"blob"===a&&(a=window.URL?"blob":"arraybuffer",this._responseType=a),this._request.responseType=a},a.getAllResponseHeaders=function(){return this._request.getAllResponseHeaders instanceof Function?this._request.getAllResponseHeaders():null},a.getResponseHeader=function(a){return this._request.getResponseHeader instanceof Function?this._request.getResponseHeader(a):null},a._handleProgress=function(a){if(a&&!(a.loaded>0&&0==a.total)){var b=new createjs.ProgressEvent(a.loaded,a.total);this.dispatchEvent(b)}},a._handleLoadStart=function(){clearTimeout(this._loadTimeout),this.dispatchEvent("loadstart")},a._handleAbort=function(a){this._clean(),this.dispatchEvent(new createjs.ErrorEvent("XHR_ABORTED",null,a))},a._handleError=function(a){this._clean(),this.dispatchEvent(new createjs.ErrorEvent(a.message))},a._handleReadyStateChange=function(){4==this._request.readyState&&this._handleLoad()},a._handleLoad=function(){if(!this.loaded){this.loaded=!0;var a=this._checkError();if(a)return void this._handleError(a);if(this._response=this._getResponse(),"arraybuffer"===this._responseType)try{this._response=new Blob([this._response])}catch(b){if(window.BlobBuilder=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder,"TypeError"===b.name&&window.BlobBuilder){var c=new BlobBuilder;c.append(this._response),this._response=c.getBlob()}}this._clean(),this.dispatchEvent(new createjs.Event("complete"))}},a._handleTimeout=function(a){this._clean(),this.dispatchEvent(new createjs.ErrorEvent("PRELOAD_TIMEOUT",null,a))},a._checkError=function(){var a=parseInt(this._request.status);switch(a){case 404:case 0:return new Error(a)}return null},a._getResponse=function(){if(null!=this._response)return this._response;if(null!=this._request.response)return this._request.response;try{if(null!=this._request.responseText)return this._request.responseText}catch(a){}try{if(null!=this._request.responseXML)return this._request.responseXML}catch(a){}return null},a._createXHR=function(a){var b=createjs.RequestUtils.isCrossDomain(a),c={},d=null;if(window.XMLHttpRequest)d=new XMLHttpRequest,b&&void 0===d.withCredentials&&window.XDomainRequest&&(d=new XDomainRequest);else{for(var e=0,f=s.ACTIVEX_VERSIONS.length;f>e;e++){var g=s.ACTIVEX_VERSIONS[e];try{d=new ActiveXObject(g);break}catch(h){}}if(null==d)return!1}null==a.mimeType&&createjs.RequestUtils.isText(a.type)&&(a.mimeType="text/plain; charset=utf-8"),a.mimeType&&d.overrideMimeType&&d.overrideMimeType(a.mimeType),this._xhrLevel="string"==typeof d.responseType?2:1;var i=null;if(i=a.method==createjs.AbstractLoader.GET?createjs.RequestUtils.buildPath(a.src,a.values):a.src,d.open(a.method||createjs.AbstractLoader.GET,i,!0),b&&d instanceof XMLHttpRequest&&1==this._xhrLevel&&(c.Origin=location.origin),a.values&&a.method==createjs.AbstractLoader.POST&&(c["Content-Type"]="application/x-www-form-urlencoded"),b||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest"),a.headers)for(var j in a.headers)c[j]=a.headers[j];for(j in c)d.setRequestHeader(j,c[j]);return d instanceof XMLHttpRequest&&void 0!==a.withCredentials&&(d.withCredentials=a.withCredentials),this._request=d,!0},a._clean=function(){clearTimeout(this._loadTimeout),null!=this._request.removeEventListener?(this._request.removeEventListener("loadstart",this._handleLoadStartProxy),this._request.removeEventListener("progress",this._handleProgressProxy),this._request.removeEventListener("abort",this._handleAbortProxy),this._request.removeEventListener("error",this._handleErrorProxy),this._request.removeEventListener("timeout",this._handleTimeoutProxy),this._request.removeEventListener("load",this._handleLoadProxy),this._request.removeEventListener("readystatechange",this._handleReadyStateChangeProxy)):(this._request.onloadstart=null,this._request.onprogress=null,this._request.onabort=null,this._request.onerror=null,this._request.ontimeout=null,this._request.onload=null,this._request.onreadystatechange=null)},a.toString=function(){return"[PreloadJS XHRRequest]"},createjs.XHRRequest=createjs.promote(XHRRequest,"AbstractRequest")}(),this.createjs=this.createjs||{},function(){"use strict";function SoundLoader(a,b){this.AbstractMediaLoader_constructor(a,b,createjs.AbstractLoader.SOUND),createjs.RequestUtils.isAudioTag(a)?this._tag=a:createjs.RequestUtils.isAudioTag(a.src)?this._tag=a:createjs.RequestUtils.isAudioTag(a.tag)&&(this._tag=createjs.RequestUtils.isAudioTag(a)?a:a.src),null!=this._tag&&(this._preferXHR=!1)}var a=createjs.extend(SoundLoader,createjs.AbstractMediaLoader),b=SoundLoader;b.canLoadItem=function(a){return a.type==createjs.AbstractLoader.SOUND},a._createTag=function(a){var b=document.createElement("audio");return b.autoplay=!1,b.preload="none",b.src=a,b},createjs.SoundLoader=createjs.promote(SoundLoader,"AbstractMediaLoader")}(),this.createjs=this.createjs||{},function(){"use strict";var PlayPropsConfig=function(){this.interrupt=null,this.delay=null,this.offset=null,this.loop=null,this.volume=null,this.pan=null,this.startTime=null,this.duration=null},a=PlayPropsConfig.prototype={},b=PlayPropsConfig;b.create=function(a){if(a instanceof b||a instanceof Object){var c=new createjs.PlayPropsConfig;return c.set(a),c}throw new Error("Type not recognized.")},a.set=function(a){for(var b in a)this[b]=a[b];return this},a.toString=function(){return"[PlayPropsConfig]"},createjs.PlayPropsConfig=b}(),this.createjs=this.createjs||{},function(){"use strict";function Sound(){throw"Sound cannot be instantiated"}function a(a,b){this.init(a,b)}var b=Sound;b.INTERRUPT_ANY="any",b.INTERRUPT_EARLY="early",b.INTERRUPT_LATE="late",b.INTERRUPT_NONE="none",b.PLAY_INITED="playInited",b.PLAY_SUCCEEDED="playSucceeded",b.PLAY_INTERRUPTED="playInterrupted",b.PLAY_FINISHED="playFinished",b.PLAY_FAILED="playFailed",b.SUPPORTED_EXTENSIONS=["mp3","ogg","opus","mpeg","wav","m4a","mp4","aiff","wma","mid"],b.EXTENSION_MAP={m4a:"mp4"},b.FILE_PATTERN=/^(?:(\w+:)\/{2}(\w+(?:\.\w+)*\/?))?([\/.]*?(?:[^?]+)?\/)?((?:[^\/?]+)\.(\w+))(?:\?(\S+)?)?$/,b.defaultInterruptBehavior=b.INTERRUPT_NONE,b.alternateExtensions=[],b.activePlugin=null,b._masterVolume=1,Object.defineProperty(b,"volume",{get:function(){return this._masterVolume},set:function(a){if(null==Number(a))return!1;if(a=Math.max(0,Math.min(1,a)),b._masterVolume=a,!this.activePlugin||!this.activePlugin.setVolume||!this.activePlugin.setVolume(a))for(var c=this._instances,d=0,e=c.length;e>d;d++)c[d].setMasterVolume(a)}}),b._masterMute=!1,Object.defineProperty(b,"muted",{get:function(){return this._masterMute},set:function(a){if(null==a)return!1;if(this._masterMute=a,!this.activePlugin||!this.activePlugin.setMute||!this.activePlugin.setMute(a))for(var b=this._instances,c=0,d=b.length;d>c;c++)b[c].setMasterMute(a);return!0}}),Object.defineProperty(b,"capabilities",{get:function(){return null==b.activePlugin?null:b.activePlugin._capabilities},set:function(){return!1}}),b._pluginsRegistered=!1,b._lastID=0,b._instances=[],b._idHash={},b._preloadHash={},b._defaultPlayPropsHash={},b.addEventListener=null,b.removeEventListener=null,b.removeAllEventListeners=null,b.dispatchEvent=null,b.hasEventListener=null,b._listeners=null,createjs.EventDispatcher.initialize(b),b.getPreloadHandlers=function(){return{callback:createjs.proxy(b.initLoad,b),types:["sound"],extensions:b.SUPPORTED_EXTENSIONS}},b._handleLoadComplete=function(a){var c=a.target.getItem().src;if(b._preloadHash[c])for(var d=0,e=b._preloadHash[c].length;e>d;d++){var f=b._preloadHash[c][d];if(b._preloadHash[c][d]=!0,b.hasEventListener("fileload")){var a=new createjs.Event("fileload");a.src=f.src,a.id=f.id,a.data=f.data,a.sprite=f.sprite,b.dispatchEvent(a)}}},b._handleLoadError=function(a){var c=a.target.getItem().src;if(b._preloadHash[c])for(var d=0,e=b._preloadHash[c].length;e>d;d++){var f=b._preloadHash[c][d];if(b._preloadHash[c][d]=!1,b.hasEventListener("fileerror")){var a=new createjs.Event("fileerror");a.src=f.src,a.id=f.id,a.data=f.data,a.sprite=f.sprite,b.dispatchEvent(a)}}},b._registerPlugin=function(a){return a.isSupported()?(b.activePlugin=new a,!0):!1},b.registerPlugins=function(a){b._pluginsRegistered=!0;for(var c=0,d=a.length;d>c;c++)if(b._registerPlugin(a[c]))return!0;return!1},b.initializeDefaultPlugins=function(){return null!=b.activePlugin?!0:b._pluginsRegistered?!1:b.registerPlugins([createjs.WebAudioPlugin,createjs.HTMLAudioPlugin])?!0:!1},b.isReady=function(){return null!=b.activePlugin},b.getCapabilities=function(){return null==b.activePlugin?null:b.activePlugin._capabilities},b.getCapability=function(a){return null==b.activePlugin?null:b.activePlugin._capabilities[a]},b.initLoad=function(a){return b._registerSound(a)},b._registerSound=function(c){if(!b.initializeDefaultPlugins())return!1;var d;if(c.src instanceof Object?(d=b._parseSrc(c.src),d.src=c.path+d.src):d=b._parsePath(c.src),null==d)return!1;c.src=d.src,c.type="sound";var e=c.data,f=null;if(null!=e&&(isNaN(e.channels)?isNaN(e)||(f=parseInt(e)):f=parseInt(e.channels),e.audioSprite))for(var g,h=e.audioSprite.length;h--;)g=e.audioSprite[h],b._idHash[g.id]={src:c.src,startTime:parseInt(g.startTime),duration:parseInt(g.duration)},g.defaultPlayProps&&(b._defaultPlayPropsHash[g.id]=createjs.PlayPropsConfig.create(g.defaultPlayProps));null!=c.id&&(b._idHash[c.id]={src:c.src});var i=b.activePlugin.register(c);return a.create(c.src,f),null!=e&&isNaN(e)?c.data.channels=f||a.maxPerChannel():c.data=f||a.maxPerChannel(),i.type&&(c.type=i.type),c.defaultPlayProps&&(b._defaultPlayPropsHash[c.src]=createjs.PlayPropsConfig.create(c.defaultPlayProps)),i},b.registerSound=function(a,c,d,e,f){var g={src:a,id:c,data:d,defaultPlayProps:f};a instanceof Object&&a.src&&(e=c,g=a),g=createjs.LoadItem.create(g),g.path=e,null==e||g.src instanceof Object||(g.src=e+a);var h=b._registerSound(g);if(!h)return!1;if(b._preloadHash[g.src]||(b._preloadHash[g.src]=[]),b._preloadHash[g.src].push(g),1==b._preloadHash[g.src].length)h.on("complete",createjs.proxy(this._handleLoadComplete,this)),h.on("error",createjs.proxy(this._handleLoadError,this)),b.activePlugin.preload(h);else if(1==b._preloadHash[g.src][0])return!0;return g},b.registerSounds=function(a,b){var c=[];a.path&&(b?b+=a.path:b=a.path,a=a.manifest);for(var d=0,e=a.length;e>d;d++)c[d]=createjs.Sound.registerSound(a[d].src,a[d].id,a[d].data,b,a[d].defaultPlayProps);return c},b.removeSound=function(c,d){if(null==b.activePlugin)return!1;c instanceof Object&&c.src&&(c=c.src);var e;if(c instanceof Object?e=b._parseSrc(c):(c=b._getSrcById(c).src,e=b._parsePath(c)),null==e)return!1;c=e.src,null!=d&&(c=d+c);for(var f in b._idHash)b._idHash[f].src==c&&delete b._idHash[f];return a.removeSrc(c),delete b._preloadHash[c],b.activePlugin.removeSound(c),!0},b.removeSounds=function(a,b){var c=[];a.path&&(b?b+=a.path:b=a.path,a=a.manifest);for(var d=0,e=a.length;e>d;d++)c[d]=createjs.Sound.removeSound(a[d].src,b);return c},b.removeAllSounds=function(){b._idHash={},b._preloadHash={},a.removeAll(),b.activePlugin&&b.activePlugin.removeAllSounds()},b.loadComplete=function(a){if(!b.isReady())return!1;var c=b._parsePath(a);return a=c?b._getSrcById(c.src).src:b._getSrcById(a).src,void 0==b._preloadHash[a]?!1:1==b._preloadHash[a][0]},b._parsePath=function(a){"string"!=typeof a&&(a=a.toString());var c=a.match(b.FILE_PATTERN);if(null==c)return!1;for(var d=c[4],e=c[5],f=b.capabilities,g=0;!f[e];)if(e=b.alternateExtensions[g++],g>b.alternateExtensions.length)return null;a=a.replace("."+c[5],"."+e);var h={name:d,src:a,extension:e};return h},b._parseSrc=function(a){var c={name:void 0,src:void 0,extension:void 0},d=b.capabilities;for(var e in a)if(a.hasOwnProperty(e)&&d[e]){c.src=a[e],c.extension=e;break}if(!c.src)return!1;var f=c.src.lastIndexOf("/");return c.name=-1!=f?c.src.slice(f+1):c.src,c},b.play=function(a,c,d,e,f,g,h,i,j){var k;k=createjs.PlayPropsConfig.create(c instanceof Object||c instanceof createjs.PlayPropsConfig?c:{interrupt:c,delay:d,offset:e,loop:f,volume:g,pan:h,startTime:i,duration:j});var l=b.createInstance(a,k.startTime,k.duration),m=b._playInstance(l,k);return m||l._playFailed(),l},b.createInstance=function(c,d,e){if(!b.initializeDefaultPlugins())return new createjs.DefaultSoundInstance(c,d,e);var f=b._defaultPlayPropsHash[c];c=b._getSrcById(c);var g=b._parsePath(c.src),h=null;
-return null!=g&&null!=g.src?(a.create(g.src),null==d&&(d=c.startTime),h=b.activePlugin.create(g.src,d,e||c.duration),f=f||b._defaultPlayPropsHash[g.src],f&&h.applyPlayProps(f)):h=new createjs.DefaultSoundInstance(c,d,e),h.uniqueId=b._lastID++,h},b.stop=function(){for(var a=this._instances,b=a.length;b--;)a[b].stop()},b.setVolume=function(a){if(null==Number(a))return!1;if(a=Math.max(0,Math.min(1,a)),b._masterVolume=a,!this.activePlugin||!this.activePlugin.setVolume||!this.activePlugin.setVolume(a))for(var c=this._instances,d=0,e=c.length;e>d;d++)c[d].setMasterVolume(a)},b.getVolume=function(){return this._masterVolume},b.setMute=function(a){if(null==a)return!1;if(this._masterMute=a,!this.activePlugin||!this.activePlugin.setMute||!this.activePlugin.setMute(a))for(var b=this._instances,c=0,d=b.length;d>c;c++)b[c].setMasterMute(a);return!0},b.getMute=function(){return this._masterMute},b.setDefaultPlayProps=function(a,c){a=b._getSrcById(a),b._defaultPlayPropsHash[b._parsePath(a.src).src]=createjs.PlayPropsConfig.create(c)},b.getDefaultPlayProps=function(a){return a=b._getSrcById(a),b._defaultPlayPropsHash[b._parsePath(a.src).src]},b._playInstance=function(a,c){var d=b._defaultPlayPropsHash[a.src]||{};if(null==c.interrupt&&(c.interrupt=d.interrupt||b.defaultInterruptBehavior),null==c.delay&&(c.delay=d.delay||0),null==c.offset&&(c.offset=a.getPosition()),null==c.loop&&(c.loop=a.loop),null==c.volume&&(c.volume=a.volume),null==c.pan&&(c.pan=a.pan),0==c.delay){var e=b._beginPlaying(a,c);if(!e)return!1}else{var f=setTimeout(function(){b._beginPlaying(a,c)},c.delay);a.delayTimeoutId=f}return this._instances.push(a),!0},b._beginPlaying=function(b,c){if(!a.add(b,c.interrupt))return!1;var d=b._beginPlaying(c);if(!d){var e=createjs.indexOf(this._instances,b);return e>-1&&this._instances.splice(e,1),!1}return!0},b._getSrcById=function(a){return b._idHash[a]||{src:a}},b._playFinished=function(b){a.remove(b);var c=createjs.indexOf(this._instances,b);c>-1&&this._instances.splice(c,1)},createjs.Sound=Sound,a.channels={},a.create=function(b,c){var d=a.get(b);return null==d?(a.channels[b]=new a(b,c),!0):!1},a.removeSrc=function(b){var c=a.get(b);return null==c?!1:(c._removeAll(),delete a.channels[b],!0)},a.removeAll=function(){for(var b in a.channels)a.channels[b]._removeAll();a.channels={}},a.add=function(b,c){var d=a.get(b.src);return null==d?!1:d._add(b,c)},a.remove=function(b){var c=a.get(b.src);return null==c?!1:(c._remove(b),!0)},a.maxPerChannel=function(){return c.maxDefault},a.get=function(b){return a.channels[b]};var c=a.prototype;c.constructor=a,c.src=null,c.max=null,c.maxDefault=100,c.length=0,c.init=function(a,b){this.src=a,this.max=b||this.maxDefault,-1==this.max&&(this.max=this.maxDefault),this._instances=[]},c._get=function(a){return this._instances[a]},c._add=function(a,b){return this._getSlot(b,a)?(this._instances.push(a),this.length++,!0):!1},c._remove=function(a){var b=createjs.indexOf(this._instances,a);return-1==b?!1:(this._instances.splice(b,1),this.length--,!0)},c._removeAll=function(){for(var a=this.length-1;a>=0;a--)this._instances[a].stop()},c._getSlot=function(a){var b,c;if(a!=Sound.INTERRUPT_NONE&&(c=this._get(0),null==c))return!0;for(var d=0,e=this.max;e>d;d++){if(b=this._get(d),null==b)return!0;if(b.playState==Sound.PLAY_FINISHED||b.playState==Sound.PLAY_INTERRUPTED||b.playState==Sound.PLAY_FAILED){c=b;break}a!=Sound.INTERRUPT_NONE&&(a==Sound.INTERRUPT_EARLY&&b.getPosition()c.getPosition())&&(c=b)}return null!=c?(c._interrupt(),this._remove(c),!0):!1},c.toString=function(){return"[Sound SoundChannel]"}}(),this.createjs=this.createjs||{},function(){"use strict";var AbstractSoundInstance=function(a,b,c,d){this.EventDispatcher_constructor(),this.src=a,this.uniqueId=-1,this.playState=null,this.delayTimeoutId=null,this._volume=1,Object.defineProperty(this,"volume",{get:this.getVolume,set:this.setVolume}),this._pan=0,Object.defineProperty(this,"pan",{get:this.getPan,set:this.setPan}),this._startTime=Math.max(0,b||0),Object.defineProperty(this,"startTime",{get:this.getStartTime,set:this.setStartTime}),this._duration=Math.max(0,c||0),Object.defineProperty(this,"duration",{get:this.getDuration,set:this.setDuration}),this._playbackResource=null,Object.defineProperty(this,"playbackResource",{get:this.getPlaybackResource,set:this.setPlaybackResource}),d!==!1&&d!==!0&&this.setPlaybackResource(d),this._position=0,Object.defineProperty(this,"position",{get:this.getPosition,set:this.setPosition}),this._loop=0,Object.defineProperty(this,"loop",{get:this.getLoop,set:this.setLoop}),this._muted=!1,Object.defineProperty(this,"muted",{get:this.getMuted,set:this.setMuted}),this._paused=!1,Object.defineProperty(this,"paused",{get:this.getPaused,set:this.setPaused})},a=createjs.extend(AbstractSoundInstance,createjs.EventDispatcher);a.play=function(a,b,c,d,e,f){var g;return g=createjs.PlayPropsConfig.create(a instanceof Object||a instanceof createjs.PlayPropsConfig?a:{interrupt:a,delay:b,offset:c,loop:d,volume:e,pan:f}),this.playState==createjs.Sound.PLAY_SUCCEEDED?(this.applyPlayProps(g),void(this._paused&&this.setPaused(!1))):(this._cleanUp(),createjs.Sound._playInstance(this,g),this)},a.stop=function(){return this._position=0,this._paused=!1,this._handleStop(),this._cleanUp(),this.playState=createjs.Sound.PLAY_FINISHED,this},a.destroy=function(){this._cleanUp(),this.src=null,this.playbackResource=null,this.removeAllEventListeners()},a.applyPlayProps=function(a){return null!=a.offset&&this.setPosition(a.offset),null!=a.loop&&this.setLoop(a.loop),null!=a.volume&&this.setVolume(a.volume),null!=a.pan&&this.setPan(a.pan),null!=a.startTime&&(this.setStartTime(a.startTime),this.setDuration(a.duration)),this},a.toString=function(){return"[AbstractSoundInstance]"},a.getPaused=function(){return this._paused},a.setPaused=function(a){return a!==!0&&a!==!1||this._paused==a||1==a&&this.playState!=createjs.Sound.PLAY_SUCCEEDED?void 0:(this._paused=a,a?this._pause():this._resume(),clearTimeout(this.delayTimeoutId),this)},a.setVolume=function(a){return a==this._volume?this:(this._volume=Math.max(0,Math.min(1,a)),this._muted||this._updateVolume(),this)},a.getVolume=function(){return this._volume},a.setMuted=function(a){return a===!0||a===!1?(this._muted=a,this._updateVolume(),this):void 0},a.getMuted=function(){return this._muted},a.setPan=function(a){return a==this._pan?this:(this._pan=Math.max(-1,Math.min(1,a)),this._updatePan(),this)},a.getPan=function(){return this._pan},a.getPosition=function(){return this._paused||this.playState!=createjs.Sound.PLAY_SUCCEEDED||(this._position=this._calculateCurrentPosition()),this._position},a.setPosition=function(a){return this._position=Math.max(0,a),this.playState==createjs.Sound.PLAY_SUCCEEDED&&this._updatePosition(),this},a.getStartTime=function(){return this._startTime},a.setStartTime=function(a){return a==this._startTime?this:(this._startTime=Math.max(0,a||0),this._updateStartTime(),this)},a.getDuration=function(){return this._duration},a.setDuration=function(a){return a==this._duration?this:(this._duration=Math.max(0,a||0),this._updateDuration(),this)},a.setPlaybackResource=function(a){return this._playbackResource=a,0==this._duration&&this._setDurationFromSource(),this},a.getPlaybackResource=function(){return this._playbackResource},a.getLoop=function(){return this._loop},a.setLoop=function(a){null!=this._playbackResource&&(0!=this._loop&&0==a?this._removeLooping(a):0==this._loop&&0!=a&&this._addLooping(a)),this._loop=a},a._sendEvent=function(a){var b=new createjs.Event(a);this.dispatchEvent(b)},a._cleanUp=function(){clearTimeout(this.delayTimeoutId),this._handleCleanUp(),this._paused=!1,createjs.Sound._playFinished(this)},a._interrupt=function(){this._cleanUp(),this.playState=createjs.Sound.PLAY_INTERRUPTED,this._sendEvent("interrupted")},a._beginPlaying=function(a){return this.setPosition(a.offset),this.setLoop(a.loop),this.setVolume(a.volume),this.setPan(a.pan),null!=a.startTime&&(this.setStartTime(a.startTime),this.setDuration(a.duration)),null!=this._playbackResource&&this._positionc;c++){var e=this._soundInstances[b][c];e.setPlaybackResource(this._audioSources[b])}},a._handlePreloadError=function(){},a._updateVolume=function(){},createjs.AbstractPlugin=AbstractPlugin}(),this.createjs=this.createjs||{},function(){"use strict";function a(a){this.AbstractLoader_constructor(a,!0,createjs.AbstractLoader.SOUND)}var b=createjs.extend(a,createjs.AbstractLoader);a.context=null,b.toString=function(){return"[WebAudioLoader]"},b._createRequest=function(){this._request=new createjs.XHRRequest(this._item,!1),this._request.setResponseType("arraybuffer")},b._sendComplete=function(){a.context.decodeAudioData(this._rawResult,createjs.proxy(this._handleAudioDecoded,this),createjs.proxy(this._sendError,this))},b._handleAudioDecoded=function(a){this._result=a,this.AbstractLoader__sendComplete()},createjs.WebAudioLoader=createjs.promote(a,"AbstractLoader")}(),this.createjs=this.createjs||{},function(){"use strict";function WebAudioSoundInstance(a,c,d,e){this.AbstractSoundInstance_constructor(a,c,d,e),this.gainNode=b.context.createGain(),this.panNode=b.context.createPanner(),this.panNode.panningModel=b._panningModel,this.panNode.connect(this.gainNode),this._updatePan(),this.sourceNode=null,this._soundCompleteTimeout=null,this._sourceNodeNext=null,this._playbackStartTime=0,this._endedHandler=createjs.proxy(this._handleSoundComplete,this)}var a=createjs.extend(WebAudioSoundInstance,createjs.AbstractSoundInstance),b=WebAudioSoundInstance;b.context=null,b._scratchBuffer=null,b.destinationNode=null,b._panningModel="equalpower",a.destroy=function(){this.AbstractSoundInstance_destroy(),this.panNode.disconnect(0),this.panNode=null,this.gainNode.disconnect(0),this.gainNode=null},a.toString=function(){return"[WebAudioSoundInstance]"},a._updatePan=function(){this.panNode.setPosition(this._pan,0,-.5)},a._removeLooping=function(){this._sourceNodeNext=this._cleanUpAudioNode(this._sourceNodeNext)},a._addLooping=function(){this.playState==createjs.Sound.PLAY_SUCCEEDED&&(this._sourceNodeNext=this._createAndPlayAudioNode(this._playbackStartTime,0))},a._setDurationFromSource=function(){this._duration=1e3*this.playbackResource.duration},a._handleCleanUp=function(){this.sourceNode&&this.playState==createjs.Sound.PLAY_SUCCEEDED&&(this.sourceNode=this._cleanUpAudioNode(this.sourceNode),this._sourceNodeNext=this._cleanUpAudioNode(this._sourceNodeNext)),0!=this.gainNode.numberOfOutputs&&this.gainNode.disconnect(0),clearTimeout(this._soundCompleteTimeout),this._playbackStartTime=0},a._cleanUpAudioNode=function(a){if(a){a.stop(0),a.disconnect(0);try{a.buffer=b._scratchBuffer}catch(c){}a=null}return a},a._handleSoundReady=function(){this.gainNode.connect(b.destinationNode);var a=.001*this._duration,c=.001*this._position;c>a&&(c=a),this.sourceNode=this._createAndPlayAudioNode(b.context.currentTime-a,c),this._playbackStartTime=this.sourceNode.startTime-c,this._soundCompleteTimeout=setTimeout(this._endedHandler,1e3*(a-c)),0!=this._loop&&(this._sourceNodeNext=this._createAndPlayAudioNode(this._playbackStartTime,0))},a._createAndPlayAudioNode=function(a,c){var d=b.context.createBufferSource();d.buffer=this.playbackResource,d.connect(this.panNode);var e=.001*this._duration;return d.startTime=a+e,d.start(d.startTime,c+.001*this._startTime,e-c),d},a._pause=function(){this._position=1e3*(b.context.currentTime-this._playbackStartTime),this.sourceNode=this._cleanUpAudioNode(this.sourceNode),this._sourceNodeNext=this._cleanUpAudioNode(this._sourceNodeNext),0!=this.gainNode.numberOfOutputs&&this.gainNode.disconnect(0),clearTimeout(this._soundCompleteTimeout)},a._resume=function(){this._handleSoundReady()},a._updateVolume=function(){var a=this._muted?0:this._volume;a!=this.gainNode.gain.value&&(this.gainNode.gain.value=a)},a._calculateCurrentPosition=function(){return 1e3*(b.context.currentTime-this._playbackStartTime)},a._updatePosition=function(){this.sourceNode=this._cleanUpAudioNode(this.sourceNode),this._sourceNodeNext=this._cleanUpAudioNode(this._sourceNodeNext),clearTimeout(this._soundCompleteTimeout),this._paused||this._handleSoundReady()},a._handleLoop=function(){this._cleanUpAudioNode(this.sourceNode),this.sourceNode=this._sourceNodeNext,this._playbackStartTime=this.sourceNode.startTime,this._sourceNodeNext=this._createAndPlayAudioNode(this._playbackStartTime,0),this._soundCompleteTimeout=setTimeout(this._endedHandler,this._duration)},a._updateDuration=function(){this.playState==createjs.Sound.PLAY_SUCCEEDED&&(this._pause(),this._resume())},createjs.WebAudioSoundInstance=createjs.promote(WebAudioSoundInstance,"AbstractSoundInstance")}(),this.createjs=this.createjs||{},function(){"use strict";function WebAudioPlugin(){this.AbstractPlugin_constructor(),this._panningModel=b._panningModel,this.context=b.context,this.dynamicsCompressorNode=this.context.createDynamicsCompressor(),this.dynamicsCompressorNode.connect(this.context.destination),this.gainNode=this.context.createGain(),this.gainNode.connect(this.dynamicsCompressorNode),createjs.WebAudioSoundInstance.destinationNode=this.gainNode,this._capabilities=b._capabilities,this._loaderClass=createjs.WebAudioLoader,this._soundInstanceClass=createjs.WebAudioSoundInstance,this._addPropsToClasses()}var a=createjs.extend(WebAudioPlugin,createjs.AbstractPlugin),b=WebAudioPlugin;b._capabilities=null,b._panningModel="equalpower",b.context=null,b._scratchBuffer=null,b._unlocked=!1,b.isSupported=function(){var a=createjs.BrowserDetect.isIOS||createjs.BrowserDetect.isAndroid||createjs.BrowserDetect.isBlackberry;return"file:"!=location.protocol||a||this._isFileXHRSupported()?(b._generateCapabilities(),null==b.context?!1:!0):!1},b.playEmptySound=function(){if(null!=b.context){var a=b.context.createBufferSource();a.buffer=b._scratchBuffer,a.connect(b.context.destination),a.start(0,0,0)}},b._isFileXHRSupported=function(){var a=!0,b=new XMLHttpRequest;try{b.open("GET","WebAudioPluginTest.fail",!1)}catch(c){return a=!1}b.onerror=function(){a=!1},b.onload=function(){a=404==this.status||200==this.status||0==this.status&&""!=this.response};try{b.send()}catch(c){a=!1}return a},b._generateCapabilities=function(){if(null==b._capabilities){var a=document.createElement("audio");if(null==a.canPlayType)return null;if(null==b.context)if(window.AudioContext)b.context=new AudioContext;else{if(!window.webkitAudioContext)return null;b.context=new webkitAudioContext}null==b._scratchBuffer&&(b._scratchBuffer=b.context.createBuffer(1,1,22050)),b._compatibilitySetUp(),"ontouchstart"in window&&"running"!=b.context.state&&(b._unlock(),document.addEventListener("mousedown",b._unlock,!0),document.addEventListener("touchend",b._unlock,!0)),b._capabilities={panning:!0,volume:!0,tracks:-1};for(var c=createjs.Sound.SUPPORTED_EXTENSIONS,d=createjs.Sound.EXTENSION_MAP,e=0,f=c.length;f>e;e++){var g=c[e],h=d[g]||g;b._capabilities[g]="no"!=a.canPlayType("audio/"+g)&&""!=a.canPlayType("audio/"+g)||"no"!=a.canPlayType("audio/"+h)&&""!=a.canPlayType("audio/"+h)}b.context.destination.numberOfChannels<2&&(b._capabilities.panning=!1)}},b._compatibilitySetUp=function(){if(b._panningModel="equalpower",!b.context.createGain){b.context.createGain=b.context.createGainNode;var a=b.context.createBufferSource();a.__proto__.start=a.__proto__.noteGrainOn,a.__proto__.stop=a.__proto__.noteOff,b._panningModel=0}},b._unlock=function(){b._unlocked||(b.playEmptySound(),"running"==b.context.state&&(document.removeEventListener("mousedown",b._unlock,!0),document.removeEventListener("touchend",b._unlock,!0),b._unlocked=!0))},a.toString=function(){return"[WebAudioPlugin]"},a._addPropsToClasses=function(){var a=this._soundInstanceClass;a.context=this.context,a._scratchBuffer=b._scratchBuffer,a.destinationNode=this.gainNode,a._panningModel=this._panningModel,this._loaderClass.context=this.context},a._updateVolume=function(){var a=createjs.Sound._masterMute?0:this._volume;a!=this.gainNode.gain.value&&(this.gainNode.gain.value=a)},createjs.WebAudioPlugin=createjs.promote(WebAudioPlugin,"AbstractPlugin")}(),this.createjs=this.createjs||{},function(){"use strict";function HTMLAudioTagPool(){throw"HTMLAudioTagPool cannot be instantiated"}function a(){this._tags=[]}var b=HTMLAudioTagPool;b._tags={},b._tagPool=new a,b._tagUsed={},b.get=function(a){var c=b._tags[a];return null==c?(c=b._tags[a]=b._tagPool.get(),c.src=a):b._tagUsed[a]?(c=b._tagPool.get(),c.src=a):b._tagUsed[a]=!0,c},b.set=function(a,c){c==b._tags[a]?b._tagUsed[a]=!1:b._tagPool.set(c)},b.remove=function(a){var c=b._tags[a];return null==c?!1:(b._tagPool.set(c),delete b._tags[a],delete b._tagUsed[a],!0)},b.getDuration=function(a){var c=b._tags[a];return null!=c&&c.duration?1e3*c.duration:0},createjs.HTMLAudioTagPool=HTMLAudioTagPool;var c=a.prototype;c.constructor=a,c.get=function(){var a;return a=0==this._tags.length?this._createTag():this._tags.pop(),null==a.parentNode&&document.body.appendChild(a),a},c.set=function(a){var b=createjs.indexOf(this._tags,a);-1==b&&(this._tags.src=null,this._tags.push(a))},c.toString=function(){return"[TagPool]"},c._createTag=function(){var a=document.createElement("audio");return a.autoplay=!1,a.preload="none",a}}(),this.createjs=this.createjs||{},function(){"use strict";function HTMLAudioSoundInstance(a,b,c,d){this.AbstractSoundInstance_constructor(a,b,c,d),this._audioSpriteStopTime=null,this._delayTimeoutId=null,this._endedHandler=createjs.proxy(this._handleSoundComplete,this),this._readyHandler=createjs.proxy(this._handleTagReady,this),this._stalledHandler=createjs.proxy(this._playFailed,this),this._audioSpriteEndHandler=createjs.proxy(this._handleAudioSpriteLoop,this),this._loopHandler=createjs.proxy(this._handleSoundComplete,this),c?this._audioSpriteStopTime=.001*(b+c):this._duration=createjs.HTMLAudioTagPool.getDuration(this.src)}var a=createjs.extend(HTMLAudioSoundInstance,createjs.AbstractSoundInstance);a.setMasterVolume=function(){this._updateVolume()},a.setMasterMute=function(){this._updateVolume()},a.toString=function(){return"[HTMLAudioSoundInstance]"},a._removeLooping=function(){null!=this._playbackResource&&(this._playbackResource.loop=!1,this._playbackResource.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED,this._loopHandler,!1))},a._addLooping=function(){null==this._playbackResource||this._audioSpriteStopTime||(this._playbackResource.addEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED,this._loopHandler,!1),this._playbackResource.loop=!0)},a._handleCleanUp=function(){var a=this._playbackResource;if(null!=a){a.pause(),a.loop=!1,a.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_ENDED,this._endedHandler,!1),a.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_READY,this._readyHandler,!1),a.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_STALLED,this._stalledHandler,!1),a.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED,this._loopHandler,!1),a.removeEventListener(createjs.HTMLAudioPlugin._TIME_UPDATE,this._audioSpriteEndHandler,!1);try{a.currentTime=this._startTime}catch(b){}createjs.HTMLAudioTagPool.set(this.src,a),this._playbackResource=null}},a._beginPlaying=function(a){return this._playbackResource=createjs.HTMLAudioTagPool.get(this.src),this.AbstractSoundInstance__beginPlaying(a)},a._handleSoundReady=function(){if(4!==this._playbackResource.readyState){var a=this._playbackResource;return a.addEventListener(createjs.HTMLAudioPlugin._AUDIO_READY,this._readyHandler,!1),a.addEventListener(createjs.HTMLAudioPlugin._AUDIO_STALLED,this._stalledHandler,!1),a.preload="auto",void a.load()}this._updateVolume(),this._playbackResource.currentTime=.001*(this._startTime+this._position),this._audioSpriteStopTime?this._playbackResource.addEventListener(createjs.HTMLAudioPlugin._TIME_UPDATE,this._audioSpriteEndHandler,!1):(this._playbackResource.addEventListener(createjs.HTMLAudioPlugin._AUDIO_ENDED,this._endedHandler,!1),0!=this._loop&&(this._playbackResource.addEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED,this._loopHandler,!1),this._playbackResource.loop=!0)),this._playbackResource.play()},a._handleTagReady=function(){this._playbackResource.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_READY,this._readyHandler,!1),this._playbackResource.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_STALLED,this._stalledHandler,!1),this._handleSoundReady()},a._pause=function(){this._playbackResource.pause()},a._resume=function(){this._playbackResource.play()},a._updateVolume=function(){if(null!=this._playbackResource){var a=this._muted||createjs.Sound._masterMute?0:this._volume*createjs.Sound._masterVolume;a!=this._playbackResource.volume&&(this._playbackResource.volume=a)}},a._calculateCurrentPosition=function(){return 1e3*this._playbackResource.currentTime-this._startTime},a._updatePosition=function(){this._playbackResource.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED,this._loopHandler,!1),this._playbackResource.addEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED,this._handleSetPositionSeek,!1);try{this._playbackResource.currentTime=.001*(this._position+this._startTime)}catch(a){this._handleSetPositionSeek(null)}},a._handleSetPositionSeek=function(){null!=this._playbackResource&&(this._playbackResource.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED,this._handleSetPositionSeek,!1),this._playbackResource.addEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED,this._loopHandler,!1))},a._handleAudioSpriteLoop=function(){this._playbackResource.currentTime<=this._audioSpriteStopTime||(this._playbackResource.pause(),0==this._loop?this._handleSoundComplete(null):(this._position=0,this._loop--,this._playbackResource.currentTime=.001*this._startTime,this._paused||this._playbackResource.play(),this._sendEvent("loop")))},a._handleLoop=function(){0==this._loop&&(this._playbackResource.loop=!1,this._playbackResource.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_SEEKED,this._loopHandler,!1))},a._updateStartTime=function(){this._audioSpriteStopTime=.001*(this._startTime+this._duration),this.playState==createjs.Sound.PLAY_SUCCEEDED&&(this._playbackResource.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_ENDED,this._endedHandler,!1),this._playbackResource.addEventListener(createjs.HTMLAudioPlugin._TIME_UPDATE,this._audioSpriteEndHandler,!1))},a._updateDuration=function(){this._audioSpriteStopTime=.001*(this._startTime+this._duration),this.playState==createjs.Sound.PLAY_SUCCEEDED&&(this._playbackResource.removeEventListener(createjs.HTMLAudioPlugin._AUDIO_ENDED,this._endedHandler,!1),this._playbackResource.addEventListener(createjs.HTMLAudioPlugin._TIME_UPDATE,this._audioSpriteEndHandler,!1))},a._setDurationFromSource=function(){this._duration=createjs.HTMLAudioTagPool.getDuration(this.src),this._playbackResource=null},createjs.HTMLAudioSoundInstance=createjs.promote(HTMLAudioSoundInstance,"AbstractSoundInstance")}(),this.createjs=this.createjs||{},function(){"use strict";function HTMLAudioPlugin(){this.AbstractPlugin_constructor(),this.defaultNumChannels=2,this._capabilities=b._capabilities,this._loaderClass=createjs.SoundLoader,this._soundInstanceClass=createjs.HTMLAudioSoundInstance}var a=createjs.extend(HTMLAudioPlugin,createjs.AbstractPlugin),b=HTMLAudioPlugin;b.MAX_INSTANCES=30,b._AUDIO_READY="canplaythrough",b._AUDIO_ENDED="ended",b._AUDIO_SEEKED="seeked",b._AUDIO_STALLED="stalled",b._TIME_UPDATE="timeupdate",b._capabilities=null,b.isSupported=function(){return b._generateCapabilities(),null!=b._capabilities},b._generateCapabilities=function(){if(null==b._capabilities){var a=document.createElement("audio");if(null==a.canPlayType)return null;b._capabilities={panning:!1,volume:!0,tracks:-1};for(var c=createjs.Sound.SUPPORTED_EXTENSIONS,d=createjs.Sound.EXTENSION_MAP,e=0,f=c.length;f>e;e++){var g=c[e],h=d[g]||g;b._capabilities[g]="no"!=a.canPlayType("audio/"+g)&&""!=a.canPlayType("audio/"+g)||"no"!=a.canPlayType("audio/"+h)&&""!=a.canPlayType("audio/"+h)}}},a.register=function(a){var b=createjs.HTMLAudioTagPool.get(a.src),c=this.AbstractPlugin_register(a);return c.setTag(b),c},a.removeSound=function(a){this.AbstractPlugin_removeSound(a),createjs.HTMLAudioTagPool.remove(a)},a.create=function(a,b,c){var d=this.AbstractPlugin_create(a,b,c);return d.setPlaybackResource(null),d},a.toString=function(){return"[HTMLAudioPlugin]"},a.setVolume=a.getVolume=a.setMute=null,createjs.HTMLAudioPlugin=createjs.promote(HTMLAudioPlugin,"AbstractPlugin")}();
\ No newline at end of file
diff --git a/_assets/libs/tweenjs-NEXT.min.js b/_assets/libs/tweenjs-NEXT.min.js
deleted file mode 100644
index c49f9d096..000000000
--- a/_assets/libs/tweenjs-NEXT.min.js
+++ /dev/null
@@ -1,12 +0,0 @@
-/*!
-* @license TweenJS
-* Visit http://createjs.com/ for documentation, updates and examples.
-*
-* Copyright (c) 2011-2015 gskinner.com, inc.
-*
-* Distributed under the terms of the MIT license.
-* http://www.opensource.org/licenses/mit-license.html
-*
-* This notice shall be included in all copies or substantial portions of the Software.
-*/
-this.createjs=this.createjs||{},createjs.extend=function(a,b){"use strict";function c(){this.constructor=a}return c.prototype=b.prototype,a.prototype=new c},this.createjs=this.createjs||{},createjs.promote=function(a,b){"use strict";var c=a.prototype,d=Object.getPrototypeOf&&Object.getPrototypeOf(c)||c.__proto__;if(d){c[(b+="_")+"constructor"]=d.constructor;for(var e in d)c.hasOwnProperty(e)&&"function"==typeof d[e]&&(c[b+e]=d[e])}return a},this.createjs=this.createjs||{},function(){"use strict";function Event(a,b,c){this.type=a,this.target=null,this.currentTarget=null,this.eventPhase=0,this.bubbles=!!b,this.cancelable=!!c,this.timeStamp=(new Date).getTime(),this.defaultPrevented=!1,this.propagationStopped=!1,this.immediatePropagationStopped=!1,this.removed=!1}var a=Event.prototype;a.preventDefault=function(){this.defaultPrevented=this.cancelable&&!0},a.stopPropagation=function(){this.propagationStopped=!0},a.stopImmediatePropagation=function(){this.immediatePropagationStopped=this.propagationStopped=!0},a.remove=function(){this.removed=!0},a.clone=function(){return new Event(this.type,this.bubbles,this.cancelable)},a.set=function(a){for(var b in a)this[b]=a[b];return this},a.toString=function(){return"[Event (type="+this.type+")]"},createjs.Event=Event}(),this.createjs=this.createjs||{},function(){"use strict";function EventDispatcher(){this._listeners=null,this._captureListeners=null}var a=EventDispatcher.prototype;EventDispatcher.initialize=function(b){b.addEventListener=a.addEventListener,b.on=a.on,b.removeEventListener=b.off=a.removeEventListener,b.removeAllEventListeners=a.removeAllEventListeners,b.hasEventListener=a.hasEventListener,b.dispatchEvent=a.dispatchEvent,b._dispatchEvent=a._dispatchEvent,b.willTrigger=a.willTrigger},a.addEventListener=function(a,b,c){var d;d=c?this._captureListeners=this._captureListeners||{}:this._listeners=this._listeners||{};var e=d[a];return e&&this.removeEventListener(a,b,c),e=d[a],e?e.push(b):d[a]=[b],b},a.on=function(a,b,c,d,e,f){return b.handleEvent&&(c=c||b,b=b.handleEvent),c=c||this,this.addEventListener(a,function(a){b.call(c,a,e),d&&a.remove()},f)},a.removeEventListener=function(a,b,c){var d=c?this._captureListeners:this._listeners;if(d){var e=d[a];if(e)for(var f=0,g=e.length;g>f;f++)if(e[f]==b){1==g?delete d[a]:e.splice(f,1);break}}},a.off=a.removeEventListener,a.removeAllEventListeners=function(a){a?(this._listeners&&delete this._listeners[a],this._captureListeners&&delete this._captureListeners[a]):this._listeners=this._captureListeners=null},a.dispatchEvent=function(a,b,c){if("string"==typeof a){var d=this._listeners;if(!(b||d&&d[a]))return!0;a=new createjs.Event(a,b,c)}else a.target&&a.clone&&(a=a.clone());try{a.target=this}catch(e){}if(a.bubbles&&this.parent){for(var f=this,g=[f];f.parent;)g.push(f=f.parent);var h,i=g.length;for(h=i-1;h>=0&&!a.propagationStopped;h--)g[h]._dispatchEvent(a,1+(0==h));for(h=1;i>h&&!a.propagationStopped;h++)g[h]._dispatchEvent(a,3)}else this._dispatchEvent(a,2);return!a.defaultPrevented},a.hasEventListener=function(a){var b=this._listeners,c=this._captureListeners;return!!(b&&b[a]||c&&c[a])},a.willTrigger=function(a){for(var b=this;b;){if(b.hasEventListener(a))return!0;b=b.parent}return!1},a.toString=function(){return"[EventDispatcher]"},a._dispatchEvent=function(a,b){var c,d=1==b?this._captureListeners:this._listeners;if(a&&d){var e=d[a.type];if(!e||!(c=e.length))return;try{a.currentTarget=this}catch(f){}try{a.eventPhase=b}catch(f){}a.removed=!1,e=e.slice();for(var g=0;c>g&&!a.immediatePropagationStopped;g++){var h=e[g];h.handleEvent?h.handleEvent(a):h(a),a.removed&&(this.off(a.type,h,1==b),a.removed=!1)}}},createjs.EventDispatcher=EventDispatcher}(),this.createjs=this.createjs||{},function(){"use strict";function Ticker(){throw"Ticker cannot be instantiated."}Ticker.RAF_SYNCHED="synched",Ticker.RAF="raf",Ticker.TIMEOUT="timeout",Ticker.useRAF=!1,Ticker.timingMode=null,Ticker.maxDelta=0,Ticker.paused=!1,Ticker.removeEventListener=null,Ticker.removeAllEventListeners=null,Ticker.dispatchEvent=null,Ticker.hasEventListener=null,Ticker._listeners=null,createjs.EventDispatcher.initialize(Ticker),Ticker._addEventListener=Ticker.addEventListener,Ticker.addEventListener=function(){return!Ticker._inited&&Ticker.init(),Ticker._addEventListener.apply(Ticker,arguments)},Ticker._inited=!1,Ticker._startTime=0,Ticker._pausedTime=0,Ticker._ticks=0,Ticker._pausedTicks=0,Ticker._interval=50,Ticker._lastTime=0,Ticker._times=null,Ticker._tickTimes=null,Ticker._timerId=null,Ticker._raf=!0,Ticker.setInterval=function(a){Ticker._interval=a,Ticker._inited&&Ticker._setupTick()},Ticker.getInterval=function(){return Ticker._interval},Ticker.setFPS=function(a){Ticker.setInterval(1e3/a)},Ticker.getFPS=function(){return 1e3/Ticker._interval};try{Object.defineProperties(Ticker,{interval:{get:Ticker.getInterval,set:Ticker.setInterval},framerate:{get:Ticker.getFPS,set:Ticker.setFPS}})}catch(a){console.log(a)}Ticker.init=function(){Ticker._inited||(Ticker._inited=!0,Ticker._times=[],Ticker._tickTimes=[],Ticker._startTime=Ticker._getTime(),Ticker._times.push(Ticker._lastTime=0),Ticker.interval=Ticker._interval)},Ticker.reset=function(){if(Ticker._raf){var a=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame;a&&a(Ticker._timerId)}else clearTimeout(Ticker._timerId);Ticker.removeAllEventListeners("tick"),Ticker._timerId=Ticker._times=Ticker._tickTimes=null,Ticker._startTime=Ticker._lastTime=Ticker._ticks=0,Ticker._inited=!1},Ticker.getMeasuredTickTime=function(a){var b=0,c=Ticker._tickTimes;if(!c||c.length<1)return-1;a=Math.min(c.length,a||0|Ticker.getFPS());for(var d=0;a>d;d++)b+=c[d];return b/a},Ticker.getMeasuredFPS=function(a){var b=Ticker._times;return!b||b.length<2?-1:(a=Math.min(b.length-1,a||0|Ticker.getFPS()),1e3/((b[0]-b[a])/a))},Ticker.setPaused=function(a){Ticker.paused=a},Ticker.getPaused=function(){return Ticker.paused},Ticker.getTime=function(a){return Ticker._startTime?Ticker._getTime()-(a?Ticker._pausedTime:0):-1},Ticker.getEventTime=function(a){return Ticker._startTime?(Ticker._lastTime||Ticker._startTime)-(a?Ticker._pausedTime:0):-1},Ticker.getTicks=function(a){return Ticker._ticks-(a?Ticker._pausedTicks:0)},Ticker._handleSynch=function(){Ticker._timerId=null,Ticker._setupTick(),Ticker._getTime()-Ticker._lastTime>=.97*(Ticker._interval-1)&&Ticker._tick()},Ticker._handleRAF=function(){Ticker._timerId=null,Ticker._setupTick(),Ticker._tick()},Ticker._handleTimeout=function(){Ticker._timerId=null,Ticker._setupTick(),Ticker._tick()},Ticker._setupTick=function(){if(null==Ticker._timerId){var a=Ticker.timingMode||Ticker.useRAF&&Ticker.RAF_SYNCHED;if(a==Ticker.RAF_SYNCHED||a==Ticker.RAF){var b=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;if(b)return Ticker._timerId=b(a==Ticker.RAF?Ticker._handleRAF:Ticker._handleSynch),void(Ticker._raf=!0)}Ticker._raf=!1,Ticker._timerId=setTimeout(Ticker._handleTimeout,Ticker._interval)}},Ticker._tick=function(){var a=Ticker.paused,b=Ticker._getTime(),c=b-Ticker._lastTime;if(Ticker._lastTime=b,Ticker._ticks++,a&&(Ticker._pausedTicks++,Ticker._pausedTime+=c),Ticker.hasEventListener("tick")){var d=new createjs.Event("tick"),e=Ticker.maxDelta;d.delta=e&&c>e?e:c,d.paused=a,d.time=b,d.runTime=b-Ticker._pausedTime,Ticker.dispatchEvent(d)}for(Ticker._tickTimes.unshift(Ticker._getTime()-b);Ticker._tickTimes.length>100;)Ticker._tickTimes.pop();for(Ticker._times.unshift(b);Ticker._times.length>100;)Ticker._times.pop()};var b=window.performance&&(performance.now||performance.mozNow||performance.msNow||performance.oNow||performance.webkitNow);Ticker._getTime=function(){return(b&&b.call(performance)||(new Date).getTime())-Ticker._startTime},createjs.Ticker=Ticker}(),this.createjs=this.createjs||{},function(){"use strict";function Tween(a,b,c){this.ignoreGlobalPause=!1,this.loop=!1,this.duration=0,this.pluginData=c||{},this.target=a,this.position=null,this.passive=!1,this._paused=!1,this._curQueueProps={},this._initQueueProps={},this._steps=[],this._actions=[],this._prevPosition=0,this._stepPosition=0,this._prevPos=-1,this._target=a,this._useTicks=!1,this._inited=!1,this._registered=!1,b&&(this._useTicks=b.useTicks,this.ignoreGlobalPause=b.ignoreGlobalPause,this.loop=b.loop,b.onChange&&this.addEventListener("change",b.onChange),b.override&&Tween.removeTweens(a)),b&&b.paused?this._paused=!0:createjs.Tween._register(this,!0),b&&null!=b.position&&this.setPosition(b.position,Tween.NONE)}var a=createjs.extend(Tween,createjs.EventDispatcher);Tween.NONE=0,Tween.LOOP=1,Tween.REVERSE=2,Tween.IGNORE={},Tween._tweens=[],Tween._plugins={},Tween.get=function(a,b,c,d){return d&&Tween.removeTweens(a),new Tween(a,b,c)},Tween.tick=function(a,b){for(var c=Tween._tweens.slice(),d=c.length-1;d>=0;d--){var e=c[d];b&&!e.ignoreGlobalPause||e._paused||e.tick(e._useTicks?1:a)}},Tween.handleEvent=function(a){"tick"==a.type&&this.tick(a.delta,a.paused)},Tween.removeTweens=function(a){if(a.tweenjs_count){for(var b=Tween._tweens,c=b.length-1;c>=0;c--){var d=b[c];d._target==a&&(d._paused=!0,b.splice(c,1))}a.tweenjs_count=0}},Tween.removeAllTweens=function(){for(var a=Tween._tweens,b=0,c=a.length;c>b;b++){var d=a[b];d._paused=!0,d.target&&(d.target.tweenjs_count=0)}a.length=0},Tween.hasActiveTweens=function(a){return a?null!=a.tweenjs_count&&!!a.tweenjs_count:Tween._tweens&&!!Tween._tweens.length},Tween.installPlugin=function(a,b){var c=a.priority;null==c&&(a.priority=c=0);for(var d=0,e=b.length,f=Tween._plugins;e>d;d++){var g=b[d];if(f[g]){for(var h=f[g],i=0,j=h.length;j>i&&!(c=a)return this;var c=this._cloneProps(this._curQueueProps);return this._addStep({d:a,p0:c,e:this._linearEase,p1:c,v:b})},a.to=function(a,b,c){return(isNaN(b)||0>b)&&(b=0),this._addStep({d:b||0,p0:this._cloneProps(this._curQueueProps),e:c,p1:this._cloneProps(this._appendQueueProps(a))})},a.call=function(a,b,c){return this._addAction({f:a,p:b?b:[this],o:c?c:this._target})},a.set=function(a,b){return this._addAction({f:this._set,o:this,p:[a,b?b:this._target]})},a.play=function(a){return a||(a=this),this.call(a.setPaused,[!1],a)},a.pause=function(a){return a||(a=this),this.call(a.setPaused,[!0],a)},a.setPosition=function(a,b){0>a&&(a=0),null==b&&(b=1);var c=a,d=!1;if(c>=this.duration&&(this.loop?c%=this.duration:(c=this.duration,d=!0)),c==this._prevPos)return d;var e=this._prevPos;if(this.position=this._prevPos=c,this._prevPosition=a,this._target)if(d)this._updateTargetProps(null,1);else if(this._steps.length>0){for(var f=0,g=this._steps.length;g>f&&!(this._steps[f].t>c);f++);var h=this._steps[f-1];this._updateTargetProps(h,(this._stepPosition=c-h.t)/h.d)}return 0!=b&&this._actions.length>0&&(this._useTicks?this._runActions(c,c):1==b&&e>c?(e!=this.duration&&this._runActions(e,this.duration),this._runActions(0,c,!0)):this._runActions(e,c)),d&&this.setPaused(!0),this.dispatchEvent("change"),d},a.tick=function(a){this._paused||this.setPosition(this._prevPosition+a)},a.setPaused=function(a){return this._paused===!!a?this:(this._paused=!!a,Tween._register(this,!a),this)},a.w=a.wait,a.t=a.to,a.c=a.call,a.s=a.set,a.toString=function(){return"[Tween]"},a.clone=function(){throw"Tween can not be cloned."},a._updateTargetProps=function(a,b){var c,d,e,f,g,h;if(a||1!=b){if(this.passive=!!a.v,this.passive)return;a.e&&(b=a.e(b,0,1,1)),c=a.p0,d=a.p1}else this.passive=!1,c=d=this._curQueueProps;for(var i in this._initQueueProps){null==(f=c[i])&&(c[i]=f=this._initQueueProps[i]),null==(g=d[i])&&(d[i]=g=f),e=f==g||0==b||1==b||"number"!=typeof f?1==b?g:f:f+(g-f)*b;var j=!1;if(h=Tween._plugins[i])for(var k=0,l=h.length;l>k;k++){var m=h[k].tween(this,i,e,c,d,b,!!a&&c==d,!a);m==Tween.IGNORE?j=!0:e=m}j||(this._target[i]=e)}},a._runActions=function(a,b,c){var d=a,e=b,f=-1,g=this._actions.length,h=1;for(a>b&&(d=b,e=a,f=g,g=h=-1);(f+=h)!=g;){var i=this._actions[f],j=i.t;(j==e||j>d&&e>j||c&&j==a)&&i.f.apply(i.o,i.p)}},a._appendQueueProps=function(a){var b,c,d,e,f;for(var g in a)if(void 0===this._initQueueProps[g]){if(c=this._target[g],b=Tween._plugins[g])for(d=0,e=b.length;e>d;d++)c=b[d].init(this,g,c);this._initQueueProps[g]=this._curQueueProps[g]=void 0===c?null:c}else c=this._curQueueProps[g];for(var g in a){if(c=this._curQueueProps[g],b=Tween._plugins[g])for(f=f||{},d=0,e=b.length;e>d;d++)b[d].step&&b[d].step(this,g,c,a[g],f);this._curQueueProps[g]=a[g]}return f&&this._appendQueueProps(f),this._curQueueProps},a._cloneProps=function(a){var b={};for(var c in a)b[c]=a[c];return b},a._addStep=function(a){return a.d>0&&(this._steps.push(a),a.t=this.duration,this.duration+=a.d),this},a._addAction=function(a){return a.t=this.duration,this._actions.push(a),this},a._set=function(a,b){for(var c in a)b[c]=a[c]},createjs.Tween=createjs.promote(Tween,"EventDispatcher")}(),this.createjs=this.createjs||{},function(){"use strict";function Timeline(a,b,c){this.EventDispatcher_constructor(),this.ignoreGlobalPause=!1,this.duration=0,this.loop=!1,this.position=null,this._paused=!1,this._tweens=[],this._labels=null,this._labelList=null,this._prevPosition=0,this._prevPos=-1,this._useTicks=!1,this._registered=!1,c&&(this._useTicks=c.useTicks,this.loop=c.loop,this.ignoreGlobalPause=c.ignoreGlobalPause,c.onChange&&this.addEventListener("change",c.onChange)),a&&this.addTween.apply(this,a),this.setLabels(b),c&&c.paused?this._paused=!0:createjs.Tween._register(this,!0),c&&null!=c.position&&this.setPosition(c.position,createjs.Tween.NONE)}var a=createjs.extend(Timeline,createjs.EventDispatcher);a.addTween=function(a){var b=arguments.length;if(b>1){for(var c=0;b>c;c++)this.addTween(arguments[c]);return arguments[0]}return 0==b?null:(this.removeTween(a),this._tweens.push(a),a.setPaused(!0),a._paused=!1,a._useTicks=this._useTicks,a.duration>this.duration&&(this.duration=a.duration),this._prevPos>=0&&a.setPosition(this._prevPos,createjs.Tween.NONE),a)},a.removeTween=function(a){var b=arguments.length;if(b>1){for(var c=!0,d=0;b>d;d++)c=c&&this.removeTween(arguments[d]);return c}if(0==b)return!1;for(var e=this._tweens,d=e.length;d--;)if(e[d]==a)return e.splice(d,1),a.duration>=this.duration&&this.updateDuration(),!0;return!1},a.addLabel=function(a,b){this._labels[a]=b;var c=this._labelList;if(c){for(var d=0,e=c.length;e>d&&!(bd&&!(b=this.duration;if(c==this._prevPos)return d;this._prevPosition=a,this.position=this._prevPos=c;for(var e=0,f=this._tweens.length;f>e;e++)if(this._tweens[e].setPosition(c,b),c!=this._prevPos)return!1;return d&&this.setPaused(!0),this.dispatchEvent("change"),d},a.setPaused=function(a){this._paused=!!a,createjs.Tween._register(this,!a)},a.updateDuration=function(){this.duration=0;for(var a=0,b=this._tweens.length;b>a;a++){var c=this._tweens[a];c.duration>this.duration&&(this.duration=c.duration)}},a.tick=function(a){this.setPosition(this._prevPosition+a)},a.resolve=function(a){var b=Number(a);return isNaN(b)&&(b=this._labels[a]),b},a.toString=function(){return"[Timeline]"},a.clone=function(){throw"Timeline can not be cloned."},a._goto=function(a){var b=this.resolve(a);null!=b&&this.setPosition(b)},a._calcPosition=function(a){return 0>a?0:aa&&(a=-1),a>1&&(a=1),function(b){return 0==a?b:0>a?b*(b*-a+1+a):b*((2-b)*a+(1-a))}},Ease.getPowIn=function(a){return function(b){return Math.pow(b,a)}},Ease.getPowOut=function(a){return function(b){return 1-Math.pow(1-b,a)}},Ease.getPowInOut=function(a){return function(b){return(b*=2)<1?.5*Math.pow(b,a):1-.5*Math.abs(Math.pow(2-b,a))}},Ease.quadIn=Ease.getPowIn(2),Ease.quadOut=Ease.getPowOut(2),Ease.quadInOut=Ease.getPowInOut(2),Ease.cubicIn=Ease.getPowIn(3),Ease.cubicOut=Ease.getPowOut(3),Ease.cubicInOut=Ease.getPowInOut(3),Ease.quartIn=Ease.getPowIn(4),Ease.quartOut=Ease.getPowOut(4),Ease.quartInOut=Ease.getPowInOut(4),Ease.quintIn=Ease.getPowIn(5),Ease.quintOut=Ease.getPowOut(5),Ease.quintInOut=Ease.getPowInOut(5),Ease.sineIn=function(a){return 1-Math.cos(a*Math.PI/2)},Ease.sineOut=function(a){return Math.sin(a*Math.PI/2)},Ease.sineInOut=function(a){return-.5*(Math.cos(Math.PI*a)-1)},Ease.getBackIn=function(a){return function(b){return b*b*((a+1)*b-a)}},Ease.backIn=Ease.getBackIn(1.7),Ease.getBackOut=function(a){return function(b){return--b*b*((a+1)*b+a)+1}},Ease.backOut=Ease.getBackOut(1.7),Ease.getBackInOut=function(a){return a*=1.525,function(b){return(b*=2)<1?.5*b*b*((a+1)*b-a):.5*((b-=2)*b*((a+1)*b+a)+2)}},Ease.backInOut=Ease.getBackInOut(1.7),Ease.circIn=function(a){return-(Math.sqrt(1-a*a)-1)},Ease.circOut=function(a){return Math.sqrt(1- --a*a)},Ease.circInOut=function(a){return(a*=2)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)},Ease.bounceIn=function(a){return 1-Ease.bounceOut(1-a)},Ease.bounceOut=function(a){return 1/2.75>a?7.5625*a*a:2/2.75>a?7.5625*(a-=1.5/2.75)*a+.75:2.5/2.75>a?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375},Ease.bounceInOut=function(a){return.5>a?.5*Ease.bounceIn(2*a):.5*Ease.bounceOut(2*a-1)+.5},Ease.getElasticIn=function(a,b){var c=2*Math.PI;return function(d){if(0==d||1==d)return d;var e=b/c*Math.asin(1/a);return-(a*Math.pow(2,10*(d-=1))*Math.sin((d-e)*c/b))}},Ease.elasticIn=Ease.getElasticIn(1,.3),Ease.getElasticOut=function(a,b){var c=2*Math.PI;return function(d){if(0==d||1==d)return d;var e=b/c*Math.asin(1/a);return a*Math.pow(2,-10*d)*Math.sin((d-e)*c/b)+1}},Ease.elasticOut=Ease.getElasticOut(1,.3),Ease.getElasticInOut=function(a,b){var c=2*Math.PI;return function(d){var e=b/c*Math.asin(1/a);return(d*=2)<1?-.5*a*Math.pow(2,10*(d-=1))*Math.sin((d-e)*c/b):a*Math.pow(2,-10*(d-=1))*Math.sin((d-e)*c/b)*.5+1}},Ease.elasticInOut=Ease.getElasticInOut(1,.3*1.5),createjs.Ease=Ease}(),this.createjs=this.createjs||{},function(){"use strict";function MotionGuidePlugin(){throw"MotionGuidePlugin cannot be instantiated."}MotionGuidePlugin.priority=0,MotionGuidePlugin._rotOffS,MotionGuidePlugin._rotOffE,MotionGuidePlugin._rotNormS,MotionGuidePlugin._rotNormE,MotionGuidePlugin.install=function(){return createjs.Tween.installPlugin(MotionGuidePlugin,["guide","x","y","rotation"]),createjs.Tween.IGNORE},MotionGuidePlugin.init=function(a,b,c){var d=a.target;return d.hasOwnProperty("x")||(d.x=0),d.hasOwnProperty("y")||(d.y=0),d.hasOwnProperty("rotation")||(d.rotation=0),"rotation"==b&&(a.__needsRot=!0),"guide"==b?null:c},MotionGuidePlugin.step=function(a,b,c,d,e){if("rotation"==b&&(a.__rotGlobalS=c,a.__rotGlobalE=d,MotionGuidePlugin.testRotData(a,e)),"guide"!=b)return d;var f,g=d;g.hasOwnProperty("path")||(g.path=[]);var h=g.path;if(g.hasOwnProperty("end")||(g.end=1),g.hasOwnProperty("start")||(g.start=c&&c.hasOwnProperty("end")&&c.path===h?c.end:0),g.hasOwnProperty("_segments")&&g._length)return d;var i=h.length,j=10;if(!(i>=6&&(i-2)%4==0))throw"invalid 'path' data, please see documentation for valid paths";g._segments=[],g._length=0;for(var k=2;i>k;k+=4){for(var l,m,n=h[k-2],o=h[k-1],p=h[k+0],q=h[k+1],r=h[k+2],s=h[k+3],t=n,u=o,v=0,w=[],x=1;j>=x;x++){var y=x/j,z=1-y;l=z*z*n+2*z*y*p+y*y*r,m=z*z*o+2*z*y*q+y*y*s,v+=w[w.push(Math.sqrt((f=l-t)*f+(f=m-u)*f))-1],t=l,u=m}g._segments.push(v),g._segments.push(w),g._length+=v}f=g.orient,g.orient=!0;var A={};return MotionGuidePlugin.calc(g,g.start,A),a.__rotPathS=Number(A.rotation.toFixed(5)),MotionGuidePlugin.calc(g,g.end,A),a.__rotPathE=Number(A.rotation.toFixed(5)),g.orient=!1,MotionGuidePlugin.calc(g,g.end,e),g.orient=f,g.orient?(a.__guideData=g,MotionGuidePlugin.testRotData(a,e),d):d},MotionGuidePlugin.testRotData=function(a,b){if(void 0===a.__rotGlobalS||void 0===a.__rotGlobalE){if(a.__needsRot)return;a.__rotGlobalS=a.__rotGlobalE=void 0!==a._curQueueProps.rotation?a._curQueueProps.rotation:b.rotation=a.target.rotation||0}if(void 0!==a.__guideData){var c=a.__guideData,d=a.__rotGlobalE-a.__rotGlobalS,e=a.__rotPathE-a.__rotPathS,f=d-e;if("auto"==c.orient)f>180?f-=360:-180>f&&(f+=360);else if("cw"==c.orient){for(;0>f;)f+=360;0==f&&d>0&&180!=d&&(f+=360)}else if("ccw"==c.orient){for(f=d-(e>180?360-e:e);f>0;)f-=360;0==f&&0>d&&-180!=d&&(f-=360)}c.rotDelta=f,c.rotOffS=a.__rotGlobalS-a.__rotPathS,a.__rotGlobalS=a.__rotGlobalE=a.__guideData=a.__needsRot=void 0}},MotionGuidePlugin.tween=function(a,b,c,d,e,f,g){var h=e.guide;if(void 0==h||h===d.guide)return c;if(h.lastRatio!=f){var i=(h.end-h.start)*(g?h.end:f)+h.start;switch(MotionGuidePlugin.calc(h,i,a.target),h.orient){case"cw":case"ccw":case"auto":a.target.rotation+=h.rotOffS+h.rotDelta*f;break;case"fixed":default:a.target.rotation+=h.rotOffS}h.lastRatio=f}return"rotation"!=b||h.orient&&"false"!=h.orient?a.target[b]:c},MotionGuidePlugin.calc=function(a,b,c){if(void 0==a._segments)throw"Missing critical pre-calculated information, please file a bug";void 0==c&&(c={x:0,y:0,rotation:0});for(var d=a._segments,e=a.path,f=a._length*b,g=d.length-2,h=0;f>d[h]&&g>h;)f-=d[h],h+=2;var i=d[h+1],j=0;for(g=i.length-1;f>i[j]&&g>j;)f-=i[j],j++;var k=j/++g+f/(g*i[j]);h=2*h+2;var l=1-k;return c.x=l*l*e[h-2]+2*l*k*e[h+0]+k*k*e[h+2],c.y=l*l*e[h-1]+2*l*k*e[h+1]+k*k*e[h+3],a.orient&&(c.rotation=57.2957795*Math.atan2((e[h+1]-e[h-1])*l+(e[h+3]-e[h+1])*k,(e[h+0]-e[h-2])*l+(e[h+2]-e[h+0])*k)),c},createjs.MotionGuidePlugin=MotionGuidePlugin}(),this.createjs=this.createjs||{},function(){"use strict";var a=createjs.TweenJS=createjs.TweenJS||{};a.version="NEXT",a.buildDate="Wed, 25 Nov 2015 19:32:49 GMT"}();
\ No newline at end of file
diff --git a/_assets/art/daisy.png b/assets/art/daisy.png
similarity index 100%
rename from _assets/art/daisy.png
rename to assets/art/daisy.png
diff --git a/_assets/art/flowers.jpg b/assets/art/flowers.jpg
similarity index 100%
rename from _assets/art/flowers.jpg
rename to assets/art/flowers.jpg
diff --git a/_assets/art/ground.png b/assets/art/ground.png
similarity index 100%
rename from _assets/art/ground.png
rename to assets/art/ground.png
diff --git a/_assets/art/hill1.png b/assets/art/hill1.png
similarity index 100%
rename from _assets/art/hill1.png
rename to assets/art/hill1.png
diff --git a/_assets/art/hill2.png b/assets/art/hill2.png
similarity index 100%
rename from _assets/art/hill2.png
rename to assets/art/hill2.png
diff --git a/assets/art/robojs/robojs.png b/assets/art/robojs/robojs.png
new file mode 100644
index 000000000..9d96eb587
Binary files /dev/null and b/assets/art/robojs/robojs.png differ
diff --git a/assets/art/robojs/robojs1.png b/assets/art/robojs/robojs1.png
new file mode 100644
index 000000000..56304a692
Binary files /dev/null and b/assets/art/robojs/robojs1.png differ
diff --git a/assets/art/robojs/robojs10.png b/assets/art/robojs/robojs10.png
new file mode 100644
index 000000000..efaf5df96
Binary files /dev/null and b/assets/art/robojs/robojs10.png differ
diff --git a/assets/art/robojs/robojs2.png b/assets/art/robojs/robojs2.png
new file mode 100644
index 000000000..a5f46e0dc
Binary files /dev/null and b/assets/art/robojs/robojs2.png differ
diff --git a/assets/art/robojs/robojs3.png b/assets/art/robojs/robojs3.png
new file mode 100644
index 000000000..cf5b9bfed
Binary files /dev/null and b/assets/art/robojs/robojs3.png differ
diff --git a/assets/art/robojs/robojs4.png b/assets/art/robojs/robojs4.png
new file mode 100644
index 000000000..e007240ab
Binary files /dev/null and b/assets/art/robojs/robojs4.png differ
diff --git a/assets/art/robojs/robojs5.png b/assets/art/robojs/robojs5.png
new file mode 100644
index 000000000..4cd72030b
Binary files /dev/null and b/assets/art/robojs/robojs5.png differ
diff --git a/assets/art/robojs/robojs6.png b/assets/art/robojs/robojs6.png
new file mode 100644
index 000000000..ca9941649
Binary files /dev/null and b/assets/art/robojs/robojs6.png differ
diff --git a/assets/art/robojs/robojs7.png b/assets/art/robojs/robojs7.png
new file mode 100644
index 000000000..6f51a3e6c
Binary files /dev/null and b/assets/art/robojs/robojs7.png differ
diff --git a/assets/art/robojs/robojs8.png b/assets/art/robojs/robojs8.png
new file mode 100644
index 000000000..b92055f50
Binary files /dev/null and b/assets/art/robojs/robojs8.png differ
diff --git a/assets/art/robojs/robojs9.png b/assets/art/robojs/robojs9.png
new file mode 100644
index 000000000..4c2b741a0
Binary files /dev/null and b/assets/art/robojs/robojs9.png differ
diff --git a/_assets/art/robot.png b/assets/art/robot.png
similarity index 100%
rename from _assets/art/robot.png
rename to assets/art/robot.png
diff --git a/_assets/art/sky.png b/assets/art/sky.png
similarity index 100%
rename from _assets/art/sky.png
rename to assets/art/sky.png
diff --git a/_assets/art/spritesheet_button.png b/assets/art/spritesheet_button.png
similarity index 100%
rename from _assets/art/spritesheet_button.png
rename to assets/art/spritesheet_button.png
diff --git a/_assets/art/spritesheet_font.png b/assets/art/spritesheet_font.png
similarity index 100%
rename from _assets/art/spritesheet_font.png
rename to assets/art/spritesheet_font.png
diff --git a/_assets/art/spritesheet_grant.png b/assets/art/spritesheet_grant.png
similarity index 100%
rename from _assets/art/spritesheet_grant.png
rename to assets/art/spritesheet_grant.png
diff --git a/_assets/art/spritesheet_icons.png b/assets/art/spritesheet_icons.png
similarity index 100%
rename from _assets/art/spritesheet_icons.png
rename to assets/art/spritesheet_icons.png
diff --git a/_assets/art/spritesheet_sparkle.png b/assets/art/spritesheet_sparkle.png
similarity index 100%
rename from _assets/art/spritesheet_sparkle.png
rename to assets/art/spritesheet_sparkle.png
diff --git a/_assets/art/tmw_desert_spacing.png b/assets/art/tmw_desert_spacing.png
similarity index 100%
rename from _assets/art/tmw_desert_spacing.png
rename to assets/art/tmw_desert_spacing.png
diff --git a/_assets/audio/bionic.mp3 b/assets/audio/bionic.mp3
similarity index 100%
rename from _assets/audio/bionic.mp3
rename to assets/audio/bionic.mp3
diff --git a/assets/github-header.png b/assets/github-header.png
new file mode 100644
index 000000000..5d4563964
Binary files /dev/null and b/assets/github-header.png differ
diff --git a/assets/icon.png b/assets/icon.png
new file mode 100644
index 000000000..297ab7325
Binary files /dev/null and b/assets/icon.png differ
diff --git a/assets/js/Slider.js b/assets/js/Slider.js
new file mode 100644
index 000000000..0b042708a
--- /dev/null
+++ b/assets/js/Slider.js
@@ -0,0 +1,79 @@
+/**
+ * @license Slider
+ * 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 3A 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.
+ */
+
+if (window.createjs === undefined || window.createjs.Shape === undefined) {
+ console.warn("The Slider asset only works with the global createjs module");
+}
+class Slider extends Shape {
+ constructor (min = 0, max = 100, width = 100, height = 20) {
+ this.min = min;
+ this.max = max;
+ this.width = width;
+ this.height = height;
+ this.values = {};
+ this.trackColor = "#EEE";
+ this.thumbColor = "#666";
+ this.cursor = "pointer";
+ this.on("mousedown", this._handleInput, this);
+ this.on("pressmove", this._handleInput, this);
+ }
+ isVisible () { return true; }
+ draw (ctx, ignoreCache) {
+ if (this._checkChange()) {
+ const x = (this.width-this.height) * Math.max(0,Math.min(1,(this.value-this.min) / (this.max-this.min)));
+ this.graphics.clear()
+ .beginFill(this.trackColor).drawRect(0,0,this.width,this.height)
+ .beginFill(this.thumbColor).drawRect(x,0,this.height, this.height);
+ }
+ super.draw(ctx, true);
+ }
+ _checkChange () {
+ const a = this, b = a.values;
+ if (a.value !== b.value || a.min !== b.min || a.max !== b.max || a.width !== b.width || a.height !== b.height) {
+ b.min = a.min;
+ b.max = a.max;
+ b.value = a.value;
+ b.width = a.width;
+ b.height = a.height;
+ return true;
+ }
+ return false;
+ }
+ _handleInput (evt) {
+ const val = Math.max(
+ this.min, Math.min(
+ this.max,
+ (evt.localX-this.height/2)/(this.width-this.height)*(this.max-this.min)+this.min
+ )
+ );
+ if (val === this.value) { return; }
+ this.value = val;
+ this.dispatchEvent("change");
+ }
+}
+export default Slider;
diff --git a/_assets/art/VectorButton.js b/assets/js/VectorButton.js
similarity index 100%
rename from _assets/art/VectorButton.js
rename to assets/js/VectorButton.js
diff --git a/assets/js/dat.gui.min.js b/assets/js/dat.gui.min.js
new file mode 100644
index 000000000..8ea141a96
--- /dev/null
+++ b/assets/js/dat.gui.min.js
@@ -0,0 +1,95 @@
+/**
+ * dat-gui JavaScript Controller Library
+ * http://code.google.com/p/dat-gui
+ *
+ * Copyright 2011 Data Arts Team, Google Creative Lab
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ */
+var dat=dat||{};dat.gui=dat.gui||{};dat.utils=dat.utils||{};dat.controllers=dat.controllers||{};dat.dom=dat.dom||{};dat.color=dat.color||{};dat.utils.css=function(){return{load:function(f,a){a=a||document;var d=a.createElement("link");d.type="text/css";d.rel="stylesheet";d.href=f;a.getElementsByTagName("head")[0].appendChild(d)},inject:function(f,a){a=a||document;var d=document.createElement("style");d.type="text/css";d.innerHTML=f;a.getElementsByTagName("head")[0].appendChild(d)}}}();
+dat.utils.common=function(){var f=Array.prototype.forEach,a=Array.prototype.slice;return{BREAK:{},extend:function(d){this.each(a.call(arguments,1),function(a){for(var c in a)this.isUndefined(a[c])||(d[c]=a[c])},this);return d},defaults:function(d){this.each(a.call(arguments,1),function(a){for(var c in a)this.isUndefined(d[c])&&(d[c]=a[c])},this);return d},compose:function(){var d=a.call(arguments);return function(){for(var e=a.call(arguments),c=d.length-1;0<=c;c--)e=[d[c].apply(this,e)];return e[0]}},
+each:function(a,e,c){if(a)if(f&&a.forEach&&a.forEach===f)a.forEach(e,c);else if(a.length===a.length+0)for(var b=0,p=a.length;b
- {{#if foundAt}}
- DEFINED IN
- {{/if}}
- {{/if}}
- {{/if}}
- {{#if foundAt}}
- `{{{name}}}:{{{line}}}`
- {{/if}}
-
-
- {{#if deprecationMessage}}
-
Deprecated: {{deprecationMessage}}
- {{/if}}
-
- {{#if since}}
-
Available since {{since}}
- {{/if}}
-
-
-
- {{{attrDescription}}}
-
-
- {{#if default}}
-
Default: {{default}}
- {{/if}}
-
- {{#if emit}}
-
-
Fires event {{name}}Change
-
-
- Fires when the value for the configuration attribute `{{{name}}}` is
- changed. You can listen for the event using the `on` method if you
- wish to be notified before the attribute's value has changed, or
- using the `after` method if you wish to be notified after the
- attribute's value has changed.
-
-
-
-
Parameters:
-
-
-
- e
- {{#crossLink "EventFacade"}}{{/crossLink}}
-
-
- An Event Facade object with the following
- attribute-specific properties added:
-
-
-
-
- prevVal
- Any
-
The value of the attribute, prior to it being set.
diff --git a/build/createjsTheme/theme.json b/build/createjsTheme/theme.json
deleted file mode 100755
index 1f522fc32..000000000
--- a/build/createjsTheme/theme.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "yuiGridsUrl": "../assets/css/yui-cssgrids-min.css",
- "yuiSeedUrl": "../assets/js/yui-source.js"
-}
diff --git a/build/package.json b/build/package.json
deleted file mode 100644
index 355e62352..000000000
--- a/build/package.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "name": "EaselJS",
- "version": "0.8.2",
- "description": "EaselJS Docs",
- "url": "http://www.createjs.com/easeljs",
- "logo": "assets/docs-icon-EaselJS.png",
- "repository": "git@github.com:CreateJS/EaselJS.git",
- "devDependencies": {
- "grunt": "~0.4.5",
- "grunt-contrib-concat": "~0.5.0",
- "grunt-contrib-uglify": "~0.6.0",
- "grunt-contrib-yuidoc": "~0.5.2",
- "grunt-contrib-compress": "~0.12.0",
- "grunt-contrib-copy": "~0.7.0",
- "grunt-contrib-sass": "^0.8.1",
- "grunt-contrib-clean":"^0.4.0",
- "grunt-contrib-connect": "~0.8.0",
- "grunt-contrib-watch": "~0.6.1",
- "lodash": "~0.9.2"
- },
- "engine": "node >= 0.10.22"
-}
diff --git a/build/path.js b/build/path.js
deleted file mode 100644
index db9028ea9..000000000
--- a/build/path.js
+++ /dev/null
@@ -1,5 +0,0 @@
-module.exports = {
- path: function(str) {
- return str.substr(str.lastIndexOf("/")+1);
- }
-}
diff --git a/build/tasks/updatebower.js b/build/tasks/updatebower.js
deleted file mode 100644
index d950ae2f1..000000000
--- a/build/tasks/updatebower.js
+++ /dev/null
@@ -1,22 +0,0 @@
-module.exports = function (grunt) {
-
- grunt.registerTask('updatebower', function() {
- var file = '../bower.json';
- var version = grunt.config.get('version');
-
- if (!grunt.file.exists(file)) {
- grunt.log.error(file+' not found.');
- return;
- }
- if (version == "NEXT") {
- grunt.log.error("NEXT versions are not submitted to Bower.");
- return;
- }
-
- var json = grunt.file.readJSON(file);
- json.version = version;
- json.main = json.main.replace(/\d\.\d\.\d|NEXT/, version);
- grunt.file.write(file, JSON.stringify(json, null, '\t'));
- });
-
-}
diff --git a/build/tasks/updateversion.js b/build/tasks/updateversion.js
deleted file mode 100644
index eec622395..000000000
--- a/build/tasks/updateversion.js
+++ /dev/null
@@ -1,36 +0,0 @@
-module.exports = function (grunt) {
-
- grunt.registerMultiTask('updateversion', function() {
- var newValues = {date:new Date().toUTCString(), version:this.data.version};
- replaceMetaData(this.data.file, newValues);
- });
-
- grunt.registerMultiTask('clearversion', function() {
- // Don't clear the version when building everything (the combined build will run this after its done)
- var buildArgs = grunt.config("buildArgs");
- if (buildArgs && buildArgs[0] == "all") {
- return;
- }
- replaceMetaData(this.data.file, {date:"", version:""});
- });
-
- function replaceMetaData(file, values) {
- if (!grunt.file.exists(file)) {
- grunt.log.error(file+' not found.');
- return;
- }
-
- var str = grunt.file.read(file);
-
- for(var n in values) {
- var pattern = new RegExp("(\/\\*="+n+"\\*\/\")(.*)(\";)", "g");
- var result = pattern.test(str);
- if (result) {
- str = str.replace(pattern, "$1"+values[n]+"$3");
- } else {
- grunt.log.error("Error -- Unable to resolve value:"+ pattern);
- }
- }
- grunt.file.write(file, str);
- }
-}
diff --git a/build/updates/README.md b/build/updates/README.md
deleted file mode 100644
index ea33056c4..000000000
--- a/build/updates/README.md
+++ /dev/null
@@ -1,11 +0,0 @@
-## Important ##
-
-The current YUIDocs does not support @readonly on properties (only attributes). This folder contains an updated
-`builder.js`, which injects this support.
-
-Copy `builder.js` into
- > node_modules/grunt-contrib-yuidoc/node-modules/yuidocjs/lib
-
-Without this file, properties will not show the "readonly" flag.
-
-Last tested with YUIDocs 0.5.2
\ No newline at end of file
diff --git a/build/updates/builder.js b/build/updates/builder.js
deleted file mode 100644
index 63c8e6d7f..000000000
--- a/build/updates/builder.js
+++ /dev/null
@@ -1,1663 +0,0 @@
-/*
-Copyright (c) 2011, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://yuilibrary.com/license/
-*/
-var marked = require('marked'),
- fs = require('graceful-fs'),
- noop = function () {},
- path = require('path'),
- TEMPLATE;
-
-/**
-* Takes the `JSON` data from the `DocParser` class, creates and parses markdown and handlebars
-based templates to generate static HTML content
-* @class DocBuilder
-* @module yuidoc
-*/
-
-YUI.add('doc-builder', function (Y) {
- /*jshint onevar:false */
-
- var fixType = Y.Lang.fixType,
- print = function (items) {
- var out = '
';
-
- Y.each(items, function (i, k) {
- out += '
';
- if (Y.Lang.isObject(i)) {
- if (!i.path) {
- out += k + '/' + print(i);
- } else {
- out += '' + k + '';
- }
- }
- out += '
';
- });
-
- out += '
';
- return out;
- };
-
- Y.Handlebars.registerHelper('buildFileTree', function (items) {
- return print(items);
- });
-
- var DEFAULT_THEME = path.join(__dirname, '../', 'themes', 'default'),
- themeDir = DEFAULT_THEME;
-
- Y.DocBuilder = function (options, data) {
- this.options = options;
- if (options.helpers) {
- this._addHelpers(options.helpers);
- }
- if (options.themedir) {
- themeDir = options.themedir;
- }
-
- this.data = data;
- Y.log('Building..', 'info', 'builder');
- this.files = 0;
- var self = this;
-
- Y.Handlebars.registerHelper('crossLink', function (item, options) {
- var str = '';
- if (!item) {
- item = '';
- }
- //console.log('CrossLink:', item);
- if (item.indexOf('|') > 0) {
- var parts = item.split('|'),
- p = [];
- Y.each(parts, function (i) {
- p.push(self._parseCrossLink.call(self, i));
- });
- str = p.join(' | ');
- } else {
- str = self._parseCrossLink.call(self, item, false, options.fn(this));
- }
- return str;
- });
-
- Y.Handlebars.registerHelper('crossLinkModule', function (item, options) {
- var str = item;
- if (self.data.modules[item]) {
- var content = options.fn(this);
- if (content === "") {
- content = item;
- }
- str = '' + content + '';
- }
- return str;
- });
-
- Y.Handlebars.registerHelper('crossLinkRaw', function (item) {
- var str = '';
- if (!item) {
- item = '';
- }
- if (item.indexOf('|') > 0) {
- var parts = item.split('|'),
- p = [];
- Y.each(parts, function (i) {
- p.push(self._parseCrossLink.call(self, i, true));
- });
- str = p.join(' | ');
- } else {
- str = self._parseCrossLink.call(self, item, true);
- }
- return str;
- });
-
- this.cacheTemplates = true;
- if (options.cacheTemplates === false) {
- this.cacheTemplates = false;
- }
- };
-
- Y.DocBuilder.prototype = {
- /**
- * Register a `Y.Handlebars` helper method
- * @method _addHelpers
- * @param {Object} helpers Object containing a hash of names and functions
- */
- _addHelpers: function (helpers) {
- Y.log('Importing helpers: ' + helpers, 'info', 'builder');
- helpers.forEach(function (imp) {
- if (!Y.Files.exists(imp) || Y.Files.exists(path.join(process.cwd(), imp))) {
- imp = path.join(process.cwd(), imp);
- }
- var h = require(imp);
- Object.keys(h).forEach(function (name) {
- Y.Handlebars.registerHelper(name, h[name]);
- });
- });
- },
- /**
- * Wrapper around the Markdown parser so it can be normalized or even side stepped
- * @method markdown
- * @private
- * @param {String} md The Markdown string to parse
- * @return {HTML} The rendered HTML
- */
- markdown: function (md) {
- var html = marked(md, this.options.markdown);
- //Only reprocess if helpers were asked for
- if (this.options.helpers || (html.indexOf('{{#crossLink') > -1)) {
- //console.log('MD: ', html);
- try {
- // marked auto-escapes quotation marks (and unfortunately
- // does not expose the escaping function)
- html = html.replace(/"/g, "\"");
- html = (Y.Handlebars.compile(html))({});
- } catch (hError) {
- //Remove all the extra escapes
- html = html.replace(/\\{/g, '{').replace(/\\}/g, '}');
- Y.log('Failed to parse Handlebars, probably an unknown helper, skipping..', 'warn', 'builder');
- }
- //console.log('HB: ', html);
- }
- return html;
- },
-
- /**
- * Parse the item to be cross linked and return an HREF linked to the item
- * @method _parseCrossLink
- * @private
- * @param {String} item The item to crossLink
- * @param {Boolean} [raw=false] Do not wrap it in HTML
- * @param {String} [content] crossLink helper content
- */
- _parseCrossLink: function (item, raw, content) {
- var self = this;
- var base = '../',
- baseItem,
- newWin = false,
- className = 'crosslink';
-
- item = fixType(item);
-
- item = baseItem = Y.Lang.trim(item.replace('{', '').replace('}', ''));
- //Remove Cruft
- item = item.replace('*', '').replace('[', '').replace(']', '');
- var link = false,
- href;
-
- if (self.data.classes[item]) {
- link = true;
- } else {
- if (self.data.classes[item.replace('.', '')]) {
- link = true;
- item = item.replace('.', '');
- }
- }
- if (self.options.externalData) {
- if (self.data.classes[item]) {
- if (self.data.classes[item].external) {
- href = self.data.classes[item].path;
- base = self.options.externalData.base;
- className += ' external';
- newWin = true;
- link = true;
- }
- }
- }
-
- if (item.indexOf('/') > -1) {
- //We have a class + method to parse
- var parts = item.split('/'),
- cls = parts[0],
- method = parts[1],
- type = 'method';
-
- if (method.indexOf(':') > -1) {
- parts = method.split(':');
- method = parts[0];
- type = parts[1];
- if (type.indexOf('attr') === 0) {
- type = 'attribute';
- }
- }
-
- if (cls && method) {
- if (self.data.classes[cls]) {
- self.data.classitems.forEach(function (i) {
- if (i.itemtype === type && i.name === method && i.class === cls) {
- link = true;
- baseItem = method;
- var t = type;
- if (t === 'attribute') {
- t = 'attr';
- }
- href = Y.webpath(base, 'classes', cls + '.html#' + t + '_' + method);
- }
- });
- }
- }
-
- }
-
- if (item === 'Object' || item === 'Array') {
- link = false;
- }
- if (!href) {
- href = Y.webpath(base, 'classes', item + '.html');
- if (base.match(/^https?:\/\//)) {
- href = base + Y.webpath('classes', item + '.html');
- }
- }
- if (!link && self.options.linkNatives) {
- if (self.NATIVES && self.NATIVES[item]) {
- href = self.NATIVES_LINKER(item);
- if (href) {
- className += ' external';
- newWin = true;
- link = true;
- }
- }
- }
- if (link) {
- if (content !== undefined) {
- content = content.trim();
- }
- if (!content) {
- content = baseItem;
- }
- item = '' + content + '';
- }
- return (raw) ? href : item;
- },
- /**
- * List of native types to cross link to MDN
- * @property NATIVES
- * @type Object
- */
- NATIVES: {
- 'Array': 1,
- 'Boolean': 1,
- 'Date': 1,
- 'decodeURI': 1,
- 'decodeURIComponent': 1,
- 'encodeURI': 1,
- 'encodeURIComponent': 1,
- 'eval': 1,
- 'Error': 1,
- 'EvalError': 1,
- 'Function': 1,
- 'Infinity': 1,
- 'isFinite': 1,
- 'isNaN': 1,
- 'Math': 1,
- 'NaN': 1,
- 'Number': 1,
- 'Object': 1,
- 'parseFloat': 1,
- 'parseInt': 1,
- 'RangeError': 1,
- 'ReferenceError': 1,
- 'RegExp': 1,
- 'String': 1,
- 'SyntaxError': 1,
- 'TypeError': 1,
- 'undefined': 1,
- 'URIError': 1,
- 'HTMLElement': 'https:/' + '/developer.mozilla.org/en/Document_Object_Model_(DOM)/',
- 'HTMLCollection': 'https:/' + '/developer.mozilla.org/en/Document_Object_Model_(DOM)/',
- 'DocumentFragment': 'https:/' + '/developer.mozilla.org/en/Document_Object_Model_(DOM)/',
- 'HTMLDocument': 'https:/' + '/developer.mozilla.org/en/Document_Object_Model_(DOM)/'
- },
- /**
- * Function to link an external type uses `NATIVES` object
- * @method NATIVES_LINKER
- * @private
- * @param {String} name The name of the type to link
- * @return {String} The combined URL
- */
- NATIVES_LINKER: function (name) {
- var url = 'https:/' + '/developer.mozilla.org/en/JavaScript/Reference/Global_Objects/';
- if (this.NATIVES[name] !== 1) {
- url = this.NATIVES[name];
- }
- return url + name;
- },
- /**
- * Mixes the various external data soures together into the local data, augmenting
- * it with flags.
- * @method _mixExternal
- * @private
- */
- _mixExternal: function () {
- var self = this;
- Y.log('External data received, mixing', 'info', 'builder');
- self.options.externalData.forEach(function (exData) {
-
- ['files', 'classes', 'modules'].forEach(function (k) {
- Y.each(exData[k], function (item, key) {
- item.external = true;
- var file = item.name;
- if (!item.file) {
- file = self.filterFileName(item.name);
- }
-
- if (item.type) {
- item.type = fixType(item.type);
- }
-
- item.path = exData.base + path.join(k, file + '.html');
-
- self.data[k][key] = item;
- });
- });
- Y.each(exData.classitems, function (item) {
- item.external = true;
- item.path = exData.base + path.join('files', self.filterFileName(item.file) + '.html');
- if (item.type) {
- item.type = fixType(item.type);
- }
- if (item.params) {
- item.params.forEach(function (p) {
- if (p.type) {
- p.type = fixType(p.type);
- }
- });
- }
- if (item["return"]) {
- item["return"].type = fixType(item["return"].type);
- }
- self.data.classitems.push(item);
- });
- });
- },
- /**
- * Fetches the remote data and fires the callback when it's all complete
- * @method mixExternal
- * @param {Callback} cb The callback to execute when complete
- * @async
- */
- mixExternal: function (cb) {
- var self = this,
- info = self.options.external;
-
- if (!info) {
- cb();
- return;
- }
- if (!info.merge) {
- info.merge = 'mix';
- }
- if (!info.data) {
- Y.log('External config found but no data path defined, skipping import.', 'warn', 'builder');
- cb();
- return;
- }
- if (!Y.Lang.isArray(info.data)) {
- info.data = [info.data];
- }
- Y.log('Importing external documentation data.', 'info', 'builder');
-
- var stack = new Y.Parallel();
- info.data.forEach(function (i) {
- var base;
- if (i.match(/^https?:\/\//)) {
- base = i.replace('data.json', '');
- Y.use('io-base', stack.add(function () {
- Y.log('Fetching: ' + i, 'info', 'builder');
- Y.io(i, {
- on: {
- complete: stack.add(function (id, e) {
- Y.log('Received: ' + i, 'info', 'builder');
- var data = JSON.parse(e.responseText);
- data.base = base;
- //self.options.externalData = Y.mix(self.options.externalData || {}, data);
- if (!self.options.externalData) {
- self.options.externalData = [];
- }
- self.options.externalData.push(data);
- })
- }
- });
- }));
- } else {
- base = path.dirname(path.resolve(i));
- var data = Y.Files.getJSON(i);
- data.base = base;
- //self.options.externalData = Y.mix(self.options.externalData || {}, data);
- if (!self.options.externalData) {
- self.options.externalData = [];
- }
- self.options.externalData.push(data);
- }
- });
-
- stack.done(function () {
- Y.log('Finished fetching remote data', 'info', 'builder');
- self._mixExternal();
- cb();
- });
- },
- /**
- * File counter
- * @property files
- * @type Number
- */
- files: null,
- /**
- * Holder for project meta data
- * @property _meta
- * @type Object
- * @private
- */
- _meta: null,
- /**
- * Prep the meta data to be fed to Selleck
- * @method getProjectMeta
- * @return {Object} The project metadata
- */
- getProjectMeta: function () {
- var obj = {
- meta: {
- yuiSeedUrl: 'http://yui.yahooapis.com/3.5.0/build/yui/yui-min.js',
- yuiGridsUrl: 'http://yui.yahooapis.com/3.5.0/build/cssgrids/cssgrids-min.css'
- }
- };
- if (!this._meta) {
- try {
- var meta,
- theme = path.join(themeDir, 'theme.json');
- if (Y.Files.exists(theme)) {
- Y.log('Loading theme from ' + theme, 'info', 'builder');
- meta = Y.Files.getJSON(theme);
- } else if (DEFAULT_THEME !== themeDir) {
- theme = path.join(DEFAULT_THEME, 'theme.json');
- if (Y.Files.exists(theme)) {
- Y.log('Loading theme from ' + theme, 'info', 'builder');
- meta = Y.Files.getJSON(theme);
- }
- }
-
- if (meta) {
- obj.meta = meta;
- this._meta = meta;
- }
- } catch (e) {
- console.error('Error', e);
- }
- } else {
- obj.meta = this._meta;
- }
- Y.each(this.data.project, function (v, k) {
- var key = k.substring(0, 1).toUpperCase() + k.substring(1, k.length);
- obj.meta['project' + key] = v;
- });
- return obj;
- },
- /**
- * Populate the meta data for classes
- * @method populateClasses
- * @param {Object} opts The original options
- * @return {Object} The modified options
- */
- populateClasses: function (opts) {
- opts.meta.classes = [];
- Y.each(this.data.classes, function (v) {
- if (v.external) {
- return;
- }
- opts.meta.classes.push({
- displayName: v.name,
- name: v.name,
- namespace: v.namespace,
- module: v.module,
- description: v.description,
- access: v.access || 'public'
- });
- });
- opts.meta.classes.sort(this.nameSort);
- return opts;
- },
- /**
- * Populate the meta data for modules
- * @method populateModules
- * @param {Object} opts The original options
- * @return {Object} The modified options
- */
- populateModules: function (opts) {
- var self = this;
- opts.meta.modules = [];
- opts.meta.allModules = [];
- Y.each(this.data.modules, function (v) {
- if (v.external) {
- return;
- }
- opts.meta.allModules.push({
- displayName: v.displayName || v.name,
- name: self.filterFileName(v.name),
- description: v.description
- });
- if (!v.is_submodule) {
- var o = {
- displayName: v.displayName || v.name,
- name: self.filterFileName(v.name)
- };
- if (v.submodules) {
- o.submodules = [];
- Y.each(v.submodules, function (i, k) {
- var moddef = self.data.modules[k];
- if (moddef) {
- o.submodules.push({
- displayName: k,
- description: moddef.description
- });
- // } else {
- // Y.log('Submodule data missing: ' + k + ' for ' + v.name, 'warn', 'builder');
- }
- });
- o.submodules.sort(self.nameSort);
- }
- opts.meta.modules.push(o);
- }
- });
- opts.meta.modules.sort(this.nameSort);
- opts.meta.allModules.sort(this.nameSort);
- return opts;
- },
- /**
- * Populate the meta data for files
- * @method populateFiles
- * @param {Object} opts The original options
- * @return {Object} The modified options
- */
- populateFiles: function (opts) {
- var self = this;
- opts.meta.files = [];
- Y.each(this.data.files, function (v) {
- if (v.external) {
- return;
- }
- opts.meta.files.push({
- displayName: v.name,
- name: self.filterFileName(v.name),
- path: v.path || v.name
- });
- });
-
- var tree = {};
- var files = [];
- Y.each(this.data.files, function (v) {
- if (v.external) {
- return;
- }
- files.push(v.name);
- });
- files.sort();
- Y.each(files, function (v) {
- var p = v.split('/'),
- par;
- p.forEach(function (i, k) {
- if (!par) {
- if (!tree[i]) {
- tree[i] = {};
- }
- par = tree[i];
- } else {
- if (!par[i]) {
- par[i] = {};
- }
- if (k + 1 === p.length) {
- par[i] = {
- path: v,
- name: self.filterFileName(v)
- };
- }
- par = par[i];
- }
- });
- });
-
- opts.meta.fileTree = tree;
-
- return opts;
- },
- /**
- * Parses file and line number from an item object and build's an HREF
- * @method addFoundAt
- * @param {Object} a The item to parse
- * @return {String} The parsed HREF
- */
- addFoundAt: function (a) {
- var self = this;
- if (a.file && a.line && !self.options.nocode) {
- a.foundAt = '../files/' + self.filterFileName(a.file) + '.html#l' + a.line;
- if (a.path) {
- a.foundAt = a.path + '#l' + a.line;
- }
- }
- return a;
- },
- /**
- * Augments the **DocParser** meta data to provide default values for certain keys as well as parses all descriptions
- * with the `Markdown Parser`
- * @method augmentData
- * @param {Object} o The object to recurse and augment
- * @return {Object} The augmented object
- */
- augmentData: function (o) {
- var self = this;
- o = self.addFoundAt(o);
- Y.each(o, function (i, k1) {
- if (i && i.forEach) {
- Y.each(i, function (a, k) {
- if (!(a instanceof Object)) {
- return;
- }
- if (!a.type) {
- a.type = 'Object'; //Default type is Object
- }
- if (a.final === '') {
- a.final = true;
- }
- if (!a.description) {
- a.description = ' ';
- } else {
- //a.description = markdown(a.description, true, self.defaultTags);
- a.description = self.markdown(a.description);
- }
- if (a.example) {
- a.example = self.markdown(a.example);
- }
- a = self.addFoundAt(a);
-
- Y.each(a, function (c, d) {
- if (c.forEach || (c instanceof Object)) {
- c = self.augmentData(c);
- a[d] = c;
- }
- });
-
- o[k1][k] = a;
- });
- } else if (i instanceof Object) {
- i = self.addFoundAt(i);
- Y.each(i, function (v, k) {
- if (k === 'final') {
- o[k1][k] = true;
- }
- if (k === 'description' || k === 'example') {
- if (k1 === 'return') {
- o[k1][k] = self.markdown(v);
- } else if (v.forEach || (v instanceof Object)) {
- o[k1][k] = self.augmentData(v);
- } else {
- //o[k1][k] = markdown(v, true, self.defaultTags);
- o[k1][k] = self.markdown(v);
- }
- }
- });
- } else if (k1 === 'description' || k1 === 'example') {
- //o[k1] = markdown(i, true, self.defaultTags);
- o[k1] = self.markdown(i);
- }
- });
- return o;
- },
- /**
- * Makes the default directories needed
- * @method makeDirs
- * @param {Callback} cb The callback to execute after it's completed
- */
- makeDirs: function (cb) {
- var self = this;
- var dirs = ['classes', 'modules', 'files'];
- if (self.options.dumpview) {
- dirs.push('json');
- }
- var writeRedirect = function (dir, file, cb) {
- Y.Files.exists(file, function (x) {
- if (x) {
- var out = path.join(dir, 'index.html');
- fs.createReadStream(file).pipe(fs.createWriteStream(out));
- }
- cb();
- });
- };
- var defaultIndex = path.join(themeDir, 'assets', 'index.html');
- var stack = new Y.Parallel();
- Y.log('Making default directories: ' + dirs.join(','), 'info', 'builder');
- dirs.forEach(function (d) {
- var dir = path.join(self.options.outdir, d);
- Y.Files.exists(dir, stack.add(function (x) {
- if (!x) {
- fs.mkdir(dir, 0777, stack.add(function () {
- writeRedirect(dir, defaultIndex, stack.add(noop));
- }));
- } else {
- writeRedirect(dir, defaultIndex, stack.add(noop));
- }
- }));
- });
- stack.done(function () {
- if (cb) {
- cb();
- }
- });
- },
-
-
- _resolveUrl: function (url, opts) {
- if (!url) {
- return null;
- }
- if (url.indexOf("://") >= 0) {
- return url;
- }
- return path.join(opts.meta.projectRoot, url);
- },
-
- /**
- * Parses `
` tags and adds the __prettyprint__ `className` to them
- * @method _parseCode
- * @private
- * @param {HTML} html The HTML to parse
- * @return {HTML} The parsed HTML
- */
- _parseCode: function (html) {
- html = html || '';
- //html = html.replace(/
/g, '
');
- html = html.replace(/
' + Y.escapeHTML(code) + '';
- });
-
- html = html.replace(/__\{\{SELLECK_BACKTICK\}\}__/g, '`');
-
- return html;
- },
- /**
- * Ported from [Selleck](https://github.com/rgrove/selleck)
- Renders the handlebars templates with the default View class.
- * @method render
- * @param {HTML} source The default template to parse
- * @param {Class} view The default view handler
- * @param {HTML} [layout=null] The HTML from the layout to use.
- * @param {Object} [partials=object] List of partials to include in this template
- * @param {Callback} callback
- * @param {Error} callback.err
- * @param {HTML} callback.html The assembled template markup
- */
- render: function (source, view, layout, partials, callback) {
- var html = [];
-
- // function buffer(line) {
- // html.push(line);
- // }
-
- // Allow callback as third or fourth param.
- if (typeof partials === 'function') {
- callback = partials;
- partials = {};
- } else if (typeof layout === 'function') {
- callback = layout;
- layout = null;
- }
- var parts = Y.merge(partials || {}, {
- layout_content: source
- });
- Y.each(parts, function (source, name) {
- Y.Handlebars.registerPartial(name, source);
- });
-
- if (!TEMPLATE || !this.cacheTemplates) {
- TEMPLATE = Y.Handlebars.compile(layout);
- }
-
-
- var _v = {};
- for (var k in view) {
- if (Y.Lang.isFunction(view[k])) {
- _v[k] = view[k]();
- } else {
- _v[k] = view[k];
- }
- }
- html = TEMPLATE(_v);
- //html = html.replace(/{{//g, '{{/');
-
-
- //html = (Y.Handlebars.compile(html))({});
-
- html = this._inlineCode(html);
- callback(null, html);
- },
- /**
- * Render the index file
- * @method renderIndex
- * @param {Function} cb The callback fired when complete
- * @param {String} cb.html The HTML to render this view
- * @param {Object} cv.view The View Data
- */
- renderIndex: function (cb) {
- var self = this;
-
- Y.prepare([DEFAULT_THEME, themeDir], self.getProjectMeta(), function (err, opts) {
- opts.meta.title = self.data.project.name;
- opts.meta.projectRoot = './';
- opts.meta.projectAssets = './assets';
- opts.meta.projectLogo = self._resolveUrl(self.data.project.logo, opts);
- opts = self.populateClasses(opts);
- opts = self.populateModules(opts);
-
- var view = new Y.DocView(opts.meta);
- self.render('{{>index}}', view, opts.layouts.main, opts.partials, function (err, html) {
- self.files++;
- cb(html, view);
- });
- });
- },
- /**
- * Generates the index.html file
- * @method writeIndex
- * @param {Callback} cb The callback to execute after it's completed
- */
- writeIndex: function (cb) {
- var self = this,
- stack = new Y.Parallel();
-
- Y.log('Preparing index.html', 'info', 'builder');
- self.renderIndex(stack.add(function (html, view) {
- stack.html = html;
- stack.view = view;
- if (self.options.dumpview) {
- Y.Files.writeFile(path.join(self.options.outdir, 'json', 'index.json'), JSON.stringify(view), stack.add(noop));
- }
- Y.Files.writeFile(path.join(self.options.outdir, 'index.html'), html, stack.add(noop));
- }));
-
- stack.done(function ( /* html, view */ ) {
- Y.log('Writing index.html', 'info', 'builder');
- cb(stack.html, stack.view);
- });
- },
- /**
- * Render a module
- * @method renderModule
- * @param {Function} cb The callback fired when complete
- * @param {String} cb.html The HTML to render this view
- * @param {Object} cv.view The View Data
- */
- renderModule: function (cb, data, layout) {
- var self = this;
- var stack = new Y.Parallel();
-
- data.displayName = data.name;
- data.name = self.filterFileName(data.name);
- Y.prepare([DEFAULT_THEME, themeDir], self.getProjectMeta(), function (err, opts) {
- opts.meta = Y.merge(opts.meta, data);
-
- //opts.meta.htmlTitle = v.name + ': ' + self.data.project.name;
- opts.meta.title = self.data.project.name;
-
- opts.meta.moduleName = data.displayName || data.name;
- opts.meta.moduleDescription = self._parseCode(self.markdown(data.description || ' '));
- opts.meta.file = data.file;
- opts.meta.line = data.line;
- opts.meta = self.addFoundAt(opts.meta);
- opts.meta.projectRoot = '../';
- opts.meta.projectAssets = '../assets';
- opts.meta.projectLogo = self._resolveUrl(self.data.project.logo, opts);
- opts = self.populateClasses(opts);
- opts = self.populateModules(opts);
- opts = self.populateFiles(opts);
-
- if (data.classes && Object.keys(data.classes).length) {
- opts.meta.moduleClasses = [];
- Y.each(Object.keys(data.classes), function (name) {
- var i = self.data.classes[name];
- if (i) {
- opts.meta.moduleClasses.push({
- name: i.name,
- displayName: i.name
- });
- }
- });
- opts.meta.moduleClasses.sort(self.nameSort);
- }
- if (data.example && data.example.length) {
- if (data.example.forEach) {
- var e = '';
- data.example.forEach(function (v) {
- e += self._parseCode(self.markdown(v));
- });
- data.example = e;
- } else {
- data.example = self._parseCode(self.markdown(data.example));
- }
- opts.meta.example = data.example;
- }
- if (data.submodules && Object.keys(data.submodules).length) {
- opts.meta.subModules = [];
- Y.each(Object.keys(data.submodules), function (name) {
- var i = self.data.modules[name];
- if (i) {
- opts.meta.subModules.push({
- name: i.name,
- displayName: i.name,
- description: i.description
- });
- }
- });
- opts.meta.subModules.sort(self.nameSort);
- }
-
- var view = new Y.DocView(opts.meta);
- var mainLayout = opts.layouts[layout];
- self.render('{{>module}}', view, mainLayout, opts.partials, stack.add(function (err, html) {
- self.files++;
- stack.html = html;
- stack.view = view;
- }));
- });
-
- stack.done(function () {
- cb(stack.html, stack.view);
- });
- },
- /**
- * Generates the module files under "out"/modules/
- * @method writeModules
- * @param {Callback} cb The callback to execute after it's completed
- */
- writeModules: function (cb, layout) {
- layout = layout || 'main';
- var self = this,
- stack = new Y.Parallel();
- stack.html = [];
- stack.view = [];
-
- var counter = 0;
- Object.keys(self.data.modules).forEach(function (k) {
- if (!self.data.modules[k].external) {
- counter++;
- }
- });
- Y.log('Rendering and writing ' + counter + ' modules pages.', 'info', 'builder');
- Y.each(self.data.modules, function (v) {
- if (v.external) {
- return;
- }
- self.renderModule(function (html, view) {
- stack.html.push(html);
- stack.view.push(view);
- if (self.options.dumpview) {
- Y.Files.writeFile(
- path.join(self.options.outdir, 'json', 'module_' + v.name + '.json'),
- JSON.stringify(view),
- stack.add(noop)
- );
- }
- Y.Files.writeFile(path.join(self.options.outdir, 'modules', v.name + '.html'), html, stack.add(noop));
- }, v, layout);
- });
- stack.done(function () {
- Y.log('Finished writing module files', 'info', 'builder');
- cb(stack.html, stack.view);
- });
- },
- /**
- * Checks an array of items (class items) to see if an item is in that list
- * @method hasProperty
- * @param {Array} a The Array of items to check
- * @param {Object} b The object to find
- * @return Boolean
- */
- hasProperty: function (a, b) {
- var other = false;
- Y.some(a, function (i, k) {
- if ((i.itemtype === b.itemtype) && (i.name === b.name)) {
- other = k;
- return true;
- }
- });
- return other;
- },
- /**
- * Counter for stepping into merges
- * @private
- * @property _mergeCounter
- * @type Number
- */
- _mergeCounter: null,
- /**
- * Merge superclass data into a child class
- * @method mergeExtends
- * @param {Object} info The item to extend
- * @param {Array} classItems The list of items to merge in
- * @param {Boolean} first Set for the first call
- */
- mergeExtends: function (info, classItems, first) {
- var self = this;
- self._mergeCounter = (first) ? 0 : (self._mergeCounter + 1);
-
- if (self._mergeCounter === 100) {
- throw ('YUIDoc detected a loop extending class ' + info.name);
- }
- if (info.extends || info.uses) {
- var hasItems = {};
- hasItems[info.extends] = 1;
- if (info.uses) {
- info.uses.forEach(function (v) {
- hasItems[v] = 1;
- });
- }
- self.data.classitems.forEach(function (v) {
- //console.error(v.class, '==', info.extends);
- if (hasItems[v.class]) {
- if (!v.static) {
- var q,
- override = self.hasProperty(classItems, v);
- if (override === false) {
- //This method was extended from the parent class but not over written
- //console.error('Merging extends from', v.class, 'onto', info.name);
- q = Y.merge({}, v);
- q.extended_from = v.class;
- classItems.push(q);
- } else {
- //This method was extended from the parent and overwritten in this class
- q = Y.merge({}, v);
- q = self.augmentData(q);
- classItems[override].overwritten_from = q;
- }
- }
- }
- });
- if (self.data.classes[info.extends]) {
- if (self.data.classes[info.extends].extends || self.data.classes[info.extends].uses) {
- //console.error('Stepping down to:', self.data.classes[info.extends]);
- classItems = self.mergeExtends(self.data.classes[info.extends], classItems);
- }
- }
- }
- return classItems;
- },
- /**
- * Render the class file
- * @method renderClass
- * @param {Function} cb The callback fired when complete
- * @param {String} cb.html The HTML to render this view
- * @param {Object} cv.view The View Data
- */
- renderClass: function (cb, data, layout) {
- var self = this;
- var stack = new Y.Parallel();
-
- Y.prepare([DEFAULT_THEME, themeDir], self.getProjectMeta(), function (err, opts) {
- //console.log(opts);
- if (err) {
- console.log(err);
- }
- opts.meta = Y.merge(opts.meta, data);
-
- opts.meta.title = self.data.project.name;
- opts.meta.moduleName = data.name;
- opts.meta.file = data.file;
- opts.meta.line = data.line;
- opts.meta = self.addFoundAt(opts.meta);
- opts.meta.projectRoot = '../';
- opts.meta.projectAssets = '../assets';
- opts.meta.projectLogo = self._resolveUrl(self.data.project.logo, opts);
-
- opts = self.populateClasses(opts);
- opts = self.populateModules(opts);
- opts = self.populateFiles(opts);
-
- opts.meta.classDescription = self._parseCode(self.markdown(data.description || ' '));
-
- opts.meta.methods = [];
- opts.meta.properties = [];
- opts.meta.attrs = [];
- opts.meta.events = [];
- opts.meta.extension_for = null;
- if (data.uses) {
- opts.meta.uses = data.uses;
- }
- if (data.entension_for && data.extension_for.length) {
- opts.meta.extension_for = data.extension_for;
- }
-
- if (data.extends) {
- opts.meta.extends = data.extends;
- }
-
- var classItems = [];
- self.data.classitems.forEach(function (i) {
- if (i.class === data.name) {
- classItems.push(i);
- }
- });
-
- classItems = self.mergeExtends(data, classItems, true);
-
- if (data.is_constructor) {
- var i = Y.mix({}, data);
- i = self.augmentData(i);
- i.paramsList = [];
- if (i.params) {
- i.params.forEach(function (p) {
- var name = p.name;
- if (p.optional) {
- name = '[' + name + ((p.optdefault) ? '=' + p.optdefault : '') + ']';
- }
- i.paramsList.push(name);
- });
- }
- //i.methodDescription = self._parseCode(markdown(i.description));
- i.hasAccessType = i.access;
- i.hasParams = i.paramsList.length;
- if (i.paramsList.length) {
- i.paramsList = i.paramsList.join(', ');
- } else {
- i.paramsList = ' ';
- }
- i.returnType = ' ';
- if (i["return"]) {
- i.hasReturn = true;
- i.returnType = i["return"].type;
- }
- //console.error(i);
- opts.meta.is_constructor = [i];
- if (i.example && i.example.length) {
- if (i.example.forEach) {
- var e = '';
- i.example.forEach(function (v) {
- e += self._parseCode(self.markdown(v));
- });
- i.example = e;
- } else {
- i.example = self._parseCode(self.markdown(i.example));
- }
- }
- }
-
- classItems.forEach(function (i) {
- var e;
- switch (i.itemtype) {
- case 'method':
- i = self.augmentData(i);
- i.paramsList = [];
- if (i.params && i.params.forEach) {
- i.params.forEach(function (p) {
- var name = p.name;
- if (p.optional) {
- name = '[' + name + ((p.optdefault) ? '=' + p.optdefault : '') + ']';
- }
- i.paramsList.push(name);
- });
- }
- //i.methodDescription = self._parseCode(markdown(i.description || ''));
- i.methodDescription = self._parseCode(i.description);
- if (i.example && i.example.length) {
- if (i.example.forEach) {
- e = '';
- i.example.forEach(function (v) {
- e += self._parseCode(self.markdown(v));
- });
- i.example = e;
- } else {
- i.example = self._parseCode(self.markdown(i.example));
- }
- }
- i.hasAccessType = i.access;
- i.hasParams = i.paramsList.length;
- if (i.paramsList.length) {
- i.paramsList = i.paramsList.join(', ');
- } else {
- i.paramsList = ' ';
- }
- i.returnType = ' ';
- if (i["return"]) {
- i.hasReturn = true;
- i.returnType = i["return"].type;
- }
-
- // If this item is provided by a module other
- // than the module that provided the original
- // class, add the original module name to the
- // item's `providedBy` property so we can
- // indicate the relationship.
- if ((i.submodule || i.module) !== (data.submodule || data.module)) {
- i.providedBy = (i.submodule || i.module);
- }
-
- opts.meta.methods.push(i);
- break;
- case 'property':
- i = self.augmentData(i);
- //i.propertyDescription = self._parseCode(markdown(i.description || ''));
- i.propertyDescription = self._parseCode(i.description);
- if (!i.type) {
- i.type = 'unknown';
- }
- if (i.final === '') {
- i.final = true;
- }
- if (i.readonly === '') {
- i.readonly = true;
- }
- if (i.example && i.example.length) {
- if (i.example.forEach) {
- e = '';
- i.example.forEach(function (v) {
- e += self._parseCode(self.markdown(v));
- });
- i.example = e;
- } else {
- i.example = self._parseCode(self.markdown(i.example));
- }
- }
-
- // If this item is provided by a module other
- // than the module that provided the original
- // class, add the original module name to the
- // item's `providedBy` property so we can
- // indicate the relationship.
- if ((i.submodule || i.module) !== (data.submodule || data.module)) {
- i.providedBy = (i.submodule || i.module);
- }
-
- opts.meta.properties.push(i);
- break;
-
- case 'attribute': // fallthru
- case 'config':
- i = self.augmentData(i);
- //i.attrDescription = self._parseCode(markdown(i.description || ''));
- i.attrDescription = self._parseCode(i.description);
-
- if (i.itemtype === 'config') {
- i.config = true;
- } else {
- i.emit = self.options.attributesEmit;
- }
- if (i.readonly === '') {
- i.readonly = true;
- }
-
- if (i.example && i.example.length) {
- if (i.example.forEach) {
- e = '';
- i.example.forEach(function (v) {
- e += self._parseCode(self.markdown(v));
- });
- i.example = e;
- } else {
- i.example = self._parseCode(self.markdown(i.example));
- }
- }
-
- // If this item is provided by a module other
- // than the module that provided the original
- // class, add the original module name to the
- // item's `providedBy` property so we can
- // indicate the relationship.
- if ((i.submodule || i.module) !== (data.submodule || data.module)) {
- i.providedBy = (i.submodule || i.module);
- }
-
- opts.meta.attrs.push(i);
- break;
- case 'event':
- i = self.augmentData(i);
- //i.eventDescription = self._parseCode(markdown(i.description || ''));
- i.eventDescription = self._parseCode(i.description);
-
- if (i.example && i.example.length) {
- if (i.example.forEach) {
- e = '';
- i.example.forEach(function (v) {
- e += self._parseCode(self.markdown(v));
- });
- i.example = e;
- } else {
- i.example = self._parseCode(self.markdown(i.example));
- }
- }
-
- // If this item is provided by a module other
- // than the module that provided the original
- // class, add the original module name to the
- // item's `providedBy` property so we can
- // indicate the relationship.
- if ((i.submodule || i.module) !== (data.submodule || data.module)) {
- i.providedBy = (i.submodule || i.module);
- }
-
- opts.meta.events.push(i);
- break;
- }
- });
-
- opts.meta.attrs.sort(self.nameSort);
- opts.meta.events.sort(self.nameSort);
- opts.meta.methods.sort(self.nameSort);
- opts.meta.properties.sort(self.nameSort);
-
- if (!opts.meta.methods.length) {
- delete opts.meta.methods;
- }
- if (!opts.meta.properties.length) {
- delete opts.meta.properties;
- }
- if (!opts.meta.attrs.length) {
- delete opts.meta.attrs;
- }
- if (!opts.meta.events.length) {
- delete opts.meta.events;
- }
-
- var view = new Y.DocView(opts.meta);
- var mainLayout = opts.layouts[layout];
- self.render('{{>classes}}', view, mainLayout, opts.partials, stack.add(function (err, html) {
- self.files++;
- stack.html = html;
- stack.view = view;
- stack.opts = opts;
- }));
- });
-
- stack.done(function () {
- cb(stack.html, stack.view, stack.opts);
- });
- },
- /**
- * Generates the class files under "out"/classes/
- * @method writeClasses
- * @param {Callback} cb The callback to execute after it's completed
- */
- writeClasses: function (cb, layout) {
- layout = layout || 'main';
- var self = this,
- stack = new Y.Parallel();
- stack.html = [];
- stack.view = [];
-
- var counter = 0;
- Object.keys(self.data.classes).forEach(function (k) {
- if (!self.data.classes[k].external) {
- counter++;
- }
- });
- Y.log('Rendering and writing ' + counter + ' class pages.', 'info', 'builder');
- Y.each(self.data.classes, function (v) {
- if (v.external) {
- return;
- }
- self.renderClass(stack.add(function (html, view) {
- stack.html.push(html);
- stack.view.push(view);
- if (self.options.dumpview) {
- Y.Files.writeFile(
- path.join(self.options.outdir, 'json', 'classes_' + v.name + '.json'),
- JSON.stringify(view),
- stack.add(noop)
- );
- }
- Y.Files.writeFile(path.join(self.options.outdir, 'classes', v.name + '.html'), html, stack.add(noop));
- }), v, layout);
- });
- stack.done(function () {
- Y.log('Finished writing class files', 'info', 'builder');
- cb(stack.html, stack.view);
- });
- },
- /**
- * Sort method of array of objects with a property called __name__
- * @method nameSort
- * @param {Object} a First object to compare
- * @param {Object} b Second object to compare
- * @return {Number} 1, -1 or 0 for sorting.
- */
- nameSort: function (a, b) {
- if (!a.name || !b.name) {
- return 0;
- }
- var an = a.name.toLowerCase(),
- bn = b.name.toLowerCase(),
- ret = 0;
-
- if (an < bn) {
- ret = -1;
- }
- if (an > bn) {
- ret = 1;
- }
- return ret;
- },
- /**
- * Generates the syntax files under `"out"/files/`
- * @method writeFiles
- * @param {Callback} cb The callback to execute after it's completed
- */
- writeFiles: function (cb, layout) {
- layout = layout || 'main';
- var self = this,
- stack = new Y.Parallel();
- stack.html = [];
- stack.view = [];
-
- var counter = 0;
- Object.keys(self.data.files).forEach(function (k) {
- if (!self.data.files[k].external) {
- counter++;
- }
- });
- Y.log('Rendering and writing ' + counter + ' source files.', 'info', 'builder');
- Y.each(self.data.files, function (v) {
- if (v.external) {
- return;
- }
- self.renderFile(stack.add(function (html, view, data) {
- if (!view || !data) {
- return;
- }
- stack.html.push(html);
- stack.view.push(view);
- if (self.options.dumpview) {
- Y.Files.writeFile(
- path.join(self.options.outdir, 'json', 'files_' + self.filterFileName(data.name) + '.json'),
- JSON.stringify(view),
- stack.add(noop)
- );
- }
- Y.Files.writeFile(
- path.join(self.options.outdir, 'files', self.filterFileName(data.name) + '.html'),
- html,
- stack.add(noop)
- );
- }), v, layout);
- });
- stack.done(function () {
- Y.log('Finished writing source files', 'info', 'builder');
- cb(stack.html, stack.view);
- });
- },
- /**
- * Render the source file
- * @method renderFile
- * @param {Function} cb The callback fired when complete
- * @param {String} cb.html The HTML to render this view
- * @param {Object} cv.view The View Data
- */
- renderFile: function (cb, data, layout) {
- var self = this;
-
- Y.prepare([DEFAULT_THEME, themeDir], self.getProjectMeta(), function (err, opts) {
- if (err) {
- console.log(err);
- }
- if (!data.name) {
- return;
- }
-
- opts.meta = Y.merge(opts.meta, data);
-
- opts.meta.title = self.data.project.name;
- opts.meta.moduleName = data.name;
- opts.meta.projectRoot = '../';
- opts.meta.projectAssets = '../assets';
- opts.meta.projectLogo = self._resolveUrl(self.data.project.logo, opts);
-
- opts = self.populateClasses(opts);
- opts = self.populateModules(opts);
- opts = self.populateFiles(opts);
-
- opts.meta.fileName = data.name;
- fs.readFile(opts.meta.fileName, Y.charset, Y.rbind(function (err, str, opts, data) {
- if (err) {
- Y.log(err, 'error', 'builder');
- cb(err);
- return;
- }
-
- if (typeof self.options.tabspace === 'string') {
- str = str.replace(/\t/g, self.options.tabspace);
- }
-
- opts.meta.fileData = str;
- var view = new Y.DocView(opts.meta, 'index');
- var mainLayout = opts.layouts[layout];
- self.render('{{>files}}', view, mainLayout, opts.partials, function (err, html) {
- self.files++;
- cb(html, view, data);
- });
-
- }, this, opts, data));
- });
-
- },
- /**
- * Write the API meta data used for the AutoComplete widget
- * @method writeAPIMeta
- * @param {Callback} cb The callback to execute when complete
- * @async
- */
- writeAPIMeta: function (cb) {
- Y.log('Writing API Meta Data', 'info', 'builder');
- var self = this;
- this.renderAPIMeta(function (js) {
- fs.writeFile(path.join(self.options.outdir, 'api.js'), js, Y.charset, cb);
- });
- },
- /**
- * Render the API meta and return the Javascript
- * @method renderAPIMeta
- * @param {Callback} cb The callback
- * @async
- */
- renderAPIMeta: function (cb) {
-
- var opts = {
- meta: {}
- };
- opts = this.populateClasses(opts);
- opts = this.populateModules(opts);
-
- ['classes', 'modules'].forEach(function (id) {
- opts.meta[id].forEach(function (v, k) {
- opts.meta[id][k] = v.name;
- if (v.submodules) {
- v.submodules.forEach(function (s) {
- opts.meta[id].push(s.displayName);
- });
- }
- });
- opts.meta[id].sort();
- });
-
- var apijs = 'YUI.add("yuidoc-meta", function(Y) {\n' +
- ' Y.YUIDoc = { meta: ' + JSON.stringify(opts.meta, null, 4) + ' };\n' +
- '});';
-
- cb(apijs);
- },
- /**
- * Normalizes a file path to a writable filename:
- *
- * var path = 'lib/file.js';
- * returns 'lib_file.js';
- *
- * @method filterFileName
- * @param {String} f The filename to normalize
- * @return {String} The filtered file path
- */
- filterFileName: function (f) {
- return f.replace(/[\/\\]/g, '_');
- },
- /**
- * Compiles the templates from the meta-data provided by DocParser
- * @method compile
- * @param {Callback} cb The callback to execute after it's completed
- */
- compile: function (cb) {
- var self = this;
- var starttime = (new Date()).getTime();
- Y.log('Compiling Templates', 'info', 'builder');
-
- this.mixExternal(function () {
- self.makeDirs(function () {
- Y.log('Copying Assets', 'info', 'builder');
- if (!Y.Files.isDirectory(path.join(self.options.outdir, 'assets'))) {
- fs.mkdirSync(path.join(self.options.outdir, 'assets'), 0777);
- }
- Y.Files.copyAssets([
- path.join(DEFAULT_THEME, 'assets'),
- path.join(themeDir, 'assets')
- ],
- path.join(self.options.outdir, 'assets'),
- false,
- function () {
- var cstack = new Y.Parallel();
-
- self.writeModules(cstack.add(function () {
- self.writeClasses(cstack.add(function () {
- if (!self.options.nocode) {
- self.writeFiles(cstack.add(noop));
- }
- }));
- }));
- /*
- self.writeModules(cstack.add(noop));
- self.writeClasses(cstack.add(noop));
- if (!self.options.nocode) {
- self.writeFiles(cstack.add(noop));
- }
- */
- self.writeIndex(cstack.add(noop));
- self.writeAPIMeta(cstack.add(noop));
-
- cstack.done(function () {
- var endtime = (new Date()).getTime();
- var timer = ((endtime - starttime) / 1000) + ' seconds';
- Y.log('Finished writing ' + self.files + ' files in ' + timer, 'info', 'builder');
- if (cb) {
- cb();
- }
- });
- });
- });
- });
- }
- };
-});
diff --git a/dist/easeljs-NEXT.js b/dist/easeljs-NEXT.js
new file mode 100644
index 000000000..4c4c20edb
--- /dev/null
+++ b/dist/easeljs-NEXT.js
@@ -0,0 +1,6294 @@
+/**
+ * @license EaselJS
+ * Visit https://createjs.com for documentation, updates and examples.
+ *
+ * Copyright (c) 2017 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.
+ */
+
+(function (exports,tweenjs) {
+ 'use strict';
+
+ var Event =
+ function () {
+ function Event(type, bubbles, cancelable) {
+ if (bubbles === void 0) {
+ bubbles = false;
+ }
+ if (cancelable === void 0) {
+ cancelable = false;
+ }
+ this.type = type;
+ this.target = null;
+ this.currentTarget = null;
+ this.eventPhase = 0;
+ this.bubbles = bubbles;
+ this.cancelable = cancelable;
+ this.timeStamp = new Date().getTime();
+ this.defaultPrevented = false;
+ this.propagationStopped = false;
+ this.immediatePropagationStopped = false;
+ this.removed = false;
+ }
+ var _proto = Event.prototype;
+ _proto.preventDefault = function preventDefault() {
+ this.defaultPrevented = this.cancelable;
+ return this;
+ };
+ _proto.stopPropagation = function stopPropagation() {
+ this.propagationStopped = true;
+ return this;
+ };
+ _proto.stopImmediatePropagation = function stopImmediatePropagation() {
+ this.immediatePropagationStopped = this.propagationStopped = true;
+ return this;
+ };
+ _proto.remove = function remove() {
+ this.removed = true;
+ return this;
+ };
+ _proto.clone = function clone() {
+ var event = new Event(this.type, this.bubbles, this.cancelable);
+ for (var n in this) {
+ if (this.hasOwnProperty(n)) {
+ event[n] = this[n];
+ }
+ }
+ return event;
+ };
+ _proto.set = function set(props) {
+ for (var n in props) {
+ this[n] = props[n];
+ }
+ return this;
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + " (type=" + this.type + ")]";
+ };
+ return Event;
+ }();
+
+ var EventDispatcher =
+ function () {
+ EventDispatcher.initialize = function initialize(target) {
+ var p = EventDispatcher.prototype;
+ target.addEventListener = p.addEventListener;
+ target.on = p.on;
+ target.removeEventListener = target.off = p.removeEventListener;
+ target.removeAllEventListeners = p.removeAllEventListeners;
+ target.hasEventListener = p.hasEventListener;
+ target.dispatchEvent = p.dispatchEvent;
+ target._dispatchEvent = p._dispatchEvent;
+ target.willTrigger = p.willTrigger;
+ };
+ function EventDispatcher() {
+ this._listeners = null;
+ this._captureListeners = null;
+ }
+ var _proto = EventDispatcher.prototype;
+ _proto.addEventListener = function addEventListener(type, listener, useCapture) {
+ if (useCapture === void 0) {
+ useCapture = false;
+ }
+ var listeners;
+ if (useCapture) {
+ listeners = this._captureListeners = this._captureListeners || {};
+ } else {
+ listeners = this._listeners = this._listeners || {};
+ }
+ var arr = listeners[type];
+ if (arr) {
+ this.removeEventListener(type, listener, useCapture);
+ arr = listeners[type];
+ }
+ if (arr) {
+ arr.push(listener);
+ } else {
+ listeners[type] = [listener];
+ }
+ return listener;
+ };
+ _proto.on = function on(type, listener, scope, once, data, useCapture) {
+ if (scope === void 0) {
+ scope = null;
+ }
+ if (once === void 0) {
+ once = false;
+ }
+ if (data === void 0) {
+ data = {};
+ }
+ if (useCapture === void 0) {
+ useCapture = false;
+ }
+ if (listener.handleEvent) {
+ scope = scope || listener;
+ listener = listener.handleEvent;
+ }
+ scope = scope || this;
+ return this.addEventListener(type, function (evt) {
+ listener.call(scope, evt, data);
+ once && evt.remove();
+ }, useCapture);
+ };
+ _proto.removeEventListener = function removeEventListener(type, listener, useCapture) {
+ if (useCapture === void 0) {
+ useCapture = false;
+ }
+ var listeners = useCapture ? this._captureListeners : this._listeners;
+ if (!listeners) {
+ return;
+ }
+ var arr = listeners[type];
+ if (!arr) {
+ return;
+ }
+ var l = arr.length;
+ for (var i = 0; i < l; i++) {
+ if (arr[i] === listener) {
+ if (l === 1) {
+ delete listeners[type];
+ }
+ else {
+ arr.splice(i, 1);
+ }
+ break;
+ }
+ }
+ };
+ _proto.off = function off(type, listener, useCapture) {
+ if (useCapture === void 0) {
+ useCapture = false;
+ }
+ this.removeEventListener(type, listener, useCapture);
+ };
+ _proto.removeAllEventListeners = function removeAllEventListeners(type) {
+ if (type === void 0) {
+ type = null;
+ }
+ if (type) {
+ if (this._listeners) {
+ delete this._listeners[type];
+ }
+ if (this._captureListeners) {
+ delete this._captureListeners[type];
+ }
+ } else {
+ this._listeners = this._captureListeners = null;
+ }
+ };
+ _proto.dispatchEvent = function dispatchEvent(eventObj, bubbles, cancelable) {
+ if (bubbles === void 0) {
+ bubbles = false;
+ }
+ if (cancelable === void 0) {
+ cancelable = false;
+ }
+ if (typeof eventObj === "string") {
+ var listeners = this._listeners;
+ if (!bubbles && (!listeners || !listeners[eventObj])) {
+ return true;
+ }
+ eventObj = new Event(eventObj, bubbles, cancelable);
+ } else if (eventObj.target && eventObj.clone) {
+ eventObj = eventObj.clone();
+ }
+ try {
+ eventObj.target = this;
+ } catch (e) {}
+ if (!eventObj.bubbles || !this.parent) {
+ this._dispatchEvent(eventObj, 2);
+ } else {
+ var top = this;
+ var list = [top];
+ while (top.parent) {
+ list.push(top = top.parent);
+ }
+ var l = list.length;
+ var i;
+ for (i = l - 1; i >= 0 && !eventObj.propagationStopped; i--) {
+ list[i]._dispatchEvent(eventObj, 1 + (i == 0));
+ }
+ for (i = 1; i < l && !eventObj.propagationStopped; i++) {
+ list[i]._dispatchEvent(eventObj, 3);
+ }
+ }
+ return !eventObj.defaultPrevented;
+ };
+ _proto.hasEventListener = function hasEventListener(type) {
+ var listeners = this._listeners,
+ captureListeners = this._captureListeners;
+ return !!(listeners && listeners[type] || captureListeners && captureListeners[type]);
+ };
+ _proto.willTrigger = function willTrigger(type) {
+ var o = this;
+ while (o) {
+ if (o.hasEventListener(type)) {
+ return true;
+ }
+ o = o.parent;
+ }
+ return false;
+ };
+ _proto.toString = function toString() {
+ return "[" + (this.constructor.name + this.name ? " " + this.name : "") + "]";
+ };
+ _proto._dispatchEvent = function _dispatchEvent(eventObj, eventPhase) {
+ var listeners = eventPhase === 1 ? this._captureListeners : this._listeners;
+ if (eventObj && listeners) {
+ var arr = listeners[eventObj.type];
+ var l;
+ if (!arr || (l = arr.length) === 0) {
+ return;
+ }
+ try {
+ eventObj.currentTarget = this;
+ } catch (e) {}
+ try {
+ eventObj.eventPhase = eventPhase;
+ } catch (e) {}
+ eventObj.removed = false;
+ arr = arr.slice();
+ for (var i = 0; i < l && !eventObj.immediatePropagationStopped; i++) {
+ var o = arr[i];
+ if (o.handleEvent) {
+ o.handleEvent(eventObj);
+ } else {
+ o(eventObj);
+ }
+ if (eventObj.removed) {
+ this.off(eventObj.type, o, eventPhase === 1);
+ eventObj.removed = false;
+ }
+ }
+ }
+ };
+ return EventDispatcher;
+ }();
+
+ function _defineProperties(target, props) {
+ for (var i = 0; i < props.length; i++) {
+ var descriptor = props[i];
+ descriptor.enumerable = descriptor.enumerable || false;
+ descriptor.configurable = true;
+ if ("value" in descriptor) descriptor.writable = true;
+ Object.defineProperty(target, descriptor.key, descriptor);
+ }
+ }
+
+ function _createClass(Constructor, protoProps, staticProps) {
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
+ if (staticProps) _defineProperties(Constructor, staticProps);
+ return Constructor;
+ }
+
+ function _inheritsLoose(subClass, superClass) {
+ subClass.prototype = Object.create(superClass.prototype);
+ subClass.prototype.constructor = subClass;
+ subClass.__proto__ = superClass;
+ }
+
+ function _assertThisInitialized(self) {
+ if (self === void 0) {
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
+ }
+
+ return self;
+ }
+
+ var Ticker =
+ function (_EventDispatcher) {
+ _inheritsLoose(Ticker, _EventDispatcher);
+ _createClass(Ticker, null, [{
+ key: "RAF_SYNCHED",
+ get: function get() {
+ return "synched";
+ }
+ }, {
+ key: "RAF",
+ get: function get() {
+ return "raf";
+ }
+ }, {
+ key: "TIMEOUT",
+ get: function get() {
+ return "timeout";
+ }
+ }]);
+ function Ticker(name) {
+ var _this;
+ _this = _EventDispatcher.call(this) || this;
+ _this.name = name;
+ _this.timingMode = Ticker.TIMEOUT;
+ _this.maxDelta = 0;
+ _this.paused = false;
+ _this._inited = false;
+ _this._startTime = 0;
+ _this._pausedTime = 0;
+ _this._ticks = 0;
+ _this._pausedTicks = 0;
+ _this._interval = 50;
+ _this._lastTime = 0;
+ _this._times = null;
+ _this._tickTimes = null;
+ _this._timerId = null;
+ _this._raf = true;
+ return _this;
+ }
+ var _proto = Ticker.prototype;
+ _proto.init = function init() {
+ if (this._inited) {
+ return;
+ }
+ this._inited = true;
+ this._times = [];
+ this._tickTimes = [];
+ this._startTime = this._getTime();
+ this._times.push(this._lastTime = 0);
+ this._setupTick();
+ };
+ _proto.reset = function reset() {
+ if (this._raf) {
+ var f = window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.oCancelAnimationFrame || window.msCancelAnimationFrame;
+ f && f(this._timerId);
+ } else {
+ clearTimeout(this._timerId);
+ }
+ this.removeAllEventListeners("tick");
+ this._timerId = this._times = this._tickTimes = null;
+ this._startTime = this._lastTime = this._ticks = 0;
+ this._inited = false;
+ };
+ _proto.addEventListener = function addEventListener(type, listener, useCapture) {
+ !this._inited && this.init();
+ return _EventDispatcher.prototype.addEventListener.call(this, type, listener, useCapture);
+ };
+ _proto.getMeasuredTickTime = function getMeasuredTickTime(ticks) {
+ if (ticks === void 0) {
+ ticks = null;
+ }
+ var times = this._tickTimes;
+ if (!times || times.length < 1) {
+ return -1;
+ }
+ ticks = Math.min(times.length, ticks || this.framerate | 0);
+ return times.reduce(function (a, b) {
+ return a + b;
+ }, 0) / ticks;
+ };
+ _proto.getMeasuredFPS = function getMeasuredFPS(ticks) {
+ if (ticks === void 0) {
+ ticks = null;
+ }
+ var times = this._times;
+ if (!times || times.length < 2) {
+ return -1;
+ }
+ ticks = Math.min(times.length - 1, ticks || this.framerate | 0);
+ return 1000 / ((times[0] - times[ticks]) / ticks);
+ };
+ _proto.getTime = function getTime(runTime) {
+ if (runTime === void 0) {
+ runTime = false;
+ }
+ return this._startTime ? this._getTime() - (runTime ? this._pausedTime : 0) : -1;
+ };
+ _proto.getEventTime = function getEventTime(runTime) {
+ if (runTime === void 0) {
+ runTime = false;
+ }
+ return this._startTime ? (this._lastTime || this._startTime) - (runTime ? this._pausedTime : 0) : -1;
+ };
+ _proto.getTicks = function getTicks(pauseable) {
+ if (pauseable === void 0) {
+ pauseable = false;
+ }
+ return this._ticks - (pauseable ? this._pausedTicks : 0);
+ };
+ _proto._handleSynch = function _handleSynch() {
+ this._timerId = null;
+ this._setupTick();
+ if (this._getTime() - this._lastTime >= (this._interval - 1) * 0.97) {
+ this._tick();
+ }
+ };
+ _proto._handleRAF = function _handleRAF() {
+ this._timerId = null;
+ this._setupTick();
+ this._tick();
+ };
+ _proto._handleTimeout = function _handleTimeout() {
+ this._timerId = null;
+ this._setupTick();
+ this._tick();
+ };
+ _proto._setupTick = function _setupTick() {
+ if (this._timerId != null) {
+ return;
+ }
+ var mode = this.timingMode || this._raf && Ticker.RAF;
+ if (mode === Ticker.RAF_SYNCHED || mode === Ticker.RAF) {
+ var f = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame;
+ if (f) {
+ this._timerId = f(mode === Ticker.RAF ? this._handleRAF.bind(this) : this._handleSynch.bind(this));
+ this._raf = true;
+ return;
+ }
+ }
+ this._raf = false;
+ this._timerId = setTimeout(this._handleTimeout.bind(this), this._interval);
+ };
+ _proto._tick = function _tick() {
+ var paused = this.paused,
+ time = this._getTime(),
+ elapsedTime = time - this._lastTime;
+ this._lastTime = time;
+ this._ticks++;
+ if (paused) {
+ this._pausedTicks++;
+ this._pausedTime += elapsedTime;
+ }
+ if (this.hasEventListener("tick")) {
+ var event = new Event("tick");
+ var maxDelta = this.maxDelta;
+ event.delta = maxDelta && elapsedTime > maxDelta ? maxDelta : elapsedTime;
+ event.paused = paused;
+ event.time = time;
+ event.runTime = time - this._pausedTime;
+ this.dispatchEvent(event);
+ }
+ this._tickTimes.unshift(this._getTime() - time);
+ while (this._tickTimes.length > 100) {
+ this._tickTimes.pop();
+ }
+ this._times.unshift(time);
+ while (this._times.length > 100) {
+ this._times.pop();
+ }
+ };
+ _proto._getTime = function _getTime() {
+ var now = window.performance && window.performance.now;
+ return (now && now.call(performance) || new Date().getTime()) - this._startTime;
+ };
+ Ticker.on = function on(type, listener, scope, once, data, useCapture) {
+ return _instance.on(type, listener, scope, once, data, useCapture);
+ };
+ Ticker.removeEventListener = function removeEventListener(type, listener, useCapture) {
+ _instance.removeEventListener(type, listener, useCapture);
+ };
+ Ticker.off = function off(type, listener, useCapture) {
+ _instance.off(type, listener, useCapture);
+ };
+ Ticker.removeAllEventListeners = function removeAllEventListeners(type) {
+ _instance.removeAllEventListeners(type);
+ };
+ Ticker.dispatchEvent = function dispatchEvent(eventObj, bubbles, cancelable) {
+ return _instance.dispatchEvent(eventObj, bubbles, cancelable);
+ };
+ Ticker.hasEventListener = function hasEventListener(type) {
+ return _instance.hasEventListener(type);
+ };
+ Ticker.willTrigger = function willTrigger(type) {
+ return _instance.willTrigger(type);
+ };
+ Ticker.toString = function toString() {
+ return _instance.toString();
+ };
+ Ticker.init = function init() {
+ _instance.init();
+ };
+ Ticker.reset = function reset() {
+ _instance.reset();
+ };
+ Ticker.addEventListener = function addEventListener(type, listener, useCapture) {
+ _instance.addEventListener(type, listener, useCapture);
+ };
+ Ticker.getMeasuredTickTime = function getMeasuredTickTime(ticks) {
+ return _instance.getMeasuredTickTime(ticks);
+ };
+ Ticker.getMeasuredFPS = function getMeasuredFPS(ticks) {
+ return _instance.getMeasuredFPS(ticks);
+ };
+ Ticker.getTime = function getTime(runTime) {
+ return _instance.getTime(runTime);
+ };
+ Ticker.getEventTime = function getEventTime(runTime) {
+ return _instance.getEventTime(runTime);
+ };
+ Ticker.getTicks = function getTicks(pauseable) {
+ return _instance.getTicks(pauseable);
+ };
+ _createClass(Ticker, [{
+ key: "interval",
+ get: function get() {
+ return this._interval;
+ },
+ set: function set(interval) {
+ this._interval = interval;
+ if (!this._inited) {
+ return;
+ }
+ this._setupTick();
+ }
+ }, {
+ key: "framerate",
+ get: function get() {
+ return 1000 / this._interval;
+ },
+ set: function set(framerate) {
+ this.interval = 1000 / framerate;
+ }
+ }], [{
+ key: "interval",
+ get: function get() {
+ return _instance.interval;
+ },
+ set: function set(interval) {
+ _instance.interval = interval;
+ }
+ }, {
+ key: "framerate",
+ get: function get() {
+ return _instance.framerate;
+ },
+ set: function set(framerate) {
+ _instance.framerate = framerate;
+ }
+ }, {
+ key: "name",
+ get: function get() {
+ return _instance.name;
+ },
+ set: function set(name) {
+ _instance.name = name;
+ }
+ }, {
+ key: "timingMode",
+ get: function get() {
+ return _instance.timingMode;
+ },
+ set: function set(timingMode) {
+ _instance.timingMode = timingMode;
+ }
+ }, {
+ key: "maxDelta",
+ get: function get() {
+ return _instance.maxDelta;
+ },
+ set: function set(maxDelta) {
+ _instance.maxDelta = maxDelta;
+ }
+ }, {
+ key: "paused",
+ get: function get() {
+ return _instance.paused;
+ },
+ set: function set(paused) {
+ _instance.paused = paused;
+ }
+ }]);
+ return Ticker;
+ }(EventDispatcher);
+ var _instance = new Ticker("createjs.global");
+
+ var StageGL = function StageGL() {
+ throw new Error("\n\t\t\tStageGL is not currently supported on the EaselJS 2.0 branch.\n\t\t\tEnd of Q1 2018 is targetted for StageGL support.\n\t\t\tFollow @CreateJS on Twitter for updates.\n\t\t");
+ };
+
+ var Shadow =
+ function () {
+ function Shadow(color, offsetX, offsetY, blur) {
+ if (color === void 0) {
+ color = "black";
+ }
+ if (offsetX === void 0) {
+ offsetX = 0;
+ }
+ if (offsetY === void 0) {
+ offsetY = 0;
+ }
+ if (blur === void 0) {
+ blur = 0;
+ }
+ this.color = color;
+ this.offsetX = offsetX;
+ this.offsetY = offsetY;
+ this.blur = blur;
+ }
+ var _proto = Shadow.prototype;
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + "]";
+ };
+ _proto.clone = function clone() {
+ return new Shadow(this.color, this.offsetX, this.offsetY, this.blur);
+ };
+ return Shadow;
+ }();
+ Shadow.identity = new Shadow("transparent");
+
+ var _nextId = 0;
+ function uid() {
+ return _nextId++;
+ }
+
+ var Point =
+ function () {
+ function Point(x, y) {
+ this.setValues(x, y);
+ }
+ var _proto = Point.prototype;
+ _proto.setValues = function setValues(x, y) {
+ if (x === void 0) {
+ x = 0;
+ }
+ if (y === void 0) {
+ y = 0;
+ }
+ this.x = x;
+ this.y = y;
+ return this;
+ };
+ _proto.copy = function copy(point) {
+ this.x = point.x;
+ this.y = point.y;
+ return this;
+ };
+ _proto.clone = function clone() {
+ return new Point(this.x, this.y);
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + " (x=" + this.x + " y=" + this.y + ")]";
+ };
+ return Point;
+ }();
+
+ var Matrix2D =
+ function () {
+ function Matrix2D(a, b, c, d, tx, ty) {
+ this.setValues(a, b, c, d, tx, ty);
+ }
+ var _proto = Matrix2D.prototype;
+ _proto.setValues = function setValues(a, b, c, d, tx, ty) {
+ if (a === void 0) {
+ a = 1;
+ }
+ if (b === void 0) {
+ b = 0;
+ }
+ if (c === void 0) {
+ c = 0;
+ }
+ if (d === void 0) {
+ d = 1;
+ }
+ if (tx === void 0) {
+ tx = 0;
+ }
+ if (ty === void 0) {
+ ty = 0;
+ }
+ this.a = a;
+ this.b = b;
+ this.c = c;
+ this.d = d;
+ this.tx = tx;
+ this.ty = ty;
+ return this;
+ };
+ _proto.append = function append(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;
+ };
+ _proto.prepend = function prepend(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;
+ };
+ _proto.appendMatrix = function appendMatrix(matrix) {
+ return this.append(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);
+ };
+ _proto.prependMatrix = function prependMatrix(matrix) {
+ return this.prepend(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);
+ };
+ _proto.appendTransform = function appendTransform(x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) {
+ var r, cos, sin;
+ if (rotation % 360) {
+ r = rotation * Matrix2D.DEG_TO_RAD;
+ cos = Math.cos(r);
+ sin = Math.sin(r);
+ } else {
+ cos = 1;
+ sin = 0;
+ }
+ if (skewX || skewY) {
+ 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) {
+ this.tx -= regX * this.a + regY * this.c;
+ this.ty -= regX * this.b + regY * this.d;
+ }
+ return this;
+ };
+ _proto.prependTransform = function prependTransform(x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) {
+ var r, cos, sin;
+ if (rotation % 360) {
+ r = rotation * Matrix2D.DEG_TO_RAD;
+ cos = Math.cos(r);
+ sin = Math.sin(r);
+ } else {
+ cos = 1;
+ sin = 0;
+ }
+ if (regX || regY) {
+ this.tx -= regX;
+ this.ty -= regY;
+ }
+ if (skewX || skewY) {
+ 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;
+ };
+ _proto.rotate = function rotate(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;
+ };
+ _proto.skew = function skew(skewX, skewY) {
+ skewX *= Matrix2D.DEG_TO_RAD;
+ skewY *= Matrix2D.DEG_TO_RAD;
+ this.append(Math.cos(skewY), Math.sin(skewY), -Math.sin(skewX), Math.cos(skewX), 0, 0);
+ return this;
+ };
+ _proto.scale = function scale(x, y) {
+ this.a *= x;
+ this.b *= x;
+ this.c *= y;
+ this.d *= y;
+ return this;
+ };
+ _proto.translate = function translate(x, y) {
+ this.tx += this.a * x + this.c * y;
+ this.ty += this.b * x + this.d * y;
+ return this;
+ };
+ _proto.identity = function identity() {
+ this.a = this.d = 1;
+ this.b = this.c = this.tx = this.ty = 0;
+ return this;
+ };
+ _proto.invert = function invert() {
+ 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;
+ };
+ _proto.isIdentity = function isIdentity() {
+ return this.tx === 0 && this.ty === 0 && this.a === 1 && this.b === 0 && this.c === 0 && this.d === 1;
+ };
+ _proto.equals = function equals(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;
+ };
+ _proto.transformPoint = function transformPoint(x, y, pt) {
+ if (pt === void 0) {
+ pt = new Point();
+ }
+ pt.x = x * this.a + y * this.c + this.tx;
+ pt.y = x * this.b + y * this.d + this.ty;
+ return pt;
+ };
+ _proto.decompose = function decompose(target) {
+ if (target === void 0) {
+ 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) {
+ 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;
+ };
+ _proto.copy = function copy(matrix) {
+ return this.setValues(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);
+ };
+ _proto.clone = function clone() {
+ return new Matrix2D(this.a, this.b, this.c, this.d, this.tx, this.ty);
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + " (a=" + this.a + " b=" + this.b + " c=" + this.c + " d=" + this.d + " tx=" + this.tx + " ty=" + this.ty + ")]";
+ };
+ return Matrix2D;
+ }();
+ Matrix2D.DEG_TO_RAD = Math.PI / 180;
+ Matrix2D.identity = new Matrix2D();
+
+ var DisplayProps =
+ function () {
+ function DisplayProps(visible, alpha, shadow, compositeOperation, matrix) {
+ this.setValues(visible, alpha, shadow, compositeOperation, matrix);
+ }
+ var _proto = DisplayProps.prototype;
+ _proto.setValues = function setValues(visible, alpha, shadow, compositeOperation, matrix) {
+ if (visible === void 0) {
+ visible = true;
+ }
+ if (alpha === void 0) {
+ alpha = 1;
+ }
+ this.visible = visible;
+ this.alpha = alpha;
+ this.shadow = shadow;
+ this.compositeOperation = compositeOperation;
+ this.matrix = matrix || this.matrix && this.matrix.identity() || new Matrix2D();
+ return this;
+ };
+ _proto.append = function append(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;
+ };
+ _proto.prepend = function prepend(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;
+ };
+ _proto.identity = function identity() {
+ this.visible = true;
+ this.alpha = 1;
+ this.shadow = this.compositeOperation = null;
+ this.matrix.identity();
+ return this;
+ };
+ _proto.clone = function clone() {
+ return new DisplayProps(this.alpha, this.shadow, this.compositeOperation, this.visible, this.matrix.clone());
+ };
+ return DisplayProps;
+ }();
+
+ var Rectangle =
+ function () {
+ function Rectangle(x, y, width, height) {
+ this.setValues(x, y, width, height);
+ }
+ var _proto = Rectangle.prototype;
+ _proto.setValues = function setValues(x, y, width, height) {
+ if (x === void 0) {
+ x = 0;
+ }
+ if (y === void 0) {
+ y = 0;
+ }
+ if (width === void 0) {
+ width = 0;
+ }
+ if (height === void 0) {
+ height = 0;
+ }
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ return this;
+ };
+ _proto.extend = function extend(x, y, width, height) {
+ if (width === void 0) {
+ width = 0;
+ }
+ if (height === void 0) {
+ height = 0;
+ }
+ if (x + width > this.x + this.width) {
+ this.width = x + width - this.x;
+ }
+ if (y + height > this.y + this.height) {
+ this.height = y + height - this.y;
+ }
+ if (x < this.x) {
+ this.width += this.x - x;
+ this.x = x;
+ }
+ if (y < this.y) {
+ this.height += this.y - y;
+ this.y = y;
+ }
+ return this;
+ };
+ _proto.pad = function pad(top, left, bottom, right) {
+ this.x -= left;
+ this.y -= top;
+ this.width += left + right;
+ this.height += top + bottom;
+ return this;
+ };
+ _proto.copy = function copy(rect) {
+ return this.setValues(rect.x, rect.y, rect.width, rect.height);
+ };
+ _proto.contains = function contains(x, y, width, height) {
+ if (width === void 0) {
+ width = 0;
+ }
+ if (height === void 0) {
+ height = 0;
+ }
+ return x >= this.x && x + width <= this.x + this.width && y >= this.y && y + height <= this.y + this.height;
+ };
+ _proto.union = function union(rect) {
+ return this.clone().extend(rect.x, rect.y, rect.width, rect.height);
+ };
+ _proto.intersection = function intersection(rect) {
+ var x1 = rect.x,
+ y1 = rect.y,
+ x2 = x1 + rect.width,
+ y2 = y1 + rect.height;
+ if (this.x > x1) {
+ x1 = this.x;
+ }
+ if (this.y > y1) {
+ y1 = this.y;
+ }
+ if (this.x + this.width < x2) {
+ x2 = this.x + this.width;
+ }
+ if (this.y + this.height < y2) {
+ y2 = this.y + this.height;
+ }
+ return x2 <= x1 || y2 <= y1 ? null : new Rectangle(x1, y1, x2 - x1, y2 - y1);
+ };
+ _proto.intersects = function intersects(rect) {
+ return rect.x <= this.x + this.width && this.x <= rect.x + rect.width && rect.y <= this.y + this.height && this.y <= rect.y + rect.height;
+ };
+ _proto.isEmpty = function isEmpty() {
+ return this.width <= 0 || this.height <= 0;
+ };
+ _proto.clone = function clone() {
+ return new Rectangle(this.x, this.y, this.width, this.height);
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + " (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + ")]";
+ };
+ return Rectangle;
+ }();
+
+ var Filter =
+ function () {
+ function Filter() {
+ this.usesContext = false;
+ this._multiPass = null;
+ this.VTX_SHADER_BODY = null;
+ this.FRAG_SHADER_BODY = null;
+ }
+ var _proto = Filter.prototype;
+ _proto.getBounds = function getBounds(rect) {};
+ _proto.shaderParamSetup = function shaderParamSetup(gl, stage, shaderProgram) {};
+ _proto.applyFilter = function applyFilter(ctx, x, y, width, height, targetCtx, targetX, targetY) {
+ targetCtx = targetCtx || ctx;
+ if (targetX == null) {
+ targetX = x;
+ }
+ if (targetY == null) {
+ targetY = y;
+ }
+ try {
+ var imageData = ctx.getImageData(x, y, width, height);
+ if (this._applyFilter(imageData)) {
+ targetCtx.putImageData(imageData, targetX, targetY);
+ return true;
+ }
+ } catch (e) {}
+ return false;
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + "]";
+ };
+ _proto.clone = function clone() {
+ return new Filter();
+ };
+ _proto._applyFilter = function _applyFilter(imageData) {};
+ return Filter;
+ }();
+
+ var BitmapCache =
+ function (_Filter) {
+ _inheritsLoose(BitmapCache, _Filter);
+ function BitmapCache() {
+ var _this;
+ _this = _Filter.call(this) || this;
+ _this.width = undefined;
+ _this.height = undefined;
+ _this.x = undefined;
+ _this.y = undefined;
+ _this.scale = 1;
+ _this.offX = 0;
+ _this.offY = 0;
+ _this.cacheID = 0;
+ _this._filterOffX = 0;
+ _this._filterOffY = 0;
+ _this._cacheDataURLID = 0;
+ _this._cacheDataURL = null;
+ _this._drawWidth = 0;
+ _this._drawHeight = 0;
+ _this._boundRect = new Rectangle();
+ return _this;
+ }
+ BitmapCache.getFilterBounds = function getFilterBounds(target, output) {
+ if (output === void 0) {
+ output = new Rectangle();
+ }
+ var filters = target.filters;
+ var filterCount = filters && filters.length;
+ if (!!filterCount <= 0) {
+ return output;
+ }
+ for (var i = 0; i < filterCount; i++) {
+ var f = filters[i];
+ if (!f || !f.getBounds) {
+ continue;
+ }
+ var test = f.getBounds();
+ if (!test) {
+ continue;
+ }
+ if (i == 0) {
+ output.setValues(test.x, test.y, test.width, test.height);
+ } else {
+ output.extend(test.x, test.y, test.width, test.height);
+ }
+ }
+ return output;
+ };
+ var _proto = BitmapCache.prototype;
+ _proto.define = function define(target, x, y, width, height, scale, options) {
+ if (x === void 0) {
+ x = 0;
+ }
+ if (y === void 0) {
+ y = 0;
+ }
+ if (width === void 0) {
+ width = 1;
+ }
+ if (height === void 0) {
+ height = 1;
+ }
+ if (scale === void 0) {
+ scale = 1;
+ }
+ if (!target) {
+ throw "No symbol to cache";
+ }
+ this._options = options;
+ this._useWebGL = options !== undefined;
+ this.target = target;
+ this.width = width >= 1 ? width : 1;
+ this.height = height >= 1 ? height : 1;
+ this.x = x;
+ this.y = y;
+ this.scale = scale;
+ this.update();
+ };
+ _proto.update = function update(compositeOperation) {
+ if (!this.target) {
+ throw "define() must be called before update()";
+ }
+ var filterBounds = BitmapCache.getFilterBounds(this.target);
+ var surface = this.target.cacheCanvas;
+ this._drawWidth = Math.ceil(this.width * this.scale) + filterBounds.width;
+ this._drawHeight = Math.ceil(this.height * this.scale) + filterBounds.height;
+ if (!surface || this._drawWidth != surface.width || this._drawHeight != surface.height) {
+ this._updateSurface();
+ }
+ this._filterOffX = filterBounds.x;
+ this._filterOffY = filterBounds.y;
+ this.offX = this.x * this.scale + this._filterOffX;
+ this.offY = this.y * this.scale + this._filterOffY;
+ this._drawToCache(compositeOperation);
+ this.cacheID = this.cacheID ? this.cacheID + 1 : 1;
+ };
+ _proto.release = function release() {
+ var stage = this.target.stage;
+ if (this._useWebGL && this._webGLCache) {
+ if (!this._webGLCache.isCacheControlled) {
+ if (this.__lastRT) {
+ this.__lastRT = undefined;
+ }
+ if (this.__rtA) {
+ this._webGLCache._killTextureObject(this.__rtA);
+ }
+ if (this.__rtB) {
+ this._webGLCache._killTextureObject(this.__rtB);
+ }
+ if (this.target && this.target.cacheCanvas) {
+ this._webGLCache._killTextureObject(this.target.cacheCanvas);
+ }
+ }
+ this._webGLCache = false;
+ } else if (stage instanceof StageGL) {
+ stage.releaseTexture(this.target.cacheCanvas);
+ }
+ this.target = this.target.cacheCanvas = null;
+ this.cacheID = this._cacheDataURLID = this._cacheDataURL = undefined;
+ this.width = this.height = this.x = this.y = this.offX = this.offY = 0;
+ this.scale = 1;
+ };
+ _proto.getCacheDataURL = function getCacheDataURL() {
+ var cacheCanvas = this.target && this.target.cacheCanvas;
+ if (!cacheCanvas) {
+ return null;
+ }
+ if (this.cacheID != this._cacheDataURLID) {
+ this._cacheDataURLID = this.cacheID;
+ this._cacheDataURL = cacheCanvas.toDataURL ? cacheCanvas.toDataURL() : null;
+ }
+ return this._cacheDataURL;
+ };
+ _proto.draw = function draw(ctx) {
+ if (!this.target) {
+ return false;
+ }
+ ctx.drawImage(this.target.cacheCanvas, this.x + this._filterOffX / this.scale, this.y + this._filterOffY / this.scale, this._drawWidth / this.scale, this._drawHeight / this.scale);
+ return true;
+ };
+ _proto.getBounds = function getBounds() {
+ var scale = this.scale;
+ return this._boundRect.setValue(this._filterOffX / scale, this._filterOffY / scale, this.width / scale, this.height / scale);
+ };
+ _proto._updateSurface = function _updateSurface() {
+ var surface;
+ if (!this._useWebGL) {
+ surface = this.target.cacheCanvas;
+ if (!surface) {
+ surface = this.target.cacheCanvas = window.createjs && createjs.createCanvas ? createjs.createCanvas() : document.createElement("canvas");
+ }
+ surface.width = this._drawWidth;
+ surface.height = this._drawHeight;
+ return;
+ }
+ if (!this._webGLCache) {
+ if (this._options.useGL === "stage") {
+ if (!(this.target.stage != null && this.target.stage.isWebGL)) {
+ throw "Cannot use 'stage' for cache because the object's parent stage is " + (this.target.stage != null ? "non WebGL." : "not set, please addChild to the correct stage.");
+ }
+ this.target.cacheCanvas = true;
+ this._webGLCache = this.target.stage;
+ } else if (this._options.useGL === "new") {
+ this.target.cacheCanvas = document.createElement("canvas");
+ this._webGLCache = new StageGL(this.target.cacheCanvas, {
+ antialias: true,
+ transparent: true,
+ autoPurge: -1
+ });
+ this._webGLCache.isCacheControlled = true;
+ } else {
+ throw "Invalid option provided to useGL, expected ['stage', 'new', StageGL, undefined], got " + this._options.useGL;
+ }
+ }
+ var stageGL = this._webGLCache;
+ surface = this.target.cacheCanvas;
+ if (stageGL.isCacheControlled) {
+ surface.width = this._drawWidth;
+ surface.height = this._drawHeight;
+ stageGL.updateViewport(this._drawWidth, this._drawHeight);
+ }
+ if (this.target.filters) {
+ stageGL.getTargetRenderTexture(this.target, this._drawWidth, this._drawHeight);
+ stageGL.getTargetRenderTexture(this.target, this._drawWidth, this._drawHeight);
+ } else if (!stageGL.isCacheControlled) {
+ stageGL.getTargetRenderTexture(this.target, this._drawWidth, this._drawHeight);
+ }
+ };
+ _proto._drawToCache = function _drawToCache(compositeOperation) {
+ var target = this.target;
+ var surface = target.cacheCanvas;
+ var webGL = this._webGLCache;
+ if (!this._useWebGL || !webGL) {
+ var ctx = surface.getContext("2d");
+ if (!compositeOperation) {
+ ctx.clearRect(0, 0, this._drawWidth + 1, this._drawHeight + 1);
+ }
+ ctx.save();
+ ctx.globalCompositeOperation = compositeOperation;
+ ctx.setTransform(this.scale, 0, 0, this.scale, -this._filterOffX, -this._filterOffY);
+ ctx.translate(-this.x, -this.y);
+ target.draw(ctx, true);
+ ctx.restore();
+ if (target.filters && target.filters.length) {
+ this._applyFilters(target);
+ }
+ surface._invalid = true;
+ return;
+ }
+ this._webGLCache.cacheDraw(target, target.filters, this);
+ surface = this.target.cacheCanvas;
+ surface.width = this._drawWidth;
+ surface.height = this._drawHeight;
+ surface._invalid = true;
+ };
+ _proto._applyFilters = function _applyFilters() {
+ var surface = this.target.cacheCanvas;
+ var filters = this.target.filters;
+ var w = this._drawWidth;
+ var h = this._drawHeight;
+ var data = surface.getContext("2d").getImageData(0, 0, w, h);
+ var l = filters.length;
+ for (var i = 0; i < l; i++) {
+ filters[i]._applyFilter(data);
+ }
+ surface.getContext("2d").putImageData(data, 0, 0);
+ };
+ return BitmapCache;
+ }(Filter);
+
+ var DisplayObject =
+ function (_EventDispatcher) {
+ _inheritsLoose(DisplayObject, _EventDispatcher);
+ function DisplayObject() {
+ var _this;
+ _this = _EventDispatcher.call(this) || this;
+ _this.alpha = 1;
+ _this.cacheCanvas = null;
+ _this.bitmapCache = null;
+ _this.id = uid();
+ _this.mouseEnabled = true;
+ _this.tickEnabled = true;
+ _this.name = null;
+ _this.parent = null;
+ _this.regX = 0;
+ _this.regY = 0;
+ _this.rotation = 0;
+ _this.scaleX = 1;
+ _this.scaleY = 1;
+ _this.skewX = 0;
+ _this.skewY = 0;
+ _this.shadow = null;
+ _this.visible = true;
+ _this.x = 0;
+ _this.y = 0;
+ _this.transformMatrix = null;
+ _this.compositeOperation = null;
+ _this.snapToPixel = true;
+ _this.filters = null;
+ _this.mask = null;
+ _this.hitArea = null;
+ _this.cursor = null;
+ _this._props = new DisplayProps();
+ _this._rectangle = new Rectangle();
+ _this._bounds = null;
+ _this._webGLRenderStyle = DisplayObject._StageGL_NONE;
+ return _this;
+ }
+ var _proto = DisplayObject.prototype;
+ _proto.isVisible = function isVisible() {
+ return !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0);
+ };
+ _proto.draw = function draw(ctx, ignoreCache) {
+ if (ignoreCache === void 0) {
+ ignoreCache = false;
+ }
+ return this.drawCache(ctx, ignoreCache);
+ };
+ _proto.drawCache = function drawCache(ctx, ignoreCache) {
+ if (ignoreCache === void 0) {
+ ignoreCache = false;
+ }
+ var cache = this.bitmapCache;
+ if (cache && !ignoreCache) {
+ return cache.draw(ctx);
+ }
+ return false;
+ };
+ _proto.updateContext = function updateContext(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);
+ }
+ };
+ _proto.cache = function cache(x, y, width, height, scale, options) {
+ if (scale === void 0) {
+ scale = 1;
+ }
+ if (!this.bitmapCache) {
+ this.bitmapCache = new BitmapCache();
+ }
+ this.bitmapCache.define(this, x, y, width, height, scale, options);
+ };
+ _proto.updateCache = function updateCache(compositeOperation) {
+ if (!this.bitmapCache) {
+ throw "No cache found. cache() must be called before updateCache()";
+ }
+ this.bitmapCache.update(compositeOperation);
+ };
+ _proto.uncache = function uncache() {
+ if (this.bitmapCache) {
+ this.bitmapCache.release();
+ this.bitmapCache = undefined;
+ }
+ };
+ _proto.getCacheDataURL = function getCacheDataURL() {
+ return this.bitmapCache ? this.bitmapCache.getDataURL() : null;
+ };
+ _proto.localToGlobal = function localToGlobal(x, y, pt) {
+ if (pt === void 0) {
+ pt = new Point();
+ }
+ return this.getConcatenatedMatrix(this._props.matrix).transformPoint(x, y, pt);
+ };
+ _proto.globalToLocal = function globalToLocal(x, y, pt) {
+ if (pt === void 0) {
+ pt = new Point();
+ }
+ return this.getConcatenatedMatrix(this._props.matrix).invert().transformPoint(x, y, pt);
+ };
+ _proto.localToLocal = function localToLocal(x, y, target, pt) {
+ pt = this.localToGlobal(x, y, pt);
+ return target.globalToLocal(pt.x, pt.y, pt);
+ };
+ _proto.setTransform = function setTransform(x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) {
+ if (x === void 0) {
+ x = 0;
+ }
+ if (y === void 0) {
+ y = 0;
+ }
+ if (scaleX === void 0) {
+ scaleX = 1;
+ }
+ if (scaleY === void 0) {
+ scaleY = 1;
+ }
+ if (rotation === void 0) {
+ rotation = 0;
+ }
+ if (skewX === void 0) {
+ skewX = 0;
+ }
+ if (skewY === void 0) {
+ skewY = 0;
+ }
+ if (regX === void 0) {
+ regX = 0;
+ }
+ if (regY === void 0) {
+ regY = 0;
+ }
+ this.x = x;
+ this.y = y;
+ this.scaleX = scaleX;
+ this.scaleY = scaleY;
+ this.rotation = rotation;
+ this.skewX = skewX;
+ this.skewY = skewY;
+ this.regX = regX;
+ this.regY = regY;
+ return this;
+ };
+ _proto.getMatrix = function getMatrix(matrix) {
+ var o = this,
+ mtx = matrix && matrix.identity() || new Matrix2D();
+ return o.transformMatrix ? mtx.copy(o.transformMatrix) : mtx.appendTransform(o.x, o.y, o.scaleX, o.scaleY, o.rotation, o.skewX, o.skewY, o.regX, o.regY);
+ };
+ _proto.getConcatenatedMatrix = function getConcatenatedMatrix(matrix) {
+ var o = this,
+ mtx = this.getMatrix(matrix);
+ while (o = o.parent) {
+ mtx.prependMatrix(o.getMatrix(o._props.matrix));
+ }
+ return mtx;
+ };
+ _proto.getConcatenatedDisplayProps = function getConcatenatedDisplayProps(props) {
+ props = props ? props.identity() : new DisplayProps();
+ var o = this,
+ mtx = o.getMatrix(props.matrix);
+ do {
+ props.prepend(o.visible, o.alpha, o.shadow, o.compositeOperation);
+ if (o != this) {
+ mtx.prependMatrix(o.getMatrix(o._props.matrix));
+ }
+ } while (o = o.parent);
+ return props;
+ };
+ _proto.hitTest = function hitTest(x, y) {
+ var ctx = DisplayObject._hitTestContext;
+ ctx.setTransform(1, 0, 0, 1, -x, -y);
+ this.draw(ctx);
+ var hit = this._testHit(ctx);
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
+ ctx.clearRect(0, 0, 2, 2);
+ return hit;
+ };
+ _proto.set = function set(props) {
+ for (var n in props) {
+ this[n] = props[n];
+ }
+ return this;
+ };
+ _proto.getBounds = function getBounds() {
+ if (this._bounds) {
+ return this._rectangle.copy(this._bounds);
+ }
+ var cacheCanvas = this.cacheCanvas;
+ if (cacheCanvas) {
+ var scale = this._cacheScale;
+ return this._rectangle.setValues(this._cacheOffsetX, this._cacheOffsetY, cacheCanvas.width / scale, cacheCanvas.height / scale);
+ }
+ return null;
+ };
+ _proto.getTransformedBounds = function getTransformedBounds() {
+ return this._getBounds();
+ };
+ _proto.setBounds = function setBounds(x, y, width, height) {
+ if (x == null) {
+ this._bounds = null;
+ }
+ this._bounds = (this._bounds || new Rectangle()).setValues(x, y, width, height);
+ };
+ _proto.clone = function clone() {
+ return this._cloneProps(new DisplayObject());
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + (this.name ? " (name=" + this.name + ")" : "") + "]";
+ };
+ _proto._cloneProps = function _cloneProps(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;
+ return o;
+ };
+ _proto._applyShadow = function _applyShadow(ctx, shadow) {
+ if (shadow === void 0) {
+ shadow = Shadow.identity;
+ }
+ shadow = shadow;
+ ctx.shadowColor = shadow.color;
+ ctx.shadowOffsetX = shadow.offsetX;
+ ctx.shadowOffsetY = shadow.offsetY;
+ ctx.shadowBlur = shadow.blur;
+ };
+ _proto._tick = function _tick(evtObj) {
+ var ls = this._listeners;
+ if (ls && ls["tick"]) {
+ evtObj.target = null;
+ evtObj.propagationStopped = evtObj.immediatePropagationStopped = false;
+ this.dispatchEvent(evtObj);
+ }
+ };
+ _proto._testHit = function _testHit(ctx) {
+ try {
+ return ctx.getImageData(0, 0, 1, 1).data[3] > 1;
+ } catch (e) {
+ if (!DisplayObject.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 false;
+ }
+ };
+ _proto._getBounds = function _getBounds(matrix, ignoreTransform) {
+ return this._transformBounds(this.getBounds(), matrix, ignoreTransform);
+ };
+ _proto._transformBounds = function _transformBounds(bounds, matrix, ignoreTransform) {
+ if (!bounds) {
+ return bounds;
+ }
+ var x = bounds.x,
+ y = bounds.y,
+ width = bounds.width,
+ height = bounds.height;
+ var mtx = this._props.matrix;
+ mtx = ignoreTransform ? mtx.identity() : this.getMatrix(mtx);
+ if (x || y) {
+ mtx.appendTransform(0, 0, 1, 1, 0, 0, 0, -x, -y);
+ }
+ if (matrix) {
+ mtx.prependMatrix(matrix);
+ }
+ var x_a = width * mtx.a,
+ x_b = width * mtx.b;
+ var y_c = height * mtx.c,
+ y_d = height * mtx.d;
+ var tx = mtx.tx,
+ ty = mtx.ty;
+ var minX = tx,
+ maxX = tx,
+ minY = ty,
+ maxY = ty;
+ if ((x = x_a + tx) < minX) {
+ minX = x;
+ } else if (x > maxX) {
+ maxX = x;
+ }
+ if ((x = x_a + y_c + tx) < minX) {
+ minX = x;
+ } else if (x > maxX) {
+ maxX = x;
+ }
+ if ((x = y_c + tx) < minX) {
+ minX = x;
+ } else if (x > maxX) {
+ maxX = x;
+ }
+ if ((y = x_b + ty) < minY) {
+ minY = y;
+ } else if (y > maxY) {
+ maxY = y;
+ }
+ if ((y = x_b + y_d + ty) < minY) {
+ minY = y;
+ } else if (y > maxY) {
+ maxY = y;
+ }
+ if ((y = y_d + ty) < minY) {
+ minY = y;
+ } else if (y > maxY) {
+ maxY = y;
+ }
+ return bounds.setValues(minX, minY, maxX - minX, maxY - minY);
+ };
+ _proto._hasMouseEventListener = function _hasMouseEventListener() {
+ var evts = DisplayObject._MOUSE_EVENTS;
+ for (var i = 0, l = evts.length; i < l; i++) {
+ if (this.hasEventListener(evts[i])) {
+ return true;
+ }
+ }
+ return !!this.cursor;
+ };
+ _createClass(DisplayObject, [{
+ key: "stage",
+ get: function get() {
+ var o = this;
+ while (o.parent) {
+ o = o.parent;
+ }
+ if (/^\[Stage(GL)?(\s\(name=\w+\))?\]$/.test(o.toString())) {
+ return o;
+ }
+ return null;
+ }
+ }, {
+ key: "scale",
+ set: function set(value) {
+ this.scaleX = this.scaleY = value;
+ },
+ get: function get() {
+ return this.scaleX;
+ }
+ }]);
+ return DisplayObject;
+ }(EventDispatcher);
+ {
+ var canvas = window.createjs && createjs.createCanvas ? createjs.createCanvas() : document.createElement("canvas");
+ if (canvas.getContext) {
+ DisplayObject._hitTestCanvas = canvas;
+ DisplayObject._hitTestContext = canvas.getContext("2d");
+ canvas.width = canvas.height = 1;
+ }
+ }
+ DisplayObject._MOUSE_EVENTS = ["click", "dblclick", "mousedown", "mouseout", "mouseover", "pressmove", "pressup", "rollout", "rollover"];
+ DisplayObject.suppressCrossDomainErrors = false;
+ DisplayObject.snapToPixelEnabled = false;
+ DisplayObject._StageGL_NONE = 0;
+ DisplayObject._StageGL_SPRITE = 1;
+ DisplayObject._StageGL_BITMAP = 2;
+
+ var Container =
+ function (_DisplayObject) {
+ _inheritsLoose(Container, _DisplayObject);
+ function Container() {
+ var _this;
+ _this = _DisplayObject.call(this) || this;
+ _this.children = [];
+ _this.mouseChildren = true;
+ _this.tickChildren = true;
+ return _this;
+ }
+ var _proto = Container.prototype;
+ _proto.isVisible = function isVisible() {
+ var hasContent = this.cacheCanvas || this.children.length;
+ return !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && hasContent);
+ };
+ _proto.draw = function draw(ctx, ignoreCache) {
+ if (ignoreCache === void 0) {
+ ignoreCache = false;
+ }
+ if (_DisplayObject.prototype.draw.call(this, ctx, ignoreCache)) {
+ return true;
+ }
+ var list = this.children.slice();
+ for (var i = 0, l = list.length; i < l; i++) {
+ var child = list[i];
+ if (!child.isVisible()) {
+ continue;
+ }
+ ctx.save();
+ child.updateContext(ctx);
+ child.draw(ctx);
+ ctx.restore();
+ }
+ return true;
+ };
+ _proto.addChild = function addChild() {
+ var l = arguments.length;
+ if (l === 0) {
+ return null;
+ }
+ var child = arguments.length <= 0 ? undefined : arguments[0];
+ if (l > 1) {
+ for (var i = 0; i < l; i++) {
+ child = this.addChild(i < 0 || arguments.length <= i ? undefined : arguments[i]);
+ }
+ return child;
+ }
+ var parent = child.parent,
+ silent = parent === this;
+ parent && parent._removeChildAt(parent.children.indexOf(child), silent);
+ child.parent = this;
+ this.children.push(child);
+ if (!silent) {
+ child.dispatchEvent("added");
+ }
+ return child;
+ };
+ _proto.addChildAt = function addChildAt() {
+ for (var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++) {
+ children[_key] = arguments[_key];
+ }
+ var l = children.length;
+ if (l === 0) {
+ return null;
+ }
+ var index = children.pop();
+ if (index < 0 || index > this.children.length) {
+ return children[l - 2];
+ }
+ if (l > 2) {
+ for (var i = 0; i < l - 1; i++) {
+ this.addChildAt(children[i], index++);
+ }
+ return children[l - 2];
+ }
+ var child = children[0];
+ var parent = child.parent,
+ silent = parent === this;
+ parent && parent._removeChildAt(parent.children.indexOf(child), silent);
+ child.parent = this;
+ this.children.splice(index++, 0, child);
+ if (!silent) {
+ child.dispatchEvent("added");
+ }
+ return child;
+ };
+ _proto.removeChild = function removeChild() {
+ var l = arguments.length;
+ if (l === 0) {
+ return true;
+ }
+ if (l > 1) {
+ var good = true;
+ for (var i = 0; i < l; i++) {
+ good = good && this.removeChild(i < 0 || arguments.length <= i ? undefined : arguments[i]);
+ }
+ return good;
+ }
+ return this._removeChildAt(this.children.indexOf(arguments.length <= 0 ? undefined : arguments[0]));
+ };
+ _proto.removeChildAt = function removeChildAt() {
+ for (var _len2 = arguments.length, indexes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
+ indexes[_key2] = arguments[_key2];
+ }
+ var l = indexes.length;
+ if (l === 0) {
+ return true;
+ }
+ if (l > 1) {
+ indexes.sort(function (a, b) {
+ return b - a;
+ });
+ var good = true;
+ for (var i = 0; i < l; i++) {
+ good = good && this._removeChildAt(indexes[i]);
+ }
+ return good;
+ }
+ return this._removeChildAt(indexes[0]);
+ };
+ _proto.removeAllChildren = function removeAllChildren() {
+ var kids = this.children;
+ while (kids.length) {
+ this._removeChildAt(0);
+ }
+ };
+ _proto.getChildAt = function getChildAt(index) {
+ return this.children[index];
+ };
+ _proto.getChildByName = function getChildByName(name) {
+ var kids = this.children;
+ var l = kids.length;
+ for (var i = 0; i < l; i++) {
+ if (kids[i].name === name) {
+ return kids[i];
+ }
+ }
+ return null;
+ };
+ _proto.sortChildren = function sortChildren(sortFunction) {
+ this.children.sort(sortFunction);
+ };
+ _proto.getChildIndex = function getChildIndex(child) {
+ return this.children.indexOf(child);
+ };
+ _proto.swapChildrenAt = function swapChildrenAt(index1, index2) {
+ var kids = this.children;
+ var o1 = kids[index1];
+ var o2 = kids[index2];
+ if (!o1 || !o2) {
+ return;
+ }
+ kids[index1] = o2;
+ kids[index2] = o1;
+ };
+ _proto.swapChildren = function swapChildren(child1, child2) {
+ var kids = this.children;
+ var l = kids.length;
+ var index1, index2;
+ for (var i = 0; i < l; i++) {
+ if (kids[i] === child1) {
+ index1 = i;
+ }
+ if (kids[i] === child2) {
+ index2 = i;
+ }
+ if (index1 != null && index2 != null) {
+ break;
+ }
+ }
+ if (i === l) {
+ return;
+ }
+ kids[index1] = child2;
+ kids[index2] = child1;
+ };
+ _proto.setChildIndex = function setChildIndex(child, index) {
+ var kids = this.children;
+ var l = kids.length;
+ if (child.parent != this || index < 0 || index >= l) {
+ return;
+ }
+ for (var i = 0; i < l; i++) {
+ if (kids[i] === child) {
+ break;
+ }
+ }
+ if (i === l || i === index) {
+ return;
+ }
+ kids.splice(i, 1);
+ kids.splice(index, 0, child);
+ };
+ _proto.contains = function contains(child) {
+ while (child) {
+ if (child === this) {
+ return true;
+ }
+ child = child.parent;
+ }
+ return false;
+ };
+ _proto.hitTest = function hitTest(x, y) {
+ return this.getObjectUnderPoint(x, y) != null;
+ };
+ _proto.getObjectsUnderPoint = function getObjectsUnderPoint(x, y, mode) {
+ if (mode === void 0) {
+ mode = 0;
+ }
+ var arr = [];
+ var pt = this.localToGlobal(x, y);
+ this._getObjectsUnderPoint(pt.x, pt.y, arr, mode > 0, mode === 1);
+ return arr;
+ };
+ _proto.getObjectUnderPoint = function getObjectUnderPoint(x, y, mode) {
+ if (mode === void 0) {
+ mode = 0;
+ }
+ var pt = this.localToGlobal(x, y);
+ return this._getObjectsUnderPoint(pt.x, pt.y, null, mode > 0, mode === 1);
+ };
+ _proto.getBounds = function getBounds() {
+ return this._getBounds(null, true);
+ };
+ _proto.getTransformedBounds = function getTransformedBounds() {
+ return this._getBounds();
+ };
+ _proto.clone = function clone(recursive) {
+ if (recursive === void 0) {
+ recursive = false;
+ }
+ var o = this._cloneProps(new Container());
+ if (recursive) {
+ this._cloneChildren(o);
+ }
+ return o;
+ };
+ _proto._tick = function _tick(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);
+ }
+ }
+ }
+ _DisplayObject.prototype._tick.call(this, evtObj);
+ };
+ _proto._cloneChildren = function _cloneChildren(o) {
+ if (o.children.length) {
+ o.removeAllChildren();
+ }
+ var arr = o.children;
+ var l = this.children.length;
+ for (var i = 0; i < l; i++) {
+ var clone = this.children[i].clone(true);
+ clone.parent = o;
+ arr.push(clone);
+ }
+ };
+ _proto._removeChildAt = function _removeChildAt(index, silent) {
+ if (silent === void 0) {
+ silent = false;
+ }
+ if (index < 0 || index > this.children.length - 1) {
+ return false;
+ }
+ var child = this.children[index];
+ if (child) {
+ child.parent = null;
+ }
+ this.children.splice(index, 1);
+ if (!silent) {
+ child.dispatchEvent("removed");
+ }
+ return true;
+ };
+ _proto._getObjectsUnderPoint = function _getObjectsUnderPoint(x, y, arr, mouse, activeListener, currentDepth) {
+ if (currentDepth === void 0) {
+ currentDepth = 0;
+ }
+ if (!currentDepth && !this._testMask(this, x, y)) {
+ return null;
+ }
+ var mtx,
+ ctx = DisplayObject._hitTestContext;
+ activeListener = activeListener || mouse && this._hasMouseEventListener();
+ var children = this.children;
+ var l = children.length;
+ for (var i = l - 1; i >= 0; i--) {
+ var child = children[i];
+ var hitArea = child.hitArea;
+ if (!child.visible || !hitArea && !child.isVisible() || mouse && !child.mouseEnabled) {
+ continue;
+ }
+ if (!hitArea && !this._testMask(child, x, y)) {
+ continue;
+ }
+ if (!hitArea && child instanceof Container) {
+ var result = child._getObjectsUnderPoint(x, y, arr, mouse, activeListener, currentDepth + 1);
+ if (!arr && result) {
+ return mouse && !this.mouseChildren ? this : result;
+ }
+ } else {
+ if (mouse && !activeListener && !child._hasMouseEventListener()) {
+ continue;
+ }
+ var props = child.getConcatenatedDisplayProps(child._props);
+ mtx = props.matrix;
+ if (hitArea) {
+ mtx.appendMatrix(hitArea.getMatrix(hitArea._props.matrix));
+ props.alpha = hitArea.alpha;
+ }
+ ctx.globalAlpha = props.alpha;
+ ctx.setTransform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx - x, mtx.ty - y);
+ (hitArea || child).draw(ctx);
+ if (!this._testHit(ctx)) {
+ continue;
+ }
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
+ ctx.clearRect(0, 0, 2, 2);
+ if (arr) {
+ arr.push(child);
+ } else {
+ return mouse && !this.mouseChildren ? this : child;
+ }
+ }
+ }
+ return null;
+ };
+ _proto._testMask = function _testMask(target, x, y) {
+ var mask = target.mask;
+ if (!mask || !mask.graphics || mask.graphics.isEmpty()) {
+ return true;
+ }
+ var mtx = this._props.matrix,
+ parent = target.parent;
+ mtx = parent ? parent.getConcatenatedMatrix(mtx) : mtx.identity();
+ mtx = mask.getMatrix(mask._props.matrix).prependMatrix(mtx);
+ var ctx = DisplayObject._hitTestContext;
+ ctx.setTransform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx - x, mtx.ty - y);
+ mask.graphics.drawAsPath(ctx);
+ ctx.fillStyle = "#000";
+ ctx.fill();
+ if (!this._testHit(ctx)) {
+ return false;
+ }
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
+ ctx.clearRect(0, 0, 2, 2);
+ return true;
+ };
+ _proto._getBounds = function _getBounds(matrix, ignoreTransform) {
+ var bounds = _DisplayObject.prototype.getBounds.call(this);
+ if (bounds) {
+ return this._transformBounds(bounds, matrix, ignoreTransform);
+ }
+ var mtx = this._props.matrix;
+ mtx = ignoreTransform ? mtx.identity() : this.getMatrix(mtx);
+ if (matrix) {
+ mtx.prependMatrix(matrix);
+ }
+ var l = this.children.length;
+ var rect = null;
+ for (var i = 0; i < l; i++) {
+ var child = this.children[i];
+ if (!child.visible || !(bounds = child._getBounds(mtx))) {
+ continue;
+ }
+ if (rect) {
+ rect.extend(bounds.x, bounds.y, bounds.width, bounds.height);
+ } else {
+ rect = bounds.clone();
+ }
+ }
+ return rect;
+ };
+ _createClass(Container, [{
+ key: "numChildren",
+ get: function get() {
+ return this.children.length;
+ }
+ }]);
+ return Container;
+ }(DisplayObject);
+
+ var MouseEvent =
+ function (_Event) {
+ _inheritsLoose(MouseEvent, _Event);
+ function MouseEvent(type, bubbles, cancelable, stageX, stageY, nativeEvent, pointerID, primary, rawX, rawY, relatedTarget) {
+ var _this;
+ _this = _Event.call(this, type, bubbles, cancelable) || this;
+ _this.stageX = stageX;
+ _this.stageY = stageY;
+ _this.rawX = rawX == null ? stageX : rawX;
+ _this.rawY = rawY == null ? stageY : rawY;
+ _this.nativeEvent = nativeEvent;
+ _this.pointerID = pointerID;
+ _this.primary = !!primary;
+ _this.relatedTarget = relatedTarget;
+ return _this;
+ }
+ var _proto = MouseEvent.prototype;
+ _proto.clone = function clone() {
+ return new MouseEvent(this.type, this.bubbles, this.cancelable, this.stageX, this.stageY, this.nativeEvent, this.pointerID, this.primary, this.rawX, this.rawY);
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + " (type=" + this.type + " stageX=" + this.stageX + " stageY=" + this.stageY + ")]";
+ };
+ _createClass(MouseEvent, [{
+ key: "localX",
+ get: function get() {
+ return this.currentTarget.globalToLocal(this.rawX, this.rawY).x;
+ }
+ }, {
+ key: "localY",
+ get: function get() {
+ return this.currentTarget.globalToLocal(this.rawX, this.rawY).y;
+ }
+ }, {
+ key: "isTouch",
+ get: function get() {
+ return this.pointerID !== -1;
+ }
+ }]);
+ return MouseEvent;
+ }(Event);
+
+ var Stage =
+ function (_Container) {
+ _inheritsLoose(Stage, _Container);
+ function Stage(canvas) {
+ var _this;
+ _this = _Container.call(this) || this;
+ _this.autoClear = true;
+ _this.canvas = typeof canvas === "string" ? document.getElementById(canvas) : canvas;
+ _this.mouseX = 0;
+ _this.mouseY = 0;
+ _this.drawRect = null;
+ _this.snapToPixelEnabled = false;
+ _this.mouseInBounds = false;
+ _this.tickOnUpdate = true;
+ _this.mouseMoveOutside = false;
+ _this.preventSelection = true;
+ _this._pointerData = {};
+ _this._pointerCount = 0;
+ _this._primaryPointerID = null;
+ _this._mouseOverIntervalID = null;
+ _this._nextStage = null;
+ _this._prevStage = null;
+ _this.enableDOMEvents(true);
+ return _this;
+ }
+ var _proto = Stage.prototype;
+ _proto.update = function update(props) {
+ if (!this.canvas) {
+ return;
+ }
+ if (this.tickOnUpdate) {
+ this.tick(props);
+ }
+ if (this.dispatchEvent("drawstart", false, true) === false) {
+ return;
+ }
+ DisplayObject._snapToPixelEnabled = this.snapToPixelEnabled;
+ var r = this.drawRect,
+ ctx = this.canvas.getContext("2d");
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
+ if (this.autoClear) {
+ if (r) {
+ ctx.clearRect(r.x, r.y, r.width, r.height);
+ } else {
+ ctx.clearRect(0, 0, this.canvas.width + 1, this.canvas.height + 1);
+ }
+ }
+ ctx.save();
+ if (this.drawRect) {
+ ctx.beginPath();
+ ctx.rect(r.x, r.y, r.width, r.height);
+ ctx.clip();
+ }
+ this.updateContext(ctx);
+ this.draw(ctx, false);
+ ctx.restore();
+ this.dispatchEvent("drawend");
+ };
+ _proto.tick = function tick(props) {
+ if (!this.tickEnabled || this.dispatchEvent("tickstart", false, true) === false) {
+ return;
+ }
+ var evtObj = new Event("tick");
+ if (props) {
+ for (var n in props) {
+ if (props.hasOwnProperty(n)) {
+ evtObj[n] = props[n];
+ }
+ }
+ }
+ this._tick(evtObj);
+ this.dispatchEvent("tickend");
+ };
+ _proto.handleEvent = function handleEvent(evt) {
+ if (evt.type === "tick") {
+ this.update(evt);
+ }
+ };
+ _proto.clear = function clear() {
+ 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);
+ };
+ _proto.toDataURL = function toDataURL(backgroundColor, mimeType) {
+ if (mimeType === void 0) {
+ mimeType = "image/png";
+ }
+ 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);
+ if (backgroundColor) {
+ ctx.putImageData(data, 0, 0);
+ ctx.globalCompositeOperation = compositeOperation;
+ }
+ return dataURL;
+ };
+ _proto.enableMouseOver = function enableMouseOver(frequency) {
+ var _this2 = this;
+ if (frequency === void 0) {
+ frequency = 20;
+ }
+ if (this._mouseOverIntervalID) {
+ clearInterval(this._mouseOverIntervalID);
+ this._mouseOverIntervalID = null;
+ if (frequency === 0) {
+ this._testMouseOver(true);
+ }
+ }
+ if (frequency <= 0) {
+ return;
+ }
+ this._mouseOverIntervalID = setInterval(function () {
+ return _this2._testMouseOver();
+ }, 1000 / Math.min(50, frequency));
+ };
+ _proto.enableDOMEvents = function enableDOMEvents(enable) {
+ var _this3 = this;
+ if (enable === void 0) {
+ enable = true;
+ }
+ var ls = this._eventListeners;
+ if (!enable && ls) {
+ for (var n in ls) {
+ var o = ls[n];
+ o.t.removeEventListener(n, o.f, false);
+ }
+ this._eventListeners = null;
+ } else if (enable && !ls && this.canvas) {
+ var t = window.addEventListener ? window : document;
+ ls = this._eventListeners = {
+ mouseup: {
+ t: t,
+ f: function f(e) {
+ return _this3._handleMouseUp(e);
+ }
+ },
+ mousemove: {
+ t: t,
+ f: function f(e) {
+ return _this3._handleMouseMove(e);
+ }
+ },
+ dblclick: {
+ t: this.canvas,
+ f: function f(e) {
+ return _this3._handleDoubleClick(e);
+ }
+ },
+ mousedown: {
+ t: this.canvas,
+ f: function f(e) {
+ return _this3._handleMouseDown(e);
+ }
+ }
+ };
+ for (var _n in ls) {
+ var _o = ls[_n];
+ _o.t.addEventListener && _o.t.addEventListener(_n, _o.f, false);
+ }
+ }
+ };
+ _proto.clone = function clone() {
+ throw "Stage cannot be cloned.";
+ };
+ _proto._getElementRect = function _getElementRect(e) {
+ var bounds;
+ try {
+ bounds = e.getBoundingClientRect();
+ }
+ catch (err) {
+ bounds = {
+ top: e.offsetTop,
+ left: e.offsetLeft,
+ width: e.offsetWidth,
+ height: e.offsetHeight
+ };
+ }
+ var offX = (window.pageXOffset || document.scrollLeft || 0) - (document.clientLeft || document.body.clientLeft || 0);
+ var offY = (window.pageYOffset || document.scrollTop || 0) - (document.clientTop || document.body.clientTop || 0);
+ var styles = window.getComputedStyle ? getComputedStyle(e, null) : e.currentStyle;
+ var padL = parseInt(styles.paddingLeft) + parseInt(styles.borderLeftWidth);
+ var padT = parseInt(styles.paddingTop) + parseInt(styles.borderTopWidth);
+ var padR = parseInt(styles.paddingRight) + parseInt(styles.borderRightWidth);
+ var padB = parseInt(styles.paddingBottom) + parseInt(styles.borderBottomWidth);
+ return {
+ left: bounds.left + offX + padL,
+ right: bounds.right + offX - padR,
+ top: bounds.top + offY + padT,
+ bottom: bounds.bottom + offY - padB
+ };
+ };
+ _proto._getPointerData = function _getPointerData(id) {
+ var data = this._pointerData[id];
+ if (!data) {
+ data = this._pointerData[id] = {
+ x: 0,
+ y: 0
+ };
+ }
+ return data;
+ };
+ _proto._handleMouseMove = function _handleMouseMove(e) {
+ if (e === void 0) {
+ e = window.event;
+ }
+ this._handlePointerMove(-1, e, e.pageX, e.pageY);
+ };
+ _proto._handlePointerMove = function _handlePointerMove(id, e, pageX, pageY, owner) {
+ if (this._prevStage && owner === undefined) {
+ return;
+ }
+ if (!this.canvas) {
+ return;
+ }
+ var nextStage = this._nextStage,
+ o = this._getPointerData(id);
+ var inBounds = o.inBounds;
+ this._updatePointerPosition(id, e, pageX, pageY);
+ if (inBounds || o.inBounds || this.mouseMoveOutside) {
+ if (id === -1 && o.inBounds === !inBounds) {
+ this._dispatchMouseEvent(this, inBounds ? "mouseleave" : "mouseenter", false, id, o, e);
+ }
+ this._dispatchMouseEvent(this, "stagemousemove", false, id, o, e);
+ this._dispatchMouseEvent(o.target, "pressmove", true, id, o, e);
+ }
+ nextStage && nextStage._handlePointerMove(id, e, pageX, pageY, null);
+ };
+ _proto._updatePointerPosition = function _updatePointerPosition(id, e, pageX, pageY) {
+ var rect = this._getElementRect(this.canvas);
+ pageX -= rect.left;
+ pageY -= rect.top;
+ var w = this.canvas.width;
+ var h = this.canvas.height;
+ pageX /= (rect.right - rect.left) / w;
+ pageY /= (rect.bottom - rect.top) / h;
+ var o = this._getPointerData(id);
+ if (o.inBounds = pageX >= 0 && pageY >= 0 && pageX <= w - 1 && pageY <= h - 1) {
+ o.x = pageX;
+ o.y = pageY;
+ } else if (this.mouseMoveOutside) {
+ o.x = pageX < 0 ? 0 : pageX > w - 1 ? w - 1 : pageX;
+ o.y = pageY < 0 ? 0 : pageY > h - 1 ? h - 1 : pageY;
+ }
+ o.posEvtObj = e;
+ o.rawX = pageX;
+ o.rawY = pageY;
+ if (id === this._primaryPointerID || id === -1) {
+ this.mouseX = o.x;
+ this.mouseY = o.y;
+ this.mouseInBounds = o.inBounds;
+ }
+ };
+ _proto._handleMouseUp = function _handleMouseUp(e) {
+ this._handlePointerUp(-1, e, false);
+ };
+ _proto._handlePointerUp = function _handlePointerUp(id, e, clear, owner) {
+ var nextStage = this._nextStage,
+ o = this._getPointerData(id);
+ if (this._prevStage && owner === undefined) {
+ return;
+ }
+ var target = null,
+ oTarget = o.target;
+ if (!owner && (oTarget || nextStage)) {
+ target = this._getObjectsUnderPoint(o.x, o.y, null, true);
+ }
+ if (o.down) {
+ this._dispatchMouseEvent(this, "stagemouseup", false, id, o, e, target);
+ o.down = false;
+ }
+ if (target === oTarget) {
+ this._dispatchMouseEvent(oTarget, "click", true, id, o, e);
+ }
+ this._dispatchMouseEvent(oTarget, "pressup", true, id, o, e);
+ if (clear) {
+ if (id == this._primaryPointerID) {
+ this._primaryPointerID = null;
+ }
+ delete this._pointerData[id];
+ } else {
+ o.target = null;
+ }
+ nextStage && nextStage._handlePointerUp(id, e, clear, owner || target && this);
+ };
+ _proto._handleMouseDown = function _handleMouseDown(e) {
+ this._handlePointerDown(-1, e, e.pageX, e.pageY);
+ };
+ _proto._handlePointerDown = function _handlePointerDown(id, e, pageX, pageY, owner) {
+ if (this.preventSelection) {
+ e.preventDefault();
+ }
+ if (this._primaryPointerID == null || id === -1) {
+ this._primaryPointerID = id;
+ }
+ if (pageY != null) {
+ this._updatePointerPosition(id, e, pageX, pageY);
+ }
+ var target = null,
+ nextStage = this._nextStage,
+ o = this._getPointerData(id);
+ if (!owner) {
+ target = o.target = this._getObjectsUnderPoint(o.x, o.y, null, true);
+ }
+ if (o.inBounds) {
+ this._dispatchMouseEvent(this, "stagemousedown", false, id, o, e, target);
+ o.down = true;
+ }
+ this._dispatchMouseEvent(target, "mousedown", true, id, o, e);
+ nextStage && nextStage._handlePointerDown(id, e, pageX, pageY, owner || target && this);
+ };
+ _proto._testMouseOver = function _testMouseOver(clear, owner, eventTarget) {
+ if (this._prevStage && owner === undefined) {
+ return;
+ }
+ var nextStage = this._nextStage;
+ if (!this._mouseOverIntervalID) {
+ nextStage && nextStage._testMouseOver(clear, owner, eventTarget);
+ return;
+ }
+ var o = this._getPointerData(-1);
+ if (!o || !clear && this.mouseX === this._mouseOverX && this.mouseY === this._mouseOverY && this.mouseInBounds) {
+ return;
+ }
+ var e = o.posEvtObj;
+ var isEventTarget = eventTarget || e && e.target === this.canvas;
+ var target = null,
+ common = -1,
+ cursor = "";
+ if (!owner && (clear || this.mouseInBounds && isEventTarget)) {
+ target = this._getObjectsUnderPoint(this.mouseX, this.mouseY, null, true);
+ this._mouseOverX = this.mouseX;
+ this._mouseOverY = this.mouseY;
+ }
+ var oldList = this._mouseOverTarget || [];
+ var oldTarget = oldList[oldList.length - 1];
+ var list = this._mouseOverTarget = [];
+ var t = target;
+ while (t) {
+ list.unshift(t);
+ if (!cursor) {
+ cursor = t.cursor;
+ }
+ t = t.parent;
+ }
+ this.canvas.style.cursor = cursor;
+ if (!owner && eventTarget) {
+ eventTarget.canvas.style.cursor = cursor;
+ }
+ for (var i = 0, l = list.length; i < l; i++) {
+ if (list[i] != oldList[i]) {
+ break;
+ }
+ common = i;
+ }
+ if (oldTarget != target) {
+ this._dispatchMouseEvent(oldTarget, "mouseout", true, -1, o, e, target);
+ }
+ for (var _i = oldList.length - 1; _i > common; _i--) {
+ this._dispatchMouseEvent(oldList[_i], "rollout", false, -1, o, e, target);
+ }
+ for (var _i2 = list.length - 1; _i2 > common; _i2--) {
+ this._dispatchMouseEvent(list[_i2], "rollover", false, -1, o, e, oldTarget);
+ }
+ if (oldTarget != target) {
+ this._dispatchMouseEvent(target, "mouseover", true, -1, o, e, oldTarget);
+ }
+ nextStage && nextStage._testMouseOver(clear, owner || target && this, eventTarget || isEventTarget && this);
+ };
+ _proto._handleDoubleClick = function _handleDoubleClick(e, owner) {
+ var target = null,
+ nextStage = this._nextStage,
+ o = this._getPointerData(-1);
+ if (!owner) {
+ target = this._getObjectsUnderPoint(o.x, o.y, null, true);
+ this._dispatchMouseEvent(target, "dblclick", true, -1, o, e);
+ }
+ nextStage && nextStage._handleDoubleClick(e, owner || target && this);
+ };
+ _proto._dispatchMouseEvent = function _dispatchMouseEvent(target, type, bubbles, pointerId, o, nativeEvent, relatedTarget) {
+ if (!target || !bubbles && !target.hasEventListener(type)) {
+ return;
+ }
+ var evt = new MouseEvent(type, bubbles, false, o.x, o.y, nativeEvent, pointerId, pointerId === this._primaryPointerID || pointerId === -1, o.rawX, o.rawY, relatedTarget);
+ target.dispatchEvent(evt);
+ };
+ _createClass(Stage, [{
+ key: "nextStage",
+ get: function get() {
+ return this._nextStage;
+ },
+ set: function set(stage) {
+ if (this._nextStage) {
+ this._nextStage._prevStage = null;
+ }
+ if (stage) {
+ stage._prevStage = this;
+ }
+ this._nextStage = stage;
+ }
+ }]);
+ return Stage;
+ }(Container);
+
+ function createCanvas(width, height) {
+ if (width === void 0) {
+ width = 1;
+ }
+ if (height === void 0) {
+ height = 1;
+ }
+ var c;
+ if (window.createjs !== undefined && window.createjs.createCanvas !== undefined) {
+ c = window.createjs.createCanvas();
+ }
+ if (window.document !== undefined && window.document.createElement !== undefined) {
+ c = document.createElement("canvas");
+ }
+ if (c !== undefined) {
+ c.width = width;
+ c.height = height;
+ return c;
+ }
+ throw "Canvas not supported in this environment.";
+ }
+
+ var VideoBuffer =
+ function () {
+ function VideoBuffer(video) {
+ this.readyState = video.readyState;
+ this._video = video;
+ this._canvas = null;
+ this._lastTime = -1;
+ if (this.readyState < 2) {
+ video.addEventListener("canplaythrough", this._videoReady.bind(this));
+ }
+ }
+ var _proto = VideoBuffer.prototype;
+ _proto.getImage = function getImage() {
+ if (this.readyState < 2) {
+ return;
+ }
+ var canvas = this._canvas,
+ video = this._video;
+ if (!canvas) {
+ canvas = this._canvas = createCanvas();
+ canvas.width = video.videoWidth;
+ canvas.height = video.videoHeight;
+ }
+ if (video.readyState >= 2 && video.currentTime !== this._lastTime) {
+ var ctx = canvas.getContext("2d");
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
+ this._lastTime = video.currentTime;
+ }
+ return canvas;
+ };
+ _proto._videoReady = function _videoReady() {
+ this.readyState = 2;
+ };
+ return VideoBuffer;
+ }();
+
+ var Bitmap =
+ function (_DisplayObject) {
+ _inheritsLoose(Bitmap, _DisplayObject);
+ function Bitmap(imageOrUri) {
+ var _this;
+ _this = _DisplayObject.call(this) || this;
+ if (typeof imageOrUri === "string") {
+ _this.image = document.createElement("img");
+ _this.image.src = imageOrUri;
+ } else {
+ _this.image = imageOrUri;
+ }
+ _this.sourceRect = null;
+ _this._webGLRenderStyle = DisplayObject._StageGL_BITMAP;
+ return _this;
+ }
+ var _proto = Bitmap.prototype;
+ _proto.isVisible = function isVisible() {
+ var image = this.image;
+ var hasContent = this.cacheCanvas || image && (image.naturalWidth || image.getContext || image.readyState >= 2);
+ return !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && hasContent);
+ };
+ _proto.draw = function draw(ctx, ignoreCache) {
+ if (ignoreCache === void 0) {
+ ignoreCache = false;
+ }
+ if (_DisplayObject.prototype.draw.call(this, ctx, ignoreCache)) {
+ return true;
+ }
+ var img = this.image,
+ rect = this.sourceRect;
+ if (img instanceof VideoBuffer) {
+ img = img.getImage();
+ }
+ if (img == null) {
+ return true;
+ }
+ if (rect) {
+ var x1 = rect.x,
+ y1 = rect.y,
+ x2 = x1 + rect.width,
+ y2 = y1 + rect.height,
+ x = 0,
+ y = 0,
+ w = img.width,
+ h = img.height;
+ if (x1 < 0) {
+ x -= x1;
+ x1 = 0;
+ }
+ if (x2 > w) {
+ x2 = w;
+ }
+ if (y1 < 0) {
+ y -= y1;
+ y1 = 0;
+ }
+ if (y2 > h) {
+ y2 = h;
+ }
+ ctx.drawImage(img, x1, y1, x2 - x1, y2 - y1, x, y, x2 - x1, y2 - y1);
+ } else {
+ ctx.drawImage(img, 0, 0);
+ }
+ return true;
+ };
+ _proto.getBounds = function getBounds() {
+ var rect = _DisplayObject.prototype.getBounds.call(this);
+ if (rect) {
+ return rect;
+ }
+ var image = this.image,
+ o = this.sourceRect || image;
+ var hasContent = image && (image.naturalWidth || image.getContext || image.readyState >= 2);
+ return hasContent ? this._rectangle.setValues(0, 0, o.width, o.height) : null;
+ };
+ _proto.clone = function clone(node) {
+ var img = this.image;
+ if (img != null && node != null) {
+ img = img.cloneNode();
+ }
+ var bmp = new Bitmap(img);
+ if (this.sourceRect) {
+ bmp.sourceRect = this.sourceRect.clone();
+ }
+ this._cloneProps(bmp);
+ return bmp;
+ };
+ return Bitmap;
+ }(DisplayObject);
+
+ var Sprite =
+ function (_DisplayObject) {
+ _inheritsLoose(Sprite, _DisplayObject);
+ function Sprite(spriteSheet, frameOrAnimation) {
+ var _this;
+ _this = _DisplayObject.call(this) || this;
+ _this.currentFrame = 0;
+ _this.currentAnimation = null;
+ _this.paused = true;
+ _this.spriteSheet = spriteSheet;
+ _this.currentAnimationFrame = 0;
+ _this.framerate = 0;
+ _this._animation = null;
+ _this._currentFrame = null;
+ _this._skipAdvance = false;
+ _this._webGLRenderStyle = DisplayObject._StageGL_SPRITE;
+ if (frameOrAnimation != null) {
+ _this.gotoAndPlay(frameOrAnimation);
+ }
+ return _this;
+ }
+ var _proto = Sprite.prototype;
+ _proto.isVisible = function isVisible() {
+ var hasContent = this.cacheCanvas || this.spriteSheet.complete;
+ return !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && hasContent);
+ };
+ _proto.draw = function draw(ctx, ignoreCache) {
+ if (_DisplayObject.prototype.draw.call(this, 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;
+ };
+ _proto.play = function play() {
+ this.paused = false;
+ };
+ _proto.stop = function stop() {
+ this.paused = true;
+ };
+ _proto.gotoAndPlay = function gotoAndPlay(frameOrAnimation) {
+ this.paused = false;
+ this._skipAdvance = true;
+ this._goto(frameOrAnimation);
+ };
+ _proto.gotoAndStop = function gotoAndStop(frameOrAnimation) {
+ this.paused = true;
+ this._goto(frameOrAnimation);
+ };
+ _proto.advance = function advance(time) {
+ var fps = this.framerate || this.spriteSheet.framerate;
+ var t = fps && time != null ? time / (1000 / fps) : 1;
+ this._normalizeFrame(t);
+ };
+ _proto.getBounds = function getBounds() {
+ return _DisplayObject.prototype.getBounds.call(this) || this.spriteSheet.getFrameBounds(this.currentFrame, this._rectangle);
+ };
+ _proto.clone = function clone() {
+ return this._cloneProps(new Sprite(this.spriteSheet));
+ };
+ _proto._cloneProps = function _cloneProps(o) {
+ _DisplayObject.prototype._cloneProps.call(this, 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;
+ };
+ _proto._tick = function _tick(evtObj) {
+ if (!this.paused) {
+ if (!this._skipAdvance) {
+ this.advance(evtObj && evtObj.delta);
+ }
+ this._skipAdvance = false;
+ }
+ _DisplayObject.prototype._tick.call(this, evtObj);
+ };
+ _proto._normalizeFrame = function _normalizeFrame(frameDelta) {
+ if (frameDelta === void 0) {
+ frameDelta = 0;
+ }
+ var animation = this._animation;
+ var paused = this.paused;
+ var frame = this._currentFrame;
+ if (animation) {
+ var speed = animation.speed || 1;
+ var animFrame = this.currentAnimationFrame;
+ var l = animation.frames.length;
+ if (animFrame + frameDelta * speed >= l) {
+ var next = animation.next;
+ if (this._dispatchAnimationEnd(animation, frame, paused, next, l - 1)) {
+ return;
+ } else if (next) {
+ return this._goto(next, frameDelta - (l - animFrame) / speed);
+ } else {
+ 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;
+ var _l = this.spriteSheet.getNumFrames();
+ if (frame >= _l && _l > 0) {
+ if (!this._dispatchAnimationEnd(animation, frame, paused, _l - 1)) {
+ if ((this._currentFrame -= _l) >= _l) {
+ return this._normalizeFrame();
+ }
+ }
+ }
+ }
+ frame = this._currentFrame | 0;
+ if (this.currentFrame != frame) {
+ this.currentFrame = frame;
+ this.dispatchEvent("change");
+ }
+ };
+ _proto._dispatchAnimationEnd = function _dispatchAnimationEnd(animation, frame, paused, next, end) {
+ var name = animation ? animation.name : null;
+ if (this.hasEventListener("animationend")) {
+ var evt = new Event("animationend");
+ evt.name = name;
+ evt.next = next;
+ this.dispatchEvent(evt);
+ }
+ var changed = this._animation != animation || this._currentFrame != frame;
+ if (!changed && !paused && this.paused) {
+ this.currentAnimationFrame = end;
+ changed = true;
+ }
+ return changed;
+ };
+ _proto._goto = function _goto(frameOrAnimation, frame) {
+ if (frame === void 0) {
+ frame = 0;
+ }
+ 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();
+ }
+ };
+ return Sprite;
+ }(DisplayObject);
+
+ var BitmapText =
+ function (_Container) {
+ _inheritsLoose(BitmapText, _Container);
+ function BitmapText(text, spriteSheet) {
+ var _this;
+ if (text === void 0) {
+ text = "";
+ }
+ if (spriteSheet === void 0) {
+ spriteSheet = null;
+ }
+ _this = _Container.call(this) || this;
+ _this.text = text;
+ _this.spriteSheet = spriteSheet;
+ _this.lineHeight = 0;
+ _this.letterSpacing = 0;
+ _this.spaceWidth = 0;
+ _this._oldProps = {
+ text: 0,
+ spriteSheet: 0,
+ lineHeight: 0,
+ letterSpacing: 0,
+ spaceWidth: 0
+ };
+ _this._oldStage = null;
+ _this._drawAction = null;
+ return _this;
+ }
+ var _proto = BitmapText.prototype;
+ _proto.draw = function draw(ctx, ignoreCache) {
+ if (this.drawCache(ctx, ignoreCache)) {
+ return;
+ }
+ this._updateState();
+ _Container.prototype.draw.call(this, ctx, ignoreCache);
+ };
+ _proto.getBounds = function getBounds() {
+ this._updateText();
+ return _Container.prototype.getBounds.call(this);
+ };
+ _proto.isVisible = function isVisible() {
+ var hasContent = this.cacheCanvas || this.spriteSheet && this.spriteSheet.complete && this.text;
+ return !!(this.visible && this.alpha > 0 && this.scaleX !== 0 && this.scaleY !== 0 && hasContent);
+ };
+ _proto.clone = function clone() {
+ return this._cloneProps(new BitmapText(this.text, this.spriteSheet));
+ };
+ _proto.addChild = function addChild() {};
+ _proto.addChildAt = function addChildAt() {};
+ _proto.removeChild = function removeChild() {};
+ _proto.removeChildAt = function removeChildAt() {};
+ _proto.removeAllChildren = function removeAllChildren() {};
+ _proto._updateState = function _updateState() {
+ this._updateText();
+ };
+ _proto._cloneProps = function _cloneProps(o) {
+ _Container.prototype._cloneProps.call(this, o);
+ o.lineHeight = this.lineHeight;
+ o.letterSpacing = this.letterSpacing;
+ o.spaceWidth = this.spaceWidth;
+ return o;
+ };
+ _proto._getFrameIndex = function _getFrameIndex(character, spriteSheet) {
+ var c,
+ o = spriteSheet.getAnimation(character);
+ if (!o) {
+ character != (c = character.toUpperCase()) || character != (c = character.toLowerCase()) || (c = null);
+ if (c) {
+ o = spriteSheet.getAnimation(c);
+ }
+ }
+ return o && o.frames[0];
+ };
+ _proto._getFrame = function _getFrame(character, spriteSheet) {
+ var index = this._getFrameIndex(character, spriteSheet);
+ return index == null ? index : spriteSheet.getFrame(index);
+ };
+ _proto._getLineHeight = function _getLineHeight(ss) {
+ var frame = this._getFrame("1", ss) || this._getFrame("T", ss) || this._getFrame("L", ss) || ss.getFrame(0);
+ return frame ? frame.rect.height : 1;
+ };
+ _proto._getSpaceWidth = function _getSpaceWidth(ss) {
+ var frame = this._getFrame("1", ss) || this._getFrame("l", ss) || this._getFrame("e", ss) || this._getFrame("a", ss) || ss.getFrame(0);
+ return frame ? frame.rect.width : 1;
+ };
+ _proto._tick = function _tick(evtObj) {
+ var stage = this.stage;
+ stage && stage.on("drawstart", this._updateText, this, true);
+ _Container.prototype._tick.call(this, evtObj);
+ };
+ _proto._updateText = function _updateText() {
+ var x = 0,
+ y = 0,
+ o = this._oldProps,
+ change = false,
+ spaceW = this.spaceWidth,
+ lineH = this.lineHeight,
+ ss = this.spriteSheet;
+ var pool = BitmapText._spritePool,
+ kids = this.children,
+ childIndex = 0,
+ numKids = kids.length,
+ sprite;
+ for (var n in o) {
+ if (o[n] != this[n]) {
+ o[n] = this[n];
+ change = true;
+ }
+ }
+ if (!change) {
+ return;
+ }
+ var hasSpace = !!this._getFrame(" ", ss);
+ if (!hasSpace && !spaceW) {
+ spaceW = this._getSpaceWidth(ss);
+ }
+ if (!lineH) {
+ lineH = this._getLineHeight(ss);
+ }
+ for (var i = 0, l = this.text.length; i < l; i++) {
+ var character = this.text.charAt(i);
+ if (character === " " && !hasSpace) {
+ x += spaceW;
+ continue;
+ } else if (character === "\n" || character === "\r") {
+ if (character === "\r" && this.text.charAt(i + 1) === "\n") {
+ i++;
+ }
+ x = 0;
+ y += lineH;
+ continue;
+ }
+ var index = this._getFrameIndex(character, ss);
+ if (index == null) {
+ continue;
+ }
+ if (childIndex < numKids) {
+ sprite = kids[childIndex];
+ } else {
+ kids.push(sprite = pool.length ? pool.pop() : new Sprite());
+ sprite.parent = this;
+ numKids++;
+ }
+ sprite.spriteSheet = ss;
+ sprite.gotoAndStop(index);
+ sprite.x = x;
+ sprite.y = y;
+ childIndex++;
+ x += sprite.getBounds().width + this.letterSpacing;
+ }
+ while (numKids > childIndex) {
+ pool.push(sprite = kids.pop());
+ sprite.parent = null;
+ numKids--;
+ }
+ if (pool.length > BitmapText.maxPoolSize) {
+ pool.length = BitmapText.maxPoolSize;
+ }
+ };
+ return BitmapText;
+ }(Container);
+ BitmapText.maxPoolSize = 100;
+ BitmapText._spritePool = [];
+
+ var DOMElement =
+ function (_DisplayObject) {
+ _inheritsLoose(DOMElement, _DisplayObject);
+ function DOMElement(htmlElement) {
+ var _this;
+ _this = _DisplayObject.call(this) || this;
+ if (typeof htmlElement === "string") {
+ htmlElement = document.getElementById(htmlElement);
+ }
+ _this.mouseEnabled = false;
+ var style = htmlElement.style;
+ style.position = "absolute";
+ style.transformOrigin = style.WebkitTransformOrigin = style.msTransformOrigin = style.MozTransformOrigin = style.OTransformOrigin = "0% 0%";
+ _this.htmlElement = htmlElement;
+ _this._oldProps = null;
+ _this._oldStage = null;
+ _this._drawAction = null;
+ return _this;
+ }
+ var _proto = DOMElement.prototype;
+ _proto.isVisible = function isVisible() {
+ return this.htmlElement != null;
+ };
+ _proto.draw = function draw(ctx, ignoreCache) {
+ return true;
+ };
+ _proto.cache = function cache() {};
+ _proto.uncache = function uncache() {};
+ _proto.updateCache = function updateCache() {};
+ _proto.hitTest = function hitTest() {};
+ _proto.localToGlobal = function localToGlobal() {};
+ _proto.globalToLocal = function globalToLocal() {};
+ _proto.localToLocal = function localToLocal() {};
+ _proto.clone = function clone() {
+ throw "DOMElement cannot be cloned.";
+ };
+ _proto._tick = function _tick(evtObj) {
+ var stage = this.stage;
+ if (stage != null && stage !== this._oldStage) {
+ this._drawAction && stage.off("drawend", this._drawAction);
+ this._drawAction = stage.on("drawend", this._handleDrawEnd, this);
+ this._oldStage = stage;
+ }
+ _DisplayObject.prototype._tick.call(this, evtObj);
+ };
+ _proto._handleDrawEnd = function _handleDrawEnd(evt) {
+ var o = this.htmlElement;
+ if (!o) {
+ return;
+ }
+ var style = o.style;
+ var props = this.getConcatenatedDisplayProps(this._props),
+ mtx = props.matrix;
+ var visibility = props.visible ? "visible" : "hidden";
+ if (visibility != style.visibility) {
+ style.visibility = visibility;
+ }
+ if (!props.visible) {
+ return;
+ }
+ var oldProps = this._oldProps,
+ oldMtx = oldProps && oldProps.matrix;
+ var n = 10000;
+ if (!oldMtx || !oldMtx.equals(mtx)) {
+ var str = "matrix(" + (mtx.a * n | 0) / n + "," + (mtx.b * n | 0) / n + "," + (mtx.c * n | 0) / n + "," + (mtx.d * n | 0) / n + "," + (mtx.tx + 0.5 | 0);
+ style.transform = style.WebkitTransform = style.OTransform = style.msTransform = str + "," + (mtx.ty + 0.5 | 0) + ")";
+ style.MozTransform = str + "px," + (mtx.ty + 0.5 | 0) + "px)";
+ if (!oldProps) {
+ oldProps = this._oldProps = new DisplayProps(true, null);
+ }
+ oldProps.matrix.copy(mtx);
+ }
+ if (oldProps.alpha != props.alpha) {
+ style.opacity = "" + (props.alpha * n | 0) / n;
+ oldProps.alpha = props.alpha;
+ }
+ };
+ return DOMElement;
+ }(DisplayObject);
+
+ var Graphics =
+ function () {
+ function Graphics() {
+ this.command = null;
+ this._stroke = null;
+ this._strokeStyle = null;
+ this._oldStrokeStyle = null;
+ this._strokeDash = null;
+ this._oldStrokeDash = null;
+ this._fill = null;
+ this._strokeIgnoreScale = false;
+ this._commitIndex = 0;
+ this._instructions = [];
+ this._activeInstructions = [];
+ this._dirty = false;
+ this._storeIndex = 0;
+ this.curveTo = this.quadraticCurveTo;
+ this.drawRect = this.rect;
+ this.mt = this.moveTo;
+ this.lt = this.lineTo;
+ this.at = this.arcTo;
+ this.bt = this.bezierCurveTo;
+ this.qt = this.quadraticCurveTo;
+ this.a = this.arc;
+ this.r = this.rect;
+ this.cp = this.closePath;
+ this.c = this.clear;
+ this.f = this.beginFill;
+ this.lf = this.beginLinearGradientFill;
+ this.rf = this.beginRadialGradientFill;
+ this.bf = this.beginBitmapFill;
+ this.ef = this.endFill;
+ this.ss = this.setStrokeStyle;
+ this.sd = this.setStrokeDash;
+ this.s = this.beginStroke;
+ this.ls = this.beginLinearGradientStroke;
+ this.rs = this.beginRadialGradientStroke;
+ this.bs = this.beginBitmapStroke;
+ this.es = this.endStroke;
+ this.dr = this.drawRect;
+ this.rr = this.drawRoundRect;
+ this.rc = this.drawRoundRectComplex;
+ this.dc = this.drawCircle;
+ this.de = this.drawEllipse;
+ this.dp = this.drawPolyStar;
+ this.p = this.decodePath;
+ this.clear();
+ }
+ Graphics.getRGB = function getRGB(r, g, b, alpha) {
+ if (r != null && b == null) {
+ alpha = g;
+ b = r & 0xFF;
+ g = r >> 8 & 0xFF;
+ r = r >> 16 & 0xFF;
+ }
+ if (alpha == null) {
+ return "rgb(" + r + "," + g + "," + b + ")";
+ } else {
+ return "rgba(" + r + "," + g + "," + b + "," + alpha + ")";
+ }
+ };
+ Graphics.getHSL = function getHSL(hue, saturation, lightness, alpha) {
+ if (alpha == null) {
+ return "hsl(" + hue % 360 + "," + saturation + "%," + lightness + "%)";
+ } else {
+ return "hsl(" + hue % 360 + "," + saturation + "%," + lightness + "%," + alpha + ")";
+ }
+ };
+ var _proto = Graphics.prototype;
+ _proto.isEmpty = function isEmpty() {
+ return !(this._instructions.length || this._activeInstructions.length);
+ };
+ _proto.draw = function draw(ctx, data) {
+ this._updateInstructions();
+ var instr = this._instructions;
+ var l = instr.length;
+ for (var i = this._storeIndex; i < l; i++) {
+ instr[i].exec(ctx, data);
+ }
+ };
+ _proto.drawAsPath = function drawAsPath(ctx) {
+ this._updateInstructions();
+ var instr,
+ instrs = this._instructions;
+ var l = instrs.length;
+ for (var i = this._storeIndex; i < l; i++) {
+ if ((instr = instrs[i]).path !== false) {
+ instr.exec(ctx);
+ }
+ }
+ };
+ _proto.moveTo = function moveTo(x, y) {
+ return this.append(new MoveTo(x, y), true);
+ };
+ _proto.lineTo = function lineTo(x, y) {
+ return this.append(new LineTo(x, y));
+ };
+ _proto.arcTo = function arcTo(x1, y1, x2, y2, radius) {
+ return this.append(new ArcTo(x1, y1, x2, y2, radius));
+ };
+ _proto.arc = function arc(x, y, radius, startAngle, endAngle, anticlockwise) {
+ return this.append(new Arc(x, y, radius, startAngle, endAngle, anticlockwise));
+ };
+ _proto.quadraticCurveTo = function quadraticCurveTo(cpx, cpy, x, y) {
+ return this.append(new QuadraticCurveTo(cpx, cpy, x, y));
+ };
+ _proto.bezierCurveTo = function bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
+ return this.append(new BezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y));
+ };
+ _proto.rect = function rect(x, y, w, h) {
+ return this.append(new Rect(x, y, w, h));
+ };
+ _proto.closePath = function closePath() {
+ return this._activeInstructions.length ? this.append(new ClosePath()) : this;
+ };
+ _proto.clear = function clear() {
+ this._instructions.length = this._activeInstructions.length = this._commitIndex = 0;
+ this._strokeStyle = this._oldStrokeStyle = this._stroke = this._fill = this._strokeDash = this._oldStrokeDash = null;
+ this._dirty = this._strokeIgnoreScale = false;
+ return this;
+ };
+ _proto.beginFill = function beginFill(color) {
+ return this._setFill(color ? new Fill(color) : null);
+ };
+ _proto.beginLinearGradientFill = function beginLinearGradientFill(colors, ratios, x0, y0, x1, y1) {
+ return this._setFill(new Fill().linearGradient(colors, ratios, x0, y0, x1, y1));
+ };
+ _proto.beginRadialGradientFill = function beginRadialGradientFill(colors, ratios, x0, y0, r0, x1, y1, r1) {
+ return this._setFill(new Fill().radialGradient(colors, ratios, x0, y0, r0, x1, y1, r1));
+ };
+ _proto.beginBitmapFill = function beginBitmapFill(image, repetition, matrix) {
+ return this._setFill(new Fill(null, matrix).bitmap(image, repetition));
+ };
+ _proto.endFill = function endFill() {
+ return this.beginFill();
+ };
+ _proto.setStrokeStyle = function setStrokeStyle(thickness, caps, joints, miterLimit, ignoreScale) {
+ if (caps === void 0) {
+ caps = 0;
+ }
+ if (joints === void 0) {
+ joints = 0;
+ }
+ if (miterLimit === void 0) {
+ miterLimit = 10;
+ }
+ if (ignoreScale === void 0) {
+ ignoreScale = false;
+ }
+ this._updateInstructions(true);
+ this._strokeStyle = this.command = new StrokeStyle(thickness, caps, joints, miterLimit, ignoreScale);
+ if (this._stroke) {
+ this._stroke.ignoreScale = ignoreScale;
+ }
+ this._strokeIgnoreScale = ignoreScale;
+ return this;
+ };
+ _proto.setStrokeDash = function setStrokeDash(segments, offset) {
+ if (offset === void 0) {
+ offset = 0;
+ }
+ this._updateInstructions(true);
+ this._strokeDash = this.command = new StrokeDash(segments, offset);
+ return this;
+ };
+ _proto.beginStroke = function beginStroke(color) {
+ return this._setStroke(color ? new Stroke(color) : null);
+ };
+ _proto.beginLinearGradientStroke = function beginLinearGradientStroke(colors, ratios, x0, y0, x1, y1) {
+ return this._setStroke(new Stroke().linearGradient(colors, ratios, x0, y0, x1, y1));
+ };
+ _proto.beginRadialGradientStroke = function beginRadialGradientStroke(colors, ratios, x0, y0, r0, x1, y1, r1) {
+ return this._setStroke(new Stroke().radialGradient(colors, ratios, x0, y0, r0, x1, y1, r1));
+ };
+ _proto.beginBitmapStroke = function beginBitmapStroke(image, repetition) {
+ if (repetition === void 0) {
+ repetition = "repeat";
+ }
+ return this._setStroke(new Stroke().bitmap(image, repetition));
+ };
+ _proto.endStroke = function endStroke() {
+ return this.beginStroke();
+ };
+ _proto.drawRoundRect = function drawRoundRect(x, y, w, h, radius) {
+ return this.drawRoundRectComplex(x, y, w, h, radius, radius, radius, radius);
+ };
+ _proto.drawRoundRectComplex = function drawRoundRectComplex(x, y, w, h, radiusTL, radiusTR, radiusBR, radiusBL) {
+ return this.append(new RoundRect(x, y, w, h, radiusTL, radiusTR, radiusBR, radiusBL));
+ };
+ _proto.drawCircle = function drawCircle(x, y, radius) {
+ return this.append(new Circle(x, y, radius));
+ };
+ _proto.drawEllipse = function drawEllipse(x, y, w, h) {
+ return this.append(new Ellipse(x, y, w, h));
+ };
+ _proto.drawPolyStar = function drawPolyStar(x, y, radius, sides, pointSize, angle) {
+ return this.append(new PolyStar(x, y, radius, sides, pointSize, angle));
+ };
+ _proto.append = function append(command, clean) {
+ this._activeInstructions.push(command);
+ this.command = command;
+ if (!clean) {
+ this._dirty = true;
+ }
+ return this;
+ };
+ _proto.decodePath = function decodePath(str) {
+ var instructions = [this.moveTo, this.lineTo, this.quadraticCurveTo, this.bezierCurveTo, this.closePath];
+ var paramCount = [2, 2, 4, 6, 0];
+ var i = 0;
+ var l = str.length;
+ var params = [];
+ var x = 0,
+ y = 0;
+ var base64 = Graphics._BASE_64;
+ while (i < l) {
+ var c = str.charAt(i);
+ var n = base64[c];
+ var fi = n >> 3;
+ var f = instructions[fi];
+ if (!f || n & 3) {
+ throw "Bad path data (@" + i + "):c";
+ }
+ var pl = paramCount[fi];
+ if (!fi) {
+ x = y = 0;
+ }
+ params.length = 0;
+ i++;
+ var charCount = (n >> 2 & 1) + 2;
+ for (var p = 0; p < pl; p++) {
+ var num = base64[str.charAt(i)];
+ var sign = num >> 5 ? -1 : 1;
+ num = (num & 31) << 6 | base64[str.charAt(i + 1)];
+ if (charCount === 3) {
+ num = num << 6 | base64[str.charAt(i + 2)];
+ }
+ num = sign * num / 10;
+ if (p % 2) {
+ x = num += x;
+ } else {
+ y = num += y;
+ }
+ params[p] = num;
+ i += charCount;
+ }
+ f.apply(this, params);
+ }
+ return this;
+ };
+ _proto.store = function store() {
+ this._updateInstructions(true);
+ this._storeIndex = this._instructions.length;
+ return this;
+ };
+ _proto.unstore = function unstore() {
+ this._storeIndex = 0;
+ return this;
+ };
+ _proto.clone = function clone() {
+ var o = new Graphics();
+ o.command = this.command;
+ o._stroke = this._stroke;
+ o._strokeStyle = this._strokeStyle;
+ o._strokeDash = this._strokeDash;
+ o._strokeIgnoreScale = this._strokeIgnoreScale;
+ o._fill = this._fill;
+ o._instructions = this._instructions.slice();
+ o._commitIndex = this._commitIndex;
+ o._activeInstructions = this._activeInstructions.slice();
+ o._dirty = this._dirty;
+ o._storeIndex = this._storeIndex;
+ return o;
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + "]";
+ };
+ _proto._updateInstructions = function _updateInstructions(commit) {
+ var instr = this._instructions,
+ active = this._activeInstructions,
+ commitIndex = this._commitIndex;
+ if (this._dirty && active.length) {
+ instr.length = commitIndex;
+ instr.push(Graphics.beginCmd);
+ var l = active.length,
+ ll = instr.length;
+ instr.length = ll + l;
+ for (var i = 0; i < l; i++) {
+ instr[i + ll] = active[i];
+ }
+ if (this._fill) {
+ instr.push(this._fill);
+ }
+ if (this._stroke) {
+ if (this._strokeDash !== this._oldStrokeDash) {
+ instr.push(this._strokeDash);
+ }
+ if (this._strokeStyle !== this._oldStrokeStyle) {
+ instr.push(this._strokeStyle);
+ }
+ if (commit) {
+ this._oldStrokeDash = this._strokeDash;
+ this._oldStrokeStyle = this._strokeStyle;
+ }
+ instr.push(this._stroke);
+ }
+ this._dirty = false;
+ }
+ if (commit) {
+ active.length = 0;
+ this._commitIndex = instr.length;
+ }
+ };
+ _proto._setFill = function _setFill(fill) {
+ this._updateInstructions(true);
+ this.command = this._fill = fill;
+ return this;
+ };
+ _proto._setStroke = function _setStroke(stroke) {
+ this._updateInstructions(true);
+ if (this.command = this._stroke = stroke) {
+ stroke.ignoreScale = this._strokeIgnoreScale;
+ }
+ return this;
+ };
+ _createClass(Graphics, [{
+ key: "instructions",
+ get: function get() {
+ this._updateInstructions();
+ return this._instructions;
+ }
+ }], [{
+ key: "LineTo",
+ get: function get() {
+ return LineTo;
+ }
+ }, {
+ key: "MoveTo",
+ get: function get() {
+ return MoveTo;
+ }
+ }, {
+ key: "ArcTo",
+ get: function get() {
+ return ArcTo;
+ }
+ }, {
+ key: "Arc",
+ get: function get() {
+ return Arc;
+ }
+ }, {
+ key: "QuadraticCurveTo",
+ get: function get() {
+ return QuadraticCurveTo;
+ }
+ }, {
+ key: "BezierCurveTo",
+ get: function get() {
+ return BezierCurveTo;
+ }
+ }, {
+ key: "Rect",
+ get: function get() {
+ return Rect;
+ }
+ }, {
+ key: "ClosePath",
+ get: function get() {
+ return ClosePath;
+ }
+ }, {
+ key: "BeginPath",
+ get: function get() {
+ return BeginPath;
+ }
+ }, {
+ key: "Fill",
+ get: function get() {
+ return Fill;
+ }
+ }, {
+ key: "Stroke",
+ get: function get() {
+ return Stroke;
+ }
+ }, {
+ key: "StrokeStyle",
+ get: function get() {
+ return StrokeStyle;
+ }
+ }, {
+ key: "StrokeDash",
+ get: function get() {
+ return StrokeDash;
+ }
+ }, {
+ key: "RoundRect",
+ get: function get() {
+ return RoundRect;
+ }
+ }, {
+ key: "Circle",
+ get: function get() {
+ return Circle;
+ }
+ }, {
+ key: "Ellipse",
+ get: function get() {
+ return Ellipse;
+ }
+ }, {
+ key: "PolyStar",
+ get: function get() {
+ return PolyStar;
+ }
+ }]);
+ return Graphics;
+ }();
+ var LineTo =
+ function () {
+ function LineTo(x, y) {
+ this.x = x;
+ this.y = y;
+ }
+ var _proto2 = LineTo.prototype;
+ _proto2.exec = function exec(ctx) {
+ ctx.lineTo(this.x, this.y);
+ };
+ return LineTo;
+ }();
+ var MoveTo =
+ function () {
+ function MoveTo(x, y) {
+ this.x = x;
+ this.y = y;
+ }
+ var _proto3 = MoveTo.prototype;
+ _proto3.exec = function exec(ctx) {
+ ctx.moveTo(this.x, this.y);
+ };
+ return MoveTo;
+ }();
+ var ArcTo =
+ function () {
+ function ArcTo(x1, y1, x2, y2, radius) {
+ this.x1 = x1;
+ this.y1 = y1;
+ this.x2 = x2;
+ this.y2 = y2;
+ this.radius = radius;
+ }
+ var _proto4 = ArcTo.prototype;
+ _proto4.exec = function exec(ctx) {
+ ctx.arcTo(this.x1, this.y1, this.x2, this.y2, this.radius);
+ };
+ return ArcTo;
+ }();
+ var Arc =
+ function () {
+ function Arc(x, y, radius, startAngle, endAngle, anticlockwise) {
+ if (anticlockwise === void 0) {
+ anticlockwise = false;
+ }
+ this.x = x;
+ this.y = y;
+ this.radius = radius;
+ this.startAngle = startAngle;
+ this.endAngle = endAngle;
+ this.anticlockwise = anticlockwise;
+ }
+ var _proto5 = Arc.prototype;
+ _proto5.exec = function exec(ctx) {
+ ctx.arc(this.x, this.y, this.radius, this.startAngle, this.endAngle, this.anticlockwise);
+ };
+ return Arc;
+ }();
+ var QuadraticCurveTo =
+ function () {
+ function QuadraticCurveTo(cpx, cpy, x, y) {
+ this.cpx = cpx;
+ this.cpy = cpy;
+ this.x = x;
+ this.y = y;
+ }
+ var _proto6 = QuadraticCurveTo.prototype;
+ _proto6.exec = function exec(ctx) {
+ ctx.quadraticCurveTo(this.cpx, this.cpy, this.x, this.y);
+ };
+ return QuadraticCurveTo;
+ }();
+ var BezierCurveTo =
+ function () {
+ function BezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
+ this.cp1x = cp1x;
+ this.cp1y = cp1y;
+ this.cp2x = cp2x;
+ this.cp2y = cp2y;
+ this.x = x;
+ this.y = y;
+ }
+ var _proto7 = BezierCurveTo.prototype;
+ _proto7.exec = function exec(ctx) {
+ ctx.bezierCurveTo(this.cp1x, this.cp1y, this.cp2x, this.cp2y, this.x, this.y);
+ };
+ return BezierCurveTo;
+ }();
+ var Rect =
+ function () {
+ function Rect(x, y, w, h) {
+ this.x = x;
+ this.y = y;
+ this.w = w;
+ this.h = h;
+ }
+ var _proto8 = Rect.prototype;
+ _proto8.exec = function exec(ctx) {
+ ctx.rect(this.x, this.y, this.w, this.h);
+ };
+ return Rect;
+ }();
+ var ClosePath =
+ function () {
+ function ClosePath() {}
+ var _proto9 = ClosePath.prototype;
+ _proto9.exec = function exec(ctx) {
+ ctx.closePath();
+ };
+ return ClosePath;
+ }();
+ var BeginPath =
+ function () {
+ function BeginPath() {}
+ var _proto10 = BeginPath.prototype;
+ _proto10.exec = function exec(ctx) {
+ ctx.beginPath();
+ };
+ return BeginPath;
+ }();
+ var Fill =
+ function () {
+ function Fill(style, matrix) {
+ this.style = style;
+ this.matrix = matrix;
+ this.path = false;
+ }
+ var _proto11 = Fill.prototype;
+ _proto11.exec = function exec(ctx) {
+ if (!this.style) {
+ return;
+ }
+ ctx.fillStyle = this.style;
+ var mtx = this.matrix;
+ if (mtx) {
+ ctx.save();
+ ctx.transform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx, mtx.ty);
+ }
+ ctx.fill();
+ if (mtx) {
+ ctx.restore();
+ }
+ };
+ _proto11.linearGradient = function linearGradient(colors, ratios, x0, y0, x1, y1) {
+ var o = this.style = Graphics._ctx.createLinearGradient(x0, y0, x1, y1);
+ var l = colors.length;
+ for (var i = 0; i < l; i++) {
+ o.addColorStop(ratios[i], colors[i]);
+ }
+ o.props = {
+ colors: colors,
+ ratios: ratios,
+ x0: x0,
+ y0: y0,
+ x1: x1,
+ y1: y1,
+ type: "linear"
+ };
+ return this;
+ };
+ _proto11.radialGradient = function radialGradient(colors, ratios, x0, y0, r0, x1, y1, r1) {
+ var o = this.style = Graphics._ctx.createRadialGradient(x0, y0, r0, x1, y1, r1);
+ var l = colors.length;
+ for (var i = 0; i < l; i++) {
+ o.addColorStop(ratios[i], colors[i]);
+ }
+ o.props = {
+ colors: colors,
+ ratios: ratios,
+ x0: x0,
+ y0: y0,
+ r0: r0,
+ x1: x1,
+ y1: y1,
+ r1: r1,
+ type: "radial"
+ };
+ return this;
+ };
+ _proto11.bitmap = function bitmap(image, repetition) {
+ if (repetition === void 0) {
+ repetition = "";
+ }
+ if (image.naturalWidth || image.getContext || image.readyState >= 2) {
+ var o = this.style = Graphics._ctx.createPattern(image, repetition);
+ o.props = {
+ image: image,
+ repetition: repetition,
+ type: "bitmap"
+ };
+ }
+ return this;
+ };
+ return Fill;
+ }();
+ var Stroke =
+ function (_Fill) {
+ _inheritsLoose(Stroke, _Fill);
+ function Stroke(style, ignoreScale) {
+ var _this;
+ _this = _Fill.call(this) || this;
+ _this.style = style;
+ _this.ignoreScale = ignoreScale;
+ _this.path = false;
+ return _this;
+ }
+ var _proto12 = Stroke.prototype;
+ _proto12.exec = function exec(ctx) {
+ if (!this.style) {
+ return;
+ }
+ ctx.strokeStyle = this.style;
+ if (this.ignoreScale) {
+ ctx.save();
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
+ }
+ ctx.stroke();
+ if (this.ignoreScale) {
+ ctx.restore();
+ }
+ };
+ return Stroke;
+ }(Fill);
+ var StrokeStyle =
+ function () {
+ function StrokeStyle(width, caps, joints, miterLimit, ignoreScale) {
+ if (width === void 0) {
+ width = 1;
+ }
+ if (caps === void 0) {
+ caps = "butt";
+ }
+ if (joints === void 0) {
+ joints = "miter";
+ }
+ if (miterLimit === void 0) {
+ miterLimit = 10;
+ }
+ if (ignoreScale === void 0) {
+ ignoreScale = false;
+ }
+ this.width = width;
+ this.caps = caps;
+ this.joints = joints;
+ this.miterLimit = miterLimit;
+ this.ignoreScale = ignoreScale;
+ this.path = false;
+ }
+ var _proto13 = StrokeStyle.prototype;
+ _proto13.exec = function exec(ctx) {
+ ctx.lineWidth = this.width;
+ ctx.lineCap = isNaN(this.caps) ? this.caps : Graphics._STROKE_CAPS_MAP[this.caps];
+ ctx.lineJoin = isNaN(this.joints) ? this.joints : Graphics._STROKE_JOINTS_MAP[this.joints];
+ ctx.miterLimit = this.miterLimit;
+ ctx.ignoreScale = this.ignoreScale;
+ };
+ return StrokeStyle;
+ }();
+ var StrokeDash =
+ function () {
+ function StrokeDash(segments, offset) {
+ if (segments === void 0) {
+ segments = [];
+ }
+ if (offset === void 0) {
+ offset = 0;
+ }
+ this.segments = segments;
+ this.offset = offset;
+ }
+ var _proto14 = StrokeDash.prototype;
+ _proto14.exec = function exec(ctx) {
+ if (ctx.setLineDash) {
+ ctx.setLineDash(this.segments);
+ ctx.lineDashOffset = this.offset;
+ }
+ };
+ return StrokeDash;
+ }();
+ var RoundRect =
+ function () {
+ function RoundRect(x, y, w, h, radiusTL, radiusTR, radiusBR, radiusBL) {
+ this.x = x;
+ this.y = y;
+ this.w = w;
+ this.h = h;
+ this.radiusTL = radiusTL;
+ this.radiusTR = radiusTR;
+ this.radiusBR = radiusBR;
+ this.radiusBL = radiusBL;
+ }
+ var _proto15 = RoundRect.prototype;
+ _proto15.exec = function exec(ctx) {
+ var max = (this.w < this.h ? this.w : this.h) / 2;
+ var mTL = 0,
+ mTR = 0,
+ mBR = 0,
+ mBL = 0;
+ var x = this.x,
+ y = this.y,
+ w = this.w,
+ h = this.h;
+ var rTL = this.radiusTL,
+ rTR = this.radiusTR,
+ rBR = this.radiusBR,
+ rBL = this.radiusBL;
+ if (rTL < 0) {
+ rTL *= mTL = -1;
+ }
+ if (rTL > max) {
+ rTL = max;
+ }
+ if (rTR < 0) {
+ rTR *= mTR = -1;
+ }
+ if (rTR > max) {
+ rTR = max;
+ }
+ if (rBR < 0) {
+ rBR *= mBR = -1;
+ }
+ if (rBR > max) {
+ rBR = max;
+ }
+ if (rBL < 0) {
+ rBL *= mBL = -1;
+ }
+ if (rBL > max) {
+ rBL = max;
+ }
+ ctx.moveTo(x + w - rTR, y);
+ ctx.arcTo(x + w + rTR * mTR, y - rTR * mTR, x + w, y + rTR, rTR);
+ ctx.lineTo(x + w, y + h - rBR);
+ ctx.arcTo(x + w + rBR * mBR, y + h + rBR * mBR, x + w - rBR, y + h, rBR);
+ ctx.lineTo(x + rBL, y + h);
+ ctx.arcTo(x - rBL * mBL, y + h + rBL * mBL, x, y + h - rBL, rBL);
+ ctx.lineTo(x, y + rTL);
+ ctx.arcTo(x - rTL * mTL, y - rTL * mTL, x + rTL, y, rTL);
+ ctx.closePath();
+ };
+ return RoundRect;
+ }();
+ var Circle =
+ function () {
+ function Circle(x, y, radius) {
+ this.x = x;
+ this.y = y;
+ this.radius = radius;
+ }
+ var _proto16 = Circle.prototype;
+ _proto16.exec = function exec(ctx) {
+ ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2);
+ };
+ return Circle;
+ }();
+ var Ellipse =
+ function () {
+ function Ellipse(x, y, w, h) {
+ this.x = x;
+ this.y = y;
+ this.w = w;
+ this.h = h;
+ }
+ var _proto17 = Ellipse.prototype;
+ _proto17.exec = function exec(ctx) {
+ var x = this.x,
+ y = this.y;
+ var w = this.w,
+ h = this.h;
+ var k = 0.5522848;
+ var ox = w / 2 * k;
+ var oy = h / 2 * k;
+ var xe = x + w;
+ var ye = y + h;
+ var xm = x + w / 2;
+ var ym = y + h / 2;
+ ctx.moveTo(x, ym);
+ ctx.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y);
+ ctx.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym);
+ ctx.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye);
+ ctx.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym);
+ };
+ return Ellipse;
+ }();
+ var PolyStar =
+ function () {
+ function PolyStar(x, y, radius, sides, pointSize, angle) {
+ if (pointSize === void 0) {
+ pointSize = 0;
+ }
+ if (angle === void 0) {
+ angle = 0;
+ }
+ this.x = x;
+ this.y = y;
+ this.radius = radius;
+ this.sides = sides;
+ this.pointSize = pointSize;
+ this.angle = angle;
+ }
+ var _proto18 = PolyStar.prototype;
+ _proto18.exec = function exec(ctx) {
+ var x = this.x,
+ y = this.y;
+ var radius = this.radius;
+ var angle = this.angle / 180 * Math.PI;
+ var sides = this.sides;
+ var ps = 1 - this.pointSize;
+ var a = Math.PI / sides;
+ ctx.moveTo(x + Math.cos(angle) * radius, y + Math.sin(angle) * radius);
+ for (var i = 0; i < sides; i++) {
+ angle += a;
+ if (ps != 1) {
+ ctx.lineTo(x + Math.cos(angle) * radius * ps, y + Math.sin(angle) * radius * ps);
+ }
+ angle += a;
+ ctx.lineTo(x + Math.cos(angle) * radius, y + Math.sin(angle) * radius);
+ }
+ ctx.closePath();
+ };
+ return PolyStar;
+ }();
+ Graphics.beginCmd = new BeginPath();
+ Graphics._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
+ };
+ Graphics._STROKE_CAPS_MAP = ["butt", "round", "square"];
+ Graphics._STROKE_JOINTS_MAP = ["miter", "round", "bevel"];
+ Graphics._ctx = createCanvas().getContext("2d");
+
+ var MovieClip =
+ function (_Container) {
+ _inheritsLoose(MovieClip, _Container);
+ function MovieClip(props) {
+ var _this;
+ _this = _Container.call(this) || this;
+ !MovieClip.inited && MovieClip.init();
+ _this.mode = props.mode != null ? props.mode : MovieClip.INDEPENDENT;
+ _this.startPosition = props.startPosition != null ? props.startPosition : 0;
+ if (typeof props.loop === "number") {
+ _this.loop = props.loop;
+ } else if (props.loop === false) {
+ _this.loop = 0;
+ } else {
+ _this.loop = -1;
+ }
+ _this.currentFrame = 0;
+ _this.timeline = new tweenjs.Timeline(Object.assign({
+ useTicks: true,
+ paused: true
+ }, props));
+ _this.paused = props.paused != null ? props.paused : false;
+ _this.actionsEnabled = true;
+ _this.autoReset = true;
+ _this.frameBounds = _this.frameBounds || props.frameBounds;
+ _this.framerate = null;
+ _this._synchOffset = 0;
+ _this._rawPosition = -1;
+ _this._t = 0;
+ _this._managed = {};
+ _this._bound_resolveState = _this._resolveState.bind(_assertThisInitialized(_assertThisInitialized(_this)));
+ return _this;
+ }
+ MovieClip.init = function init() {
+ if (MovieClip.inited) {
+ return;
+ }
+ MovieClipPlugin.install();
+ MovieClip.inited = true;
+ };
+ var _proto = MovieClip.prototype;
+ _proto.isVisible = function isVisible() {
+ return !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0);
+ };
+ _proto.draw = function draw(ctx, ignoreCache) {
+ if (this.drawCache(ctx, ignoreCache)) {
+ return true;
+ }
+ this._updateState();
+ _Container.prototype.draw.call(this, ctx, ignoreCache);
+ return true;
+ };
+ _proto.play = function play() {
+ this.paused = false;
+ };
+ _proto.stop = function stop() {
+ this.paused = true;
+ };
+ _proto.gotoAndPlay = function gotoAndPlay(positionOrLabel) {
+ this.play();
+ this._goto(positionOrLabel);
+ };
+ _proto.gotoAndStop = function gotoAndStop(positionOrLabel) {
+ this.stop();
+ this._goto(positionOrLabel);
+ };
+ _proto.advance = function advance(time) {
+ if (this.mode !== MovieClip.INDEPENDENT) {
+ return;
+ }
+ var o = this,
+ fps = o.framerate;
+ while ((o = o.parent) && fps === null) {
+ if (o.mode === MovieClip.INDEPENDENT) {
+ fps = o._framerate;
+ }
+ }
+ this._framerate = fps;
+ if (this.paused) {
+ return;
+ }
+ var t = fps !== null && fps !== -1 && time !== null ? time / (1000 / fps) + this._t : 1;
+ var frames = t | 0;
+ this._t = t - frames;
+ while (frames--) {
+ this._updateTimeline(this._rawPosition + 1, false);
+ }
+ };
+ _proto.clone = function clone() {
+ throw "MovieClip cannot be cloned.";
+ };
+ _proto._updateState = function _updateState() {
+ if (this._rawPosition === -1 || this.mode !== MovieClip.INDEPENDENT) {
+ this._updateTimeline(-1);
+ }
+ };
+ _proto._tick = function _tick(evtObj) {
+ this.advance(evtObj && evtObj.delta);
+ _Container.prototype._tick.call(this, evtObj);
+ };
+ _proto._goto = function _goto(positionOrLabel) {
+ var pos = this.timeline.resolve(positionOrLabel);
+ if (pos == null) {
+ return;
+ }
+ this._t = 0;
+ this._updateTimeline(pos, true);
+ };
+ _proto._reset = function _reset() {
+ this._rawPosition = -1;
+ this._t = this.currentFrame = 0;
+ this.paused = false;
+ };
+ _proto._updateTimeline = function _updateTimeline(rawPosition, jump) {
+ var synced = this.mode !== MovieClip.INDEPENDENT,
+ tl = this.timeline;
+ if (synced) {
+ rawPosition = this.startPosition + (this.mode === MovieClip.SINGLE_FRAME ? 0 : this._synchOffset);
+ }
+ if (rawPosition < 1) {
+ rawPosition = 0;
+ }
+ if (this._rawPosition === rawPosition && !synced) {
+ return;
+ }
+ this._rawPosition = rawPosition;
+ tl.loop = this.loop;
+ tl.setPosition(rawPosition, synced || !this.actionsEnabled, jump, this._bound_resolveState);
+ };
+ _proto._renderFirstFrame = function _renderFirstFrame() {
+ var tl = this.timeline,
+ pos = tl.rawPosition;
+ tl.setPosition(0, true, true, this._bound_resolveState);
+ tl.rawPosition = pos;
+ };
+ _proto._resolveState = function _resolveState() {
+ var tl = this.timeline;
+ this.currentFrame = tl.position;
+ for (var n in this._managed) {
+ this._managed[n] = 1;
+ }
+ var tweens = tl.tweens;
+ for (var _iterator = tweens, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
+ var _ref;
+ if (_isArray) {
+ if (_i >= _iterator.length) break;
+ _ref = _iterator[_i++];
+ } else {
+ _i = _iterator.next();
+ if (_i.done) break;
+ _ref = _i.value;
+ }
+ var tween = _ref;
+ var target = tween.target;
+ if (target === this || tween.passive) {
+ continue;
+ }
+ var offset = tween._stepPosition;
+ if (target instanceof DisplayObject) {
+ this._addManagedChild(target, offset);
+ } else {
+ this._setState(target.state, offset);
+ }
+ }
+ var kids = this.children;
+ for (var i = kids.length - 1; i >= 0; i--) {
+ var id = kids[i].id;
+ if (this._managed[id] === 1) {
+ this.removeChildAt(i);
+ delete this._managed[id];
+ }
+ }
+ };
+ _proto._setState = function _setState(state, offset) {
+ if (!state) {
+ return;
+ }
+ for (var i = state.length - 1; i >= 0; i--) {
+ var o = state[i];
+ var target = o.t;
+ var props = o.p;
+ for (var n in props) {
+ target[n] = props[n];
+ }
+ this._addManagedChild(target, offset);
+ }
+ };
+ _proto._addManagedChild = function _addManagedChild(child, offset) {
+ if (child._off) {
+ return;
+ }
+ this.addChildAt(child, 0);
+ if (child instanceof MovieClip) {
+ child._synchOffset = offset;
+ if (child.mode === MovieClip.INDEPENDENT && child.autoReset && !this._managed[child.id]) {
+ child._reset();
+ }
+ }
+ this._managed[child.id] = 2;
+ };
+ _proto._getBounds = function _getBounds(matrix, ignoreTransform) {
+ var bounds = this.getBounds();
+ if (!bounds && this.frameBounds) {
+ bounds = this._rectangle.copy(this.frameBounds[this.currentFrame]);
+ }
+ if (bounds) {
+ return this._transformBounds(bounds, matrix, ignoreTransform);
+ }
+ return _Container.prototype._getBounds.call(this, matrix, ignoreTransform);
+ };
+ _createClass(MovieClip, [{
+ key: "labels",
+ get: function get() {
+ return this.timeline.labels;
+ }
+ }, {
+ key: "currentLabel",
+ get: function get() {
+ return this.timeline.currentLabel;
+ }
+ }, {
+ key: "duration",
+ get: function get() {
+ return this.timeline.duration;
+ }
+ }, {
+ key: "totalFrames",
+ get: function get() {
+ return this.duration;
+ }
+ }]);
+ return MovieClip;
+ }(Container);
+ MovieClip.INDEPENDENT = "independent";
+ MovieClip.SINGLE_FRAME = "single";
+ MovieClip.SYNCHED = "synched";
+ MovieClip.inited = false;
+ var MovieClipPlugin =
+ function () {
+ function MovieClipPlugin() {
+ throw "MovieClipPlugin cannot be instantiated.";
+ }
+ MovieClipPlugin.install = function install() {
+ tweenjs.Tween.installPlugin(MovieClipPlugin);
+ };
+ MovieClipPlugin.init = function init(tween, prop, value) {
+ return value;
+ };
+ MovieClipPlugin.tween = function tween(_tween, prop, value, startValues, endValues, ratio, wait, end) {
+ if (!(_tween.target instanceof MovieClip)) {
+ return value;
+ }
+ return ratio === 1 ? endValues[prop] : startValues[prop];
+ };
+ return MovieClipPlugin;
+ }();
+ MovieClipPlugin.priority = 100;
+
+ var Shape =
+ function (_DisplayObject) {
+ _inheritsLoose(Shape, _DisplayObject);
+ function Shape(graphics) {
+ var _this;
+ if (graphics === void 0) {
+ graphics = new Graphics();
+ }
+ _this = _DisplayObject.call(this) || this;
+ _this.graphics = graphics;
+ return _this;
+ }
+ var _proto = Shape.prototype;
+ _proto.isVisible = function isVisible() {
+ var hasContent = this.cacheCanvas || this.graphics && !this.graphics.isEmpty();
+ return !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && hasContent);
+ };
+ _proto.draw = function draw(ctx, ignoreCache) {
+ if (ignoreCache === void 0) {
+ ignoreCache = false;
+ }
+ if (_DisplayObject.prototype.draw.call(this, ctx, ignoreCache)) {
+ return true;
+ }
+ this.graphics.draw(ctx, this);
+ return true;
+ };
+ _proto.clone = function clone(recursive) {
+ if (recursive === void 0) {
+ recursive = false;
+ }
+ var g = recursive && this.graphics ? this.graphics.clone() : this.graphics;
+ return this._cloneProps(new Shape(g));
+ };
+ return Shape;
+ }(DisplayObject);
+
+ var SpriteSheet =
+ function (_EventDispatcher) {
+ _inheritsLoose(SpriteSheet, _EventDispatcher);
+ function SpriteSheet(data) {
+ var _this;
+ _this = _EventDispatcher.call(this) || this;
+ _this.complete = true;
+ _this.framerate = 0;
+ _this._animations = null;
+ _this._frames = null;
+ _this._images = null;
+ _this._data = null;
+ _this._loadCount = 0;
+ _this._frameHeight = 0;
+ _this._frameWidth = 0;
+ _this._numFrames = 0;
+ _this._regX = 0;
+ _this._regY = 0;
+ _this._spacing = 0;
+ _this._margin = 0;
+ _this._parseData(data);
+ return _this;
+ }
+ var _proto = SpriteSheet.prototype;
+ _proto.getNumFrames = function getNumFrames(animation) {
+ if (animation == null) {
+ return this._frames ? this._frames.length : this._numFrames || 0;
+ } else {
+ var data = this._data[animation];
+ if (data == null) {
+ return 0;
+ } else {
+ return data.frames.length;
+ }
+ }
+ };
+ _proto.getAnimation = function getAnimation(name) {
+ return this._data[name];
+ };
+ _proto.getFrame = function getFrame(frameIndex) {
+ var frame;
+ if (this._frames && (frame = this._frames[frameIndex])) {
+ return frame;
+ }
+ return null;
+ };
+ _proto.getFrameBounds = function getFrameBounds(frameIndex, rectangle) {
+ if (rectangle === void 0) {
+ rectangle = new Rectangle();
+ }
+ var frame = this.getFrame(frameIndex);
+ return frame ? rectangle.setValues(-frame.regX, -frame.regY, frame.rect.width, frame.rect.height) : null;
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + "]";
+ };
+ _proto.clone = function clone() {
+ throw "SpriteSheet cannot be cloned.";
+ };
+ _proto._parseData = function _parseData(data) {
+ var _this2 = this;
+ if (data == null) {
+ return;
+ }
+ this.framerate = data.framerate || 0;
+ if (data.images) {
+ var _loop = function _loop() {
+ if (_isArray) {
+ if (_i >= _iterator.length) return "break";
+ _ref = _iterator[_i++];
+ } else {
+ _i = _iterator.next();
+ if (_i.done) return "break";
+ _ref = _i.value;
+ }
+ var img = _ref;
+ var a = _this2._images = [];
+ var src = void 0;
+ if (typeof img === "string") {
+ src = img;
+ img = document.createElement("img");
+ img.src = src;
+ }
+ a.push(img);
+ if (!img.getContext && !img.naturalWidth) {
+ _this2._loadCount++;
+ _this2.complete = false;
+ img.onload = function () {
+ return _this2._handleImageLoad(src);
+ };
+ img.onerror = function () {
+ return _this2._handleImageError(src);
+ };
+ }
+ };
+ for (var _iterator = data.images, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
+ var _ref;
+ var _ret = _loop();
+ if (_ret === "break") break;
+ }
+ }
+ if (data.frames != null) {
+ if (Array.isArray(data.frames)) {
+ this._frames = [];
+ for (var _iterator2 = data.frames, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
+ var _ref2;
+ if (_isArray2) {
+ if (_i2 >= _iterator2.length) break;
+ _ref2 = _iterator2[_i2++];
+ } else {
+ _i2 = _iterator2.next();
+ if (_i2.done) break;
+ _ref2 = _i2.value;
+ }
+ var arr = _ref2;
+ this._frames.push({
+ image: this._images[arr[4] ? arr[4] : 0],
+ rect: new Rectangle(arr[0], arr[1], arr[2], arr[3]),
+ regX: arr[5] || 0,
+ regY: arr[6] || 0
+ });
+ }
+ } else {
+ var o = data.frames;
+ this._frameWidth = o.width;
+ this._frameHeight = o.height;
+ this._regX = o.regX || 0;
+ this._regY = o.regY || 0;
+ this._spacing = o.spacing || 0;
+ this._margin = o.margin || 0;
+ this._numFrames = o.count;
+ if (this._loadCount === 0) {
+ this._calculateFrames();
+ }
+ }
+ }
+ this._animations = [];
+ if (data.animations != null) {
+ this._data = {};
+ var _o = data.animations;
+ for (var name in _o) {
+ var anim = {
+ name: name
+ };
+ var obj = _o[name];
+ var a = void 0;
+ if (typeof obj === "number") {
+ a = anim.frames = [obj];
+ } else if (Array.isArray(obj)) {
+ if (obj.length === 1) {
+ anim.frames = [obj[0]];
+ } else {
+ anim.speed = obj[3];
+ anim.next = obj[2];
+ a = anim.frames = [];
+ for (var i = obj[0]; i <= obj[1]; i++) {
+ a.push(i);
+ }
+ }
+ } else {
+ anim.speed = obj.speed;
+ anim.next = obj.next;
+ var frames = obj.frames;
+ a = anim.frames = typeof frames === "number" ? [frames] : frames.slice(0);
+ }
+ if (anim.next === true || anim.next === undefined) {
+ anim.next = name;
+ }
+ if (anim.next === false || a.length < 2 && anim.next === name) {
+ anim.next = null;
+ }
+ if (!anim.speed) {
+ anim.speed = 1;
+ }
+ this._animations.push(name);
+ this._data[name] = anim;
+ }
+ }
+ };
+ _proto._handleImageLoad = function _handleImageLoad(src) {
+ if (--this._loadCount === 0) {
+ this._calculateFrames();
+ this.complete = true;
+ this.dispatchEvent("complete");
+ }
+ };
+ _proto._handleImageError = function _handleImageError(src) {
+ var errorEvent = new Event("error");
+ errorEvent.src = src;
+ this.dispatchEvent(errorEvent);
+ if (--this._loadCount === 0) {
+ this.dispatchEvent("complete");
+ }
+ };
+ _proto._calculateFrames = function _calculateFrames() {
+ if (this._frames || this._frameWidth === 0) {
+ return;
+ }
+ this._frames = [];
+ var maxFrames = this._numFrames || 100000;
+ var frameCount = 0,
+ frameWidth = this._frameWidth,
+ frameHeight = this._frameHeight;
+ var spacing = this._spacing,
+ margin = this._margin;
+ imgLoop: for (var i = 0, imgs = this._images, l = imgs.length; i < l; i++) {
+ var img = imgs[i],
+ imgW = img.width || img.naturalWidth,
+ imgH = img.height || img.naturalHeight;
+ var y = margin;
+ while (y <= imgH - margin - frameHeight) {
+ var x = margin;
+ while (x <= imgW - margin - frameWidth) {
+ if (frameCount >= maxFrames) {
+ break imgLoop;
+ }
+ frameCount++;
+ this._frames.push({
+ image: img,
+ rect: new Rectangle(x, y, frameWidth, frameHeight),
+ regX: this._regX,
+ regY: this._regY
+ });
+ x += frameWidth + spacing;
+ }
+ y += frameHeight + spacing;
+ }
+ }
+ this._numFrames = frameCount;
+ };
+ _createClass(SpriteSheet, [{
+ key: "animations",
+ get: function get() {
+ return this._animations.slice();
+ }
+ }]);
+ return SpriteSheet;
+ }(EventDispatcher);
+
+ var Text =
+ function (_DisplayObject) {
+ _inheritsLoose(Text, _DisplayObject);
+ function Text(text, font, color) {
+ var _this;
+ _this = _DisplayObject.call(this) || this;
+ _this.text = text;
+ _this.font = font;
+ _this.color = color;
+ _this.textAlign = "left";
+ _this.textBaseline = "top";
+ _this.maxWidth = null;
+ _this.outline = 0;
+ _this.lineHeight = 0;
+ _this.lineWidth = null;
+ return _this;
+ }
+ var _proto = Text.prototype;
+ _proto.isVisible = function isVisible() {
+ var hasContent = this.cacheCanvas || this.text != null && this.text !== "";
+ return !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && hasContent);
+ };
+ _proto.draw = function draw(ctx, ignoreCache) {
+ if (_DisplayObject.prototype.draw.call(this, ctx, ignoreCache)) {
+ return true;
+ }
+ var col = this.color || "#000";
+ if (this.outline) {
+ ctx.strokeStyle = col;
+ ctx.lineWidth = this.outline * 1;
+ } else {
+ ctx.fillStyle = col;
+ }
+ this._drawText(this._prepContext(ctx));
+ return true;
+ };
+ _proto.getMeasuredWidth = function getMeasuredWidth() {
+ return this._getMeasuredWidth(this.text);
+ };
+ _proto.getMeasuredLineHeight = function getMeasuredLineHeight() {
+ return this._getMeasuredWidth("M") * 1.2;
+ };
+ _proto.getMeasuredHeight = function getMeasuredHeight() {
+ return this._drawText(null, {}).height;
+ };
+ _proto.getBounds = function getBounds() {
+ var rect = _DisplayObject.prototype.getBounds.call(this);
+ 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);
+ };
+ _proto.getMetrics = function getMetrics() {
+ 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);
+ };
+ _proto.clone = function clone() {
+ return this._cloneProps(new Text(this.text, this.font, this.color));
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + " (text=" + (this.text.length > 20 ? this.text.substr(0, 17) + "..." : this.text) + ")]";
+ };
+ _proto._cloneProps = function _cloneProps(o) {
+ _DisplayObject.prototype._cloneProps.call(this, 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;
+ };
+ _proto._prepContext = function _prepContext(ctx) {
+ ctx.font = this.font || "10px sans-serif";
+ ctx.textAlign = this.textAlign || "left";
+ ctx.textBaseline = this.textBaseline || "top";
+ ctx.lineJoin = "miter";
+ ctx.miterLimit = 2.5;
+ return ctx;
+ };
+ _proto._drawText = function _drawText(ctx, o, lines) {
+ var paint = !!ctx;
+ if (!paint) {
+ ctx = Text._ctx;
+ 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 _iterator = hardLines, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
+ var _ref;
+ if (_isArray) {
+ if (_i >= _iterator.length) break;
+ _ref = _iterator[_i++];
+ } else {
+ _i = _iterator.next();
+ if (_i.done) break;
+ _ref = _i.value;
+ }
+ var str = _ref;
+ var w = null;
+ if (this.lineWidth != null && (w = ctx.measureText(str).width) > this.lineWidth) {
+ var words = str.split(/(\s)/);
+ str = words[0];
+ w = ctx.measureText(str).width;
+ var l = words.length;
+ for (var i = 1; i < l; i += 2) {
+ var wordW = ctx.measureText(words[i] + words[i + 1]).width;
+ if (w + wordW > this.lineWidth) {
+ if (paint) {
+ this._drawTextLine(ctx, str, count * lineHeight);
+ }
+ if (lines) {
+ lines.push(str);
+ }
+ if (w > maxW) {
+ maxW = w;
+ }
+ str = words[i + 1];
+ w = ctx.measureText(str).width;
+ count++;
+ } else {
+ str += words[i] + words[i + 1];
+ w += wordW;
+ }
+ }
+ }
+ if (paint) {
+ this._drawTextLine(ctx, str, count * lineHeight);
+ }
+ if (lines) {
+ lines.push(str);
+ }
+ if (o && w == null) {
+ w = ctx.measureText(str).width;
+ }
+ if (w > maxW) {
+ maxW = w;
+ }
+ count++;
+ }
+ if (o) {
+ o.width = maxW;
+ o.height = count * lineHeight;
+ }
+ if (!paint) {
+ ctx.restore();
+ }
+ return o;
+ };
+ _proto._drawTextLine = function _drawTextLine(ctx, text, y) {
+ if (this.outline) {
+ ctx.strokeText(text, 0, y, this.maxWidth || 0xFFFF);
+ } else {
+ ctx.fillText(text, 0, y, this.maxWidth || 0xFFFF);
+ }
+ };
+ _proto._getMeasuredWidth = function _getMeasuredWidth(text) {
+ var ctx = Text._ctx;
+ ctx.save();
+ var w = this._prepContext(ctx).measureText(text).width;
+ ctx.restore();
+ return w;
+ };
+ return Text;
+ }(DisplayObject);
+ Text.H_OFFSETS = {
+ start: 0,
+ left: 0,
+ center: -0.5,
+ end: -1,
+ right: -1
+ };
+ Text.V_OFFSETS = {
+ top: 0,
+ hanging: -0.01,
+ middle: -0.4,
+ alphabetic: -0.8,
+ ideographic: -0.85,
+ bottom: -1
+ };
+ Text._ctx = createCanvas().getContext("2d");
+
+ var AlphaMapFilter =
+ function (_Filter) {
+ _inheritsLoose(AlphaMapFilter, _Filter);
+ function AlphaMapFilter(alphaMap) {
+ var _this;
+ _this = _Filter.call(this) || this;
+ _this.alphaMap = alphaMap;
+ _this._alphaMap = null;
+ _this._mapData = null;
+ _this._mapTexture = null;
+ _this.FRAG_SHADER_BODY = "\n\t\t\tuniform sampler2D uAlphaSampler;\n\n\t\t\tvoid main (void) {\n\t\t\t\tvec4 color = texture2D(uSampler, vRenderCoord);\n\t\t\t\tvec4 alphaMap = texture2D(uAlphaSampler, vTextureCoord);\n\n\t\t\t\t// some image formats can have transparent white rgba(1,1,1, 0) when put on the GPU, this means we need a slight tweak\n\t\t\t\t// using ceil ensure that the colour will be used so long as it exists but pure transparency will be treated black\n\t\t\t\tgl_FragColor = vec4(color.rgb, color.a * (alphaMap.r * ceil(alphaMap.a)));\n\t\t\t}\n\t\t";
+ return _this;
+ }
+ var _proto = AlphaMapFilter.prototype;
+ _proto.shaderParamSetup = function shaderParamSetup(gl, stage, shaderProgram) {
+ if (!this._mapTexture) {
+ this._mapTexture = gl.createTexture();
+ }
+ gl.activeTexture(gl.TEXTURE1);
+ gl.bindTexture(gl.TEXTURE_2D, this._mapTexture);
+ stage.setTextureParams(gl);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this.alphaMap);
+ gl.uniform1i(gl.getUniformLocation(shaderProgram, "uAlphaSampler"), 1);
+ };
+ _proto.clone = function clone() {
+ var o = new AlphaMapFilter(this.alphaMap);
+ o._alphaMap = this._alphaMap;
+ o._mapData = this._mapData;
+ return o;
+ };
+ _proto._applyFilter = function _applyFilter(imageData) {
+ if (!this.alphaMap) {
+ return true;
+ }
+ if (!this._prepAlphaMap()) {
+ return false;
+ }
+ var data = imageData.data;
+ var map = this._mapData;
+ var l = data.length;
+ for (var i = 0; i < l; i += 4) {
+ data[i + 3] = map[i] || 0;
+ }
+ return true;
+ };
+ _proto._prepAlphaMap = function _prepAlphaMap() {
+ if (!this.alphaMap) {
+ return false;
+ }
+ if (this.alphaMap === this._alphaMap && this._mapData) {
+ return true;
+ }
+ this._mapData = null;
+ var map = this._alphaMap = this.alphaMap;
+ var canvas = map;
+ var ctx;
+ if (map instanceof HTMLCanvasElement) {
+ ctx = canvas.getContext("2d");
+ } else {
+ canvas = window.createjs && createjs.createCanvas ? createjs.createCanvas() : document.createElement("canvas");
+ canvas.width = map.width;
+ canvas.height = map.height;
+ ctx = canvas.getContext("2d");
+ ctx.drawImage(map, 0, 0);
+ }
+ try {
+ this._mapData = ctx.getImageData(0, 0, map.width, map.height).data;
+ return true;
+ } catch (e) {
+ return false;
+ }
+ };
+ return AlphaMapFilter;
+ }(Filter);
+
+ var AlphaMaskFilter =
+ function (_Filter) {
+ _inheritsLoose(AlphaMaskFilter, _Filter);
+ function AlphaMaskFilter(mask) {
+ var _this;
+ _this = _Filter.call(this) || this;
+ _this.mask = mask;
+ _this.usesContext = true;
+ _this.FRAG_SHADER_BODY = "\n\t\t\tuniform sampler2D uAlphaSampler;\n\n\t\t\tvoid main (void) {\n\t\t\t\tvec4 color = texture2D(uSampler, vRenderCoord);\n\t\t\t\tvec4 alphaMap = texture2D(uAlphaSampler, vTextureCoord);\n\n\t\t\t\tgl_FragColor = vec4(color.rgb, color.a * alphaMap.a);\n\t\t\t}\n\t\t";
+ return _this;
+ }
+ var _proto = AlphaMaskFilter.prototype;
+ _proto.applyFilter = function applyFilter(ctx, x, y, width, height, targetCtx, targetX, targetY) {
+ if (!this.mask) {
+ return true;
+ }
+ targetCtx = targetCtx || ctx;
+ if (targetX == null) {
+ targetX = x;
+ }
+ if (targetY == null) {
+ targetY = y;
+ }
+ targetCtx.save();
+ if (ctx != targetCtx) {
+ return false;
+ }
+ targetCtx.globalCompositeOperation = "destination-in";
+ targetCtx.drawImage(this.mask, targetX, targetY);
+ targetCtx.restore();
+ return true;
+ };
+ _proto.clone = function clone() {
+ return new AlphaMaskFilter(this.mask);
+ };
+ _proto.shaderParamSetup = function shaderParamSetup(gl, stage, shaderProgram) {
+ if (!this._mapTexture) {
+ this._mapTexture = gl.createTexture();
+ }
+ gl.activeTexture(gl.TEXTURE1);
+ gl.bindTexture(gl.TEXTURE_2D, this._mapTexture);
+ stage.setTextureParams(gl);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this.mask);
+ gl.uniform1i(gl.getUniformLocation(shaderProgram, "uAlphaSampler"), 1);
+ };
+ return AlphaMaskFilter;
+ }(Filter);
+
+ var BlurFilter =
+ function (_Filter) {
+ _inheritsLoose(BlurFilter, _Filter);
+ function BlurFilter(blurX, blurY, quality) {
+ var _this;
+ if (blurX === void 0) {
+ blurX = 0;
+ }
+ if (blurY === void 0) {
+ blurY = 0;
+ }
+ if (quality === void 0) {
+ quality = 1;
+ }
+ _this = _Filter.call(this) || this;
+ _this._blurX = blurX;
+ _this._blurXTable = [];
+ _this._lastBlurX = null;
+ _this._blurY = blurY;
+ _this._blurYTable = [];
+ _this._lastBlurY = null;
+ _this._quality = isNaN(quality) || quality < 1 ? 1 : quality;
+ _this._lastQuality = null;
+ _this.FRAG_SHADER_TEMPLATE = "\n\t\t\tuniform float xWeight[{{blurX}}];\n\t\t\tuniform float yWeight[{{blurY}}];\n\t\t\tuniform vec2 textureOffset;\n\t\t\tvoid main (void) {\n\t\t\t\tvec4 color = vec4(0.0);\n\n\t\t\t\tfloat xAdj = ({{blurX}}.0-1.0)/2.0;\n\t\t\t\tfloat yAdj = ({{blurY}}.0-1.0)/2.0;\n\t\t\t\tvec2 sampleOffset;\n\n\t\t\t\tfor(int i=0; i<{{blurX}}; i++) {\n\t\t\t\t\tfor(int j=0; j<{{blurY}}; j++) {\n\t\t\t\t\t\tsampleOffset = vRenderCoord + (textureOffset * vec2(float(i)-xAdj, float(j)-yAdj));\n\t\t\t\t\t\tcolor += texture2D(uSampler, sampleOffset) * (xWeight[i] * yWeight[j]);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = color.rgba;\n\t\t\t}\n\t\t";
+ return _this;
+ }
+ var _proto = BlurFilter.prototype;
+ _proto.shaderParamSetup = function shaderParamSetup(gl, stage, shaderProgram) {
+ gl.uniform1fv(gl.getUniformLocation(shaderProgram, "xWeight"), this._blurXTable);
+ gl.uniform1fv(gl.getUniformLocation(shaderProgram, "yWeight"), this._blurYTable);
+ gl.uniform2f(gl.getUniformLocation(shaderProgram, "textureOffset"), 2 / (stage._viewportWidth * this._quality), 2 / (stage._viewportHeight * this._quality));
+ };
+ _proto.getBounds = function getBounds(rect) {
+ var x = this.blurX | 0,
+ y = this.blurY | 0;
+ if (x <= 0 && y <= 0) {
+ return rect;
+ }
+ var q = Math.pow(this.quality, 0.2);
+ return (rect || new Rectangle()).pad(y * q + 1, x * q + 1, y * q + 1, x * q + 1);
+ };
+ _proto.clone = function clone() {
+ return new BlurFilter(this.blurX, this.blurY, this.quality);
+ };
+ _proto._updateShader = function _updateShader() {
+ var result = this.FRAG_SHADER_TEMPLATE;
+ result = result.replace(/{{blurX}}/g, this._blurXTable.length.toFixed(0));
+ result = result.replace(/{{blurY}}/g, this._blurYTable.length.toFixed(0));
+ this.FRAG_SHADER_BODY = result;
+ };
+ _proto._getTable = function _getTable(spread) {
+ var EDGE = 4.2;
+ if (spread <= 1) {
+ return [1];
+ }
+ var result = [];
+ var count = Math.ceil(spread * 2);
+ count += count % 2 ? 0 : 1;
+ var adjust = count / 2 | 0;
+ for (var i = -adjust; i <= adjust; i++) {
+ var x = i / adjust * EDGE;
+ result.push(1 / Math.sqrt(2 * Math.PI) * Math.pow(Math.E, -(Math.pow(x, 2) / 4)));
+ }
+ var factor = result.reduce(function (a, b) {
+ return a + b;
+ }, 0);
+ return result.map(function (currentValue) {
+ return currentValue / factor;
+ });
+ };
+ _proto._applyFilter = function _applyFilter(imageData) {
+ var radiusX = this._blurX >> 1;
+ if (isNaN(radiusX) || radiusX < 0) return false;
+ var radiusY = this._blurY >> 1;
+ if (isNaN(radiusY) || radiusY < 0) return false;
+ if (radiusX === 0 && radiusY === 0) return false;
+ var iterations = this.quality;
+ if (isNaN(iterations) || iterations < 1) iterations = 1;
+ iterations |= 0;
+ if (iterations > 3) iterations = 3;
+ if (iterations < 1) iterations = 1;
+ var px = imageData.data;
+ var x = 0,
+ y = 0,
+ i = 0,
+ p = 0,
+ yp = 0,
+ yi = 0,
+ yw = 0,
+ r = 0,
+ g = 0,
+ b = 0,
+ a = 0,
+ pr = 0,
+ pg = 0,
+ pb = 0,
+ pa = 0;
+ var divx = radiusX + radiusX + 1 | 0;
+ var divy = radiusY + radiusY + 1 | 0;
+ var w = imageData.width | 0;
+ var h = imageData.height | 0;
+ var w1 = w - 1 | 0;
+ var h1 = h - 1 | 0;
+ var rxp1 = radiusX + 1 | 0;
+ var ryp1 = radiusY + 1 | 0;
+ var ssx = {
+ r: 0,
+ b: 0,
+ g: 0,
+ a: 0
+ };
+ var sx = ssx;
+ for (i = 1; i < divx; i++) {
+ sx = sx.n = {
+ r: 0,
+ b: 0,
+ g: 0,
+ a: 0
+ };
+ }
+ sx.n = ssx;
+ var ssy = {
+ r: 0,
+ b: 0,
+ g: 0,
+ a: 0
+ };
+ var sy = ssy;
+ for (i = 1; i < divy; i++) {
+ sy = sy.n = {
+ r: 0,
+ b: 0,
+ g: 0,
+ a: 0
+ };
+ }
+ sy.n = ssy;
+ var si = null;
+ var mtx = BlurFilter.MUL_TABLE[radiusX] | 0;
+ var stx = BlurFilter.SHG_TABLE[radiusX] | 0;
+ var mty = BlurFilter.MUL_TABLE[radiusY] | 0;
+ var sty = BlurFilter.SHG_TABLE[radiusY] | 0;
+ while (iterations-- > 0) {
+ yw = yi = 0;
+ var ms = mtx;
+ var ss = stx;
+ for (y = h; --y > -1;) {
+ r = rxp1 * (pr = px[yi | 0]);
+ g = rxp1 * (pg = px[yi + 1 | 0]);
+ b = rxp1 * (pb = px[yi + 2 | 0]);
+ a = rxp1 * (pa = px[yi + 3 | 0]);
+ sx = ssx;
+ for (i = rxp1; --i > -1;) {
+ sx.r = pr;
+ sx.g = pg;
+ sx.b = pb;
+ sx.a = pa;
+ sx = sx.n;
+ }
+ for (i = 1; i < rxp1; i++) {
+ p = yi + ((w1 < i ? w1 : i) << 2) | 0;
+ r += sx.r = px[p];
+ g += sx.g = px[p + 1];
+ b += sx.b = px[p + 2];
+ a += sx.a = px[p + 3];
+ sx = sx.n;
+ }
+ si = ssx;
+ for (x = 0; x < w; x++) {
+ px[yi++] = r * ms >>> ss;
+ px[yi++] = g * ms >>> ss;
+ px[yi++] = b * ms >>> ss;
+ px[yi++] = a * ms >>> ss;
+ p = yw + ((p = x + radiusX + 1) < w1 ? p : w1) << 2;
+ r -= si.r - (si.r = px[p]);
+ g -= si.g - (si.g = px[p + 1]);
+ b -= si.b - (si.b = px[p + 2]);
+ a -= si.a - (si.a = px[p + 3]);
+ si = si.n;
+ }
+ yw += w;
+ }
+ ms = mty;
+ ss = sty;
+ for (x = 0; x < w; x++) {
+ yi = x << 2 | 0;
+ r = ryp1 * (pr = px[yi]) | 0;
+ g = ryp1 * (pg = px[yi + 1 | 0]) | 0;
+ b = ryp1 * (pb = px[yi + 2 | 0]) | 0;
+ a = ryp1 * (pa = px[yi + 3 | 0]) | 0;
+ sy = ssy;
+ for (i = 0; i < ryp1; i++) {
+ sy.r = pr;
+ sy.g = pg;
+ sy.b = pb;
+ sy.a = pa;
+ sy = sy.n;
+ }
+ yp = w;
+ for (i = 1; i <= radiusY; i++) {
+ yi = yp + x << 2;
+ r += sy.r = px[yi];
+ g += sy.g = px[yi + 1];
+ b += sy.b = px[yi + 2];
+ a += sy.a = px[yi + 3];
+ sy = sy.n;
+ if (i < h1) {
+ yp += w;
+ }
+ }
+ yi = x;
+ si = ssy;
+ if (iterations > 0) {
+ for (y = 0; y < h; y++) {
+ p = yi << 2;
+ px[p + 3] = pa = a * ms >>> ss;
+ if (pa > 0) {
+ px[p] = r * ms >>> ss;
+ px[p + 1] = g * ms >>> ss;
+ px[p + 2] = b * ms >>> ss;
+ } else {
+ px[p] = px[p + 1] = px[p + 2] = 0;
+ }
+ p = x + ((p = y + ryp1) < h1 ? p : h1) * w << 2;
+ r -= si.r - (si.r = px[p]);
+ g -= si.g - (si.g = px[p + 1]);
+ b -= si.b - (si.b = px[p + 2]);
+ a -= si.a - (si.a = px[p + 3]);
+ si = si.n;
+ yi += w;
+ }
+ } else {
+ for (y = 0; y < h; y++) {
+ p = yi << 2;
+ px[p + 3] = pa = a * ms >>> ss;
+ if (pa > 0) {
+ pa = 255 / pa;
+ px[p] = (r * ms >>> ss) * pa;
+ px[p + 1] = (g * ms >>> ss) * pa;
+ px[p + 2] = (b * ms >>> ss) * pa;
+ } else {
+ px[p] = px[p + 1] = px[p + 2] = 0;
+ }
+ p = x + ((p = y + ryp1) < h1 ? p : h1) * w << 2;
+ r -= si.r - (si.r = px[p]);
+ g -= si.g - (si.g = px[p + 1]);
+ b -= si.b - (si.b = px[p + 2]);
+ a -= si.a - (si.a = px[p + 3]);
+ si = si.n;
+ yi += w;
+ }
+ }
+ }
+ }
+ return true;
+ };
+ _createClass(BlurFilter, [{
+ key: "blurX",
+ get: function get() {
+ return this._blurX;
+ },
+ set: function set(blurX) {
+ if (isNaN(blurX) || blurX < 0) {
+ blurX = 0;
+ }
+ this._blurX = blurX;
+ }
+ }, {
+ key: "blurY",
+ get: function get() {
+ return this._blurY;
+ },
+ set: function set(blurY) {
+ if (isNaN(blurY) || blurY < 0) {
+ blurY = 0;
+ }
+ this._blurY = blurY;
+ }
+ }, {
+ key: "quality",
+ get: function get() {
+ return this._quality | 0;
+ },
+ set: function set(quality) {
+ if (isNaN(quality) || quality < 0) {
+ quality = 0;
+ }
+ this._quality = quality;
+ }
+ }, {
+ key: "_buildShader",
+ get: function get() {
+ var xChange = this._lastBlurX !== this._blurX;
+ var yChange = this._lastBlurY !== this._blurY;
+ var qChange = this._lastQuality !== this._quality;
+ if (xChange || yChange || qChange) {
+ if (xChange || qChange) {
+ this._blurXTable = this._getTable(this._blurX * this._quality);
+ }
+ if (yChange || qChange) {
+ this._blurYTable = this._getTable(this._blurY * this._quality);
+ }
+ this._updateShader();
+ this._lastBlurX = this._blurX;
+ this._lastBlurY = this._blurY;
+ this._lastQuality = this._quality;
+ return undefined;
+ }
+ return this._compiledShader;
+ }
+ }, {
+ key: "_builtShader",
+ set: function set(value) {
+ this._compiledShader = value;
+ }
+ }]);
+ return BlurFilter;
+ }(Filter);
+ BlurFilter.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];
+ BlurFilter.SHG_TABLE = [0, 9, 10, 11, 9, 12, 10, 11, 12, 9, 13, 13, 10, 9, 13, 13, 14, 14, 14, 14, 10, 13, 14, 14, 14, 13, 13, 13, 9, 14, 14, 14, 15, 14, 15, 14, 15, 15, 14, 15, 15, 15, 14, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 12, 14, 15, 15, 13, 15, 15, 15, 15, 16, 16, 16, 15, 16, 14, 16, 16, 14, 16, 13, 16, 16, 16, 15, 16, 13, 16, 15, 16, 14, 9, 16, 16, 16, 16, 16, 16, 16, 16, 16, 13, 14, 16, 16, 15, 16, 16, 10, 16, 15, 16, 14, 16, 16, 14, 16, 16, 14, 16, 16, 14, 15, 16, 16, 16, 14, 15, 14, 15, 13, 16, 16, 15, 17, 17, 17, 17, 17, 17, 14, 15, 17, 17, 16, 16, 17, 16, 15, 17, 16, 17, 11, 17, 16, 17, 16, 17, 16, 17, 17, 16, 17, 17, 16, 17, 17, 16, 16, 17, 17, 17, 16, 14, 17, 17, 17, 17, 15, 16, 14, 16, 15, 16, 13, 16, 15, 16, 14, 16, 15, 16, 12, 16, 15, 16, 17, 17, 17, 17, 17, 13, 16, 15, 17, 17, 17, 16, 15, 17, 17, 17, 16, 15, 17, 17, 14, 16, 17, 17, 16, 17, 17, 16, 15, 17, 16, 14, 17, 16, 15, 17, 16, 17, 17, 16, 17, 15, 16, 17, 14, 17, 16, 15, 17, 16, 17, 13, 17, 16, 17, 17, 16, 17, 14, 17, 16, 17, 16, 17, 16, 17, 9];
+
+ var ColorFilter =
+ function (_Filter) {
+ _inheritsLoose(ColorFilter, _Filter);
+ function ColorFilter(redMultiplier, greenMultiplier, blueMultiplier, alphaMultiplier, redOffset, greenOffset, blueOffset, alphaOffset) {
+ var _this;
+ if (redMultiplier === void 0) {
+ redMultiplier = 1;
+ }
+ if (greenMultiplier === void 0) {
+ greenMultiplier = 1;
+ }
+ if (blueMultiplier === void 0) {
+ blueMultiplier = 1;
+ }
+ if (alphaMultiplier === void 0) {
+ alphaMultiplier = 1;
+ }
+ if (redOffset === void 0) {
+ redOffset = 0;
+ }
+ if (greenOffset === void 0) {
+ greenOffset = 0;
+ }
+ if (blueOffset === void 0) {
+ blueOffset = 0;
+ }
+ if (alphaOffset === void 0) {
+ alphaOffset = 0;
+ }
+ _this = _Filter.call(this) || this;
+ _this.redMultiplier = redMultiplier;
+ _this.greenMultiplier = greenMultiplier;
+ _this.blueMultiplier = blueMultiplier;
+ _this.alphaMultiplier = alphaMultiplier;
+ _this.redOffset = redOffset;
+ _this.greenOffset = greenOffset;
+ _this.blueOffset = blueOffset;
+ _this.alphaOffset = alphaOffset;
+ _this.FRAG_SHADER_BODY = "\n\t\t\tuniform vec4 uColorMultiplier;\n\t\t\tuniform vec4 uColorOffset;\n\n\t\t\tvoid main (void) {\n\t\t\t\tvec4 color = texture2D(uSampler, vRenderCoord);\n\n\t\t\t\tgl_FragColor = (color * uColorMultiplier) + uColorOffset;\n\t\t\t}\n\t\t";
+ return _this;
+ }
+ var _proto = ColorFilter.prototype;
+ _proto.shaderParamSetup = function shaderParamSetup(gl, stage, shaderProgram) {
+ gl.uniform4f(gl.getUniformLocation(shaderProgram, "uColorMultiplier"), this.redMultiplier, this.greenMultiplier, this.blueMultiplier, this.alphaMultiplier);
+ gl.uniform4f(gl.getUniformLocation(shaderProgram, "uColorOffset"), this.redOffset / 255, this.greenOffset / 255, this.blueOffset / 255, this.alphaOffset / 255);
+ };
+ _proto.clone = function clone() {
+ return new ColorFilter(this.redMultiplier, this.greenMultiplier, this.blueMultiplier, this.alphaMultiplier, this.redOffset, this.greenOffset, this.blueOffset, this.alphaOffset);
+ };
+ _proto._applyFilter = function _applyFilter(imageData) {
+ var data = imageData.data;
+ var l = data.length;
+ for (var i = 0; i < l; i += 4) {
+ data[i] = data[i] * this.redMultiplier + this.redOffset;
+ data[i + 1] = data[i + 1] * this.greenMultiplier + this.greenOffset;
+ data[i + 2] = data[i + 2] * this.blueMultiplier + this.blueOffset;
+ data[i + 3] = data[i + 3] * this.alphaMultiplier + this.alphaOffset;
+ }
+ return true;
+ };
+ return ColorFilter;
+ }(Filter);
+
+ var ColorMatrix =
+ function () {
+ function ColorMatrix(brightness, contrast, saturation, hue) {
+ this.setColor(brightness, contrast, saturation, hue);
+ }
+ var _proto = ColorMatrix.prototype;
+ _proto.setColor = function setColor(brightness, contrast, saturation, hue) {
+ return this.reset().adjustColor(brightness, contrast, saturation, hue);
+ };
+ _proto.reset = function reset() {
+ return this.copy(ColorMatrix.IDENTITY_MATRIX);
+ };
+ _proto.adjustColor = function adjustColor(brightness, contrast, saturation, hue) {
+ return this.adjustBrightness(brightness).adjustContrast(contrast).adjustSaturation(saturation).adjustHue(hue);
+ };
+ _proto.adjustBrightness = function adjustBrightness(value) {
+ if (value === 0 || isNaN(value)) {
+ return this;
+ }
+ value = this._cleanValue(value, 255);
+ this._multiplyMatrix([1, 0, 0, 0, value, 0, 1, 0, 0, value, 0, 0, 1, 0, value, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
+ return this;
+ };
+ _proto.adjustContrast = function adjustContrast(value) {
+ if (value === 0 || isNaN(value)) {
+ return this;
+ }
+ value = this._cleanValue(value, 100);
+ var x;
+ if (value < 0) {
+ x = 127 + value / 100 * 127;
+ } else {
+ x = value % 1;
+ if (x === 0) {
+ x = ColorMatrix.DELTA_INDEX[value];
+ } else {
+ x = ColorMatrix.DELTA_INDEX[value << 0] * (1 - x) + ColorMatrix.DELTA_INDEX[(value << 0) + 1] * x;
+ }
+ x = x * 127 + 127;
+ }
+ this._multiplyMatrix([x / 127, 0, 0, 0, 0.5 * (127 - x), 0, x / 127, 0, 0, 0.5 * (127 - x), 0, 0, x / 127, 0, 0.5 * (127 - x), 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
+ return this;
+ };
+ _proto.adjustSaturation = function adjustSaturation(value) {
+ if (value === 0 || isNaN(value)) {
+ return this;
+ }
+ value = this._cleanValue(value, 100);
+ var x = 1 + (value > 0 ? 3 * value / 100 : value / 100);
+ var lumR = 0.3086;
+ var lumG = 0.6094;
+ var lumB = 0.0820;
+ this._multiplyMatrix([lumR * (1 - x) + x, lumG * (1 - x), lumB * (1 - x), 0, 0, lumR * (1 - x), lumG * (1 - x) + x, lumB * (1 - x), 0, 0, lumR * (1 - x), lumG * (1 - x), lumB * (1 - x) + x, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
+ return this;
+ };
+ _proto.adjustHue = function adjustHue(value) {
+ if (value === 0 || isNaN(value)) {
+ return this;
+ }
+ value = this._cleanValue(value, 180) / 180 * Math.PI;
+ var cosVal = Math.cos(value);
+ var sinVal = Math.sin(value);
+ var lumR = 0.213;
+ var lumG = 0.715;
+ var lumB = 0.072;
+ this._multiplyMatrix([lumR + cosVal * (1 - lumR) + sinVal * -lumR, lumG + cosVal * -lumG + sinVal * -lumG, lumB + cosVal * -lumB + sinVal * (1 - lumB), 0, 0, lumR + cosVal * -lumR + sinVal * 0.143, lumG + cosVal * (1 - lumG) + sinVal * 0.140, lumB + cosVal * -lumB + sinVal * -0.283, 0, 0, lumR + cosVal * -lumR + sinVal * -(1 - lumR), lumG + cosVal * -lumG + sinVal * lumG, lumB + cosVal * (1 - lumB) + sinVal * lumB, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
+ return this;
+ };
+ _proto.concat = function concat(matrix) {
+ matrix = this._fixMatrix(matrix);
+ if (matrix.length != ColorMatrix.LENGTH) {
+ return this;
+ }
+ this._multiplyMatrix(matrix);
+ return this;
+ };
+ _proto.clone = function clone() {
+ return new ColorMatrix().copy(this);
+ };
+ _proto.toArray = function toArray() {
+ var arr = [];
+ var l = ColorMatrix.LENGTH;
+ for (var i = 0; i < l; i++) {
+ arr[i] = this[i];
+ }
+ return arr;
+ };
+ _proto.copy = function copy(matrix) {
+ var l = ColorMatrix.LENGTH;
+ for (var i = 0; i < l; i++) {
+ this[i] = matrix[i];
+ }
+ return this;
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + "]";
+ };
+ _proto._multiplyMatrix = function _multiplyMatrix(matrix) {
+ var col = [];
+ for (var i = 0; i < 5; i++) {
+ for (var j = 0; j < 5; j++) {
+ col[j] = this[j + i * 5];
+ }
+ for (var _j = 0; _j < 5; _j++) {
+ var val = 0;
+ for (var k = 0; k < 5; k++) {
+ val += matrix[_j + k * 5] * col[k];
+ }
+ this[_j + i * 5] = val;
+ }
+ }
+ };
+ _proto._cleanValue = function _cleanValue(value, limit) {
+ return Math.min(limit, Math.max(-limit, value));
+ };
+ _proto._fixMatrix = function _fixMatrix(matrix) {
+ if (matrix instanceof ColorMatrix) {
+ matrix = matrix.toArray();
+ }
+ if (matrix.length < ColorMatrix.LENGTH) {
+ matrix = matrix.slice(0, matrix.length).concat(ColorMatrix.IDENTITY_MATRIX.slice(matrix.length, ColorMatrix.LENGTH));
+ } else if (matrix.length > ColorMatrix.LENGTH) {
+ matrix = matrix.slice(0, ColorMatrix.LENGTH);
+ }
+ return matrix;
+ };
+ return ColorMatrix;
+ }();
+ ColorMatrix.DELTA_INDEX = Object.freeze([0, 0.01, 0.02, 0.04, 0.05, 0.06, 0.07, 0.08, 0.1, 0.11, 0.12, 0.14, 0.15, 0.16, 0.17, 0.18, 0.20, 0.21, 0.22, 0.24, 0.25, 0.27, 0.28, 0.30, 0.32, 0.34, 0.36, 0.38, 0.40, 0.42, 0.44, 0.46, 0.48, 0.5, 0.53, 0.56, 0.59, 0.62, 0.65, 0.68, 0.71, 0.74, 0.77, 0.80, 0.83, 0.86, 0.89, 0.92, 0.95, 0.98, 1.0, 1.06, 1.12, 1.18, 1.24, 1.30, 1.36, 1.42, 1.48, 1.54, 1.60, 1.66, 1.72, 1.78, 1.84, 1.90, 1.96, 2.0, 2.12, 2.25, 2.37, 2.50, 2.62, 2.75, 2.87, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.3, 4.7, 4.9, 5.0, 5.5, 6.0, 6.5, 6.8, 7.0, 7.3, 7.5, 7.8, 8.0, 8.4, 8.7, 9.0, 9.4, 9.6, 9.8, 10.0]);
+ ColorMatrix.IDENTITY_MATRIX = Object.freeze([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]);
+ ColorMatrix.LENGTH = 25;
+
+ var ColorMatrixFilter =
+ function (_Filter) {
+ _inheritsLoose(ColorMatrixFilter, _Filter);
+ function ColorMatrixFilter(matrix) {
+ var _this;
+ _this = _Filter.call(this) || this;
+ _this.matrix = matrix;
+ _this.FRAG_SHADER_BODY = "\n\t\t\tuniform mat4 uColorMatrix;\n\t\t\tuniform vec4 uColorMatrixOffset;\n\n\t\t\tvoid main (void) {\n\t\t\t\tvec4 color = texture2D(uSampler, vRenderCoord);\n\n\t\t\t\tmat4 m = uColorMatrix;\n\t\t\t\tvec4 newColor = vec4(0,0,0,0);\n\t\t\t\tnewColor.r = color.r*m[0][0] + color.g*m[0][1] + color.b*m[0][2] + color.a*m[0][3];\n\t\t\t\tnewColor.g = color.r*m[1][0] + color.g*m[1][1] + color.b*m[1][2] + color.a*m[1][3];\n\t\t\t\tnewColor.b = color.r*m[2][0] + color.g*m[2][1] + color.b*m[2][2] + color.a*m[2][3];\n\t\t\t\tnewColor.a = color.r*m[3][0] + color.g*m[3][1] + color.b*m[3][2] + color.a*m[3][3];\n\n\t\t\t\tgl_FragColor = newColor + uColorMatrixOffset;\n\t\t\t}\n\t\t";
+ return _this;
+ }
+ var _proto = ColorMatrixFilter.prototype;
+ _proto.shaderParamSetup = function shaderParamSetup(gl, stage, shaderProgram) {
+ var mat = this.matrix;
+ var colorMatrix = new Float32Array([mat[0], mat[1], mat[2], mat[3], mat[5], mat[6], mat[7], mat[8], mat[10], mat[11], mat[12], mat[13], mat[15], mat[16], mat[17], mat[18]]);
+ gl.uniformMatrix4fv(gl.getUniformLocation(shaderProgram, "uColorMatrix"), false, colorMatrix);
+ gl.uniform4f(gl.getUniformLocation(shaderProgram, "uColorMatrixOffset"), mat[4] / 255, mat[9] / 255, mat[14] / 255, mat[19] / 255);
+ };
+ _proto.clone = function clone() {
+ return new ColorMatrixFilter(this.matrix);
+ };
+ _proto._applyFilter = function _applyFilter(imageData) {
+ var data = imageData.data;
+ var l = data.length;
+ var r, g, b, a;
+ var mtx = this.matrix;
+ var m0 = mtx[0],
+ m1 = mtx[1],
+ m2 = mtx[2],
+ m3 = mtx[3],
+ m4 = mtx[4];
+ var m5 = mtx[5],
+ m6 = mtx[6],
+ m7 = mtx[7],
+ m8 = mtx[8],
+ m9 = mtx[9];
+ var m10 = mtx[10],
+ m11 = mtx[11],
+ m12 = mtx[12],
+ m13 = mtx[13],
+ m14 = mtx[14];
+ var m15 = mtx[15],
+ m16 = mtx[16],
+ m17 = mtx[17],
+ m18 = mtx[18],
+ m19 = mtx[19];
+ for (var i = 0; i < l; i += 4) {
+ r = data[i];
+ g = data[i + 1];
+ b = data[i + 2];
+ a = data[i + 3];
+ data[i] = r * m0 + g * m1 + b * m2 + a * m3 + m4;
+ data[i + 1] = r * m5 + g * m6 + b * m7 + a * m8 + m9;
+ data[i + 2] = r * m10 + g * m11 + b * m12 + a * m13 + m14;
+ data[i + 3] = r * m15 + g * m16 + b * m17 + a * m18 + m19;
+ }
+ return true;
+ };
+ return ColorMatrixFilter;
+ }(Filter);
+
+ var ButtonHelper =
+ function () {
+ function ButtonHelper(target, outLabel, overLabel, downLabel, play, hitArea, hitLabel) {
+ if (outLabel === void 0) {
+ outLabel = "out";
+ }
+ if (overLabel === void 0) {
+ overLabel = "over";
+ }
+ if (downLabel === void 0) {
+ downLabel = "down";
+ }
+ if (play === void 0) {
+ play = false;
+ }
+ if (!target.addEventListener) {
+ return;
+ }
+ this.target = target;
+ this.overLabel = overLabel;
+ this.outLabel = outLabel;
+ this.downLabel = downLabel == null;
+ this.play = play;
+ this._isPressed = false;
+ this._isOver = false;
+ this._enabled = false;
+ target.mouseChildren = false;
+ this.enabled = true;
+ this.handleEvent({});
+ if (hitArea) {
+ if (hitLabel) {
+ hitArea.actionsEnabled = false;
+ hitArea.gotoAndStop && hitArea.gotoAndStop(hitLabel);
+ }
+ target.hitArea = hitArea;
+ }
+ }
+ var _proto = ButtonHelper.prototype;
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + "]";
+ };
+ _proto.handleEvent = function handleEvent(evt) {
+ var label,
+ t = this.target,
+ type = evt.type;
+ if (type === "mousedown") {
+ this._isPressed = true;
+ label = this.downLabel;
+ } else if (type === "pressup") {
+ this._isPressed = false;
+ label = this._isOver ? this.overLabel : this.outLabel;
+ } else if (type === "rollover") {
+ this._isOver = true;
+ label = this._isPressed ? this.downLabel : this.overLabel;
+ } else {
+ this._isOver = false;
+ label = this._isPressed ? this.overLabel : this.outLabel;
+ }
+ if (this.play) {
+ t.gotoAndPlay && t.gotoAndPlay(label);
+ } else {
+ t.gotoAndStop && t.gotoAndStop(label);
+ }
+ };
+ _proto._reset = function _reset() {
+ var p = this.paused;
+ this.__reset();
+ this.paused = p;
+ };
+ _createClass(ButtonHelper, [{
+ key: "enabled",
+ get: function get() {
+ return this._enabled;
+ },
+ set: function set(enabled) {
+ if (enabled === this._enabled) {
+ return;
+ }
+ var o = this.target;
+ this._enabled = enabled;
+ if (enabled) {
+ o.cursor = "pointer";
+ o.addEventListener("rollover", this);
+ o.addEventListener("rollout", this);
+ o.addEventListener("mousedown", this);
+ o.addEventListener("pressup", this);
+ if (o._reset) {
+ o.__reset = o._reset;
+ o._reset = this._reset;
+ }
+ } else {
+ o.cursor = null;
+ o.removeEventListener("rollover", this);
+ o.removeEventListener("rollout", this);
+ o.removeEventListener("mousedown", this);
+ o.removeEventListener("pressup", this);
+ if (o.__reset) {
+ o._reset = o.__reset;
+ delete o.__reset;
+ }
+ }
+ }
+ }]);
+ return ButtonHelper;
+ }();
+
+ var Touch = {
+ isSupported: function isSupported() {
+ return !!('ontouchstart' in window ||
+ window.MSPointerEvent && window.navigator.msMaxTouchPoints > 0
+ || window.PointerEvent && window.navigator.maxTouchPoints > 0);
+ },
+ enable: function enable(stage, singleTouch, allowDefault) {
+ if (singleTouch === void 0) {
+ singleTouch = false;
+ }
+ if (allowDefault === void 0) {
+ allowDefault = false;
+ }
+ if (!stage || !stage.canvas || !this.isSupported()) {
+ return false;
+ }
+ if (stage.__touch) {
+ return true;
+ }
+ stage.__touch = {
+ pointers: {},
+ multitouch: !singleTouch,
+ preventDefault: !allowDefault,
+ count: 0
+ };
+ if ('ontouchstart' in window) {
+ this._IOS_enable(stage);
+ } else if (window.PointerEvent || window.MSPointerEvent) {
+ this._IE_enable(stage);
+ }
+ return true;
+ },
+ disable: function disable(stage) {
+ if (!stage) {
+ return;
+ }
+ if ('ontouchstart' in window) {
+ this._IOS_disable(stage);
+ } else if (window.PointerEvent || window.MSPointerEvent) {
+ this._IE_disable(stage);
+ }
+ delete stage.__touch;
+ },
+ _IOS_enable: function _IOS_enable(stage) {
+ var _this = this;
+ var canvas = stage.canvas;
+ var f = stage.__touch.f = function (e) {
+ return _this._IOS_handleEvent(stage, e);
+ };
+ canvas.addEventListener("touchstart", f, false);
+ canvas.addEventListener("touchmove", f, false);
+ canvas.addEventListener("touchend", f, false);
+ canvas.addEventListener("touchcancel", f, false);
+ },
+ _IOS_disable: function _IOS_disable(stage) {
+ var canvas = stage.canvas;
+ if (!canvas) {
+ return;
+ }
+ var f = stage.__touch.f;
+ canvas.removeEventListener("touchstart", f, false);
+ canvas.removeEventListener("touchmove", f, false);
+ canvas.removeEventListener("touchend", f, false);
+ canvas.removeEventListener("touchcancel", f, false);
+ },
+ _IOS_handleEvent: function _IOS_handleEvent(stage, e) {
+ if (!stage) {
+ return;
+ }
+ if (stage.__touch.preventDefault) {
+ e.preventDefault && e.preventDefault();
+ }
+ var touches = e.changedTouches;
+ var type = e.type;
+ var l = touches.length;
+ for (var _iterator = touches, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
+ var _ref;
+ if (_isArray) {
+ if (_i >= _iterator.length) break;
+ _ref = _iterator[_i++];
+ } else {
+ _i = _iterator.next();
+ if (_i.done) break;
+ _ref = _i.value;
+ }
+ var touch = _ref;
+ var id = touch.identifier;
+ if (touch.target != stage.canvas) {
+ continue;
+ }
+ if (type === "touchstart") {
+ this._handleStart(stage, id, e, touch.pageX, touch.pageY);
+ } else if (type === "touchmove") {
+ this._handleMove(stage, id, e, touch.pageX, touch.pageY);
+ } else if (type === "touchend" || type === "touchcancel") {
+ this._handleEnd(stage, id, e);
+ }
+ }
+ },
+ _IE_enable: function _IE_enable(stage) {
+ var _this2 = this;
+ var canvas = stage.canvas;
+ var f = stage.__touch.f = function (e) {
+ return _this2._IE_handleEvent(stage, e);
+ };
+ if (window.PointerEvent === undefined) {
+ canvas.addEventListener("MSPointerDown", f, false);
+ window.addEventListener("MSPointerMove", f, false);
+ window.addEventListener("MSPointerUp", f, false);
+ window.addEventListener("MSPointerCancel", f, false);
+ if (stage.__touch.preventDefault) {
+ canvas.style.msTouchAction = "none";
+ }
+ } else {
+ canvas.addEventListener("pointerdown", f, false);
+ window.addEventListener("pointermove", f, false);
+ window.addEventListener("pointerup", f, false);
+ window.addEventListener("pointercancel", f, false);
+ if (stage.__touch.preventDefault) {
+ canvas.style.touchAction = "none";
+ }
+ }
+ stage.__touch.activeIDs = {};
+ },
+ _IE_disable: function _IE_disable(stage) {
+ var f = stage.__touch.f;
+ if (window.PointerEvent === undefined) {
+ window.removeEventListener("MSPointerMove", f, false);
+ window.removeEventListener("MSPointerUp", f, false);
+ window.removeEventListener("MSPointerCancel", f, false);
+ if (stage.canvas) {
+ stage.canvas.removeEventListener("MSPointerDown", f, false);
+ }
+ } else {
+ window.removeEventListener("pointermove", f, false);
+ window.removeEventListener("pointerup", f, false);
+ window.removeEventListener("pointercancel", f, false);
+ if (stage.canvas) {
+ stage.canvas.removeEventListener("pointerdown", f, false);
+ }
+ }
+ },
+ _IE_handleEvent: function _IE_handleEvent(stage, e) {
+ if (!stage) {
+ return;
+ }
+ if (stage.__touch.preventDefault) {
+ e.preventDefault && e.preventDefault();
+ }
+ var type = e.type;
+ var id = e.pointerId;
+ var ids = stage.__touch.activeIDs;
+ if (type === "MSPointerDown" || type === "pointerdown") {
+ if (e.srcElement != stage.canvas) {
+ return;
+ }
+ ids[id] = true;
+ this._handleStart(stage, id, e, e.pageX, e.pageY);
+ } else if (ids[id]) {
+ if (type === "MSPointerMove" || type === "pointermove") {
+ this._handleMove(stage, id, e, e.pageX, e.pageY);
+ } else if (type === "MSPointerUp" || type === "MSPointerCancel" || type === "pointerup" || type === "pointercancel") {
+ delete ids[id];
+ this._handleEnd(stage, id, e);
+ }
+ }
+ },
+ _handleStart: function _handleStart(stage, id, e, x, y) {
+ var props = stage.__touch;
+ if (!props.multitouch && props.count) {
+ return;
+ }
+ var ids = props.pointers;
+ if (ids[id]) {
+ return;
+ }
+ ids[id] = true;
+ props.count++;
+ stage._handlePointerDown(id, e, x, y);
+ },
+ _handleMove: function _handleMove(stage, id, e, x, y) {
+ if (!stage.__touch.pointers[id]) {
+ return;
+ }
+ stage._handlePointerMove(id, e, x, y);
+ },
+ _handleEnd: function _handleEnd(stage, id, e) {
+ var props = stage.__touch;
+ var ids = props.pointers;
+ if (!ids[id]) {
+ return;
+ }
+ props.count--;
+ stage._handlePointerUp(id, e, true);
+ delete ids[id];
+ }
+ };
+
+ var SpriteSheetBuilder =
+ function (_EventDispatcher) {
+ _inheritsLoose(SpriteSheetBuilder, _EventDispatcher);
+ function SpriteSheetBuilder(framerate) {
+ var _this;
+ if (framerate === void 0) {
+ framerate = 0;
+ }
+ _this = _EventDispatcher.call(this) || this;
+ _this.maxWidth = 2048;
+ _this.maxHeight = 2048;
+ _this.spriteSheet = null;
+ _this.scale = 1;
+ _this.padding = 1;
+ _this.timeSlice = 0.3;
+ _this.progress = -1;
+ _this.framerate = framerate;
+ _this._frames = [];
+ _this._animations = {};
+ _this._data = null;
+ _this._nextFrameIndex = 0;
+ _this._index = 0;
+ _this._timerID = null;
+ _this._scale = 1;
+ return _this;
+ }
+ var _proto = SpriteSheetBuilder.prototype;
+ _proto.addFrame = function addFrame(source, sourceRect, scale, setupFunction, setupData) {
+ if (scale === void 0) {
+ scale = 1;
+ }
+ if (this._data) {
+ throw SpriteSheetBuilder.ERR_RUNNING;
+ }
+ var rect = sourceRect || source.bounds || source.nominalBounds || source.getBounds && source.getBounds();
+ if (!rect) {
+ return null;
+ }
+ return this._frames.push({
+ source: source,
+ sourceRect: rect,
+ scale: scale,
+ funct: setupFunction,
+ data: setupData,
+ index: this._frames.length,
+ height: rect.height * scale
+ }) - 1;
+ };
+ _proto.addAnimation = function addAnimation(name, frames, next, speed) {
+ if (this._data) {
+ throw SpriteSheetBuilder.ERR_RUNNING;
+ }
+ this._animations[name] = {
+ frames: frames,
+ next: next,
+ speed: speed
+ };
+ };
+ _proto.addMovieClip = function addMovieClip(source, sourceRect, scale, setupFunction, setupData, labelFunction) {
+ if (scale === void 0) {
+ scale = 1;
+ }
+ if (this._data) {
+ throw SpriteSheetBuilder.ERR_RUNNING;
+ }
+ var rects = source.frameBounds;
+ var rect = sourceRect || source.bounds || source.nominalBounds || source.getBounds && source.getBounds();
+ if (!rect && !rects) {
+ return;
+ }
+ var baseFrameIndex = this._frames.length;
+ var duration = source.timeline.duration;
+ for (var i = 0; i < duration; i++) {
+ var r = rects && rects[i] ? rects[i] : rect;
+ this.addFrame(source, r, scale, this._setupMovieClipFrame, {
+ i: i,
+ f: setupFunction,
+ d: setupData
+ });
+ }
+ var labels = source.timeline._labels;
+ var lbls = [];
+ for (var n in labels) {
+ lbls.push({
+ index: labels[n],
+ label: n
+ });
+ }
+ if (lbls.length) {
+ lbls.sort(function (a, b) {
+ return a.index - b.index;
+ });
+ for (var _i = 0, l = lbls.length; _i < l; _i++) {
+ var label = lbls[_i].label;
+ var start = baseFrameIndex + lbls[_i].index;
+ var end = baseFrameIndex + (_i === l - 1 ? duration : lbls[_i + 1].index);
+ var frames = [];
+ for (var _i2 = start; _i2 < end; _i2++) {
+ frames.push(_i2);
+ }
+ if (labelFunction) {
+ label = labelFunction(label, source, start, end);
+ if (!label) {
+ continue;
+ }
+ }
+ this.addAnimation(label, frames, true);
+ }
+ }
+ };
+ _proto.build = function build() {
+ if (this._data) {
+ throw SpriteSheetBuilder.ERR_RUNNING;
+ }
+ this._startBuild();
+ while (this._drawNext()) {}
+ this._endBuild();
+ return this.spriteSheet;
+ };
+ _proto.buildAsync = function buildAsync(timeSlice) {
+ var _this2 = this;
+ if (this._data) {
+ throw SpriteSheetBuilder.ERR_RUNNING;
+ }
+ this.timeSlice = timeSlice;
+ this._startBuild();
+ this._timerID = setTimeout(function () {
+ return _this2._run();
+ }, 50 - Math.max(0.01, Math.min(0.99, this.timeSlice || 0.3)) * 50);
+ };
+ _proto.stopAsync = function stopAsync() {
+ clearTimeout(this._timerID);
+ this._data = null;
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + "]";
+ };
+ _proto._startBuild = function _startBuild() {
+ var pad = this.padding || 0;
+ this.progress = 0;
+ this.spriteSheet = null;
+ this._index = 0;
+ this._scale = this.scale;
+ var dataFrames = [];
+ this._data = {
+ images: [],
+ frames: dataFrames,
+ framerate: this.framerate,
+ animations: this._animations
+ };
+ var frames = this._frames.slice();
+ frames.sort(function (a, b) {
+ return a.height <= b.height ? -1 : 1;
+ });
+ if (frames[frames.length - 1].height + pad * 2 > this.maxHeight) {
+ throw SpriteSheetBuilder.ERR_DIMENSIONS;
+ }
+ var y = 0,
+ x = 0;
+ var img = 0;
+ while (frames.length) {
+ var o = this._fillRow(frames, y, img, dataFrames, pad);
+ if (o.w > x) {
+ x = o.w;
+ }
+ y += o.h;
+ if (!o.h || !frames.length) {
+ var canvas = window.createjs && createjs.createCanvas ? createjs.createCanvas() : document.createElement("canvas");
+ canvas.width = this._getSize(x, this.maxWidth);
+ canvas.height = this._getSize(y, this.maxHeight);
+ this._data.images[img] = canvas;
+ if (!o.h) {
+ x = y = 0;
+ img++;
+ }
+ }
+ }
+ };
+ _proto._setupMovieClipFrame = function _setupMovieClipFrame(source, data) {
+ var ae = source.actionsEnabled;
+ source.actionsEnabled = false;
+ source.gotoAndStop(data.i);
+ source.actionsEnabled = ae;
+ data.f && data.f(source, data.d, data.i);
+ };
+ _proto._getSize = function _getSize(size, max) {
+ var pow = 4;
+ while (Math.pow(2, ++pow) < size) {}
+ return Math.min(max, Math.pow(2, pow));
+ };
+ _proto._fillRow = function _fillRow(frames, y, img, dataFrames, pad) {
+ var w = this.maxWidth;
+ var maxH = this.maxHeight;
+ y += pad;
+ var h = maxH - y;
+ var x = pad;
+ var height = 0;
+ for (var i = frames.length - 1; i >= 0; i--) {
+ var frame = frames[i];
+ var sc = this._scale * frame.scale;
+ var rect = frame.sourceRect;
+ var source = frame.source;
+ var rx = Math.floor(sc * rect.x - pad);
+ var ry = Math.floor(sc * rect.y - pad);
+ var rh = Math.ceil(sc * rect.height + pad * 2);
+ var rw = Math.ceil(sc * rect.width + pad * 2);
+ if (rw > w) {
+ throw SpriteSheetBuilder.ERR_DIMENSIONS;
+ }
+ if (rh > h || x + rw > w) {
+ continue;
+ }
+ frame.img = img;
+ frame.rect = new Rectangle(x, y, rw, rh);
+ height = height || rh;
+ frames.splice(i, 1);
+ dataFrames[frame.index] = [x, y, rw, rh, img, Math.round(-rx + sc * source.regX - pad), Math.round(-ry + sc * source.regY - pad)];
+ x += rw;
+ }
+ return {
+ w: x,
+ h: height
+ };
+ };
+ _proto._endBuild = function _endBuild() {
+ this.spriteSheet = new SpriteSheet(this._data);
+ this._data = null;
+ this.progress = 1;
+ this.dispatchEvent("complete");
+ };
+ _proto._run = function _run() {
+ var _this3 = this;
+ var ts = Math.max(0.01, Math.min(0.99, this.timeSlice || 0.3)) * 50;
+ var t = new Date().getTime() + ts;
+ var complete = false;
+ while (t > new Date().getTime()) {
+ if (!this._drawNext()) {
+ complete = true;
+ break;
+ }
+ }
+ if (complete) {
+ this._endBuild();
+ } else {
+ this._timerID = setTimeout(function () {
+ return _this3._run();
+ }, 50 - ts);
+ }
+ var p = this.progress = this._index / this._frames.length;
+ if (this.hasEventListener("progress")) {
+ var evt = new Event("progress");
+ evt.progress = p;
+ this.dispatchEvent(evt);
+ }
+ };
+ _proto._drawNext = function _drawNext() {
+ var frame = this._frames[this._index];
+ var sc = frame.scale * this._scale;
+ var rect = frame.rect;
+ var sourceRect = frame.sourceRect;
+ var canvas = this._data.images[frame.img];
+ var ctx = canvas.getContext("2d");
+ frame.funct && frame.funct(frame.source, frame.data);
+ ctx.save();
+ ctx.beginPath();
+ ctx.rect(rect.x, rect.y, rect.width, rect.height);
+ ctx.clip();
+ ctx.translate(Math.ceil(rect.x - sourceRect.x * sc), Math.ceil(rect.y - sourceRect.y * sc));
+ ctx.scale(sc, sc);
+ frame.source.draw(ctx);
+ ctx.restore();
+ return ++this._index < this._frames.length;
+ };
+ return SpriteSheetBuilder;
+ }(EventDispatcher);
+ SpriteSheetBuilder.ERR_DIMENSIONS = "frame dimensions exceed max spritesheet dimensions";
+ SpriteSheetBuilder.ERR_RUNNING = "a build is already running";
+
+ var SpriteSheetUtils = {
+ _workingCanvas: createCanvas(),
+ get _workingContext() {
+ return this._workingCanvas.getContext("2d");
+ },
+ extractFrame: function extractFrame(spriteSheet, frameOrAnimation) {
+ if (isNaN(frameOrAnimation)) {
+ frameOrAnimation = spriteSheet.getAnimation(frameOrAnimation).frames[0];
+ }
+ var data = spriteSheet.getFrame(frameOrAnimation);
+ if (!data) {
+ return null;
+ }
+ var r = data.rect;
+ var canvas = this._workingCanvas;
+ canvas.width = r.width;
+ canvas.height = r.height;
+ this._workingContext.drawImage(data.image, r.x, r.y, r.width, r.height, 0, 0, r.width, r.height);
+ var img = document.createElement("img");
+ img.src = canvas.toDataURL("image/png");
+ return img;
+ },
+ _flip: function _flip(spriteSheet, count, h, v) {
+ var imgs = spriteSheet._images;
+ var canvas = this._workingCanvas;
+ var ctx = this._workingContext;
+ var il = imgs.length / count;
+ for (var i = 0; i < il; i++) {
+ var src = imgs[i];
+ src.__tmp = i;
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
+ ctx.clearRect(0, 0, canvas.width + 1, canvas.height + 1);
+ canvas.width = src.width;
+ canvas.height = src.height;
+ ctx.setTransform(h ? -1 : 1, 0, 0, v ? -1 : 1, h ? src.width : 0, v ? src.height : 0);
+ ctx.drawImage(src, 0, 0);
+ var img = document.createElement("img");
+ img.src = canvas.toDataURL("image/png");
+ img.width = src.width || src.naturalWidth;
+ img.height = src.height || src.naturalHeight;
+ imgs.push(img);
+ }
+ var frames = spriteSheet._frames;
+ var fl = frames.length / count;
+ for (var _i = 0; _i < fl; _i++) {
+ var _src = frames[_i];
+ var rect = _src.rect.clone();
+ var _img = imgs[_src.image.__tmp + il * count];
+ var frame = {
+ image: _img,
+ rect: rect,
+ regX: _src.regX,
+ regY: _src.regY
+ };
+ if (h) {
+ rect.x = (_img.width || _img.naturalWidth) - rect.x - rect.width;
+ frame.regX = rect.width - _src.regX;
+ }
+ if (v) {
+ rect.y = (_img.height || _img.naturalHeight) - rect.y - rect.height;
+ frame.regY = rect.height - _src.regY;
+ }
+ frames.push(frame);
+ }
+ var sfx = "_" + (h ? "h" : "") + (v ? "v" : "");
+ var names = spriteSheet._animations;
+ var data = spriteSheet._data;
+ var al = names.length / count;
+ for (var _i2 = 0; _i2 < al; _i2++) {
+ var name = names[_i2];
+ var _src2 = data[name];
+ var anim = {
+ name: name + sfx,
+ speed: _src2.speed,
+ next: _src2.next,
+ frames: []
+ };
+ if (_src2.next) {
+ anim.next += sfx;
+ }
+ var _frames = _src2.frames;
+ for (var _i3 = 0, l = _frames.length; _i3 < l; _i3++) {
+ anim.frames.push(_frames[_i3] + fl * count);
+ }
+ data[anim.name] = anim;
+ names.push(anim.name);
+ }
+ }
+ };
+
+ var WebGLInspector =
+ function (_EventDispatcher) {
+ _inheritsLoose(WebGLInspector, _EventDispatcher);
+ function WebGLInspector(stage) {
+ var _this;
+ _this = _EventDispatcher.call(this) || this;
+ _this._stage = stage;
+ return _this;
+ }
+ WebGLInspector.dispProps = function dispProps(item, prepend) {
+ if (prepend === void 0) {
+ prepend = "";
+ }
+ var p = "\tP: " + item.x.toFixed(2) + "x" + item.y.toFixed(2) + "\t";
+ var r = "\tR: " + item.regX.toFixed(2) + "x" + item.regY.toFixed(2) + "\t";
+ WebGLInspector._log(prepend, item.toString() + "\t", p, r);
+ };
+ WebGLInspector._log = function _log() {
+ if (WebGLInspector.alternateOutput) {
+ var _WebGLInspector$alter;
+ (_WebGLInspector$alter = WebGLInspector.alternateOutput).log.apply(_WebGLInspector$alter, arguments);
+ } else {
+ var _console;
+ (_console = console).log.apply(_console, arguments);
+ }
+ };
+ var _proto = WebGLInspector.prototype;
+ _proto.log = function log(stage) {
+ if (!stage) {
+ stage = this._stage;
+ }
+ WebGLInspector._log("Batches Per Draw: " + (stage._batchID / stage._drawID).toFixed(4));
+ this.logContextInfo(stage._webGLContext);
+ this.logDepth(stage.children, "");
+ this.logTextureFill(stage);
+ };
+ _proto.toggleGPUDraw = function toggleGPUDraw(stage, enabled) {
+ if (!stage) {
+ stage = this._stage;
+ }
+ if (enabled === undefined) {
+ enabled = !!stage._drawBuffers_;
+ }
+ if (enabled && stage._drawBuffers_) {
+ stage._drawBuffers = stage._drawBuffers_;
+ stage._drawBuffers_ = undefined;
+ } else {
+ stage._drawBuffers_ = stage._drawBuffers;
+ stage._drawBuffers = function _inspectorDrawBuffers(gl) {
+ if (this.vocalDebug) {
+ WebGLInspector._log("BlankDraw[" + this._drawID + ":" + this._batchID + "] : " + this.batchReason);
+ }
+ };
+ }
+ };
+ _proto.logDepth = function logDepth(children, prepend, logFunc) {
+ if (prepend === void 0) {
+ prepend = "";
+ }
+ if (logFunc === void 0) {
+ logFunc = WebGLInspector._log;
+ }
+ if (!children) {
+ children = this._stage.children;
+ }
+ var l = children.length;
+ for (var i = 0; i < l; i++) {
+ var child = children[i];
+ logFunc(prepend + "-", child);
+ if (child.children && child.children.length) {
+ this.logDepth(child.children, "|" + prepend, logFunc);
+ }
+ }
+ };
+ _proto.logContextInfo = function logContextInfo(gl) {
+ if (!gl) {
+ gl = this._stage._webGLContext;
+ }
+ var data = "\n\t\t\t== LOG:\n\n\t\t\tMax textures per draw: " + gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS) + "\n\n\t\t\tMax textures active: " + gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS) + "\n\n\t\t\t\n\n\t\t\tMax texture size: " + gl.getParameter(gl.MAX_TEXTURE_SIZE) / 2 + "\n\n\t\t\tMax cache size: " + gl.getParameter(gl.MAX_RENDERBUFFER_SIZE) / 2 + "\n\n\t\t\t\n\n\t\t\tMax attributes per vertex: " + gl.getParameter(gl.MAX_VERTEX_ATTRIBS) + "\n\n\t\t\tWebGL Version string: " + gl.getParameter(gl.VERSION) + "\n\n\t\t\t======\n\t\t";
+ WebGLInspector._log(data);
+ };
+ _proto.logTextureFill = function logTextureFill(stage) {
+ if (!stage) {
+ stage = this._stage;
+ }
+ var dict = stage._textureDictionary;
+ var count = stage._batchTextureCount;
+ WebGLInspector._log(textureMax + ": " + count);
+ var output = [];
+ for (var n in dict) {
+ var str = n.replace(window.location.origin, "");
+ var tex = dict[n];
+ var shifted = tex._lastActiveIndex ? tex._lastActiveIndex === tex._activeIndex : false;
+ output.push({
+ src: src,
+ element: tex,
+ shifted: shifted
+ });
+ tex._lastActiveIndex = tex._activeIndex;
+ }
+ output.sort(function (a, b) {
+ if (a.element._drawID === stage._drawID) {
+ return 1;
+ }
+ if (a.element._drawID < b.element._drawID) {
+ return -1;
+ }
+ return 0;
+ });
+ var l = output.length;
+ for (var i = 0; i < l; i++) {
+ var out = output[i];
+ var active = out.element._drawID === stage._drawID;
+ WebGLInspector._log("[" + out.src + "] " + (active ? "ACTIVE" : "stale") + " " + (out.shifted ? "steady" : "DRIFT"), out.element);
+ }
+ };
+ return WebGLInspector;
+ }(EventDispatcher);
+ WebGLInspector.alternateOutput = null;
+
+ exports.Event = Event;
+ exports.EventDispatcher = EventDispatcher;
+ exports.Ticker = Ticker;
+ exports.StageGL = StageGL;
+ exports.Stage = Stage;
+ exports.Container = Container;
+ exports.DisplayObject = DisplayObject;
+ exports.Bitmap = Bitmap;
+ exports.BitmapText = BitmapText;
+ exports.DOMElement = DOMElement;
+ exports.Graphics = Graphics;
+ exports.MovieClip = MovieClip;
+ exports.Shadow = Shadow;
+ exports.Shape = Shape;
+ exports.Sprite = Sprite;
+ exports.SpriteSheet = SpriteSheet;
+ exports.Text = Text;
+ exports.MouseEvent = MouseEvent;
+ exports.AlphaMapFilter = AlphaMapFilter;
+ exports.AlphaMaskFilter = AlphaMaskFilter;
+ exports.BitmapCache = BitmapCache;
+ exports.BlurFilter = BlurFilter;
+ exports.ColorFilter = ColorFilter;
+ exports.ColorMatrix = ColorMatrix;
+ exports.ColorMatrixFilter = ColorMatrixFilter;
+ exports.Filter = Filter;
+ exports.DisplayProps = DisplayProps;
+ exports.Matrix2D = Matrix2D;
+ exports.Point = Point;
+ exports.Rectangle = Rectangle;
+ exports.ButtonHelper = ButtonHelper;
+ exports.Touch = Touch;
+ exports.SpriteSheetBuilder = SpriteSheetBuilder;
+ exports.SpriteSheetUtils = SpriteSheetUtils;
+ exports.uid = uid;
+ exports.createCanvas = createCanvas;
+ exports.WebGLInspector = WebGLInspector;
+
+ var v = exports.versions = exports.versions || {};
+ v.easeljs = "NEXT";
+
+}((this.createjs = this.createjs || {}),this.createjs));
+//# sourceMappingURL=easeljs-NEXT.js.map
diff --git a/dist/easeljs-NEXT.js.map b/dist/easeljs-NEXT.js.map
new file mode 100644
index 000000000..57fc6ebbf
--- /dev/null
+++ b/dist/easeljs-NEXT.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"easeljs-NEXT.js","sources":["../../core/src/events/Event.js","../../core/src/events/EventDispatcher.js","../../core/src/utils/Ticker.js","../src/display/StageGL.js","../src/display/Shadow.js","../src/utils/uid.js","../src/geom/Point.js","../src/geom/Matrix2D.js","../src/geom/DisplayProps.js","../src/geom/Rectangle.js","../src/filters/Filter.js","../src/filters/BitmapCache.js","../src/display/DisplayObject.js","../src/display/Container.js","../src/events/MouseEvent.js","../src/display/Stage.js","../src/utils/Canvas.js","../src/utils/VideoBuffer.js","../src/display/Bitmap.js","../src/display/Sprite.js","../src/display/BitmapText.js","../src/display/DOMElement.js","../src/display/Graphics.js","../src/display/MovieClip.js","../src/display/Shape.js","../src/display/SpriteSheet.js","../src/display/Text.js","../src/filters/AlphaMapFilter.js","../src/filters/AlphaMaskFilter.js","../src/filters/BlurFilter.js","../src/filters/ColorFilter.js","../src/filters/ColorMatrix.js","../src/filters/ColorMatrixFilter.js","../src/ui/ButtonHelper.js","../src/ui/Touch.js","../src/utils/SpriteSheetBuilder.js","../src/utils/SpriteSheetUtils.js","../src/utils/WebGLInspector.js"],"sourcesContent":["/**\n * @license Event\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * Contains properties and methods shared by all events for use with {@link core.EventDispatcher}.\n * Note that Event objects are often reused, so you should never\n * rely on an event object's state outside of the call stack it was received in.\n *\n * @memberof core\n * @example\n * const evt = new Event(\"myEvent\");\n * const dispatcher = new EventDispatcher();\n * dispatcher.on(\"myEvent\", event => console.log(event.type));\n * dispatcher.dispatchEvent(evt); // logs \"myEvent\"\n *\n * @param {string} type The event type.\n * @param {boolean} [bubbles=false] Indicates whether the event will bubble through the display list.\n * @param {boolean} [cancelable=false] Indicates whether the default behaviour of this event can be cancelled.\n */\nclass Event {\n\n\tconstructor (type, bubbles = false, cancelable = false) {\n\t\t/**\n\t\t * The type of event.\n\t\t * @type string\n\t\t */\n\t\tthis.type = type;\n\n\t\t/**\n\t\t * The object that generated an event.\n\t\t *\n\t\t * @type Object\n\t\t * @default null\n\t\t * @readonly\n\t\t */\n\t\tthis.target = null;\n\n\t\t/**\n\t\t * The current target that a bubbling event is being dispatched from. For non-bubbling events, this will\n\t\t * always be the same as target. For example, if childObj.parent = parentObj, and a bubbling event\n\t\t * is generated from childObj, then a listener on parentObj would receive the event with\n\t\t * target=childObj (the original target) and currentTarget=parentObj (where the listener was added).\n\t\t *\n\t\t * @type Object\n\t\t * @default null\n\t\t * @readonly\n\t\t */\n\t\tthis.currentTarget = null;\n\n\t\t/**\n\t\t * For bubbling events, this indicates the current event phase:\n\t\t * \n\t\t * \t
capture phase: starting from the top parent to the target
\n\t\t * \t
at target phase: currently being dispatched from the target
\n\t\t * \t
bubbling phase: from the target to the top parent
\n\t\t * \n\t\t *\n\t\t * @type number\n\t\t * @default 0\n\t\t * @readonly\n\t\t */\n\t\tthis.eventPhase = 0;\n\n\t\t/**\n\t\t * Indicates whether the event will bubble through the display list.\n\t\t *\n\t\t * @type boolean\n\t\t * @readonly\n\t\t */\n\t\tthis.bubbles = bubbles;\n\n\t\t/**\n\t\t * Indicates whether the default behaviour of this event can be cancelled via {@link core.Event#preventDefault}.\n\t\t *\n\t\t * @type boolean\n\t\t * @readonly\n\t\t */\n\t\tthis.cancelable = cancelable;\n\n\t\t/**\n\t\t * The epoch time at which this event was created.\n\t\t *\n\t\t * @type number\n\t\t * @readonly\n\t\t */\n\t\tthis.timeStamp = new Date().getTime();\n\n\t\t/**\n\t\t * Indicates if {@link core.Event#preventDefault} has been called on this event.\n\t\t *\n\t\t * @type boolean\n\t\t * @default false\n\t\t * @readonly\n\t\t */\n\t\tthis.defaultPrevented = false;\n\n\t\t/**\n\t\t * Indicates if {@link core.Event#stopPropagation} or {@link core.Event#stopImmediatePropagation} has been called on this event.\n\t\t *\n\t\t * @type boolean\n\t\t * @default false\n\t\t * @readonly\n\t\t */\n\t\tthis.propagationStopped = false;\n\n\t\t/**\n\t\t * Indicates if {@link core.Event#stopImmediatePropagation} has been called on this event.\n\t\t *\n\t\t * @type boolean\n\t\t * @default false\n\t\t * @readonly\n\t\t */\n\t\tthis.immediatePropagationStopped = false;\n\n\t\t/**\n\t\t * Indicates if {@link core.Event#remove} has been called on this event.\n\t\t *\n\t\t * @type boolean\n\t\t * @default false\n\t\t * @readonly\n\t\t */\n\t\tthis.removed = false;\n\t}\n\n\t/**\n\t * Sets {@link core.Event#defaultPrevented} to true if the event is cancelable.\n\t * Mirrors the DOM level 2 event standard. In general, cancelable events that have `preventDefault()` called will\n\t * cancel the default behaviour associated with the event.\n\t * @return {core.Event} this, chainable\n\t */\n\tpreventDefault () {\n\t\tthis.defaultPrevented = this.cancelable;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets {@link core.Event#propagationStopped} to true.\n\t * Mirrors the DOM event standard.\n\t * @return {core.Event} this, chainable\n\t */\n\tstopPropagation () {\n\t\tthis.propagationStopped = true;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets {@link core.Event#propagationStopped} and {@link core.Event#immediatePropagationStopped} to true.\n\t * Mirrors the DOM event standard.\n\t * @return {core.Event} this, chainable\n\t */\n\tstopImmediatePropagation () {\n\t\tthis.immediatePropagationStopped = this.propagationStopped = true;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Causes the active listener to be removed via removeEventListener();\n\t *\n\t * @example\n\t * myBtn.addEventListener(\"click\", event => {\n\t * event.remove(); // removes this listener.\n\t * });\n\t *\n\t * @return {core.Event} this, chainable\n\t */\n\tremove () {\n\t\tthis.removed = true;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns a clone of the Event instance.\n\t *\n\t * @return {core.Event} a clone of the Event instance.\n\t */\n\tclone () {\n\t\tconst event = new Event(this.type, this.bubbles, this.cancelable);\n\t\tfor (let n in this) {\n\t\t\tif (this.hasOwnProperty(n)) {\n\t\t\t\tevent[n] = this[n];\n\t\t\t}\n\t\t}\n\t\treturn event;\n\t}\n\n\t/**\n\t * Provides a return {core.Event} this, chainable shortcut method for setting a number of properties on the instance.\n\t *\n\t * @param {Object} props A generic object containing properties to copy to the instance.\n\t * @return {core.Event} this, chainable\n\t */\n\tset (props) {\n\t\tfor (let n in props) { this[n] = props[n]; }\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t *\n\t * @return {string} A string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name} (type=${this.type})]`;\n\t}\n\n}\n\nexport default Event;\n","/**\n * @license EventDispatcher\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Event from \"./Event\";\n\n/**\n * EventDispatcher provides methods for managing queues of event listeners and dispatching events.\n *\n * You can either extend EventDispatcher or mix its methods into an existing prototype or instance by using the\n * EventDispatcher {@link core.EventDispatcher.initialize} method.\n *\n * Together with the CreateJS Event class, EventDispatcher provides an extended event model that is based on the\n * DOM Level 2 event model, including addEventListener, removeEventListener, and dispatchEvent. It supports\n * bubbling / capture, preventDefault, stopPropagation, stopImmediatePropagation, and handleEvent.\n *\n * EventDispatcher also exposes a {@link core.EventDispatcher#on} method, which makes it easier\n * to create scoped listeners, listeners that only run once, and listeners with associated arbitrary data. The\n * {@link core.EventDispatcher#off} method is merely an alias to {@link core.EventDispatcher#removeEventListener}.\n *\n * Another addition to the DOM Level 2 model is the {@link core.EventDispatcher#removeAllEventListeners}\n * method, which can be used to listeners for all events, or listeners for a specific event. The Event object also\n * includes a {@link core.Event#remove} method which removes the active listener.\n *\n * @memberof core\n * @example\n * // add EventDispatcher capabilities to the \"MyClass\" class.\n * EventDispatcher.initialize(MyClass.prototype);\n *\n * // Add an event.\n * instance.addEventListener(\"eventName\", event => console.log(event.target + \" was clicked.\"));\n *\n * // scope (\"this\") can be be a challenge with events.\n * // using the {@link core.EventDispatcher#on} method to subscribe to events simplifies this.\n * instance.addEventListener(\"click\", event => console.log(instance === this)); // false, scope is ambiguous.\n * instance.on(\"click\", event => console.log(instance === this)); // true, `on` uses dispatcher scope by default.\n */\nclass EventDispatcher {\n\n\t/**\n\t * Static initializer to mix EventDispatcher methods into a target object or prototype.\n\t *\n\t * @static\n\t * @example\n\t * EventDispatcher.initialize(MyClass.prototype); // add to the prototype of the class\n\t * EventDispatcher.initialize(myInstance); // add to a specific instance\n\t *\n\t * @param {Object} target The target object to inject EventDispatcher methods into.\n\t */\n\tstatic initialize (target) {\n\t\tconst p = EventDispatcher.prototype;\n\t\ttarget.addEventListener = p.addEventListener;\n\t\ttarget.on = p.on;\n\t\ttarget.removeEventListener = target.off = p.removeEventListener;\n\t\ttarget.removeAllEventListeners = p.removeAllEventListeners;\n\t\ttarget.hasEventListener = p.hasEventListener;\n\t\ttarget.dispatchEvent = p.dispatchEvent;\n\t\ttarget._dispatchEvent = p._dispatchEvent;\n\t\ttarget.willTrigger = p.willTrigger;\n\t}\n\n\tconstructor () {\n\t\t/**\n\t\t * @private\n\t\t * @default null\n\t\t * @type Object\n\t\t */\n\t\tthis._listeners = null;\n\n\t\t/**\n\t\t * @private\n\t\t * @default null\n\t\t * @type Object\n\t\t */\n\t\tthis._captureListeners = null;\n\t}\n\n\t/**\n\t * Adds the specified event listener. Note that adding multiple listeners to the same function will result in\n\t * multiple callbacks getting fired.\n\t *\n\t * @example\n\t * displayObject.addEventListener(\"click\", event => console.log('clicked', event));\n\t *\n\t * @param {string} type The string type of the event.\n\t * @param {Function|Object} listener An object with a handleEvent method, or a function that will be called when the event is dispatched.\n\t * @param {boolean} [useCapture=false] For events that bubble, indicates whether to listen for the event in the capture or bubbling/target phase.\n\t * @return {Function|Object} Returns the listener for chaining or assignment.\n\t */\n\taddEventListener (type, listener, useCapture = false) {\n\t\tlet listeners;\n\t\tif (useCapture) {\n\t\t\tlisteners = this._captureListeners = this._captureListeners || {};\n\t\t} else {\n\t\t\tlisteners = this._listeners = this._listeners || {};\n\t\t}\n\t\tlet arr = listeners[type];\n\t\tif (arr) {\n\t\t\tthis.removeEventListener(type, listener, useCapture);\n\t\t\tarr = listeners[type]; // remove may have deleted the array\n\t\t}\n\t\tif (arr) { arr.push(listener); }\n\t\telse { listeners[type] = [listener]; }\n\t\treturn listener;\n\t}\n\n\t/**\n\t * A shortcut method for using addEventListener that makes it easier to specify an execution scope, have a listener\n\t * only run once, associate arbitrary data with the listener, and remove the listener.\n\t *\n\t * This method works by creating an anonymous wrapper function and subscribing it with `addEventListener`.\n\t * The wrapper function is returned for use with `removeEventListener` (or `off`).\n\t *\n\t * To remove a listener added with `on`, you must pass in the returned wrapper function as the listener, or use\n\t * {@link core.Event#remove}. Likewise, each time you call `on` a NEW wrapper function is subscribed, so multiple calls\n\t * to `on` with the same params will create multiple listeners.\n\t *\n\t * @example\n\t * const listener = myBtn.on(\"click\", handleClick, null, false, { count: 3 });\n\t * function handleClick (evt, data) {\n\t * data.count -= 1;\n\t * console.log(this == myBtn); // true - scope defaults to the dispatcher\n\t * if (data.count == 0) {\n\t * alert(\"clicked 3 times!\");\n\t * myBtn.off(\"click\", listener);\n\t * // alternately: evt.remove();\n\t * }\n\t * }\n\t *\n\t * @param {string} type The string type of the event.\n\t * @param {Function|Object} listener An object with a handleEvent method, or a function that will be called when the event is dispatched.\n\t * @param {Object} [scope=null] The scope to execute the listener in. Defaults to the dispatcher/currentTarget for function listeners, and to the listener itself for object listeners (ie. using handleEvent).\n\t * @param {boolean} [once=false] If true, the listener will remove itself after the first time it is triggered.\n\t * @param {*} [data={}] Arbitrary data that will be included as the second parameter when the listener is called.\n\t * @param {boolean} [useCapture=false] For events that bubble, indicates whether to listen for the event in the capture or bubbling/target phase.\n\t * @return {Function} Returns the anonymous function that was created and assigned as the listener. This is needed to remove the listener later using .removeEventListener.\n\t */\n\ton (type, listener, scope = null, once = false, data = {}, useCapture = false) {\n\t\tif (listener.handleEvent) {\n\t\t\tscope = scope || listener;\n\t\t\tlistener = listener.handleEvent;\n\t\t}\n\t\tscope = scope || this;\n\t\treturn this.addEventListener(type, evt => {\n\t\t\tlistener.call(scope, evt, data);\n\t\t\tonce && evt.remove();\n\t\t}, useCapture);\n\t}\n\n\t/**\n\t * Removes the specified event listener.\n\t *\n\t * You must pass the exact function reference used when the event was added. If a proxy\n\t * function, or function closure is used as the callback, the proxy/closure reference must be used - a new proxy or\n\t * closure will not work.\n\t *\n\t * @example\n\t * displayObject.removeEventListener(\"click\", handleClick);\n\t *\n\t * @param {string} type The string type of the event.\n\t * @param {Function|Object} listener The listener function or object.\n\t * @param {boolean} [useCapture=false] For events that bubble, indicates whether to listen for the event in the capture or bubbling/target phase.\n\t */\n\tremoveEventListener (type, listener, useCapture = false) {\n\t\tconst listeners = useCapture ? this._captureListeners : this._listeners;\n\t\tif (!listeners) { return; }\n\t\tconst arr = listeners[type];\n\t\tif (!arr) { return; }\n\t\tconst l = arr.length;\n\t\tfor (let i = 0; i < l; i++) {\n\t\t\tif (arr[i] === listener) {\n\t\t\t\tif (l === 1) { delete(listeners[type]); } // allows for faster checks.\n\t\t\t\telse { arr.splice(i, 1); }\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * A shortcut to the removeEventListener method, with the same parameters and return value. This is a companion to the\n\t * `on` method.\n\t *\n\t * To remove a listener added with `on`, you must pass in the returned wrapper function as the listener. See\n\t * {@link core.EventDispatcher#on} for an example.\n\t *\n\t * @param {string} type The string type of the event.\n\t * @param {Function|Object} listener The listener function or object.\n\t * @param {boolean} [useCapture=false] For events that bubble, indicates whether to listen for the event in the capture or bubbling/target phase.\n\t */\n\toff (type, listener, useCapture = false) {\n\t\tthis.removeEventListener(type, listener, useCapture);\n\t}\n\n\t/**\n\t * Removes all listeners for the specified type, or all listeners of all types.\n\t *\n\t * @example\n\t * // remove all listeners\n\t * displayObject.removeAllEventListeners();\n\t *\n\t * // remove all click listeners\n\t * displayObject.removeAllEventListeners(\"click\");\n\t *\n\t * @param {string} [type=null] The string type of the event. If omitted, all listeners for all types will be removed.\n\t */\n\tremoveAllEventListeners (type = null) {\n\t\tif (type) {\n\t\t\tif (this._listeners) { delete(this._listeners[type]); }\n\t\t\tif (this._captureListeners) { delete(this._captureListeners[type]); }\n\t\t} else {\n\t\t\tthis._listeners = this._captureListeners = null;\n\t\t}\n\t}\n\n\t/**\n\t * Dispatches the specified event to all listeners.\n\t *\n\t * @example\n\t * // use a string event\n\t * this.dispatchEvent(\"complete\")\n\t *\n\t * // use an Event instance\n\t * const event = new createjs.Event(\"progress\");\n\t * this.dispatchEvent(event);\n\t *\n\t * @param {Object|Event|string} eventObj An object with a \"type\" property, or a string type.\n\t * While a generic object will work, it is recommended to use a CreateJS Event instance. If a string is used,\n\t * dispatchEvent will construct an Event instance if necessary with the specified type. This latter approach can\n\t * be used to avoid event object instantiation for non-bubbling events that may not have any listeners.\n\t * @param {boolean} [bubbles=false] Specifies the `bubbles` value when a string was passed to eventObj.\n\t * @param {boolean} [cancelable=false] Specifies the `cancelable` value when a string was passed to eventObj.\n\t * @return {boolean} Returns false if `preventDefault()` was called on a cancelable event, true otherwise.\n\t */\n\tdispatchEvent (eventObj, bubbles = false, cancelable = false) {\n\t\tif (typeof eventObj === \"string\") {\n\t\t\t// skip everything if there's no listeners and it doesn't bubble:\n\t\t\tconst listeners = this._listeners;\n\t\t\tif (!bubbles && (!listeners || !listeners[eventObj])) { return true; }\n\t\t\teventObj = new Event(eventObj, bubbles, cancelable);\n\t\t} else if (eventObj.target && eventObj.clone) {\n\t\t\t// redispatching an active event object, so clone it:\n\t\t\teventObj = eventObj.clone();\n\t\t}\n\n\t\t// TODO: it would be nice to eliminate this. Maybe in favour of evtObj instanceof Event? Or !!evtObj.createEvent\n\t\ttry { eventObj.target = this; } catch (e) {} // try/catch allows redispatching of native events\n\n\t\tif (!eventObj.bubbles || !this.parent) {\n\t\t\tthis._dispatchEvent(eventObj, 2);\n\t\t} else {\n\t\t\tlet top = this;\n\t\t\tconst list = [top];\n\t\t\twhile (top.parent) { list.push(top = top.parent); }\n\t\t\tconst l = list.length;\n\t\t\tlet i;\n\n\t\t\t// capture & atTarget\n\t\t\tfor (i = l - 1; i >= 0 && !eventObj.propagationStopped; i--) {\n\t\t\t\tlist[i]._dispatchEvent(eventObj, 1+(i==0));\n\t\t\t}\n\t\t\t// bubbling\n\t\t\tfor (i = 1; i < l && !eventObj.propagationStopped; i++) {\n\t\t\t\tlist[i]._dispatchEvent(eventObj, 3);\n\t\t\t}\n\t\t}\n\t\treturn !eventObj.defaultPrevented;\n\t}\n\n\t/**\n\t * Indicates whether there is at least one listener for the specified event type.\n\t *\n\t * @param {string} type The string type of the event.\n\t * @return {boolean} Returns true if there is at least one listener for the specified event.\n\t */\n\thasEventListener (type) {\n\t\tconst listeners = this._listeners, captureListeners = this._captureListeners;\n\t\treturn !!((listeners && listeners[type]) || (captureListeners && captureListeners[type]));\n\t}\n\n\t/**\n\t * Indicates whether there is at least one listener for the specified event type on this object or any of its\n\t * ancestors (parent, parent's parent, etc). A return value of true indicates that if a bubbling event of the\n\t * specified type is dispatched from this object, it will trigger at least one listener.\n\t *\n\t * This is similar to {@link core.EventDispatcher#hasEventListener}, but it searches the entire\n\t * event flow for a listener, not just this object.\n\t *\n\t * @param {string} type The string type of the event.\n\t * @return {boolean} Returns `true` if there is at least one listener for the specified event.\n\t */\n\twillTrigger (type) {\n\t\tlet o = this;\n\t\twhile (o) {\n\t\t\tif (o.hasEventListener(type)) { return true; }\n\t\t\to = o.parent;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name + this.name ? ` ${this.name}` : \"\"}]`;\n\t}\n\n\t/**\n\t * @private\n\t * @param {Object|Event|string} eventObj\n\t * @param {Object} eventPhase\n\t */\n\t_dispatchEvent (eventObj, eventPhase) {\n\t\tconst listeners = eventPhase === 1 ? this._captureListeners : this._listeners;\n\t\tif (eventObj && listeners) {\n\t\t\tlet arr = listeners[eventObj.type];\n\t\t\tlet l;\n\t\t\tif (!arr || (l = arr.length) === 0) { return; }\n\t\t\ttry { eventObj.currentTarget = this; } catch (e) {}\n\t\t\ttry { eventObj.eventPhase = eventPhase; } catch (e) {}\n\t\t\teventObj.removed = false;\n\n\t\t\tarr = arr.slice(); // to avoid issues with items being removed or added during the dispatch\n\t\t\tfor (let i = 0; i < l && !eventObj.immediatePropagationStopped; i++) {\n\t\t\t\tlet o = arr[i];\n\t\t\t\tif (o.handleEvent) { o.handleEvent(eventObj); }\n\t\t\t\telse { o(eventObj); }\n\t\t\t\tif (eventObj.removed) {\n\t\t\t\t\tthis.off(eventObj.type, o, eventPhase === 1);\n\t\t\t\t\teventObj.removed = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n}\n\nexport default EventDispatcher;\n","/**\n * @license Ticker\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport EventDispatcher from \"../events/EventDispatcher\";\nimport Event from \"../events/Event\";\n\n/**\n * The Ticker provides a centralized tick or heartbeat broadcast at a set interval. Listeners can subscribe to the tick\n * event to be notified when a set time interval has elapsed.\n *\n * Note that the interval that the tick event is called is a target interval, and may be broadcast at a slower interval\n * when under high CPU load. The Ticker class uses a static interface (ex. `Ticker.framerate = 30;`) and\n * can not be instantiated.\n *\n * @todo Pass timingMode, maxDelta, paused values as instantiation arguments?\n *\n * @memberof core\n * @example\n * Ticker.addEventListener(\"tick\", event => {\n * // Actions carried out each tick (aka frame)\n * if (!event.paused) {\n * // Actions carried out when the Ticker is not paused.\n * }\n * });\n * @example\n * // Ticker export explanation\n * import Ticker, { Ticker as TickerClass, getTicker } from \"@createjs/core\";\n * Ticker.name, Ticker.RAF // -> createjs.global, undefined\n * TickerClass.RAF // -> raf\n * Ticker === getTicker(\"createjs.global\") // -> true\n *\n * @extends core.EventDispatcher\n * @param {string} name The name assigned to this instance.\n */\nclass Ticker extends EventDispatcher {\n\n\t/**\n\t * In this mode, Ticker uses the requestAnimationFrame API, but attempts to synch the ticks to target framerate. It\n\t * uses a simple heuristic that compares the time of the RAF return to the target time for the current frame and\n\t * dispatches the tick when the time is within a certain threshold.\n\t *\n\t * This mode has a higher variance for time between frames than {{#crossLink \"Ticker/TIMEOUT:property\"}}{{/crossLink}},\n\t * but does not require that content be time based as with {{#crossLink \"Ticker/RAF:property\"}}{{/crossLink}} while\n\t * gaining the benefits of that API (screen synch, background throttling).\n\t *\n\t * Variance is usually lowest for framerates that are a divisor of the RAF frequency. This is usually 60, so\n\t * framerates of 10, 12, 15, 20, and 30 work well.\n\t *\n\t * Falls back to {{#crossLink \"Ticker/TIMEOUT:property\"}}{{/crossLink}} if the requestAnimationFrame API is not\n\t * supported.\n\t *\n\t * @static\n\t * @type {string}\n\t * @default \"synched\"\n\t * @readonly\n\t */\n\tstatic get RAF_SYNCHED () { return \"synched\"; }\n\n\t/**\n\t * In this mode, Ticker passes through the requestAnimationFrame heartbeat, ignoring the target framerate completely.\n\t * Because requestAnimationFrame frequency is not deterministic, any content using this mode should be time based.\n\t * You can leverage {@link core.Ticker#getTime} and the {@link core.Ticker#event:tick}\n\t * event object's \"delta\" properties to make this easier.\n\t *\n\t * Falls back on {@link core.Ticker.TIMEOUT} if the requestAnimationFrame API is not supported.\n\t *\n\t * @static\n\t * @type {string}\n\t * @default \"raf\"\n\t * @readonly\n\t */\n\tstatic get RAF () { return \"raf\"; }\n\n\t/**\n\t * In this mode, Ticker uses the setTimeout API. This provides predictable, adaptive frame timing, but does not\n\t * provide the benefits of requestAnimationFrame (screen synch, background throttling).\n\t *\n\t * @static\n\t * @type {string}\n\t * @default \"timeout\"\n\t * @readonly\n\t */\n\tstatic get TIMEOUT () { return \"timeout\"; }\n\n\tconstructor (name) {\n\t\tsuper();\n\n\t\t/**\n\t\t * The name of this instance.\n\t\t * @type {string}\n\t\t */\n\t\tthis.name = name;\n\n\t\t/**\n\t\t * Specifies the timing api (setTimeout or requestAnimationFrame) and mode to use.\n\t\t *\n\t\t * @see {@link core.Ticker.TIMEOUT}\n\t\t * @see {@link core.Ticker.RAF}\n\t\t * @see {@link core.Ticker.RAF_SYNCHED}\n\t\t *\n\t\t * @type {string}\n\t\t * @default Ticker.TIMEOUT\n\t\t */\n\t\tthis.timingMode = Ticker.TIMEOUT;\n\n\t\t/**\n\t\t * Specifies a maximum value for the delta property in the tick event object. This is useful when building time\n\t\t * based animations and systems to prevent issues caused by large time gaps caused by background tabs, system sleep,\n\t\t * alert dialogs, or other blocking routines. Double the expected frame duration is often an effective value\n\t\t * (ex. maxDelta=50 when running at 40fps).\n\t\t *\n\t\t * This does not impact any other values (ex. time, runTime, etc), so you may experience issues if you enable maxDelta\n\t\t * when using both delta and other values.\n\t\t *\n\t\t * If 0, there is no maximum.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 0\n\t\t */\n\t\tthis.maxDelta = 0;\n\n\t\t/**\n\t\t * When the ticker is paused, all listeners will still receive a tick event, but the `paused` property\n\t\t * of the event will be `true`. Also, while paused the `runTime` will not increase.\n\t\t *\n\t\t * @example\n\t\t * Ticker.addEventListener(\"tick\", event => console.log(event.paused, Ticker.getTime(false), Ticker.getTime(true)));\n\t\t * Ticker.paused = true;\n\t\t *\n\t\t * @see {@link core.Ticker#event:tick}\n\t\t * @see {@link core.Ticker#getTime}\n\t\t * @see {@link core.Ticker#getEventTime}\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.paused = false;\n\n\t\t/**\n\t\t * @private\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis._inited = false;\n\n\t\t/**\n\t\t * @private\n\t\t * @type {number}\n\t\t * @default 0\n\t\t */\n\t\tthis._startTime = 0;\n\n\t\t/**\n\t\t * @private\n\t\t * @type {number}\n\t\t * @default 0\n\t\t */\n\t\tthis._pausedTime = 0;\n\n\t\t/**\n\t\t * The number of ticks that have passed.\n\t\t *\n\t\t * @private\n\t\t * @type {number}\n\t\t * @default 0\n\t\t */\n\t\tthis._ticks = 0;\n\n\t\t/**\n\t\t * The number of ticks that have passed while Ticker has been paused.\n\t\t *\n\t\t * @private\n\t\t * @type {number}\n\t\t * @default\n\t\t */\n\t\tthis._pausedTicks = 0;\n\n\t\t/**\n\t\t * @private\n\t\t * @type {number}\n\t\t * @default\n\t\t */\n\t\tthis._interval = 50;\n\n\t\t/**\n\t\t * @private\n\t\t * @type {number}\n\t\t * @default\n\t\t */\n\t\tthis._lastTime = 0;\n\n\t\t/**\n\t\t * @private\n\t\t * @type {Array}\n\t\t * @default null\n\t\t */\n\t\tthis._times = null;\n\n\t\t/**\n\t\t * @private\n\t\t * @type {Array}\n\t\t * @default null\n\t\t */\n\t\tthis._tickTimes = null;\n\n\t\t/**\n\t\t * Stores the timeout or requestAnimationFrame id.\n\t\t *\n\t\t * @private\n\t\t * @type {number}\n\t\t * @default null\n\t\t */\n\t\tthis._timerId = null;\n\n\t\t/**\n\t\t * True if currently using requestAnimationFrame, false if using setTimeout. This may be different than timingMode\n\t\t * if that property changed and a tick hasn't fired.\n\t\t *\n\t\t * @private\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis._raf = true;\n\t}\n\n\t/**\n\t * Indicates the target time (in milliseconds) between ticks. Default is 50 (20 FPS).\n\t * Note that actual time between ticks may be more than specified depending on CPU load.\n\t * This property is ignored if the ticker is using the `RAF` timing mode.\n\t *\n\t * @type {number}\n\t */\n\tget interval () { return this._interval; }\n\tset interval (interval) {\n\t\tthis._interval = interval;\n\t\tif (!this._inited) { return; }\n\t\tthis._setupTick();\n\t}\n\n\t/**\n\t * Indicates the target frame rate in frames per second (FPS). Effectively just a shortcut to `interval`, where\n\t * `framerate == 1000/interval`.\n\t *\n\t * @type {number}\n\t */\n\tget framerate () { return 1000 / this._interval; }\n\tset framerate (framerate) { this.interval = 1000 / framerate; }\n\n\t/**\n\t * Starts the tick. This is called automatically when the first listener is added.\n\t */\n\tinit () {\n\t\tif (this._inited) { return; }\n\t\tthis._inited = true;\n\t\tthis._times = [];\n\t\tthis._tickTimes = [];\n\t\tthis._startTime = this._getTime();\n\t\tthis._times.push(this._lastTime = 0);\n\t\tthis._setupTick();\n\t}\n\n\t/**\n\t * Stops the Ticker and removes all listeners. Use init() to restart the Ticker.\n\t */\n\treset () {\n\t\tif (this._raf) {\n\t\t\tlet f = window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.oCancelAnimationFrame || window.msCancelAnimationFrame;\n\t\t\tf && f(this._timerId);\n\t\t} else {\n\t\t\tclearTimeout(this._timerId);\n\t\t}\n\t\tthis.removeAllEventListeners(\"tick\");\n\t\tthis._timerId = this._times = this._tickTimes = null;\n\t\tthis._startTime = this._lastTime = this._ticks = 0;\n\t\tthis._inited = false;\n\t}\n\n\t/**\n\t * Init the Ticker instance if it hasn't been already.\n\t */\n\taddEventListener (type, listener, useCapture) {\n\t\t!this._inited && this.init();\n\t\treturn super.addEventListener(type, listener, useCapture);\n\t}\n\n\t/**\n\t * Returns the average time spent within a tick. This can vary significantly from the value provided by getMeasuredFPS\n\t * because it only measures the time spent within the tick execution stack.\n\t *\n\t * Example 1: With a target FPS of 20, getMeasuredFPS() returns 20fps, which indicates an average of 50ms between\n\t * the end of one tick and the end of the next. However, getMeasuredTickTime() returns 15ms. This indicates that\n\t * there may be up to 35ms of \"idle\" time between the end of one tick and the start of the next.\n\t *\n\t * Example 2: With a target FPS of 30, getFPS() returns 10fps, which indicates an average of 100ms between the end of\n\t * one tick and the end of the next. However, getMeasuredTickTime() returns 20ms. This would indicate that something\n\t * other than the tick is using ~80ms (another script, DOM rendering, etc).\n\t *\n\t * @param {number} [ticks=null] The number of previous ticks over which to measure the average time spent in a tick.\n\t * Defaults to the number of ticks per second. To get only the last tick's time, pass in 1.\n\t * @return {number} The average time spent in a tick in milliseconds.\n\t */\n\tgetMeasuredTickTime (ticks = null) {\n\t\tconst times = this._tickTimes;\n\t\tif (!times || times.length < 1) { return -1; }\n\t\t// by default, calculate average for the past ~1 second:\n\t\tticks = Math.min(times.length, ticks || (this.framerate | 0));\n\t\treturn times.reduce((a, b) => a + b, 0) / ticks;\n\t}\n\n\t/**\n\t * Returns the actual frames / ticks per second.\n\t *\n\t * @param {number} [ticks=null] The number of previous ticks over which to measure the actual frames / ticks per second.\n\t * Defaults to the number of ticks per second.\n\t * @return {number} The actual frames / ticks per second. Depending on performance, this may differ\n\t * from the target frames per second.\n\t */\n\tgetMeasuredFPS (ticks = null) {\n\t\tconst times = this._times;\n\t\tif (!times || times.length < 2) { return -1; }\n\t\t// by default, calculate fps for the past ~1 second:\n\t\tticks = Math.min(times.length - 1, ticks || (this.framerate | 0));\n\t\treturn 1000 / ((times[0] - times[ticks]) / ticks);\n\t}\n\n\t/**\n\t * Returns the number of milliseconds that have elapsed since Ticker was initialized via {@link core.Ticker#init}.\n\t * Returns -1 if Ticker has not been initialized. For example, you could use\n\t * this in a time synchronized animation to determine the exact amount of time that has elapsed.\n\t *\n\t * @param {boolean} [runTime=false] If true only time elapsed while Ticker was not paused will be returned.\n\t * If false, the value returned will be total time elapsed since the first tick event listener was added.\n\t * @return {number} Number of milliseconds that have elapsed since Ticker was initialized or -1.\n\t */\n\tgetTime (runTime = false) {\n\t\treturn this._startTime ? this._getTime() - (runTime ? this._pausedTime : 0) : -1;\n\t}\n\n\t/**\n\t * Similar to {@link core.Ticker#getTime}, but returns the time on the most recent {@link core.Ticker#event:tick}\n\t * event object.\n\t *\n\t * @param {boolean} [runTime=false] If true, the runTime property will be returned instead of time.\n\t * @returns {number} The time or runTime property from the most recent tick event or -1.\n\t */\n\tgetEventTime (runTime = false) {\n\t\treturn this._startTime ? (this._lastTime || this._startTime) - (runTime ? this._pausedTime : 0) : -1;\n\t}\n\n\t/**\n\t * Returns the number of ticks that have been broadcast by Ticker.\n\t *\n\t * @param {boolean} [pauseable=false] Indicates whether to include ticks that would have been broadcast\n\t * while Ticker was paused. If true only tick events broadcast while Ticker is not paused will be returned.\n\t * If false, tick events that would have been broadcast while Ticker was paused will be included in the return\n\t * value.\n\t * @return {number} of ticks that have been broadcast.\n\t */\n\tgetTicks (pauseable = false) {\n\t\treturn this._ticks - (pauseable ? this._pausedTicks : 0);\n\t}\n\n\t/**\n\t * @private\n\t */\n\t_handleSynch () {\n\t\tthis._timerId = null;\n\t\tthis._setupTick();\n\n\t\t// run if enough time has elapsed, with a little bit of flexibility to be early:\n\t\tif (this._getTime() - this._lastTime >= (this._interval - 1) * 0.97) {\n\t\t\tthis._tick();\n\t\t}\n\t}\n\n\t/**\n\t * @private\n\t */\n\t_handleRAF () {\n\t\tthis._timerId = null;\n\t\tthis._setupTick();\n\t\tthis._tick();\n\t}\n\n\t/**\n\t * @private\n\t */\n\t_handleTimeout () {\n\t\tthis._timerId = null;\n\t\tthis._setupTick();\n\t\tthis._tick();\n\t}\n\n\t/**\n\t * @private\n\t */\n\t_setupTick () {\n\t\tif (this._timerId != null) { return; } // avoid duplicates\n\t\tconst mode = this.timingMode || (this._raf && Ticker.RAF);\n\t\tif (mode === Ticker.RAF_SYNCHED || mode === Ticker.RAF) {\n\t\t\tconst f = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame;\n\t\t\tif (f) {\n\t\t\t\tthis._timerId = f(mode === Ticker.RAF ? this._handleRAF.bind(this) : this._handleSynch.bind(this));\n\t\t\t\tthis._raf = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tthis._raf = false;\n\t\tthis._timerId = setTimeout(this._handleTimeout.bind(this), this._interval);\n\t}\n\n\t/**\n\t * @private\n\t * @emits core.Ticker#event:tick\n\t */\n\t_tick () {\n\t\tconst paused = this.paused, time = this._getTime(), elapsedTime = time - this._lastTime;\n\t\tthis._lastTime = time;\n\t\tthis._ticks++;\n\n\t\tif (paused) {\n\t\t\tthis._pausedTicks++;\n\t\t\tthis._pausedTime += elapsedTime;\n\t\t}\n\n\t\tif (this.hasEventListener(\"tick\")) {\n\t\t\tconst event = new Event(\"tick\");\n\t\t\tconst maxDelta = this.maxDelta;\n\t\t\tevent.delta = (maxDelta && elapsedTime > maxDelta) ? maxDelta : elapsedTime;\n\t\t\tevent.paused = paused;\n\t\t\tevent.time = time;\n\t\t\tevent.runTime = time - this._pausedTime;\n\t\t\tthis.dispatchEvent(event);\n\t\t}\n\n\t\tthis._tickTimes.unshift(this._getTime() - time);\n\t\twhile (this._tickTimes.length > 100) { this._tickTimes.pop(); }\n\n\t\tthis._times.unshift(time);\n\t\twhile (this._times.length > 100) { this._times.pop(); }\n\t}\n\n\t/**\n\t * @private\n\t */\n\t_getTime () {\n\t\tconst now = window.performance && window.performance.now;\n\t\treturn ((now && now.call(performance)) || (new Date().getTime())) - this._startTime;\n\t}\n\n\tstatic on (type, listener, scope, once, data, useCapture) { return _instance.on(type, listener, scope, once, data, useCapture); }\n\tstatic removeEventListener (type, listener, useCapture) { _instance.removeEventListener(type, listener, useCapture); }\n\tstatic off (type, listener, useCapture) { _instance.off(type, listener, useCapture); }\n\tstatic removeAllEventListeners (type) { _instance.removeAllEventListeners(type); }\n\tstatic dispatchEvent (eventObj, bubbles, cancelable) { return _instance.dispatchEvent(eventObj, bubbles, cancelable); }\n\tstatic hasEventListener (type) { return _instance.hasEventListener(type); }\n\tstatic willTrigger (type) { return _instance.willTrigger(type); }\n\tstatic toString () { return _instance.toString(); }\n\tstatic init () { _instance.init(); }\n\tstatic reset () { _instance.reset(); }\n\tstatic addEventListener (type, listener, useCapture) { _instance.addEventListener(type, listener, useCapture); }\n\tstatic getMeasuredTickTime (ticks) { return _instance.getMeasuredTickTime(ticks); }\n\tstatic getMeasuredFPS (ticks) { return _instance.getMeasuredFPS(ticks); }\n\tstatic getTime (runTime) { return _instance.getTime(runTime); }\n\tstatic getEventTime (runTime) { return _instance.getEventTime(runTime); }\n\tstatic getTicks (pauseable) { return _instance.getTicks(pauseable); }\n\n\tstatic get interval () { return _instance.interval; }\n\tstatic set interval (interval) { _instance.interval = interval; }\n\tstatic get framerate () { return _instance.framerate; }\n\tstatic set framerate (framerate) { _instance.framerate = framerate; }\n\tstatic get name () { return _instance.name; }\n\tstatic set name (name) { _instance.name = name; }\n\tstatic get timingMode () { return _instance.timingMode; }\n\tstatic set timingMode (timingMode) { _instance.timingMode = timingMode; }\n\tstatic get maxDelta () { return _instance.maxDelta; }\n\tstatic set maxDelta (maxDelta) { _instance.maxDelta = maxDelta; }\n\tstatic get paused () { return _instance.paused; }\n\tstatic set paused (paused) { _instance.paused = paused; }\n\n}\n\n/**\n * Dispatched each tick. The event will be dispatched to each listener even when the Ticker has been paused.\n *\n * @example\n * Ticker.addEventListener(\"tick\", event => console.log(\"Paused:\", event.paused, event.delta));\n *\n * @event core.Ticker#tick\n * @type {Object}\n * @property {Object} target The object that dispatched the event.\n * @property {string} type The event type.\n * @property {boolean} paused Indicates whether the ticker is currently paused.\n * @property {number} delta The time elapsed in ms since the last tick.\n * @property {number} time The total time in ms since Ticker was initialized.\n * @property {number} runTime The total time in ms that Ticker was not paused since it was initialized. For example,\n * you could determine the amount of time that the Ticker has been paused since initialization with `time-runTime`.\n * @since 0.6.0\n */\n\nexport default Ticker;\n\n// the default Ticker instance\nconst _instance = new Ticker(\"createjs.global\");\n","/**\n * @license\n *\n * StageGL\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nclass StageGL {\n\tconstructor () {\n\t\tthrow new Error(`\n\t\t\tStageGL is not currently supported on the EaselJS 2.0 branch.\n\t\t\tEnd of Q1 2018 is targetted for StageGL support.\n\t\t\tFollow @CreateJS on Twitter for updates.\n\t\t`);\n\t}\n}\n\nexport default StageGL;\n","/**\n * @license Shadow\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * This class encapsulates the properties required to define a shadow to apply to a {@link easeljs.DisplayObject}\n * via its `shadow` property.\n *\n * @memberof easeljs\n * @example\n * img.shadow = new Shadow(\"#000000\", 5, 5, 10);\n *\n * @param {String} [color=black] The color of the shadow. This can be any valid CSS color value.\n * @param {Number} [offsetX=0] The x offset of the shadow in pixels.\n * @param {Number} [offsetY=0] The y offset of the shadow in pixels.\n * @param {Number} [blur=0] The size of the blurring effect.\n */\nexport default class Shadow {\n\n\tconstructor (color = \"black\", offsetX = 0, offsetY = 0, blur = 0) {\n\t\t/**\n\t\t * The color of the shadow. This can be any valid CSS color value.\n\t\t * @type {String}\n\t\t * @default black\n\t\t */\n\t\tthis.color = color;\n\n\t\t/**\n\t\t * The x offset of the shadow.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.offsetX = offsetX;\n\n\t\t/**\n\t\t * The y offset of the shadow.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.offsetY = offsetY;\n\n\t\t/**\n\t\t * The blur of the shadow.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.blur = blur;\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @return {String}\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name}]`;\n\t}\n\n\t/**\n\t * Returns a clone of this Shadow instance.\n\t * @return {Shadow} A clone of the current Shadow instance.\n\t */\n\tclone () {\n\t\treturn new Shadow(this.color, this.offsetX, this.offsetY, this.blur);\n\t}\n\n}\n\n/**\n * An identity shadow object (all properties are set to 0).\n * @type {easeljs.Shadow}\n * @static\n * @readonly\n */\nShadow.identity = new Shadow(\"transparent\");\n","/**\n * @license uid\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/** @ignore */\nlet _nextId = 0;\n\n/**\n * Global utility for generating sequential unique ID numbers.\n *\n * @memberof easeljs\n * @name easeljs.uid\n * @example\n * import { uid } from \"@createjs/easeljs\";\n * var ids = [];\n * while (ids.length <= 3) {\n * ids.push(uid());\n * }\n * // ids == [0, 1, 2, 3]\n */\nexport default function uid () {\n\treturn _nextId++;\n}\n","/**\n * @license Point\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * Represents a point on a 2 dimensional x / y coordinate system.\n *\n * @memberof easeljs\n * @example\n * let point = new Point(0, 100);\n *\n * @param {Number} [x] X position.\n * @param {Number} [y] Y position.\n */\nexport default class Point {\n\n\tconstructor (x, y) {\n\t\tthis.setValues(x, y);\n\n\t\t// assigned in the setValues method.\n\t\t/**\n\t\t * X position.\n\t\t * @property x\n\t\t * @type {Number}\n\t\t */\n\n\t\t/**\n\t\t * Y position.\n\t\t * @property y\n\t\t * @type {Number}\n\t\t */\n\t}\n\n\t/**\n\t * Sets the specified values on this instance.\n\t * @param {Number} [x=0] X position.\n\t * @param {Number} [y=0] Y position.\n\t * @return {easeljs.Point} This instance. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tsetValues (x = 0, y = 0) {\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Copies all properties from the specified point to this point.\n\t * @param {easeljs.Point} point The point to copy properties from.\n\t * @return {easeljs.Point} This point. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tcopy (point) {\n\t\tthis.x = point.x;\n\t\tthis.y = point.y;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns a clone of the Point instance.\n\t * @return {easeljs.Point} a clone of the Point instance.\n\t */\n\tclone () {\n\t\treturn new Point(this.x, this.y);\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name} (x=${this.x} y=${this.y})]`;\n\t}\n\n}\n","/**\n * @license Matrix2D\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Point from \"./Point\";\n\n/**\n * Represents an affine transformation matrix, and provides tools for constructing and concatenating matrices.\n *\n *
\n * This matrix can be visualized as:\n *\n * \t[ a c tx\n * \t b d ty\n * \t 0 0 1 ]\n *\n * Note the locations of b and c.\n *
\n *\n * @param {Number} [a] Specifies the a property for the new matrix.\n * @param {Number} [b] Specifies the b property for the new matrix.\n * @param {Number} [c] Specifies the c property for the new matrix.\n * @param {Number} [d] Specifies the d property for the new matrix.\n * @param {Number} [tx] Specifies the tx property for the new matrix.\n * @param {Number} [ty] Specifies the ty property for the new matrix.\n */\nexport default class Matrix2D {\n\n\tconstructor (a, b, c, d, tx, ty) {\n\t\tthis.setValues(a, b, c, d, tx, ty);\n\n\t\t// assigned in the setValues method.\n\t\t/**\n\t\t * Position (0, 0) in a 3x3 affine transformation matrix.\n\t\t * @property a\n\t\t * @type {Number}\n\t\t */\n\n\t\t/**\n\t\t * Position (0, 1) in a 3x3 affine transformation matrix.\n\t\t * @property b\n\t\t * @type {Number}\n\t\t */\n\n\t\t/**\n\t\t * Position (1, 0) in a 3x3 affine transformation matrix.\n\t\t * @property c\n\t\t * @type {Number}\n\t\t */\n\n\t\t/**\n\t\t * Position (1, 1) in a 3x3 affine transformation matrix.\n\t\t * @property d\n\t\t * @type {Number}\n\t\t */\n\n\t\t/**\n\t\t * Position (2, 0) in a 3x3 affine transformation matrix.\n\t\t * @property tx\n\t\t * @type {Number}\n\t\t */\n\n\t\t/**\n\t\t * Position (2, 1) in a 3x3 affine transformation matrix.\n\t\t * @property ty\n\t\t * @type {Number}\n\t\t */\n\t}\n\n\t/**\n\t * Sets the specified values on this instance.\n\t * @param {Number} [a=1] Specifies the a property for the new matrix.\n\t * @param {Number} [b=0] Specifies the b property for the new matrix.\n\t * @param {Number} [c=0] Specifies the c property for the new matrix.\n\t * @param {Number} [d=1] Specifies the d property for the new matrix.\n\t * @param {Number} [tx=0] Specifies the tx property for the new matrix.\n\t * @param {Number} [ty=0] Specifies the ty property for the new matrix.\n\t * @return {Matrix2D} This instance. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tsetValues (a = 1, b = 0, c = 0, d = 1, tx = 0, ty = 0) {\n\t\t// don't forget to update docs in the constructor if these change:\n\t\tthis.a = a;\n\t\tthis.b = b;\n\t\tthis.c = c;\n\t\tthis.d = d;\n\t\tthis.tx = tx;\n\t\tthis.ty = ty;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Appends the specified matrix properties to this matrix. All parameters are required.\n\t * This is the equivalent of multiplying `(this matrix) * (specified matrix)`.\n\t * @param {Number} a\n\t * @param {Number} b\n\t * @param {Number} c\n\t * @param {Number} d\n\t * @param {Number} tx\n\t * @param {Number} ty\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t */\n\tappend (a, b, c, d, tx, ty) {\n\t\tlet a1 = this.a;\n\t\tlet b1 = this.b;\n\t\tlet c1 = this.c;\n\t\tlet d1 = this.d;\n\t\tif (a != 1 || b != 0 || c != 0 || d != 1) {\n\t\t\tthis.a = a1*a+c1*b;\n\t\t\tthis.b = b1*a+d1*b;\n\t\t\tthis.c = a1*c+c1*d;\n\t\t\tthis.d = b1*c+d1*d;\n\t\t}\n\t\tthis.tx = a1*tx+c1*ty+this.tx;\n\t\tthis.ty = b1*tx+d1*ty+this.ty;\n\t\treturn this;\n\t};\n\n\t/**\n\t * Prepends the specified matrix properties to this matrix.\n\t * This is the equivalent of multiplying `(specified matrix) * (this matrix)`.\n\t * @param {Number} a\n\t * @param {Number} b\n\t * @param {Number} c\n\t * @param {Number} d\n\t * @param {Number} tx\n\t * @param {Number} ty\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t */\n\tprepend (a, b, c, d, tx, ty) {\n\t\tlet a1 = this.a;\n\t\tlet c1 = this.c;\n\t\tlet tx1 = this.tx;\n\n\t\tthis.a = a*a1+c*this.b;\n\t\tthis.b = b*a1+d*this.b;\n\t\tthis.c = a*c1+c*this.d;\n\t\tthis.d = b*c1+d*this.d;\n\t\tthis.tx = a*tx1+c*this.ty+tx;\n\t\tthis.ty = b*tx1+d*this.ty+ty;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Appends the specified matrix to this matrix.\n\t * This is the equivalent of multiplying `(this matrix) * (specified matrix)`.\n\t * @param {easeljs.Matrix2D} matrix\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t */\n\tappendMatrix (matrix) {\n\t\treturn this.append(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);\n\t}\n\n\t/**\n\t * Prepends the specified matrix to this matrix.\n\t * This is the equivalent of multiplying `(specified matrix) * (this matrix)`.\n\t *\n\t * @example
Calculate the combined transformation for a child object
\n\t * let o = displayObject;\n\t * let mtx = o.getMatrix();\n\t * while (o = o.parent) {\n\t * \t // prepend each parent's transformation in turn:\n\t * \t o.prependMatrix(o.getMatrix());\n\t * }\n\t *\n\t * @param {easeljs.Matrix2D} matrix\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t */\n\tprependMatrix (matrix) {\n\t\treturn this.prepend(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);\n\t}\n\n\t/**\n\t * Generates matrix properties from the specified display object transform properties, and appends them to this matrix.\n\t *\n\t * @example
Generate a matrix representing the transformations of a display object
\n\t * let mtx = new Matrix2D();\n\t * mtx.appendTransform(o.x, o.y, o.scaleX, o.scaleY, o.rotation);\n\t *\n\t * @param {Number} x\n\t * @param {Number} y\n\t * @param {Number} scaleX\n\t * @param {Number} scaleY\n\t * @param {Number} rotation\n\t * @param {Number} skewX\n\t * @param {Number} skewY\n\t * @param {Number} [regX]\n\t * @param {Number} [regY]\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t */\n\tappendTransform (x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) {\n\t\tlet r, cos, sin;\n\t\tif (rotation%360) {\n\t\t\tr = rotation*Matrix2D.DEG_TO_RAD;\n\t\t\tcos = Math.cos(r);\n\t\t\tsin = Math.sin(r);\n\t\t} else {\n\t\t\tcos = 1;\n\t\t\tsin = 0;\n\t\t}\n\n\t\tif (skewX || skewY) {\n\t\t\t// TODO: can this be combined into a single append operation?\n\t\t\tskewX *= Matrix2D.DEG_TO_RAD;\n\t\t\tskewY *= Matrix2D.DEG_TO_RAD;\n\t\t\tthis.append(Math.cos(skewY), Math.sin(skewY), -Math.sin(skewX), Math.cos(skewX), x, y);\n\t\t\tthis.append(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, 0, 0);\n\t\t} else {\n\t\t\tthis.append(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, x, y);\n\t\t}\n\n\t\tif (regX || regY) {\n\t\t\t// append the registration offset:\n\t\t\tthis.tx -= regX*this.a+regY*this.c;\n\t\t\tthis.ty -= regX*this.b+regY*this.d;\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Generates matrix properties from the specified display object transform properties, and prepends them to this matrix.\n\t *\n\t * Note that the above example would not account for {@link easeljs.DisplayObject#transformMatrix} values.\n\t * See {@link easeljs.Matrix2D#prependMatrix} for an example that does.\n\t *\n\t * @example
Calculate the combined transformation for a child object
\n\t * let o = displayObject;\n\t * let mtx = new Matrix2D();\n\t * do {\n\t * \t // prepend each parent's transformation in turn:\n\t * \t mtx.prependTransform(o.x, o.y, o.scaleX, o.scaleY, o.rotation, o.skewX, o.skewY, o.regX, o.regY);\n\t * } while (o = o.parent);\n\t *\n\t * @param {Number} x\n\t * @param {Number} y\n\t * @param {Number} scaleX\n\t * @param {Number} scaleY\n\t * @param {Number} rotation\n\t * @param {Number} skewX\n\t * @param {Number} skewY\n\t * @param {Number} [regX]\n\t * @param {Number} [regY]\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t */\n\tprependTransform (x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) {\n\t\tlet r, cos, sin;\n\t\tif (rotation%360) {\n\t\t\tr = rotation*Matrix2D.DEG_TO_RAD;\n\t\t\tcos = Math.cos(r);\n\t\t\tsin = Math.sin(r);\n\t\t} else {\n\t\t\tcos = 1;\n\t\t\tsin = 0;\n\t\t}\n\n\t\tif (regX || regY) {\n\t\t\t// prepend the registration offset:\n\t\t\tthis.tx -= regX; this.ty -= regY;\n\t\t}\n\t\tif (skewX || skewY) {\n\t\t\t// TODO: can this be combined into a single prepend operation?\n\t\t\tskewX *= Matrix2D.DEG_TO_RAD;\n\t\t\tskewY *= Matrix2D.DEG_TO_RAD;\n\t\t\tthis.prepend(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, 0, 0);\n\t\t\tthis.prepend(Math.cos(skewY), Math.sin(skewY), -Math.sin(skewX), Math.cos(skewX), x, y);\n\t\t} else {\n\t\t\tthis.prepend(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, x, y);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Applies a clockwise rotation transformation to the matrix.\n\t * @param {Number} angle The angle to rotate by, in degrees. To use a value in radians, multiply it by `Math.PI/180`.\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t */\n\trotate (angle) {\n\t\tangle *= Matrix2D.DEG_TO_RAD;\n\t\tlet cos = Math.cos(angle);\n\t\tlet sin = Math.sin(angle);\n\n\t\tlet a1 = this.a;\n\t\tlet b1 = this.b;\n\n\t\tthis.a = a1*cos+this.c*sin;\n\t\tthis.b = b1*cos+this.d*sin;\n\t\tthis.c = -a1*sin+this.c*cos;\n\t\tthis.d = -b1*sin+this.d*cos;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Applies a skew transformation to the matrix.\n\t * @param {Number} skewX The amount to skew horizontally in degrees. To use a value in radians, multiply it by `Math.PI/180`.\n\t * @param {Number} skewY The amount to skew vertically in degrees.\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tskew (skewX, skewY) {\n\t\tskewX *= Matrix2D.DEG_TO_RAD;\n\t\tskewY *= Matrix2D.DEG_TO_RAD;\n\t\tthis.append(Math.cos(skewY), Math.sin(skewY), -Math.sin(skewX), Math.cos(skewX), 0, 0);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Applies a scale transformation to the matrix.\n\t * @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.\n\t * @param {Number} y The amount to scale vertically.\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t */\n\tscale (x, y) {\n\t\tthis.a *= x;\n\t\tthis.b *= x;\n\t\tthis.c *= y;\n\t\tthis.d *= y;\n\t\t//this.tx *= x;\n\t\t//this.ty *= y;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Translates the matrix on the x and y axes.\n\t * @param {Number} x\n\t * @param {Number} y\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t */\n\ttranslate (x, y) {\n\t\tthis.tx += this.a*x + this.c*y;\n\t\tthis.ty += this.b*x + this.d*y;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the properties of the matrix to those of an identity matrix (one that applies a null transformation).\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t */\n\tidentity () {\n\t\tthis.a = this.d = 1;\n\t\tthis.b = this.c = this.tx = this.ty = 0;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Inverts the matrix, causing it to perform the opposite transformation.\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t */\n\tinvert () {\n\t\tlet a1 = this.a;\n\t\tlet b1 = this.b;\n\t\tlet c1 = this.c;\n\t\tlet d1 = this.d;\n\t\tlet tx1 = this.tx;\n\t\tlet n = a1*d1-b1*c1;\n\n\t\tthis.a = d1/n;\n\t\tthis.b = -b1/n;\n\t\tthis.c = -c1/n;\n\t\tthis.d = a1/n;\n\t\tthis.tx = (c1*this.ty-d1*tx1)/n;\n\t\tthis.ty = -(a1*this.ty-b1*tx1)/n;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns true if the matrix is an identity matrix.\n\t * @return {Boolean}\n\t */\n\tisIdentity () {\n\t\treturn this.tx === 0 && this.ty === 0 && this.a === 1 && this.b === 0 && this.c === 0 && this.d === 1;\n\t}\n\n\t/**\n\t * Returns true if this matrix is equal to the specified matrix (all property values are equal).\n\t * @param {easeljs.Matrix2D} matrix The matrix to compare.\n\t * @return {Boolean}\n\t */\n\tequals (matrix) {\n\t\treturn this.tx === matrix.tx && this.ty === matrix.ty && this.a === matrix.a && this.b === matrix.b && this.c === matrix.c && this.d === matrix.d;\n\t}\n\n\t/**\n\t * Transforms a point according to this matrix.\n\t * @param {Number} x The x component of the point to transform.\n\t * @param {Number} y The y component of the point to transform.\n\t * @param {easeljs.Point | Object} [pt] An object to copy the result into. If omitted a generic object with x/y properties will be returned.\n\t * @return {easeljs.Point} This matrix. Useful for chaining method calls.\n\t */\n\ttransformPoint (x, y, pt = new Point()) {\n\t\tpt.x = x*this.a+y*this.c+this.tx;\n\t\tpt.y = x*this.b+y*this.d+this.ty;\n\t\treturn pt;\n\t}\n\n\t/**\n\t * Decomposes the matrix into transform properties (x, y, scaleX, scaleY, and rotation). Note that these values\n\t * may not match the transform properties you used to generate the matrix, though they will produce the same visual\n\t * results.\n\t * @param {Object} [target] The object to apply the transform properties to. If null, then a new object will be returned.\n\t * @return {Object} The target, or a new generic object with the transform properties applied.\n\t*/\n\tdecompose (target = {}) {\n\t\t// 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\n\t\ttarget.x = this.tx;\n\t\ttarget.y = this.ty;\n\t\ttarget.scaleX = Math.sqrt(this.a * this.a + this.b * this.b);\n\t\ttarget.scaleY = Math.sqrt(this.c * this.c + this.d * this.d);\n\n\t\tlet skewX = Math.atan2(-this.c, this.d);\n\t\tlet skewY = Math.atan2(this.b, this.a);\n\n\t\tlet delta = Math.abs(1-skewX/skewY);\n\t\tif (delta < 0.00001) { // effectively identical, can use rotation:\n\t\t\ttarget.rotation = skewY/Matrix2D.DEG_TO_RAD;\n\t\t\tif (this.a < 0 && this.d >= 0) {\n\t\t\t\ttarget.rotation += (target.rotation <= 0) ? 180 : -180;\n\t\t\t}\n\t\t\ttarget.skewX = target.skewY = 0;\n\t\t} else {\n\t\t\ttarget.skewX = skewX/Matrix2D.DEG_TO_RAD;\n\t\t\ttarget.skewY = skewY/Matrix2D.DEG_TO_RAD;\n\t\t}\n\t\treturn target;\n\t}\n\n\t/**\n\t * Copies all properties from the specified matrix to this matrix.\n\t * @param {easeljs.Matrix2D} matrix The matrix to copy properties from.\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tcopy (matrix) {\n\t\treturn this.setValues(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);\n\t}\n\n\t/**\n\t * Returns a clone of the Matrix2D instance.\n\t * @return {easeljs.Matrix2D} a clone of the Matrix2D instance.\n\t */\n\tclone () {\n\t\treturn new Matrix2D(this.a, this.b, this.c, this.d, this.tx, this.ty);\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name} (a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty})]`;\n\t}\n\n}\n\n/**\n * Multiplier for converting degrees to radians. Used internally by Matrix2D.\n * @static\n * @type {Number}\n * @readonly\n */\nMatrix2D.DEG_TO_RAD = Math.PI/180;\n/**\n * An identity matrix, representing a null transformation.\n * @static\n * @type {easeljs.Matrix2D}\n * @readonly\n */\nMatrix2D.identity = new Matrix2D();\n","/**\n * @license DisplayProps\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Matrix2D from \"./Matrix2D\";\n\n/**\n * Used for calculating and encapsulating display related properties.\n * @memberof easeljs\n * @param {Number} [visible] Visible value.\n * @param {Number} [alpha] Alpha value.\n * @param {Number} [shadow] A Shadow instance or null.\n * @param {Number} [compositeOperation] A compositeOperation value or null.\n * @param {Number} [matrix] A transformation matrix. Defaults to a new identity matrix.\n */\nexport default class DisplayProps {\n\n\tconstructor (visible, alpha, shadow, compositeOperation, matrix) {\n\t\tthis.setValues(visible, alpha, shadow, compositeOperation, matrix);\n\n\t\t// assigned in the setValues method.\n\t\t/**\n\t\t * Property representing the alpha that will be applied to a display object.\n\t\t * @property alpha\n\t\t * @type {Number}\n\t\t */\n\n\t\t/**\n\t\t * Property representing the shadow that will be applied to a display object.\n\t\t * @property shadow\n\t\t * @type {easeljs.Shadow}\n\t\t */\n\n\t\t/**\n\t\t * Property representing the compositeOperation that will be applied to a display object.\n\t\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Compositing}\n\t\t * @property compositeOperation\n\t\t * @type {String}\n\t\t */\n\n\t\t/**\n\t\t * Property representing the value for visible that will be applied to a display object.\n\t\t * @property visible\n\t\t * @type {Boolean}\n\t\t */\n\n\t\t/**\n\t\t * The transformation matrix that will be applied to a display object.\n\t\t * @property matrix\n\t\t * @type {easeljs.Matrix2D}\n\t\t */\n\t}\n\n\t/**\n\t * Reinitializes the instance with the specified values.\n\t * @param {Number} [visible=true] Visible value.\n\t * @param {Number} [alpha=1] Alpha value.\n\t * @param {Number} [shadow] A Shadow instance or null.\n\t * @param {Number} [compositeOperation] A compositeOperation value or null.\n\t * @param {Number} [matrix] A transformation matrix. Defaults to an identity matrix.\n\t * @return {easeljs.DisplayProps} This instance. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tsetValues (visible = true, alpha = 1, shadow, compositeOperation, matrix) {\n\t\tthis.visible = visible;\n\t\tthis.alpha = alpha;\n\t\tthis.shadow = shadow;\n\t\tthis.compositeOperation = compositeOperation;\n\t\tthis.matrix = matrix || (this.matrix&&this.matrix.identity()) || new Matrix2D();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Appends the specified display properties. This is generally used to apply a child's properties its parent's.\n\t * @param {Boolean} visible desired visible value\n\t * @param {Number} alpha desired alpha value\n\t * @param {easeljs.Shadow} shadow desired shadow value\n\t * @param {String} compositeOperation desired composite operation value\n\t * @param {easeljs.Matrix2D} [matrix] a Matrix2D instance\n\t * @return {easeljs.DisplayProps} This instance. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tappend (visible, alpha, shadow, compositeOperation, matrix) {\n\t\tthis.alpha *= alpha;\n\t\tthis.shadow = shadow || this.shadow;\n\t\tthis.compositeOperation = compositeOperation || this.compositeOperation;\n\t\tthis.visible = this.visible && visible;\n\t\tmatrix&&this.matrix.appendMatrix(matrix);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Prepends the specified display properties. This is generally used to apply a parent's properties to a child's.\n\t * For example, to get the combined display properties that would be applied to a child, you could use:\n\t *\n\t * @example\n\t * let o = displayObject;\n\t * let props = new DisplayProps();\n\t * do {\n\t * \t // prepend each parent's props in turn:\n\t * \t props.prepend(o.visible, o.alpha, o.shadow, o.compositeOperation, o.getMatrix());\n\t * } while (o = o.parent);\n\t *\n\t * @param {Boolean} visible desired visible value\n\t * @param {Number} alpha desired alpha value\n\t * @param {easeljs.Shadow} shadow desired shadow value\n\t * @param {String} compositeOperation desired composite operation value\n\t * @param {easeljs.Matrix2D} [matrix] a Matrix2D instance\n\t * @return {easeljs.DisplayProps} This instance. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tprepend (visible, alpha, shadow, compositeOperation, matrix) {\n\t\tthis.alpha *= alpha;\n\t\tthis.shadow = this.shadow || shadow;\n\t\tthis.compositeOperation = this.compositeOperation || compositeOperation;\n\t\tthis.visible = this.visible && visible;\n\t\tmatrix&&this.matrix.prependMatrix(matrix);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Resets this instance and its matrix to default values.\n\t * @return {easeljs.DisplayProps} This instance. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tidentity () {\n\t\tthis.visible = true;\n\t\tthis.alpha = 1;\n\t\tthis.shadow = this.compositeOperation = null;\n\t\tthis.matrix.identity();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns a clone of the DisplayProps instance. Clones the associated matrix.\n\t * @return {easeljs.DisplayProps} a clone of the DisplayProps instance.\n\t */\n\tclone () {\n\t\treturn new DisplayProps(this.alpha, this.shadow, this.compositeOperation, this.visible, this.matrix.clone());\n\t}\n\n}\n","/**\n * @license Rectangle\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * Represents a rectangle as defined by the points (x, y) and (x+width, y+height).\n * Used by {@link easeljs.DisplayObjects#getBounds}.\n *\n * @memberof easeljs\n * @example\n * let rect = new Rectangle(0, 0, 100, 100);\n *\n * @param {Number} [x] X position.\n * @param {Number} [y] Y position.\n * @param {Number} [width] The width of the Rectangle.\n * @param {Number} [height] The height of the Rectangle.\n */\nexport default class Rectangle {\n\n\tconstructor (x, y, width, height) {\n\t\tthis.setValues(x, y, width, height);\n\n\t\t// assigned in the setValues method.\n\t\t/**\n\t\t * X position.\n\t\t * @property x\n\t\t * @type {Number}\n\t\t */\n\n\t\t/**\n\t\t * Y position.\n\t\t * @property y\n\t\t * @type {Number}\n\t\t */\n\n\t\t/**\n\t\t * Width.\n\t\t * @property width\n\t\t * @type {Number}\n\t\t */\n\n\t\t/**\n\t\t * Height.\n\t\t * @property height\n\t\t * @type {Number}\n\t\t */\n\t}\n\n\t/**\n\t * Sets the specified values on this instance.\n\t * @param {Number} [x=0] X position.\n\t * @param {Number} [y=0] Y position.\n\t * @param {Number} [width=0] The width of the Rectangle.\n\t * @param {Number} [height=0] The height of the Rectangle.\n\t * @return {easeljs.Rectangle} This instance. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tsetValues (x = 0, y = 0, width = 0, height = 0) {\n\t\t// don't forget to update docs in the constructor if these change:\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.width = width;\n\t\tthis.height = height;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Extends the rectangle's bounds to include the described point or rectangle.\n\t * @param {Number} x X position of the point or rectangle.\n\t * @param {Number} y Y position of the point or rectangle.\n\t * @param {Number} [width=0] The width of the rectangle.\n\t * @param {Number} [height=0] The height of the rectangle.\n\t * @return {easeljs.Rectangle} This instance. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\textend (x, y, width = 0, height = 0) {\n\t\tif (x+width > this.x+this.width) { this.width = x+width-this.x; }\n\t\tif (y+height > this.y+this.height) { this.height = y+height-this.y; }\n\t\tif (x < this.x) { this.width += this.x-x; this.x = x; }\n\t\tif (y < this.y) { this.height += this.y-y; this.y = y; }\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds the specified padding to the rectangle's bounds.\n\t * @param {Number} top\n\t * @param {Number} left\n\t * @param {Number} bottom\n\t * @param {Number} right\n\t * @return {easeljs.Rectangle} This instance. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tpad (top, left, bottom, right) {\n\t\tthis.x -= left;\n\t\tthis.y -= top;\n\t\tthis.width += left+right;\n\t\tthis.height += top+bottom;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Copies all properties from the specified rectangle to this rectangle.\n\t * @param {easeljs.Rectangle} rectangle The rectangle to copy properties from.\n\t * @return {easeljs.Rectangle} This rectangle. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tcopy (rect) {\n\t\treturn this.setValues(rect.x, rect.y, rect.width, rect.height);\n\t}\n\n\t/**\n\t * Returns true if this rectangle fully encloses the described point or rectangle.\n\t * @param {Number} x X position of the point or rectangle.\n\t * @param {Number} y Y position of the point or rectangle.\n\t * @param {Number} [width=0] The width of the rectangle.\n\t * @param {Number} [height=0] The height of the rectangle.\n\t * @return {Boolean} True if the described point or rectangle is contained within this rectangle.\n\t*/\n\tcontains (x, y, width = 0, height = 0) {\n\t\treturn (x >= this.x && x+width <= this.x+this.width && y >= this.y && y+height <= this.y+this.height);\n\t}\n\n\t/**\n\t * Returns a new rectangle which contains this rectangle and the specified rectangle.\n\t * @param {easeljs.Rectangle} rect The rectangle to calculate a union with.\n\t * @return {easeljs.Rectangle} A new rectangle describing the union.\n\t*/\n\tunion (rect) {\n\t\treturn this.clone().extend(rect.x, rect.y, rect.width, rect.height);\n\t}\n\n\t/**\n\t * Returns a new rectangle which describes the intersection (overlap) of this rectangle and the specified rectangle,\n\t * or null if they do not intersect.\n\t * @param {easeljs.Rectangle} rect The rectangle to calculate an intersection with.\n\t * @return {easeljs.Rectangle} A new rectangle describing the intersection or null.\n\t*/\n\tintersection (rect) {\n\t\tlet x1 = rect.x, y1 = rect.y, x2 = x1+rect.width, y2 = y1+rect.height;\n\t\tif (this.x > x1) { x1 = this.x; }\n\t\tif (this.y > y1) { y1 = this.y; }\n\t\tif (this.x + this.width < x2) { x2 = this.x + this.width; }\n\t\tif (this.y + this.height < y2) { y2 = this.y + this.height; }\n\t\treturn (x2 <= x1 || y2 <= y1) ? null : new Rectangle(x1, y1, x2-x1, y2-y1);\n\t}\n\n\t/**\n\t * Returns true if the specified rectangle intersects (has any overlap) with this rectangle.\n\t * @param {easeljs.Rectangle} rect The rectangle to compare.\n\t * @return {Boolean} True if the rectangles intersect.\n\t*/\n\tintersects (rect) {\n\t\treturn (rect.x <= this.x+this.width && this.x <= rect.x+rect.width && rect.y <= this.y+this.height && this.y <= rect.y + rect.height);\n\t}\n\n\t/**\n\t * Returns true if the width or height are equal or less than 0.\n\t * @return {Boolean} True if the rectangle is empty.\n\t*/\n\tisEmpty () {\n\t\treturn this.width <= 0 || this.height <= 0;\n\t}\n\n\t/**\n\t * Returns a clone of the Rectangle instance.\n\t * @return {easeljs.Rectangle} a clone of the Rectangle instance.\n\t */\n\tclone () {\n\t\treturn new Rectangle(this.x, this.y, this.width, this.height);\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name} (x=${this.x} y=${this.y} width=${this.width} height=${this.height})]`;\n\t}\n\n}\n","/**\n * @license Filter\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * Base class that all filters should inherit from. Filters need to be applied to objects that have been cached using\n * the {@link easeljs.DisplayObject#cache} method. If an object changes, please cache it again, or use\n * {@link easeljs.DisplayObject#updateCache}. Note that the filters must be applied before caching.\n *\n * Note that each filter can implement a {@link easeljs.Filter#getBounds} method, which returns the\n * margins that need to be applied in order to fully display the filter. For example, the {@link easeljs.BlurFilter}\n * will cause an object to feather outwards, resulting in a margin around the shape.\n *\n *
EaselJS Filters
\n * EaselJS comes with a number of pre-built filters:\n *
\n *
{@link easeljs.AlphaMapFilter}: Map a greyscale image to the alpha channel of a display object
\n *
{@link easeljs.AlphaMaskFilter}: Map an image's alpha channel to the alpha channel of a display object
\n *
{@link easeljs.BlurFilter}: Apply vertical and horizontal blur to a display object
\n *
{@link easeljs.ColorFilter}: Color transform a display object
\n *
{@link easeljs.ColorMatrixFilter}: Transform an image using a {{#crossLink \"ColorMatrix\"}}{{/crossLink}}
\n *
\n *\n * @memberof easeljs\n * @example\n * shape.filters = [\n * new createjs.ColorFilter(0, 0, 0, 1, 255, 0, 0),\n * new createjs.BlurFilter(5, 5, 10)\n * ];\n * shape.cache(0, 0, 100, 100);\n */\nexport default class Filter {\n\n\tconstructor () {\n\t\t/**\n\t\t * A flag stating that this filter uses a context draw mode and cannot be batched into imageData processing.\n\t\t * @type {Boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.usesContext = false;\n\n\t\t/**\n\t\t * Another filter that is required to act as part of this filter and created and managed under the hood.\n\t\t * @private\n\t\t * @type {easeljs.Filter}\n\t\t * @default null\n\t\t */\n\t\tthis._multiPass = null;\n\n\t\t/**\n\t\t * Pre-processing shader code, will be parsed before being fed in.\n\t\t * This should be based upon StageGL.SHADER_VERTEX_BODY_REGULAR\n\t\t * @virtual\n\t\t * @type {String}\n\t\t * @readonly\n\t\t */\n\t\tthis.VTX_SHADER_BODY = null;\n\n\t\t/**\n\t\t * Pre-processing shader code, will be parsed before being fed in.\n\t\t * This should be based upon StageGL.SHADER_FRAGMENT_BODY_REGULAR\n\t\t * @virtual\n\t\t * @type {String}\n\t\t * @readonly\n\t\t */\n\t\tthis.FRAG_SHADER_BODY = null;\n\t}\n\n\t/**\n\t * Provides padding values for this filter. That is, how much the filter will extend the visual bounds of an object it is applied to.\n\t * @abstract\n\t * @param {easeljs.Rectangle} [rect] If specified, the provided Rectangle instance will be expanded by the padding amounts and returned.\n\t * @return {easeljs.Rectangle} If a `rect` param was provided, it is returned. If not, either a new rectangle with the padding values, or null if no padding is required for this filter.\n\t */\n\tgetBounds (rect) { }\n\n\t/**\n\t * @virtual\n\t * @abstract\n\t * @param {WebGLContext} gl The context associated with the stage performing the render.\n\t * @param {easeljs.StageGL} stage The stage instance that will be rendering.\n\t * @param {ShaderProgram} shaderProgram The compiled shader that is going to be sued to perform the render.\n\t */\n\tshaderParamSetup (gl, stage, shaderProgram) { }\n\n\t/**\n\t * Applies the filter to the specified context.\n\t * @param {CanvasRenderingContext2D} ctx The 2D context to use as the source.\n\t * @param {Number} x The x position to use for the source rect.\n\t * @param {Number} y The y position to use for the source rect.\n\t * @param {Number} width The width to use for the source rect.\n\t * @param {Number} height The height to use for the source rect.\n\t * @param {CanvasRenderingContext2D} [targetCtx] The 2D context to draw the result to. Defaults to the context passed to ctx.\n\t * @param {Number} [targetX] The x position to draw the result to. Defaults to the value passed to x.\n\t * @param {Number} [targetY] The y position to draw the result to. Defaults to the value passed to y.\n\t * @return {Boolean} If the filter was applied successfully.\n\t */\n\tapplyFilter (ctx, x, y, width, height, targetCtx, targetX, targetY) {\n\t\t// this is the default behaviour because most filters access pixel data. It is overridden when not needed.\n\t\ttargetCtx = targetCtx || ctx;\n\t\tif (targetX == null) { targetX = x; }\n\t\tif (targetY == null) { targetY = y; }\n\t\ttry {\n\t\t\tlet imageData = ctx.getImageData(x, y, width, height);\n\t\t\tif (this._applyFilter(imageData)) {\n\t\t\t\ttargetCtx.putImageData(imageData, targetX, targetY);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} catch (e) {}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name}]`;\n\t}\n\n\t/**\n\t * Returns a clone of this Filter instance.\n\t * @return {easeljs.Filter} A clone of the current Filter instance.\n\t */\n\tclone () {\n\t\treturn new Filter();\n\t}\n\n\t/**\n\t * @abstract\n\t * @param {ImageData} imageData Target ImageData instance.\n\t * @return {Boolean}\n\t */\n\t_applyFilter (imageData) { }\n\n}\n","/**\n * @license BitmapCache\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Filter from \"./Filter\";\nimport Rectangle from \"../geom/Rectangle\";\nimport StageGL from \"../display/StageGL\";\n\n/**\n * The BitmapCache is an internal representation of all the cache properties and logic required in order to \"cache\"\n * an object. This information and functionality used to be located on a {@link easeljs.DisplayObject#cache}\n * method in {@link easeljs.DisplayObject}, but was moved to its own class.\n *\n * Caching in this context is purely visual, and will render the DisplayObject out into an image to be used instead\n * of the object. The actual cache itself is still stored on the target with the {@link easeljs.DisplayObject#cacheCanvas}.\n *\n * Working with a singular image like a {@link easeljs.Bitmap}, there is little benefit to performing\n * a cache operation, as it is already a single image. Caching is best done on containers that have multiple complex\n * parts that do not change often, so that rendering the image will improve overall rendering speed. A cached object\n * will not visually update until explicitly told to do so with a call to {@link easeljs.Stage#update},\n * much like a Stage. If a cache is being updated every frame, it is likely not improving rendering performance.\n * Caches are best used when updates will be sparse.\n *\n * Caching is also a co-requisite for applying filters to prevent expensive filters running constantly without need.\n * The BitmapCache is also responsible for applying filters to objects, and reads each {@link easeljs.Filter}.\n * Real-time Filters are not recommended when dealing with a Context2D canvas if performance is a concern. For best\n * performance and to still allow for some visual effects, use a {{#crossLink \"DisplayObject/compositeOperation:property\"}}{{/crossLink}}\n * when possible.\n *\n * @memberof easeljs\n * @extends easeljs.Filter\n */\nexport default class BitmapCache extends Filter {\n\n\tconstructor () {\n\t\tsuper();\n\n\t\t/**\n\t\t * Width of the cache relative to the target object.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default undefined\n\t\t */\n\t\tthis.width = undefined;\n\n\t\t/**\n\t\t * Height of the cache relative to the target object.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default undefined\n\t\t */\n\t\tthis.height = undefined;\n\n\t\t/**\n\t\t * Horizontal position of the cache relative to the target's origin.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default undefined\n\t\t */\n\t\tthis.x = undefined;\n\n\t\t/**\n\t\t * Vertical position of the cache relative to target's origin.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default undefined\n\t\t */\n\t\tthis.y = undefined;\n\n\t\t/**\n\t\t * The internal scale of the cache image, does not affects display size. This is useful to both increase and\n\t\t * decrease render quality. Objects with increased scales are more likely to look good when scaled up. Objects\n\t\t * with decreased scales can save on rendering performance.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 1\n\t\t */\n\t\tthis.scale = 1;\n\n\t\t/**\n\t\t * The relative offset of the {@link easeljs.BitmapCache#x} position, used for drawing\n\t\t * into the cache with the correct offsets. Re-calculated every update call before drawing.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.offX = 0;\n\n\t\t/**\n\t\t * The relative offset of the {@link easeljs.BitmapCache#y} position, used for drawing\n\t\t * into the cache with the correct offsets. Re-calculated every update call before drawing.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.offY = 0;\n\n\t\t/**\n\t\t * Track how many times the cache has been updated, mostly used for preventing duplicate cacheURLs. This can be\n\t\t * useful to see if a cache has been updated.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.cacheID = 0;\n\n\t\t/**\n\t\t * Relative offset of the x position, used for drawing the cache into other scenes.\n\t\t * Re-calculated every update call before drawing.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t * @todo Is this description right? Its the same as offX.\n\t\t */\n\t\tthis._filterOffX = 0;\n\n\t\t/**\n\t\t * Relative offset of the y position, used for drawing into the cache into other scenes.\n\t\t * Re-calculated every update call before drawing.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t * @todo Is this description right? Its the same as offY.\n\t\t */\n\t\tthis._filterOffY = 0;\n\n\t\t/**\n\t\t * The cacheID when a DataURL was requested.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis._cacheDataURLID = 0;\n\n\t\t/**\n\t\t * The cache's DataURL, generated on-demand using the getter.\n\t\t * @protected\n\t\t * @type {String}\n\t\t * @default null\n\t\t */\n\t\tthis._cacheDataURL = null;\n\n\t\t/**\n\t\t * Internal tracking of final bounding width, approximately `width*scale;` however, filters can complicate the actual value.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis._drawWidth = 0;\n\n\t\t/**\n\t\t * Internal tracking of final bounding height, approximately `height*scale;` however, filters can complicate the actual value.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis._drawHeight = 0;\n\n\t\t/**\n\t\t * Internal tracking of the last requested bounds, may happen repeadtedly so stored to avoid object creation.\n\t\t * @protected\n\t\t * @type {easeljs.Rectangle}\n\t\t * @default easeljs.Rectangle\n\t\t */\n\t\tthis._boundRect = new Rectangle();\n\n\t}\n\n\t/**\n\t * Returns the bounds that surround all applied filters. This relies on each filter to describe how it changes bounds.\n\t * @param {easeljs.DisplayObject} target The object to check the filter bounds for.\n\t * @param {easeljs.Rectangle} [output] Calculated bounds will be applied to this rect.\n\t * @return {easeljs.Rectangle}\n\t * @static\n\t */\n\tstatic getFilterBounds (target, output = new Rectangle()) {\n\t\tlet filters = target.filters;\n\t\tlet filterCount = filters && filters.length;\n\t\tif (!!filterCount <= 0) { return output; }\n\n\t\tfor (let i=0; i= 1 ? width : 1;\n\t\tthis.height = height >= 1 ? height : 1;\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.scale = scale;\n\n\t\tthis.update();\n\t}\n\n\t/**\n\t * Directly called via {@link easeljs.DisplayObject#updateCache}, but also internally. This\n\t * has the dual responsibility of making sure the surface is ready to be drawn to, and performing the draw. For\n\t * full details of each behaviour, check the protected functions {@link easeljs.BitmapCache#_updateSurface}\n\t * and {@link easeljs.BitmapCache#_drawToCache} respectively.\n\t * @param {String} [compositeOperation] The DisplayObject this cache is linked to.\n\t */\n\tupdate (compositeOperation) {\n\t\tif (!this.target) { throw \"define() must be called before update()\"; }\n\n\t\tlet filterBounds = BitmapCache.getFilterBounds(this.target);\n\t\tlet surface = this.target.cacheCanvas;\n\n\t\tthis._drawWidth = Math.ceil(this.width*this.scale) + filterBounds.width;\n\t\tthis._drawHeight = Math.ceil(this.height*this.scale) + filterBounds.height;\n\n\t\tif (!surface || this._drawWidth != surface.width || this._drawHeight != surface.height) {\n\t\t\tthis._updateSurface();\n\t\t}\n\n\t\tthis._filterOffX = filterBounds.x;\n\t\tthis._filterOffY = filterBounds.y;\n\t\tthis.offX = this.x*this.scale + this._filterOffX;\n\t\tthis.offY = this.y*this.scale + this._filterOffY;\n\n\t\tthis._drawToCache(compositeOperation);\n\n\t\tthis.cacheID = this.cacheID?this.cacheID+1:1;\n\t}\n\n\t/**\n\t * Reset and release all the properties and memory associated with this cache.\n\t */\n\trelease () {\n\t\tlet stage = this.target.stage;\n\t\tif (this._useWebGL && this._webGLCache) {\n\t\t\t// if it isn't cache controlled clean up after yourself\n\t\t\tif (!this._webGLCache.isCacheControlled) {\n\t\t\t\tif (this.__lastRT) { this.__lastRT = undefined; }\n\t\t\t\tif (this.__rtA) { this._webGLCache._killTextureObject(this.__rtA); }\n\t\t\t\tif (this.__rtB) { this._webGLCache._killTextureObject(this.__rtB); }\n\t\t\t\tif (this.target && this.target.cacheCanvas) { this._webGLCache._killTextureObject(this.target.cacheCanvas); }\n\t\t\t}\n\t\t\t// set the context to none and let the garbage collector get the rest when the canvas itself gets removed\n\t\t\tthis._webGLCache = false;\n\t\t} else if (stage instanceof StageGL) {\n\t\t\tstage.releaseTexture(this.target.cacheCanvas);\n\t\t}\n\t\tthis.target = this.target.cacheCanvas = null;\n\t\tthis.cacheID = this._cacheDataURLID = this._cacheDataURL = undefined;\n\t\tthis.width = this.height = this.x = this.y = this.offX = this.offY = 0;\n\t\tthis.scale = 1;\n\t}\n\n\t/**\n\t * Returns a data URL for the cache, or `null` if this display object is not cached.\n\t * Uses {@link easeljs.BitmapCache#cacheID} to ensure a new data URL is not generated if the\n\t * cache has not changed.\n\t * @return {String} The image data url for the cache.\n\t */\n\tgetCacheDataURL () {\n\t\tlet cacheCanvas = this.target && this.target.cacheCanvas;\n\t\tif (!cacheCanvas) { return null; }\n\t\tif (this.cacheID != this._cacheDataURLID) {\n\t\t\tthis._cacheDataURLID = this.cacheID;\n\t\t\tthis._cacheDataURL = cacheCanvas.toDataURL?cacheCanvas.toDataURL():null;\t// incase function is\n\t\t}\n\t\treturn this._cacheDataURL;\n\t}\n\n\t/**\n\t * Use context2D drawing commands to display the cache canvas being used.\n\t * @param {CanvasRenderingContext2D} ctx The context to draw into.\n\t * @return {Boolean} Whether the draw was handled successfully.\n\t */\n\tdraw (ctx) {\n\t\tif (!this.target) { return false; }\n\t\tctx.drawImage(\n\t\t\tthis.target.cacheCanvas,\n\t\t\tthis.x + (this._filterOffX/this.scale),\n\t\t\tthis.y + (this._filterOffY/this.scale),\n\t\t\tthis._drawWidth/this.scale,\n\t\t\tthis._drawHeight/this.scale\n\t\t);\n\t\treturn true;\n\t}\n\n\t/**\n\t * Determine the bounds of the shape in local space.\n\t * @returns {easeljs.Rectangle}\n\t */\n\tgetBounds () {\n\t\tconst scale = this.scale;\n\t\treturn this._boundRect.setValue(\n\t\t\tthis._filterOffX/scale,\n\t\t\tthis._filterOffY/scale,\n\t\t\tthis.width/scale,\n\t\t\tthis.height/scale\n\t\t);\n\t}\n\n\t/**\n\t * Basic context2D caching works by creating a new canvas element and setting its physical size. This function will\n\t * create and or size the canvas as needed.\n\t * @protected\n\t */\n\t_updateSurface () {\n\t\tlet surface;\n\t\tif (!this._useWebGL) {\n\t\t\tsurface = this.target.cacheCanvas;\n\t\t\t// create it if it's missing\n\t\t\tif (!surface) {\n\t\t\t\tsurface = this.target.cacheCanvas = window.createjs&&createjs.createCanvas?createjs.createCanvas():document.createElement(\"canvas\");\n\t\t\t}\n\t\t\t// now size it\n\t\t\tsurface.width = this._drawWidth;\n\t\t\tsurface.height = this._drawHeight;\n\t\t\t// skip the webgl-only updates\n\t\t\treturn;\n\t\t}\n\n\t\t// create it if it's missing\n\t\tif (!this._webGLCache) {\n\t\t\tif (this._options.useGL === \"stage\") {\n\t\t\t\tif(!(this.target.stage != null && this.target.stage.isWebGL)) {\n\t\t\t\t\tthrow `Cannot use 'stage' for cache because the object's parent stage is ${this.target.stage != null ? \"non WebGL.\" : \"not set, please addChild to the correct stage.\"}`;\n\t\t\t\t}\n\t\t\t\tthis.target.cacheCanvas = true; // will be replaced with RenderTexture, temporary positive value for old \"isCached\" checks\n\t\t\t\tthis._webGLCache = this.target.stage;\n\t\t\t} else if (this._options.useGL === \"new\") {\n\t\t\t\tthis.target.cacheCanvas = document.createElement(\"canvas\"); // we can turn off autopurge because we wont be making textures here\n\t\t\t\tthis._webGLCache = new StageGL(this.target.cacheCanvas, {antialias: true, transparent: true, autoPurge: -1});\n\t\t\t\tthis._webGLCache.isCacheControlled = true; // use this flag to control stage sizing and final output\n\t\t\t} else {\n\t\t\t\tthrow \"Invalid option provided to useGL, expected ['stage', 'new', StageGL, undefined], got \"+ this._options.useGL;\n\t\t\t}\n\t\t}\n\n\t\t// now size render surfaces\n\t\tlet stageGL = this._webGLCache;\n\t\tsurface = this.target.cacheCanvas;\n\n\t\t// if we have a dedicated stage we've gotta size it\n\t\tif (stageGL.isCacheControlled) {\n\t\t\tsurface.width = this._drawWidth;\n\t\t\tsurface.height = this._drawHeight;\n\t\t\tstageGL.updateViewport(this._drawWidth, this._drawHeight);\n\t\t}\n\t\tif (this.target.filters) {\n\t\t\t// with filters we can't tell how many we'll need but the most we'll ever need is two, so make them now\n\t\t\tstageGL.getTargetRenderTexture(this.target, this._drawWidth,this._drawHeight);\n\t\t\tstageGL.getTargetRenderTexture(this.target, this._drawWidth,this._drawHeight);\n\t\t} else if (!stageGL.isCacheControlled) {\n\t\t\t// without filters then we only need one RenderTexture, and that's only if its not a dedicated stage\n\t\t\tstageGL.getTargetRenderTexture(this.target, this._drawWidth,this._drawHeight);\n\t\t}\n\t}\n\n\t/**\n\t * Perform the cache draw out for context 2D now that the setup properties have been performed.\n\t * @protected\n\t */\n\t_drawToCache (compositeOperation) {\n\t\tlet target = this.target;\n\t\tlet surface = target.cacheCanvas;\n\t\tlet webGL = this._webGLCache;\n\n\t\tif (!this._useWebGL || !webGL) {\n\t\t\tlet ctx = surface.getContext(\"2d\");\n\n\t\t\tif (!compositeOperation) {\n\t\t\t\tctx.clearRect(0, 0, this._drawWidth+1, this._drawHeight+1);\n\t\t\t}\n\n\t\t\tctx.save();\n\t\t\tctx.globalCompositeOperation = compositeOperation;\n\t\t\tctx.setTransform(this.scale,0,0,this.scale, -this._filterOffX,-this._filterOffY);\n\t\t\tctx.translate(-this.x, -this.y);\n\t\t\ttarget.draw(ctx, true);\n\t\t\tctx.restore();\n\n\t\t\tif (target.filters && target.filters.length) {\n\t\t\t\tthis._applyFilters(target);\n\t\t\t}\n\t\t\tsurface._invalid = true;\n\t\t\treturn;\n\t\t}\n\n\t\tthis._webGLCache.cacheDraw(target, target.filters, this);\n\t\t// NOTE: we may of swapped around which element the surface is, so we re-fetch it\n\t\tsurface = this.target.cacheCanvas;\n\t\tsurface.width = this._drawWidth;\n\t\tsurface.height = this._drawHeight;\n\t\tsurface._invalid = true;\n\t}\n\n\t/**\n\t * Work through every filter and apply its individual transformation to it.\n\t * @protected\n\t */\n\t_applyFilters () {\n\t\tlet surface = this.target.cacheCanvas;\n\t\tlet filters = this.target.filters;\n\n\t\tlet w = this._drawWidth;\n\t\tlet h = this._drawHeight;\n\n\t\t// setup\n\t\tlet data = surface.getContext(\"2d\").getImageData(0,0, w,h);\n\n\t\t// apply\n\t\tlet l = filters.length;\n\t\tfor (let i=0; iWebGL cache with 2d context\n * let stage = new Stage();\n * let bmp = new Bitmap(src);\n * bmp.cache(0, 0, bmp.width, bmp.height, 1, true); // no StageGL to use, so make one\n * let shape = new Shape();\n * shape.graphics.clear().fill(\"red\").drawRect(0,0,20,20);\n * shape.cache(0, 0, 20, 20, 1); // cannot use WebGL cache\n *\n * @example
WebGL cache with WebGL context
\n * let stageGL = new StageGL();\n * let bmp = new Bitmap(src);\n * bmp.cache(0, 0, bmp.width, bmp.height, 1, stageGL); // use our StageGL to cache\n * let shape = new Shape();\n * shape.graphics.clear().fill(\"red\").drawRect(0,0,20,20);\n * shape.cache(0, 0, 20, 20, 1); // cannot use WebGL cache\n *\n * @param {Number} x The x coordinate origin for the cache region.\n * @param {Number} y The y coordinate origin for the cache region.\n * @param {Number} width The width of the cache region.\n * @param {Number} height The height of the cache region.\n * @param {Number} [scale=1] The scale at which the cache will be created. For example, if you cache a vector shape using\n * \tmyShape.cache(0,0,100,100,2) then the resulting cacheCanvas will be 200x200 px. This lets you scale and rotate\n * \tcached elements with greater fidelity.\n * @param {Boolean | easeljs.StageGL} [options] Select whether to use context 2D, or WebGL rendering, and whether to make a new stage instance or use an existing one.\n */\n","/**\n * @license DisplayObject\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport { EventDispatcher } from \"@createjs/core\";\nimport Shadow from \"./Shadow\";\nimport uid from \"../utils/uid\";\nimport DisplayProps from \"../geom/DisplayProps\";\nimport Rectangle from \"../geom/Rectangle\";\nimport Point from \"../geom/Point\";\nimport Matrix2D from \"../geom/Matrix2D\";\nimport BitmapCache from \"../filters/BitmapCache\";\n\n/**\n * DisplayObject is an abstract class that should not be constructed directly. Instead construct subclasses such as\n * {@link easeljs.Container}, {@link easeljs.Bitmap}, and {@link easeljs.Shape}.\n * DisplayObject is the base class for all display classes in the EaselJS library. It defines the core properties and\n * methods that are shared between all display objects, such as transformation properties (x, y, scaleX, scaleY, etc),\n * caching, and mouse handlers.\n *\n * @memberof easeljs\n * @extends EventDispatcher\n */\nexport default class DisplayObject extends EventDispatcher {\n\n\tconstructor () {\n\t\tsuper();\n\n\t\t/**\n\t\t * The alpha (transparency) for this display object. 0 is fully transparent, 1 is fully opaque.\n\t\t * @type {Number}\n\t\t * @default 1\n\t\t */\n\t\tthis.alpha = 1;\n\n\t\t/**\n\t\t * If a cache is active, this returns the canvas that holds the image of this display object.\n\t\t * Use this to display the result of a cache. This will be a HTMLCanvasElement unless special cache rules have been deliberately enabled for this cache.\n\t\t * @see {@link easeljs.DisplayObject#cache}\n\t\t * @type {HTMLCanvasElement | Object}\n\t\t * @default null\n\t\t * @readonly\n\t\t */\n\t\tthis.cacheCanvas = null;\n\n\t\t/**\n\t\t * If a cache has been made, this returns the class that is managing the cacheCanvas and its properties.\n\t\t * @see {@link easeljs.BitmapCache}\n\t\t * @type {easeljs.BitmapCache}\n\t\t * @default null\n\t\t * @readonly\n\t\t */\n\t\tthis.bitmapCache = null;\n\n\t\t/**\n\t\t * Unique ID for this display object. Makes display objects easier for some uses.\n\t\t * @type {Number}\n\t\t */\n\t\tthis.id = uid();\n\n\t\t/**\n\t\t * Indicates whether to include this object when running mouse interactions. Setting this to `false` for children\n\t\t * of a {@link easeljs.Container} will cause events on the Container to not fire when that child is\n\t\t * clicked. Setting this property to `false` does not prevent the {@link easeljs.Container#getObjectsUnderPoint}\n\t\t * method from returning the child.\n\t\t *\n\t\t * Note: In EaselJS 0.7.0, the `mouseEnabled` property will not work properly with nested Containers.\n\t\t *\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.mouseEnabled = true;\n\n\t\t/**\n\t\t * If false, the tick will not run on this display object (or its children). This can provide some performance benefits.\n\t\t * In addition to preventing the {@link core.Ticker#event:tick} event from being dispatched, it will also prevent tick related updates\n\t\t * on some display objects (ex. Sprite & MovieClip frame advancing, DOMElement visibility handling).\n\t\t * @type Boolean\n\t\t * @default true\n\t\t */\n\t\tthis.tickEnabled = true;\n\n\t\t/**\n\t\t * An optional name for this display object. Included in {@link easeljs.DisplayObject#toString}. Useful for debugging.\n\t\t * @type {String}\n\t\t * @default null\n\t\t */\n\t\tthis.name = null;\n\n\t\t/**\n\t\t * A reference to the {@link easeljs.Container} or {@link easeljs.Stage} object that\n\t\t * contains this display object, or null if it has not been added to one.\n\t\t * @type {easeljs.Container}\n\t\t * @default null\n\t\t * @readonly\n\t\t */\n\t\tthis.parent = null;\n\n\t\t/**\n\t\t * The left offset for this display object's registration point. For example, to make a 100x100px Bitmap rotate\n\t\t * around its center, you would set regX and {@link easeljs.DisplayObject#regY} to 50.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.regX = 0;\n\n\t\t/**\n\t\t * The y offset for this display object's registration point. For example, to make a 100x100px Bitmap rotate around\n\t\t * its center, you would set {@link easeljs.DisplayObject#regX} and regY to 50.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.regY = 0;\n\n\t\t/**\n\t\t * The rotation in degrees for this display object.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.rotation = 0;\n\n\t\t/**\n\t\t * The factor to stretch this display object horizontally. For example, setting scaleX to 2 will stretch the display\n\t\t * object to twice its nominal width. To horizontally flip an object, set the scale to a negative number.\n\t\t * @type {Number}\n\t\t * @default 1\n\t\t */\n\t\tthis.scaleX = 1;\n\n\t\t/**\n\t\t * The factor to stretch this display object vertically. For example, setting scaleY to 0.5 will stretch the display\n\t\t * object to half its nominal height. To vertically flip an object, set the scale to a negative number.\n\t\t * @type {Number}\n\t\t * @default 1\n\t\t */\n\t\tthis.scaleY = 1;\n\n\t\t/**\n\t\t * The factor to skew this display object horizontally.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.skewX = 0;\n\n\t\t/**\n\t\t * The factor to skew this display object vertically.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.skewY = 0;\n\n\t\t/**\n\t\t * A shadow object that defines the shadow to render on this display object. Set to `null` to remove a shadow. If\n\t\t * null, this property is inherited from the parent container.\n\t\t * @type {easeljs.Shadow}\n\t\t * @default null\n\t\t */\n\t\tthis.shadow = null;\n\n\t\t/**\n\t\t * Indicates whether this display object should be rendered to the canvas and included when running the Stage\n\t\t * {@link easeljs.Stage#getObjectsUnderPoint} method.\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.visible = true;\n\n\t\t/**\n\t\t * The x (horizontal) position of the display object, relative to its parent.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.x = 0;\n\n\t\t/**\n\t\t * The y (vertical) position of the display object, relative to its parent.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.y = 0;\n\n\t\t/**\n\t\t * If set, defines the transformation for this display object, overriding all other transformation properties\n\t\t * (x, y, rotation, scale, skew).\n\t\t * @type {easeljs.Matrix2D}\n\t\t * @default null\n\t\t */\n\t\tthis.transformMatrix = null;\n\n\t\t/**\n\t\t * The composite operation indicates how the pixels of this display object will be composited with the elements\n\t\t * behind it. If `null`, this property is inherited from the parent container.\n\t\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#compositing \"WHATWG spec on compositing\"}\n\t\t * @type {String}\n\t\t * @default null\n\t\t */\n\t\tthis.compositeOperation = null;\n\n\t\t/**\n\t\t * Indicates whether the display object should be drawn to a whole pixel when {@link easeljs.Stage#snapToPixelEnabled} is true.\n\t\t * To enable/disable snapping on whole categories of display objects, set this value on the prototype (Ex. Text.prototype.snapToPixel = true).\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.snapToPixel = true;\n\n\t\t/**\n\t\t * An array of Filter objects to apply to this display object. Filters are only applied / updated when {@link easeljs.DisplayObject#cache}\n\t\t * or {@link easeljs.DisplayObject#updateCache} is called on the display object, and only apply to the area that is cached.\n\t\t * @type {Array}\n\t\t * @default null\n\t\t */\n\t\tthis.filters = null;\n\n\t\t/**\n\t\t * A Shape instance that defines a vector mask (clipping path) for this display object. The shape's transformation\n\t\t * will be applied relative to the display object's parent coordinates (as if it were a child of the parent).\n\t\t * @type {easeljs.Shape}\n\t\t * @default null\n\t\t */\n\t\tthis.mask = null;\n\n\t\t/**\n\t\t * A display object that will be tested when checking mouse interactions or testing {@link easeljs.Container#getObjectsUnderPoint}.\n\t\t * The hit area will have its transformation applied relative to this display object's coordinate space (as though\n\t\t * the hit test object were a child of this display object and relative to its regX/Y). The hitArea will be tested\n\t\t * using only its own `alpha` value regardless of the alpha value on the target display object, or the target's\n\t\t * ancestors (parents).\n\t\t *\n\t\t * If set on a {@link easeljs.Container}, children of the Container will not receive mouse events.\n\t\t * This is similar to setting {@link easeljs.DisplayObject#mouseChildren} to false.\n\t\t *\n\t\t * Note that hitArea is NOT currently used by the `hitTest()` method, nor is it supported for {@link easeljs.Stage}.\n\t\t *\n\t\t * @type {easeljs.DisplayObject}\n\t\t * @default null\n\t\t */\n\t\tthis.hitArea = null;\n\n\t\t/**\n\t\t * A CSS cursor (ex. \"pointer\", \"help\", \"text\", etc) that will be displayed when the user hovers over this display\n\t\t * object. You must enable mouseover events using the {@link easeljs.Stage#enableMouseOver} method to\n\t\t * use this property. Setting a non-null cursor on a Container will override the cursor set on its descendants.\n\t\t *\n\t\t * @type {String}\n\t\t * @default null\n\t\t */\n\t\tthis.cursor = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.DisplayProps}\n\t\t */\n\t\tthis._props = new DisplayProps();\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.Rectangle}\n\t\t */\n\t\tthis._rectangle = new Rectangle();\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.Rectangle}\n\t\t * @default null\n\t\t */\n\t\tthis._bounds = null;\n\n\t\t/**\n\t\t * Where StageGL should look for required display properties, matters only for leaf display objects. Containers\n\t\t * or cached objects won't use this property, it's for native display of terminal elements.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis._webGLRenderStyle = DisplayObject._StageGL_NONE;\n\t}\n\n\t/**\n\t * Returns the {@link easeljs.Stage} instance that this display object will be rendered on, or null if it has not been added to one.\n\t * @type {Stage}\n\t * @readonly\n\t */\n\tget stage () {\n\t\t// uses dynamic access to avoid circular dependencies;\n\t\tlet o = this;\n\t\twhile (o.parent) { o = o.parent; }\n\t\tif (/^\\[Stage(GL)?(\\s\\(name=\\w+\\))?\\]$/.test(o.toString())) { return o; }\n\t\treturn null;\n\t}\n\n\t/**\n\t * Set both the {@link easeljs.DisplayObject#scaleX} and the {@link easeljs.DisplayObject#scaleY} property to the same value.\n\t * Note that when you get the value, if the `scaleX` and `scaleY` are different values, it will return only the `scaleX`.\n\t * @type {Number}\n\t * @default 1\n\t */\n\tset scale (value) { this.scaleX = this.scaleY = value; }\n\tget scale () { return this.scaleX; }\n\n\t/**\n\t * Returns true or false indicating whether the display object would be visible if drawn to a canvas.\n\t * This does not account for whether it would be visible within the boundaries of the stage.\n\t * NOTE: This method is mainly for internal use, though it may be useful for advanced uses.\n\t * @return {Boolean} Boolean indicating whether the display object would be visible if drawn to a canvas\n\t */\n\tisVisible () {\n\t\treturn !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0);\n\t}\n\n\t/**\n\t * Alias for drawCache(). Used by grandchildren (or deeper) in their draw method to directly\n\t * call {@link easeljs.DisplayObject#drawCache}, bypassing their parent(s).\n\t *\n\t * @param {CanvasRenderingContext2D} ctx The canvas 2D context object to draw into.\n\t * @param {Boolean} [ignoreCache=false] Indicates whether the draw operation should ignore any current cache. For example,\n\t * used for drawing the cache (to prevent it from simply drawing an existing cache back into itself).\n\t * @return {Boolean}\n\t */\n\tdraw (ctx, ignoreCache = false) {\n\t\treturn this.drawCache(ctx, ignoreCache);\n\t}\n\n\t/**\n\t * Draws the display object into the specified context ignoring its visible, alpha, shadow, and transform.\n\t * Returns `true` if the draw was handled (useful for overriding functionality).\n\t *\n\t * NOTE: This method is mainly for internal use, though it may be useful for advanced uses.\n\t * @param {CanvasRenderingContext2D} ctx The canvas 2D context object to draw into.\n\t * @param {Boolean} [ignoreCache=false] Indicates whether the draw operation should ignore any current cache. For example,\n\t * used for drawing the cache (to prevent it from simply drawing an existing cache back into itself).\n\t * @return {Boolean}\n\t */\n\tdrawCache (ctx, ignoreCache = false) {\n\t\tlet cache = this.bitmapCache;\n\t\tif (cache && !ignoreCache) {\n\t\t\treturn cache.draw(ctx);\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Applies this display object's transformation, alpha, globalCompositeOperation, clipping path (mask), and shadow\n\t * to the specified context. This is typically called prior to {@link easeljs.DisplayObject#draw}.\n\t * @param {CanvasRenderingContext2D} ctx The canvas 2D to update.\n\t */\n\tupdateContext (ctx) {\n\t\tlet o=this, mask=o.mask, mtx=o._props.matrix;\n\n\t\tif (mask && mask.graphics && !mask.graphics.isEmpty()) {\n\t\t\tmask.getMatrix(mtx);\n\t\t\tctx.transform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx, mtx.ty);\n\n\t\t\tmask.graphics.drawAsPath(ctx);\n\t\t\tctx.clip();\n\n\t\t\tmtx.invert();\n\t\t\tctx.transform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx, mtx.ty);\n\t\t}\n\n\t\tthis.getMatrix(mtx);\n\t\tlet tx = mtx.tx, ty = mtx.ty;\n\t\tif (DisplayObject._snapToPixelEnabled && o.snapToPixel) {\n\t\t\ttx = tx + (tx < 0 ? -0.5 : 0.5) | 0;\n\t\t\tty = ty + (ty < 0 ? -0.5 : 0.5) | 0;\n\t\t}\n\t\tctx.transform(mtx.a, mtx.b, mtx.c, mtx.d, tx, ty);\n\t\tctx.globalAlpha *= o.alpha;\n\t\tif (o.compositeOperation) { ctx.globalCompositeOperation = o.compositeOperation; }\n\t\tif (o.shadow) { this._applyShadow(ctx, o.shadow); }\n\t}\n\n\t/**\n\t * Draws the display object into a new element, which is then used for subsequent draws. Intended for complex content\n\t * that does not change frequently (ex. a Container with many children that do not move, or a complex vector Shape),\n\t * this can provide for much faster rendering because the content does not need to be re-rendered each tick. The\n\t * cached display object can be moved, rotated, faded, etc freely, however if its content changes, you must manually\n\t * update the cache by calling `updateCache()` again. You must specify the cached area via the x, y, w,\n\t * and h parameters. This defines the rectangle that will be rendered and cached using this display object's coordinates.\n\t *\n\t * Note that filters need to be defined before the cache is applied or you will have to call updateCache after\n\t * application. Check out the {@link easeljs.Filter} class for more information. Some filters\n\t * (ex. {@link easeljs.BlurFilter}) may not work as expected in conjunction with the scale param.\n\t *\n\t * Usually, the resulting cacheCanvas will have the dimensions width*scale by height*scale, however some filters (ex. BlurFilter)\n\t * will add padding to the canvas dimensions.\n\t *\n\t * Actual implementation of the caching mechanism can change with a {@link easeljs.StageGL} and so\n\t * all caching and filter behaviour has been moved to the {@link easeljs.BitmapCache}\n\t *\n\t * @example\n\t * // If you defined a Shape that drew a circle at 0, 0 with a radius of 25:\n\t * var shape = new createjs.Shape();\n\t * shape.graphics.beginFill(\"#ff0000\").drawCircle(0, 0, 25);\n\t * shape.cache(-25, -25, 50, 50);\n\t *\n\t * @param {Number} x The x coordinate origin for the cache region.\n\t * @param {Number} y The y coordinate origin for the cache region.\n\t * @param {Number} width The width of the cache region.\n\t * @param {Number} height The height of the cache region.\n\t * @param {Number} [scale=1] The scale at which the cache will be created. For example, if you cache a vector shape using\n\t * \tmyShape.cache(0,0,100,100,2) then the resulting cacheCanvas will be 200x200 px. This lets you scale and rotate\n\t * \tcached elements with greater fidelity. Default is 1.\n\t * @param {Object} [options] When using alternate displays there may be extra caching opportunities or needs.\n\t */\n\tcache (x, y, width, height, scale = 1, options) {\n\t\tif (!this.bitmapCache) {\n\t\t\tthis.bitmapCache = new BitmapCache();\n\t\t}\n\t\tthis.bitmapCache.define(this, x, y, width, height, scale, options);\n\t}\n\n\t/**\n\t * Redraws the display object to its cache. Calling updateCache without an active cache will throw an error.\n\t * If compositeOperation is null the current cache will be cleared prior to drawing. Otherwise the display object\n\t * will be drawn over the existing cache using the specified compositeOperation.\n\t *\n\t * Actual implementation of the caching mechanism can change with a {@link easeljs.StageGL} and so\n\t * all caching and filter behaviour has been moved to the {@link easeljs.BitmapCache}\n\t *\n\t * @example\n\t * // clear current graphics\n\t * shapeInstance.clear();\n\t * // draw new instructions\n\t * shapeInstance.setStrokeStyle(3).beginStroke(\"#FF0000\").moveTo(100, 100).lineTo(200,200);\n\t * // update cache, drawing new line on top of old one\n\t * shapeInstance.updateCache();\n\t *\n\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#compositing \"WHATWG spec on compositing\"}\n\t * @param {String} compositeOperation The compositeOperation to use, or null to clear the cache and redraw it.\n\t */\n\tupdateCache (compositeOperation) {\n\t\tif (!this.bitmapCache) {\n\t\t\tthrow \"No cache found. cache() must be called before updateCache()\";\n\t\t}\n\t\tthis.bitmapCache.update(compositeOperation);\n\t}\n\n\t/**\n\t * Clears the current cache.\n\t * @see {@link easeljs.DisplayObject.#cache}\n\t */\n\tuncache () {\n\t\tif (this.bitmapCache) {\n\t\t\tthis.bitmapCache.release();\n\t\t\tthis.bitmapCache = undefined;\n\t\t}\n\t}\n\n\t/**\n\t * Returns a data URL for the cache, or null if this display object is not cached.\n\t * Only generated if the cache has changed, otherwise returns last result.\n\t * @return {String} The image data url for the cache.\n\t */\n\tgetCacheDataURL () {\n\t\treturn this.bitmapCache ? this.bitmapCache.getDataURL() : null;\n\t}\n\n\t/**\n\t * Transforms the specified x and y position from the coordinate space of the display object\n\t * to the global (stage) coordinate space. For example, this could be used to position an HTML label\n\t * over a specific point on a nested display object. Returns a Point instance with x and y properties\n\t * correlating to the transformed coordinates on the stage.\n\t *\n\t * @example\n\t * displayObject.x = 300;\n\t * displayObject.y = 200;\n\t * stage.addChild(displayObject);\n\t * let point = displayObject.localToGlobal(100, 100);\n\t * // Results in x=400, y=300\n\t *\n\t * @param {Number} x The x position in the source display object to transform.\n\t * @param {Number} y The y position in the source display object to transform.\n\t * @param {easeljs.Point | Object} [pt=Point] An object to copy the result into. If omitted a new Point object with x/y properties will be returned.\n\t * @return {easeljs.Point} A Point instance with x and y properties correlating to the transformed coordinates\n\t * on the stage.\n\t */\n\tlocalToGlobal (x, y, pt = new Point()) {\n\t\treturn this.getConcatenatedMatrix(this._props.matrix).transformPoint(x, y, pt);\n\t}\n\n\t/**\n\t * Transforms the specified x and y position from the global (stage) coordinate space to the\n\t * coordinate space of the display object. For example, this could be used to determine\n\t * the current mouse position within the display object. Returns a Point instance with x and y properties\n\t * correlating to the transformed position in the display object's coordinate space.\n\t *\n\t * @example\n\t * displayObject.x = 300;\n\t * displayObject.y = 200;\n\t * stage.addChild(displayObject);\n\t * let point = displayObject.globalToLocal(100, 100);\n\t * // Results in x=-200, y=-100\n\t *\n\t * @param {Number} x The x position on the stage to transform.\n\t * @param {Number} y The y position on the stage to transform.\n\t * @param {easeljs.Point | Object} [pt=Point] An object to copy the result into. If omitted a new Point object with x/y properties will be returned.\n\t * @return {easeljs.Point} A Point instance with x and y properties correlating to the transformed position in the\n\t * display object's coordinate space.\n\t */\n\tglobalToLocal (x, y, pt = new Point()) {\n\t\treturn this.getConcatenatedMatrix(this._props.matrix).invert().transformPoint(x, y, pt);\n\t}\n\n\t/**\n\t * Transforms the specified x and y position from the coordinate space of this display object to the coordinate\n\t * space of the target display object. Returns a Point instance with x and y properties correlating to the\n\t * transformed position in the target's coordinate space. Effectively the same as using the following code with\n\t * {@link easeljs.DisplayObject#localToGlobal} and {@link easeljs.DisplayObject#globalToLocal}.\n\t *\n\t * @example\n\t * // long way\n\t * let pt = this.localToGlobal(x, y);\n\t * pt = target.globalToLocal(pt.x, pt.y);\n\t * // shorthand\n\t * let pt = this.localToLocal(x, y, target);\n\t *\n\t * @param {Number} x The x position in the source display object to transform.\n\t * @param {Number} y The y position on the source display object to transform.\n\t * @param {easeljs.DisplayObject} target The target display object to which the coordinates will be transformed.\n\t * @param {easeljs.Point | Object} [pt] An object to copy the result into. If omitted a new Point object with x/y properties will be returned.\n\t * @return {easeljs.Point} Returns a Point instance with x and y properties correlating to the transformed position\n\t * in the target's coordinate space.\n\t */\n\tlocalToLocal (x, y, target, pt) {\n\t\tpt = this.localToGlobal(x, y, pt);\n\t\treturn target.globalToLocal(pt.x, pt.y, pt);\n\t}\n\n\t/**\n\t * Shortcut method to quickly set the transform properties on the display object. All parameters are optional.\n\t * Omitted parameters will have the default value set.\n\t *\n\t * @example\n\t * displayObject.setTransform(100, 100, 2, 2);\n\t *\n\t * @param {Number} [x=0] The horizontal translation (x position) in pixels\n\t * @param {Number} [y=0] The vertical translation (y position) in pixels\n\t * @param {Number} [scaleX=1] The horizontal scale, as a percentage of 1\n\t * @param {Number} [scaleY=1] the vertical scale, as a percentage of 1\n\t * @param {Number} [rotation=0] The rotation, in degrees\n\t * @param {Number} [skewX=0] The horizontal skew factor\n\t * @param {Number} [skewY=0] The vertical skew factor\n\t * @param {Number} [regX=0] The horizontal registration point in pixels\n\t * @param {Number} [regY=0] The vertical registration point in pixels\n\t * @return {easeljs.DisplayObject} Returns this instance. Useful for chaining commands.\n\t*/\n\tsetTransform (x=0, y=0, scaleX=1, scaleY=1, rotation=0, skewX=0, skewY=0, regX=0, regY=0) {\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.scaleX = scaleX;\n\t\tthis.scaleY = scaleY;\n\t\tthis.rotation = rotation;\n\t\tthis.skewX = skewX;\n\t\tthis.skewY = skewY;\n\t\tthis.regX = regX;\n\t\tthis.regY = regY;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns a matrix based on this object's current transform.\n\t * @param {easeljs.Matrix2D} [matrix] A Matrix2D object to populate with the calculated values. If null, a new Matrix object is returned.\n\t * @return {easeljs.Matrix2D} A matrix representing this display object's transform.\n\t */\n\tgetMatrix (matrix) {\n\t\tlet o = this, mtx = matrix&&matrix.identity() || new Matrix2D();\n\t\treturn o.transformMatrix ? mtx.copy(o.transformMatrix) : mtx.appendTransform(o.x, o.y, o.scaleX, o.scaleY, o.rotation, o.skewX, o.skewY, o.regX, o.regY);\n\t}\n\n\t/**\n\t * Generates a Matrix2D object representing the combined transform of the display object and all of its\n\t * parent Containers up to the highest level ancestor (usually the {@link easeljs.Stage}). This can\n\t * be used to transform positions between coordinate spaces, such as with {@link easeljs.DisplayObject#localToGlobal}\n\t * and {@link easeljs.DisplayObject#globalToLocal}.\n\t *\n\t * @param {easeljs.Matrix2D} [matrix] A Matrix2D object to populate with the calculated values. If null, a new Matrix2D object is returned.\n\t * @return {easeljs.Matrix2D} The combined matrix.\n\t */\n\tgetConcatenatedMatrix (matrix) {\n\t\tlet o = this, mtx = this.getMatrix(matrix);\n\t\twhile (o = o.parent) {\n\t\t\tmtx.prependMatrix(o.getMatrix(o._props.matrix));\n\t\t}\n\t\treturn mtx;\n\t}\n\n\t/**\n\t * Generates a DisplayProps object representing the combined display properties of the object and all of its\n\t * parent Containers up to the highest level ancestor (usually the {@link easeljs.Stage}).\n\t * @param {easeljs.DisplayProps} [props] A DisplayProps object to populate with the calculated values. If null, a new DisplayProps object is returned.\n\t * @return {easeljs.DisplayProps} The combined display properties.\n\t */\n\tgetConcatenatedDisplayProps (props) {\n\t\tprops = props ? props.identity() : new DisplayProps();\n\t\tlet o = this, mtx = o.getMatrix(props.matrix);\n\t\tdo {\n\t\t\tprops.prepend(o.visible, o.alpha, o.shadow, o.compositeOperation);\n\n\t\t\t// we do this to avoid problems with the matrix being used for both operations when o._props.matrix is passed in as the props param.\n\t\t\t// this could be simplified (ie. just done as part of the prepend above) if we switched to using a pool.\n\t\t\tif (o != this) { mtx.prependMatrix(o.getMatrix(o._props.matrix)); }\n\t\t} while (o = o.parent);\n\t\treturn props;\n\t}\n\n\t/**\n\t * Tests whether the display object intersects the specified point in local coordinates (ie. draws a pixel with alpha > 0 at\n\t * the specified position). This ignores the alpha, shadow, hitArea, mask, and compositeOperation of the display object.\n\t *\n\t * Please note that shape-to-shape collision is not currently supported by EaselJS.\n\t *\n\t * @example\n\t * stage.addEventListener(\"stagemousedown\", event => {\n\t * let hit = shape.hitTest(event.stageX, event.stageY);\n\t * // hit == true when shape is clicked\n\t * });\n\t *\n\t * @param {Number} x The x position to check in the display object's local coordinates.\n\t * @param {Number} y The y position to check in the display object's local coordinates.\n\t * @return {Boolean} A Boolean indicating whether a visible portion of the DisplayObject intersect the specified\n\t * local Point.\n\t*/\n\thitTest (x, y) {\n\t\tlet ctx = DisplayObject._hitTestContext;\n\t\tctx.setTransform(1, 0, 0, 1, -x, -y);\n\t\tthis.draw(ctx);\n\n\t\tlet hit = this._testHit(ctx);\n\t\tctx.setTransform(1, 0, 0, 1, 0, 0);\n\t\tctx.clearRect(0, 0, 2, 2);\n\t\treturn hit;\n\t}\n\n\t/**\n\t * Provides a chainable shortcut method for setting a number of properties on the instance.\n\t *\n\t * @example\n\t * let graphics = new Graphics().beginFill(\"#ff0000\").drawCircle(0, 0, 25);\n\t * let shape = stage.addChild(new Shape()).set({ graphics, x: 100, y: 100, alpha: 0.5 });\n\t *\n\t * @param {Object} props A generic object containing properties to copy to the DisplayObject instance.\n\t * @return {easeljs.DisplayObject} Returns the instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t*/\n\tset (props) {\n\t\tfor (let n in props) { this[n] = props[n]; }\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns a rectangle representing this object's bounds in its local coordinate system (ie. with no transformation).\n\t * Objects that have been cached will return the bounds of the cache.\n\t *\n\t * Not all display objects can calculate their own bounds (ex. Shape). For these objects, you can use\n\t * {@link easeljs.DisplayObject#setBounds} so that they are included when calculating Container bounds.\n\t *\n\t *
\n\t * \t
All
\n\t * \t\tAll display objects support setting bounds manually using setBounds(). Likewise, display objects that\n\t * \t\thave been cached using cache() will return the bounds of their cache. Manual and cache bounds will override\n\t * \t\tthe automatic calculations listed below.\n\t * \t
\n\t * \t
Bitmap
\n\t * \t\tReturns the width and height of the sourceRect (if specified) or image, extending from (x=0,y=0).\n\t * \t
\n\t * \t
Sprite
\n\t * \t\tReturns the bounds of the current frame. May have non-zero x/y if a frame registration point was specified\n\t * \t\tin the spritesheet data. See also {@link easeljs.SpriteSheet#getFrameBounds}\n\t * \t
\n\t * \t
Container
\n\t * \t\tReturns the aggregate (combined) bounds of all children that return a non-null value from getBounds().\n\t * \t
\n\t * \t
Shape
\n\t * \t\tDoes not currently support automatic bounds calculations. Use setBounds() to manually define bounds.\n\t * \t
\n\t * \t
Text
\n\t * \t\tReturns approximate bounds. Horizontal values (x/width) are quite accurate, but vertical values (y/height) are\n\t * \t\tnot, especially when using textBaseline values other than \"top\".\n\t * \t
\n\t * \t
BitmapText
\n\t * \t\tReturns approximate bounds. Values will be more accurate if spritesheet frame registration points are close\n\t * \t\tto (x=0,y=0).\n\t * \t
\n\t*
\n\t *\n\t * @example\n\t * /* Bounds can be expensive to calculate for some objects (ex. text, or containers with many children), and\n\t * are recalculated each time you call getBounds(). You can prevent recalculation on static objects by setting the\n\t * bounds explicitly. *\\/\n\t * let bounds = obj.getBounds();\n\t * obj.setBounds(bounds.x, bounds.y, bounds.width, bounds.height);\n\t * // getBounds will now use the set values, instead of recalculating\n\t *\n\t * @example\n\t * // To reduce memory impact, the returned Rectangle instance may be reused internally\n\t * let bounds = obj.getBounds().clone();\n\t * // OR:\n\t * rect.copy(obj.getBounds());\n\t *\n\t * @return {easeljs.Rectangle} A Rectangle instance representing the bounds, or null if bounds are not available for this object.\n\t */\n\tgetBounds () {\n\t\tif (this._bounds) { return this._rectangle.copy(this._bounds); }\n\t\tlet cacheCanvas = this.cacheCanvas;\n\t\tif (cacheCanvas) {\n\t\t\tlet scale = this._cacheScale;\n\t\t\treturn this._rectangle.setValues(this._cacheOffsetX, this._cacheOffsetY, cacheCanvas.width/scale, cacheCanvas.height/scale);\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**\n\t * Returns a rectangle representing this object's bounds in its parent's coordinate system (ie. with transformations applied).\n\t * Objects that have been cached will return the transformed bounds of the cache.\n\t *\n\t * Not all display objects can calculate their own bounds (ex. Shape). For these objects, you can use\n\t * {@link easeljs.DisplayObject#setBounds} so that they are included when calculating Container bounds.\n\t *\n\t * To reduce memory impact, the returned Rectangle instance may be reused internally; clone the instance or copy its\n\t * values if you need to retain it.\n\t *\n\t * Container instances calculate aggregate bounds for all children that return bounds via getBounds.\n\t * @return {easeljs.Rectangle} A Rectangle instance representing the bounds, or null if bounds are not available for this object.\n\t */\n\tgetTransformedBounds () {\n\t\treturn this._getBounds();\n\t}\n\n\t/**\n\t * Allows you to manually specify the bounds of an object that either cannot calculate their own bounds (ex. Shape &\n\t * Text) for future reference, or so the object can be included in Container bounds. Manually set bounds will always\n\t * override calculated bounds.\n\t *\n\t * The bounds should be specified in the object's local (untransformed) coordinates. For example, a Shape instance\n\t * with a 25px radius circle centered at 0,0 would have bounds of (-25, -25, 50, 50).\n\t *\n\t * @param {Number} x The x origin of the bounds. Pass null to remove the manual bounds.\n\t * @param {Number} y The y origin of the bounds.\n\t * @param {Number} width The width of the bounds.\n\t * @param {Number} height The height of the bounds.\n\t */\n\tsetBounds (x, y, width, height) {\n\t\tif (x == null) { this._bounds = null; }\n\t\tthis._bounds = (this._bounds || new Rectangle()).setValues(x, y, width, height);\n\t}\n\n\t/**\n\t * Returns a clone of this DisplayObject. Some properties that are specific to this instance's current context are\n\t * reverted to their defaults (for example .parent). Caches are not maintained across clones, and some elements\n\t * are copied by reference (masks, individual filter instances, hit area)\n\t *\n\t * @return {easeljs.DisplayObject} A clone of the current DisplayObject instance.\n\t */\n\tclone () {\n\t\treturn this._cloneProps(new DisplayObject());\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name}${this.name ? ` (name=${this.name})` : \"\"}]`;\n\t}\n\n\t/**\n\t * @protected\n\t * @param {easeljs.DisplayObject} o The DisplayObject instance which will have properties from the current DisplayObject\n\t * instance copied into.\n\t * @return {easeljs.DisplayObject} o\n\t */\n\t_cloneProps (o) {\n\t\to.alpha = this.alpha;\n\t\to.mouseEnabled = this.mouseEnabled;\n\t\to.tickEnabled = this.tickEnabled;\n\t\to.name = this.name;\n\t\to.regX = this.regX;\n\t\to.regY = this.regY;\n\t\to.rotation = this.rotation;\n\t\to.scaleX = this.scaleX;\n\t\to.scaleY = this.scaleY;\n\t\to.shadow = this.shadow;\n\t\to.skewX = this.skewX;\n\t\to.skewY = this.skewY;\n\t\to.visible = this.visible;\n\t\to.x = this.x;\n\t\to.y = this.y;\n\t\to.compositeOperation = this.compositeOperation;\n\t\to.snapToPixel = this.snapToPixel;\n\t\to.filters = this.filters==null?null:this.filters.slice(0);\n\t\to.mask = this.mask;\n\t\to.hitArea = this.hitArea;\n\t\to.cursor = this.cursor;\n\t\to._bounds = this._bounds;\n\t\treturn o;\n\t}\n\n\t/**\n\t * @protected\n\t * @param {CanvasRenderingContext2D} ctx\n\t * @param {easeljs.Shadow} [shadow=Shadow]\n\t */\n\t_applyShadow (ctx, shadow = Shadow.identity) {\n\t\tshadow = shadow;\n\t\tctx.shadowColor = shadow.color;\n\t\tctx.shadowOffsetX = shadow.offsetX;\n\t\tctx.shadowOffsetY = shadow.offsetY;\n\t\tctx.shadowBlur = shadow.blur;\n\t}\n\n\t/**\n\t * @protected\n\t * @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.\n\t */\n\t_tick (evtObj) {\n\t\t// because tick can be really performance sensitive, check for listeners before calling dispatchEvent.\n\t\tlet ls = this._listeners;\n\t\tif (ls && ls[\"tick\"]) {\n\t\t\t// reset & reuse the event object to avoid construction / GC costs:\n\t\t\tevtObj.target = null;\n\t\t\tevtObj.propagationStopped = evtObj.immediatePropagationStopped = false;\n\t\t\tthis.dispatchEvent(evtObj);\n\t\t}\n\t}\n\n\t/**\n\t * @protected\n\t * @param {CanvasRenderingContext2D} ctx\n\t * @return {Boolean}\n\t */\n\t_testHit (ctx) {\n\t\ttry {\n\t\t\treturn ctx.getImageData(0, 0, 1, 1).data[3] > 1;\n\t\t} catch (e) {\n\t\t\tif (!DisplayObject.suppressCrossDomainErrors) {\n\t\t\t\tthrow \"An error has occurred. This is most likely due to security restrictions on reading canvas pixel data with local or cross-domain images.\";\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * @protected\n\t * @param {easeljs.Matrix2D} matrix\n\t * @param {Boolean} ignoreTransform If true, does not apply this object's transform.\n\t * @return {easeljs.Rectangle}\n\t */\n\t_getBounds (matrix, ignoreTransform) {\n\t\treturn this._transformBounds(this.getBounds(), matrix, ignoreTransform);\n\t}\n\n\t/**\n\t * @protected\n\t * @param {easeljs.Rectangle} bounds\n\t * @param {easeljs.Matrix2D} matrix\n\t * @param {Boolean} ignoreTransform\n\t * @return {easeljs.Rectangle}\n\t */\n\t_transformBounds (bounds, matrix, ignoreTransform) {\n\t\tif (!bounds) { return bounds; }\n\t\tlet { x, y, width, height } = bounds;\n\t\tlet mtx = this._props.matrix;\n\t\tmtx = ignoreTransform ? mtx.identity() : this.getMatrix(mtx);\n\n\t\tif (x || y) { mtx.appendTransform(0,0,1,1,0,0,0,-x,-y); } // TODO: simplify this.\n\t\tif (matrix) { mtx.prependMatrix(matrix); }\n\n\t\tlet x_a = width*mtx.a, x_b = width*mtx.b;\n\t\tlet y_c = height*mtx.c, y_d = height*mtx.d;\n\t\tlet tx = mtx.tx, ty = mtx.ty;\n\n\t\tlet minX = tx, maxX = tx, minY = ty, maxY = ty;\n\n\t\tif ((x = x_a + tx) < minX) { minX = x; } else if (x > maxX) { maxX = x; }\n\t\tif ((x = x_a + y_c + tx) < minX) { minX = x; } else if (x > maxX) { maxX = x; }\n\t\tif ((x = y_c + tx) < minX) { minX = x; } else if (x > maxX) { maxX = x; }\n\n\t\tif ((y = x_b + ty) < minY) { minY = y; } else if (y > maxY) { maxY = y; }\n\t\tif ((y = x_b + y_d + ty) < minY) { minY = y; } else if (y > maxY) { maxY = y; }\n\t\tif ((y = y_d + ty) < minY) { minY = y; } else if (y > maxY) { maxY = y; }\n\n\t\treturn bounds.setValues(minX, minY, maxX-minX, maxY-minY);\n\t}\n\n\t/**\n\t * Indicates whether the display object has any mouse event listeners or a cursor.\n\t * @protected\n\t * @return {Boolean}\n\t */\n\t_hasMouseEventListener () {\n\t\tlet evts = DisplayObject._MOUSE_EVENTS;\n\t\tfor (let i=0, l=evts.length; i}\n * @readonly\n */\nDisplayObject._MOUSE_EVENTS = [\"click\",\"dblclick\",\"mousedown\",\"mouseout\",\"mouseover\",\"pressmove\",\"pressup\",\"rollout\",\"rollover\"];\n\n/**\n * Suppresses errors generated when using features like hitTest, mouse events, and {{#crossLink \"getObjectsUnderPoint\"}}{{/crossLink}}\n * with cross domain content.\n * @static\n * @type {Boolean}\n * @default false\n */\nDisplayObject.suppressCrossDomainErrors = false;\n\n/**\n * @static\n * @type {Boolean}\n * @default false\n */\nDisplayObject.snapToPixelEnabled = false;\n\n/**\n * Enum like property for determining StageGL render lookup, i.e. where to expect properties.\n * @static\n * @type {Number}\n */\nDisplayObject._StageGL_NONE = 0;\n\n/**\n * Enum like property for determining StageGL render lookup, i.e. where to expect properties.\n * @static\n * @type {Number}\n */\nDisplayObject._StageGL_SPRITE = 1;\n\n/**\n * Enum like property for determining StageGL render lookup, i.e. where to expect properties.\n * @static\n * @type {Number}\n */\nDisplayObject._StageGL_BITMAP = 2;\n\n/**\n * Dispatched when the user presses their left mouse button over the display object.\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.DisplayObject#mousedown\n * @since 0.6.0\n */\n\n/**\n * Dispatched when the user presses their left mouse button and then releases it while over the display object.\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.DisplayObject#click\n * @since 0.6.0\n */\n\n/**\n * Dispatched when the user double clicks their left mouse button over this display object.\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.DisplayObject#dblclick\n * @since 0.6.0\n */\n\n/**\n * Dispatched when the user's mouse enters this display object. This event must be enabled using\n * {@link easeljs.Stage#enableMouseOver}.\n * @see {@link easeljs.DisplayObject#event:rollover}\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.DisplayObject#mouseover\n * @since 0.6.0\n */\n\n/**\n * Dispatched when the user's mouse leaves this display object. This event must be enabled using\n * {@link easeljs.Stage#enableMouseOver}.\n * @see {@link easeljs.DisplayObject#event:rollout}\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.DisplayObject#mouseout\n * @since 0.6.0\n */\n\n/**\n * This event is similar to {@link easeljs.DisplayObject#event:mouseover}, with the following\n * differences: it does not bubble, and it considers {@link easeljs.Container} instances as an\n * aggregate of their content.\n *\n * For example, myContainer contains two overlapping children: shapeA and shapeB. The user moves their mouse over\n * shapeA and then directly on to shapeB. With a listener for {@link easeljs.DisplayObject#event:mouseover} on\n * myContainer, two events would be received, each targeting a child element:\n * \n *
when the mouse enters shapeA (target=shapeA)
\n *
when the mouse enters shapeB (target=shapeB)
\n * \n * However, with a listener for \"rollover\" instead, only a single event is received when the mouse first enters\n * the aggregate myContainer content (target=myContainer).\n *\n * This event must be enabled using {@link easeljs.Stage#enableMouseOver}.\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.DisplayObject#rollover\n * @since 0.7.0\n */\n\n/**\n * This event is similar to {@link easeljs.DisplayObject#event:mouseout}, with the following\n * differences: it does not bubble, and it considers {@link easeljs.Container} instances as an\n * aggregate of their content.\n *\n * For example, myContainer contains two overlapping children: shapeA and shapeB. The user moves their mouse over\n * shapeA, then directly on to shapeB, then off both. With a listener for {@link easeljs.DisplayObject#event:mouseout}\n * on myContainer, two events would be received, each targeting a child element:\n *
when the mouse leaves shapeA (target=shapeA)
\n *
when the mouse leaves shapeB (target=shapeB)
\n * \n * However, with a listener for \"rollout\" instead, only a single event is received when the mouse leaves\n * the aggregate myContainer content (target=myContainer).\n *\n * This event must be enabled using {@link easeljs.Stage#enableMouseOver}.\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.DisplayObject#rollout\n * @since 0.7.0\n */\n\n/**\n * After a {@link easeljs.DisplayObject#event:mousedown} occurs on a display object, a pressmove\n * event will be generated on that object whenever the mouse moves until the mouse press is released. This can be\n * useful for dragging and similar operations.\n * @event easeljs.DisplayObject#pressmove\n * @since 0.7.0\n */\n\n/**\n * After a {@link easeljs.DisplayObject#event:mousedown} occurs on a display object, a pressup event\n * will be generated on that object when that mouse press is released. This can be useful for dragging and similar\n * operations.\n * @event easeljs.DisplayObject#pressup\n * @since 0.7.0\n */\n\n/**\n * Dispatched when the display object is added to a parent container.\n * @event easeljs.DisplayObject#added\n */\n\n/**\n * Dispatched when the display object is removed from its parent container.\n * @event easeljs.DisplayObject#removed\n */\n\n/**\n * Dispatched on each display object on a stage whenever the stage updates. This occurs immediately before the\n * rendering (draw) pass. When {@link easeljs.Stage#update} is called, first all display objects on\n * the stage dispatch the tick event, then all of the display objects are drawn to stage. Children will have their\n * tick event dispatched in order of their depth prior to the event being dispatched on their parent.\n * @event easeljs.DisplayObject#tick\n * @param {Object} target The object that dispatched the event.\n * @param {String} type The event type.\n * @param {Array} params An array containing any arguments that were passed to the Stage.update() method.\n * @since 0.6.0\n */\n","/**\n * @license Container\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport DisplayObject from \"./DisplayObject\";\n\n/**\n * A Container is a nestable display list that allows you to work with compound display elements. For example you could\n * group arm, leg, torso and head {{#crossLink \"Bitmap\"}}{{/crossLink}} instances together into a Person Container, and\n * transform them as a group, while still being able to move the individual parts relative to each other. Children of\n * containers have their `transform` and `alpha` properties concatenated with their parent\n * Container.\n *\n * For example, a {{#crossLink \"Shape\"}}{{/crossLink}} with x=100 and alpha=0.5, placed in a Container with `x=50`\n * and `alpha=0.7` will be rendered to the canvas at `x=150` and `alpha=0.35`.\n * Containers have some overhead, so you generally shouldn't create a Container to hold a single child.\n *\n * @memberof easeljs\n * @extends easeljs.DisplayObject\n * @example\n * import { Container } from \"@createjs/easeljs\";\n * const container = new Container();\n * container.addChild(bitmapInstance, shapeInstance);\n * container.x = 100;\n */\nexport default class Container extends DisplayObject {\n\n\tconstructor () {\n\t\tsuper();\n\n\t\t/**\n\t\t * The array of children in the display list. You should usually use the child management methods such as\n\t\t * {@link easeljs.Container#addChild}, {@link easeljs.Container#removeChild}, {@link easeljs.Container#swapChildren},\n\t\t * etc, rather than accessing this directly, but it is included for advanced uses.\n\t\t * @type {Array}\n\t\t * @default []\n\t\t */\n\t\tthis.children = [];\n\n\t\t/**\n\t\t * Indicates whether the children of this container are independently enabled for mouse/pointer interaction.\n\t\t * If false, the children will be aggregated under the container - for example, a click on a child shape would\n\t\t * trigger a click event on the container.\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.mouseChildren = true;\n\n\t\t/**\n\t\t * If false, the tick will not be propagated to children of this Container. This can provide some performance benefits.\n\t\t * In addition to preventing the {@link core.Ticker#event:tick} event from being dispatched, it will also prevent tick related updates\n\t\t * on some display objects (ex. Sprite & MovieClip frame advancing, DOMElement visibility handling).\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.tickChildren = true;\n\t}\n\n\t/**\n\t * Returns the number of children in the container.\n\t * @type {Number}\n\t * @readonly\n\t */\n\tget numChildren () {\n\t\treturn this.children.length;\n\t}\n\n\tisVisible () {\n\t\tlet hasContent = this.cacheCanvas || this.children.length;\n\t\treturn !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && hasContent);\n\t}\n\n\tdraw (ctx, ignoreCache = false) {\n\t\tif (super.draw(ctx, ignoreCache)) { return true; }\n\n\t\t// this ensures we don't have issues with display list changes that occur during a draw:\n\t\tlet list = this.children.slice();\n\t\tfor (let i=0,l=list.length; i 1) {\n\t\t\tfor (let i = 0; i < l; i++) { child = this.addChild(children[i]); }\n\t\t\treturn child;\n\t\t}\n // Note: a lot of duplication with addChildAt, but push is WAY faster than splice.\n let parent = child.parent, silent = parent === this;\n parent && parent._removeChildAt(parent.children.indexOf(child), silent);\n\t\tchild.parent = this;\n\t\tthis.children.push(child);\n if (!silent) { child.dispatchEvent(\"added\"); }\n\t\treturn child;\n\t}\n\n\t/**\n\t * Adds a child to the display list at the specified index, bumping children at equal or greater indexes up one, and\n\t * setting its parent to this container.\n\t *\n\t * @example\n\t * container.addChildAt(child1, index);\n\t * // You can also add multiple children, such as:\n\t * container.addChildAt(child1, child2, ..., index);\n\t * // The index must be between 0 and numChildren. For example, to add myShape under otherShape in the display list, you could use:\n\t * container.addChildAt(myShape, container.getChildIndex(otherShape));\n\t * // This would also bump otherShape's index up by one. Fails silently if the index is out of range.\n\t *\n\t * @param {...easeljs.DisplayObject} children The display object(s) to add.\n\t * @param {Number} index The index to add the child at.\n\t * @return {easeljs.DisplayObject} Returns the last child that was added, or the last child if multiple children were added.\n\t */\n\taddChildAt (...children) {\n\t\tconst l = children.length;\n if (l === 0) { return null; }\n let index = children.pop();\n\t\tif (index < 0 || index > this.children.length) { return children[l - 2]; }\n\t\tif (l > 2) {\n\t\t\tfor (let i = 0; i < l - 1; i++) { this.addChildAt(children[i], index++); }\n\t\t\treturn children[l - 2];\n\t\t}\n\t\tlet child = children[0];\n let parent = child.parent, silent = parent === this;\n parent && parent._removeChildAt(parent.children.indexOf(child), silent);\n\t\tchild.parent = this;\n\t\tthis.children.splice(index++, 0, child);\n if (!silent) { child.dispatchEvent(\"added\"); }\n\t\treturn child;\n\t}\n\n\t/**\n\t * Removes the specified child from the display list. Note that it is faster to use removeChildAt() if the index is\n\t * already known.\n\t *\n\t * @example\n\t * container.removeChild(child);\n\t * // You can also remove multiple children:\n\t * container.removeChild(child1, child2, ...);\n\t *\n\t * @param {...easeljs.DisplayObject} children The display object(s) to remove.\n\t * @return {Boolean} true if the child (or children) was removed, or false if it was not in the display list.\n\t */\n\tremoveChild (...children) {\n\t\tconst l = children.length;\n if (l === 0) { return true; }\n\t\tif (l > 1) {\n\t\t\tlet good = true;\n\t\t\tfor (let i = 0; i < l; i++) { good = good && this.removeChild(children[i]); }\n\t\t\treturn good;\n\t\t}\n\t\treturn this._removeChildAt(this.children.indexOf(children[0]));\n\t}\n\n\t/**\n\t * Removes the child at the specified index from the display list, and sets its parent to null.\n\t *\n\t * @example\n\t * container.removeChildAt(2);\n\t * // You can also remove multiple children:\n\t * container.removeChildAt(2, 7, ...)\n\t *\n\t * @param {...Number} indexes The indexes of children to remove.\n\t * @return {Boolean} true if the child (or children) was removed, or false if any index was out of range.\n\t */\n\tremoveChildAt (...indexes) {\n\t\tconst l = indexes.length;\n if (l === 0) { return true; }\n\t\tif (l > 1) {\n\t\t\tindexes.sort((a, b) => b - a);\n\t\t\tlet good = true;\n\t\t\tfor (let i = 0; i < l; i++) { good = good && this._removeChildAt(indexes[i]); }\n\t\t\treturn good;\n\t\t}\n\t\treturn this._removeChildAt(indexes[0]);\n\t}\n\n\t/**\n\t * Removes all children from the display list.\n\t */\n\tremoveAllChildren () {\n\t\tlet kids = this.children;\n\t\twhile (kids.length) { this._removeChildAt(0); }\n\t}\n\n\t/**\n\t * Returns the child at the specified index.\n\t * @param {Number} index The index of the child to return.\n\t * @return {easeljs.DisplayObject} The child at the specified index. Returns null if there is no child at the index.\n\t */\n\tgetChildAt (index) {\n\t\treturn this.children[index];\n\t}\n\n\t/**\n\t * Returns the child with the specified name.\n\t * @param {String} name The name of the child to return.\n\t * @return {easeljs.DisplayObject} The child with the specified name.\n\t */\n\tgetChildByName (name) {\n\t\tlet kids = this.children;\n\t\tconst l = kids.length;\n\t\tfor (let i = 0; i < l; i++) {\n\t\t\tif (kids[i].name === name) { return kids[i]; }\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**\n\t * Performs an array sort operation on the child list.\n\t *\n\t * @example\n\t * // Display children with a higher y in front.\n\t * container.sortChildren((obj1, obj2, options) => {\n\t * \t if (obj1.y > obj2.y) { return 1; }\n\t * if (obj1.y < obj2.y) { return -1; }\n\t * return 0;\n\t * });\n\t *\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort}\n\t * @param {Function} sortFunction the function to use to sort the child list.\n\t */\n\tsortChildren (sortFunction) {\n\t\tthis.children.sort(sortFunction);\n\t}\n\n\t/**\n\t * Returns the index of the specified child in the display list, or -1 if it is not in the display list.\n\t * @param {easeljs.DisplayObject} child The child to return the index of.\n\t * @return {Number} The index of the specified child. -1 if the child is not found.\n\t */\n\tgetChildIndex (child) {\n\t\treturn this.children.indexOf(child);\n\t}\n\n\t/**\n\t * Swaps the children at the specified indexes. Fails silently if either index is out of range.\n\t * @param {Number} index1\n\t * @param {Number} index2\n\t */\n\tswapChildrenAt (index1, index2) {\n\t\tlet kids = this.children;\n\t\tlet o1 = kids[index1];\n\t\tlet o2 = kids[index2];\n\t\tif (!o1 || !o2) { return; }\n\t\tkids[index1] = o2;\n\t\tkids[index2] = o1;\n\t};\n\n\t/**\n\t * Swaps the specified children's depth in the display list. Fails silently if either child is not a child of this\n\t * Container.\n\t * @param {easeljs.DisplayObject} child1\n\t * @param {easeljs.DisplayObject} child2\n\t */\n\tswapChildren (child1, child2) {\n\t\tlet kids = this.children;\n\t\tconst l = kids.length;\n\t\tlet index1,index2;\n\t\tfor (var i = 0; i < l; i++) {\n\t\t\tif (kids[i] === child1) { index1 = i; }\n\t\t\tif (kids[i] === child2) { index2 = i; }\n\t\t\tif (index1 != null && index2 != null) { break; }\n\t\t}\n\t\tif (i === l) { return; } // TODO: throw error?\n\t\tkids[index1] = child2;\n\t\tkids[index2] = child1;\n\t}\n\n\t/**\n\t * Changes the depth of the specified child. Fails silently if the child is not a child of this container, or the index is out of range.\n\t * @param {easeljs.DisplayObject} child\n\t * @param {Number} index\n\t */\n\tsetChildIndex (child, index) {\n\t\tlet kids = this.children;\n\t\tconst l = kids.length;\n\t\tif (child.parent != this || index < 0 || index >= l) { return; }\n\t\tfor (var i = 0; i < l; i++) {\n\t\t\tif (kids[i] === child) { break; }\n\t\t}\n\t\tif (i === l || i === index) { return; }\n\t\tkids.splice(i, 1);\n\t\tkids.splice(index, 0, child);\n\t}\n\n\t/**\n\t * Returns true if the specified display object either is this container or is a descendent (child, grandchild, etc)\n\t * of this container.\n\t * @param {easeljs.DisplayObject} child The DisplayObject to be checked.\n\t * @return {Boolean} true if the specified display object either is this container or is a descendent.\n\t */\n\tcontains (child) {\n\t\twhile (child) {\n\t\t\tif (child === this) { return true; }\n\t\t\tchild = child.parent;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Tests whether the display object intersects the specified local point (ie. draws a pixel with alpha > 0 at the\n\t * specified position). This ignores the alpha, shadow and compositeOperation of the display object, and all\n\t * transform properties including regX/Y.\n\t * @param {Number} x The x position to check in the display object's local coordinates.\n\t * @param {Number} y The y position to check in the display object's local coordinates.\n\t * @return {Boolean} A Boolean indicating whether there is a visible section of a DisplayObject that overlaps the specified\n\t * coordinates.\n\t */\n\thitTest (x, y) {\n\t\t// TODO: optimize to use the fast cache check where possible.\n\t\treturn this.getObjectUnderPoint(x, y) != null;\n\t}\n\n\t/**\n\t * Returns an array of all display objects under the specified coordinates that are in this container's display\n\t * list. This routine ignores any display objects with {@link easeljs.DisplayObject#mouseEnabled} set to `false`.\n\t * The array will be sorted in order of visual depth, with the top-most display object at index 0.\n\t * This uses shape based hit detection, and can be an expensive operation to run, so it is best to use it carefully.\n\t * For example, if testing for objects under the mouse, test on tick (instead of on {@link easeljs.DisplayObject#event:mousemove}),\n\t * and only if the mouse's position has changed.\n\t *\n\t *
\n\t *
By default (mode=0) this method evaluates all display objects.
\n\t *
By setting the `mode` parameter to `1`, the {@link easeljs.DisplayObject#mouseEnabled}\n\t * and {@link easeljs.DisplayObject#mouseChildren} properties will be respected.
\n\t *
Setting the `mode` to `2` additionally excludes display objects that do not have active mouse event\n\t * listeners or a {@link easeljs.DisplayObject#cursor} property. That is, only objects\n\t * that would normally intercept mouse interaction will be included. This can significantly improve performance\n\t * in some cases by reducing the number of display objects that need to be tested.
\n\t *
\n\t *\n\t * This method accounts for both {@link easeljs.DisplayObject#hitArea} and {@link easeljs.DisplayObject#mask}.\n\t *\n\t * @param {Number} x The x position in the container to test.\n\t * @param {Number} y The y position in the container to test.\n\t * @param {Number} [mode=0] The mode to use to determine which display objects to include. 0-all, 1-respect mouseEnabled/mouseChildren, 2-only mouse opaque objects.\n\t * @return {Array} An array of DisplayObjects under the specified coordinates.\n\t */\n\tgetObjectsUnderPoint (x, y, mode = 0) {\n\t\tlet arr = [];\n\t\tlet pt = this.localToGlobal(x, y);\n\t\tthis._getObjectsUnderPoint(pt.x, pt.y, arr, mode > 0, mode === 1);\n\t\treturn arr;\n\t}\n\n\t/**\n\t * Similar to {@link easeljs.Container#getObjectsUnderPoint}, but returns only the top-most display\n\t * object. This runs significantly faster than `getObjectsUnderPoint()`, but is still potentially an expensive\n\t * operation.\n\t *\n\t * @param {Number} x The x position in the container to test.\n\t * @param {Number} y The y position in the container to test.\n\t * @param {Number} [mode=0] The mode to use to determine which display objects to include. 0-all, 1-respect mouseEnabled/mouseChildren, 2-only mouse opaque objects.\n\t * @return {easeljs.DisplayObject} The top-most display object under the specified coordinates.\n\t */\n\tgetObjectUnderPoint (x, y, mode = 0) {\n\t\tlet pt = this.localToGlobal(x, y);\n\t\treturn this._getObjectsUnderPoint(pt.x, pt.y, null, mode > 0, mode === 1);\n\t}\n\n\tgetBounds () {\n\t\treturn this._getBounds(null, true);\n\t}\n\n\tgetTransformedBounds () {\n\t\treturn this._getBounds();\n\t}\n\n\t/**\n\t * Returns a clone of this Container. Some properties that are specific to this instance's current context are\n\t * reverted to their defaults (for example `.parent`).\n\t * @param {Boolean} [recursive=false] If true, all of the descendants of this container will be cloned recursively. If false, the\n\t * properties of the container will be cloned, but the new instance will not have any children.\n\t * @return {easeljs.Container} A clone of the current Container instance.\n\t */\n\tclone (recursive = false) {\n\t\tlet o = this._cloneProps(new Container());\n\t\tif (recursive) { this._cloneChildren(o); }\n\t\treturn o;\n\t}\n\n\t_tick (evtObj) {\n\t\tif (this.tickChildren) {\n\t\t\tfor (let i = this.children.length - 1; i >= 0; i--) {\n\t\t\t\tlet child = this.children[i];\n\t\t\t\tif (child.tickEnabled && child._tick) { child._tick(evtObj); }\n\t\t\t}\n\t\t}\n\t\tsuper._tick(evtObj);\n\t}\n\n\t/**\n\t * Recursively clones all children of this container, and adds them to the target container.\n\t * @protected\n\t * @param {easeljs.Container} o The target container.\n\t */\n\t_cloneChildren (o) {\n\t\tif (o.children.length) { o.removeAllChildren(); }\n\t\tlet arr = o.children;\n\t\tconst l = this.children.length;\n\t\tfor (let i = 0; i < l; i++) {\n\t\t\tlet clone = this.children[i].clone(true);\n\t\t\tclone.parent = o;\n\t\t\tarr.push(clone);\n\t\t}\n\t}\n\n /**\n * Removes the child at the specified index from the display list, and sets its parent to null.\n * Used by `removeChildAt`, `addChild`, and `addChildAt`.\n *\n * @protected\n * @param {Number} index The index of the child to remove.\n * @param {Boolean} [silent=false] Prevents dispatch of `removed` event if true.\n * @return {Boolean} true if the child (or children) was removed, or false if any index was out of range.\n */\n _removeChildAt (index, silent = false) {\n\t\tif (index < 0 || index > this.children.length - 1) { return false; }\n\t\tlet child = this.children[index];\n\t\tif (child) { child.parent = null; }\n\t\tthis.children.splice(index, 1);\n\t\tif (!silent) { child.dispatchEvent(\"removed\"); }\n\t\treturn true;\n }\n\n\t/**\n\t * @protected\n\t * @param {Number} x\n\t * @param {Number} y\n\t * @param {Array} arr\n\t * @param {Boolean} mouse If true, it will respect mouse interaction properties like mouseEnabled, mouseChildren, and active listeners.\n\t * @param {Boolean} activeListener If true, there is an active mouse event listener on a parent object.\n\t * @param {Number} [currentDepth=0] Indicates the current depth of the search.\n\t * @return {easeljs.DisplayObject}\n\t */\n\t_getObjectsUnderPoint (x, y, arr, mouse, activeListener, currentDepth = 0) {\n\t\tif (!currentDepth && !this._testMask(this, x, y)) { return null; }\n\t\tlet mtx, ctx = DisplayObject._hitTestContext;\n\t\tactiveListener = activeListener || (mouse && this._hasMouseEventListener());\n\n\t\t// draw children one at a time, and check if we get a hit:\n\t\tlet children = this.children;\n\t\tconst l = children.length;\n\t\tfor (let i = l - 1; i >= 0; i--) {\n\t\t\tlet child = children[i];\n\t\t\tlet hitArea = child.hitArea;\n\t\t\tif (!child.visible || (!hitArea && !child.isVisible()) || (mouse && !child.mouseEnabled)) { continue; }\n\t\t\tif (!hitArea && !this._testMask(child, x, y)) { continue; }\n\n\t\t\t// if a child container has a hitArea then we only need to check its hitArea, so we can treat it as a normal DO:\n\t\t\tif (!hitArea && child instanceof Container) {\n\t\t\t\tlet result = child._getObjectsUnderPoint(x, y, arr, mouse, activeListener, currentDepth + 1);\n\t\t\t\tif (!arr && result) { return (mouse && !this.mouseChildren) ? this : result; }\n\t\t\t} else {\n\t\t\t\tif (mouse && !activeListener && !child._hasMouseEventListener()) { continue; }\n\n\t\t\t\t// TODO: can we pass displayProps forward, to avoid having to calculate this backwards every time? It's kind of a mixed bag. When we're only hunting for DOs with event listeners, it may not make sense.\n\t\t\t\tlet props = child.getConcatenatedDisplayProps(child._props);\n\t\t\t\tmtx = props.matrix;\n\n\t\t\t\tif (hitArea) {\n\t\t\t\t\tmtx.appendMatrix(hitArea.getMatrix(hitArea._props.matrix));\n\t\t\t\t\tprops.alpha = hitArea.alpha;\n\t\t\t\t}\n\n\t\t\t\tctx.globalAlpha = props.alpha;\n\t\t\t\tctx.setTransform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx-x, mtx.ty-y);\n\t\t\t\t(hitArea || child).draw(ctx);\n\t\t\t\tif (!this._testHit(ctx)) { continue; }\n\t\t\t\tctx.setTransform(1, 0, 0, 1, 0, 0);\n\t\t\t\tctx.clearRect(0, 0, 2, 2);\n\t\t\t\tif (arr) { arr.push(child); }\n\t\t\t\telse { return (mouse && !this.mouseChildren) ? this : child; }\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**\n\t * @protected\n\t * @param {easeljs.DisplayObject} target\n\t * @param {Number} x\n\t * @param {Number} y\n\t * @return {Boolean} Indicates whether the x/y is within the masked region.\n\t */\n\t_testMask (target, x, y) {\n\t\tlet mask = target.mask;\n\t\tif (!mask || !mask.graphics || mask.graphics.isEmpty()) { return true; }\n\n\t\tlet mtx = this._props.matrix, parent = target.parent;\n\t\tmtx = parent ? parent.getConcatenatedMatrix(mtx) : mtx.identity();\n\t\tmtx = mask.getMatrix(mask._props.matrix).prependMatrix(mtx);\n\n\t\tlet ctx = DisplayObject._hitTestContext;\n\t\tctx.setTransform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx-x, mtx.ty-y);\n\n\t\t// draw the mask as a solid fill:\n\t\tmask.graphics.drawAsPath(ctx);\n\t\tctx.fillStyle = \"#000\";\n\t\tctx.fill();\n\n\t\tif (!this._testHit(ctx)) { return false; }\n\t\tctx.setTransform(1, 0, 0, 1, 0, 0);\n\t\tctx.clearRect(0, 0, 2, 2);\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * @protected\n\t * @param {easeljs.Matrix2D} matrix\n\t * @param {Boolean} ignoreTransform If true, does not apply this object's transform.\n\t * @return {easeljs.Rectangle}\n\t */\n\t_getBounds (matrix, ignoreTransform) {\n\t\tlet bounds = super.getBounds();\n\t\tif (bounds) { return this._transformBounds(bounds, matrix, ignoreTransform); }\n\n\t\tlet mtx = this._props.matrix;\n\t\tmtx = ignoreTransform ? mtx.identity() : this.getMatrix(mtx);\n\t\tif (matrix) { mtx.prependMatrix(matrix); }\n\n\t\tconst l = this.children.length;\n\t\tlet rect = null;\n\t\tfor (let i = 0; i < l; i++) {\n\t\t\tlet child = this.children[i];\n\t\t\tif (!child.visible || !(bounds = child._getBounds(mtx))) { continue; }\n\t\t\tif (rect) { rect.extend(bounds.x, bounds.y, bounds.width, bounds.height); }\n\t\t\telse { rect = bounds.clone(); }\n\t\t}\n\t\treturn rect;\n\t}\n\n}\n","/**\n * @license MouseEvent\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport { Event } from \"@createjs/core\";\n\n/**\n * Passed as the parameter to all mouse/pointer/touch related events. For a listing of mouse events and their properties,\n * see the {@link easeljs.DisplayObject} and {@link easeljs.Stage} event listings.\n * @memberof easeljs\n * @extends core.Event\n * @param {String} type The event type.\n * @param {Boolean} bubbles Indicates whether the event will bubble through the display list.\n * @param {Boolean} cancelable Indicates whether the default behaviour of this event can be cancelled.\n * @param {Number} stageX The normalized x position relative to the stage.\n * @param {Number} stageY The normalized y position relative to the stage.\n * @param {easeljs.MouseEvent} nativeEvent The native DOM event related to this mouse event.\n * @param {Number} pointerID The unique id for the pointer.\n * @param {Boolean} primary Indicates whether this is the primary pointer in a multitouch environment.\n * @param {Number} rawX The raw x position relative to the stage.\n * @param {Number} rawY The raw y position relative to the stage.\n * @param {easeljs.DisplayObject} relatedTarget The secondary target for the event.\n */\nexport default class MouseEvent extends Event {\n\n\tconstructor (type, bubbles, cancelable, stageX, stageY, nativeEvent, pointerID, primary, rawX, rawY, relatedTarget) {\n\t\tsuper(type, bubbles, cancelable);\n\n// public properties:\n\t\t/**\n\t\t * The normalized x position on the stage. This will always be within the range 0 to stage width.\n\t\t * @type {Number}\n\t\t*/\n\t\tthis.stageX = stageX;\n\n\t\t/**\n\t\t * The normalized y position on the stage. This will always be within the range 0 to stage height.\n\t\t * @type {Number}\n\t\t */\n\t\tthis.stageY = stageY;\n\n\t\t/**\n\t\t * The raw x position relative to the stage. Normally this will be the same as the stageX value, unless\n\t\t * stage.mouseMoveOutside is true and the pointer is outside of the stage bounds.\n\t\t * @type {Number}\n\t\t*/\n\t\tthis.rawX = (rawX==null)?stageX:rawX;\n\n\t\t/**\n\t\t * The raw y position relative to the stage. Normally this will be the same as the stageY value, unless\n\t\t * stage.mouseMoveOutside is true and the pointer is outside of the stage bounds.\n\t\t * @type {Number}\n\t\t*/\n\t\tthis.rawY = (rawY==null)?stageY:rawY;\n\n\t\t/**\n\t\t * The native MouseEvent generated by the browser. The properties and API for this\n\t\t * event may differ between browsers. This property will be null if the\n\t\t * EaselJS property was not directly generated from a native MouseEvent.\n\t\t * @type {HTMLMouseEvent}\n\t\t */\n\t\tthis.nativeEvent = nativeEvent;\n\n\t\t/**\n\t\t * The unique id for the pointer (touch point or cursor). This will be either -1 for the mouse, or the system\n\t\t * supplied id value.\n\t\t * @type {Number}\n\t\t */\n\t\tthis.pointerID = pointerID;\n\n\t\t/**\n\t\t * Indicates whether this is the primary pointer in a multitouch environment. This will always be true for the mouse.\n\t\t * For touch pointers, the first pointer in the current stack will be considered the primary pointer.\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis.primary = !!primary;\n\n\t\t/**\n\t\t * The secondary target for the event, if applicable. This is used for mouseout/rollout\n\t\t * events to indicate the object that the mouse entered from, mouseover/rollover for the object the mouse exited,\n\t\t * and stagemousedown/stagemouseup events for the object that was the under the cursor, if any.\n\t\t *\n\t\t * Only valid interaction targets will be returned (ie. objects with mouse listeners or a cursor set).\n\t\t * @type {easeljs.DisplayObject}\n\t\t */\n\t\tthis.relatedTarget = relatedTarget;\n\t}\n\n\t/**\n\t * Returns the x position of the mouse in the local coordinate system of the current target (ie. the dispatcher).\n\t * @type {Number}\n\t * @readonly\n\t */\n\tget localX () {\n\t\treturn this.currentTarget.globalToLocal(this.rawX, this.rawY).x;\n\t}\n\n\t/**\n\t * Returns the y position of the mouse in the local coordinate system of the current target (ie. the dispatcher).\n\t * @type {Number}\n\t * @readonly\n\t */\n\tget localY () {\n\t\treturn this.currentTarget.globalToLocal(this.rawX, this.rawY).y;\n\t}\n\n\t/**\n\t * Indicates whether the event was generated by a touch input (versus a mouse input).\n\t * @type {Boolean}\n\t * @readonly\n\t */\n\tget isTouch () {\n\t\treturn this.pointerID !== -1;\n\t}\n\n\t/**\n\t * Returns a clone of the MouseEvent instance.\n\t * @return {easeljs.MouseEvent} a clone of the MouseEvent instance.\n\t */\n\tclone () {\n\t\treturn new MouseEvent(this.type, this.bubbles, this.cancelable, this.stageX, this.stageY, this.nativeEvent, this.pointerID, this.primary, this.rawX, this.rawY);\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name} (type=${this.type} stageX=${this.stageX} stageY=${this.stageY})]`;\n\t}\n\n}\n","/**\n * @license Stage\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Container from \"./Container\";\nimport DisplayObject from \"./DisplayObject\";\nimport { Event } from \"@createjs/core\";\nimport MouseEvent from \"../events/MouseEvent\";\n\n/**\n * A stage is the root level {@link easeljs.Container} for a display list. Each time its {@link easeljs.Stage#tick}\n * method is called, it will render its display list to its target canvas.\n *\n * @memberof easeljs\n * @extends easeljs.Container\n * @example\n * let stage = new Stage(\"canvasElementId\");\n * let image = new Bitmap(\"imagePath.png\");\n * stage.addChild(image);\n * Ticker.addEventListener(\"tick\", event => {\n * image.x += 10;\n * \t stage.update();\n * });\n *\n * @param {HTMLCanvasElement | String | Object} canvas A canvas object that the Stage will render to, or the string id\n * of a canvas object in the current document.\n */\nexport default class Stage extends Container {\n\n\tconstructor (canvas) {\n\t\tsuper();\n\n\t\t/**\n\t\t * Indicates whether the stage should automatically clear the canvas before each render. You can set this to `false`\n\t\t * to manually control clearing (for generative art, or when pointing multiple stages at the same canvas for\n\t\t * example).\n\t\t *\n\t\t * @example\n\t\t * let stage = new Stage(\"canvasId\");\n\t\t * stage.autoClear = false;\n\t\t *\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.autoClear = true;\n\n\t\t/**\n\t\t * The canvas the stage will render to. Multiple stages can share a single canvas, but you must disable autoClear for all but the\n\t\t * first stage that will be ticked (or they will clear each other's render).\n\t\t *\n\t\t * When changing the canvas property you must disable the events on the old canvas, and enable events on the\n\t\t * new canvas or mouse events will not work as expected.\n\t\t *\n\t\t * @example\n\t\t * stage.enableDOMEvents(false);\n\t\t * stage.canvas = anotherCanvas;\n\t\t * stage.enableDOMEvents(true);\n\t\t *\n\t\t * @type {HTMLCanvasElement | Object}\n\t\t */\n\t\tthis.canvas = (typeof canvas === \"string\") ? document.getElementById(canvas) : canvas;\n\n\t\t/**\n\t\t * The current mouse X position on the canvas. If the mouse leaves the canvas, this will indicate the most recent\n\t\t * position over the canvas, and mouseInBounds will be set to false.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t * @readonly\n\t\t */\n\t\tthis.mouseX = 0;\n\n\t\t/**\n\t\t * The current mouse Y position on the canvas. If the mouse leaves the canvas, this will indicate the most recent\n\t\t * position over the canvas, and mouseInBounds will be set to false.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t * @readonly\n\t\t */\n\t\tthis.mouseY = 0;\n\n\t\t/**\n\t\t * Specifies the area of the stage to affect when calling update. This can be use to selectively\n\t\t * re-draw specific regions of the canvas. If null, the whole canvas area is drawn.\n\t\t * @type {easeljs.Rectangle}\n\t\t */\n\t\tthis.drawRect = null;\n\n\t\t/**\n\t\t * Indicates whether display objects should be rendered on whole pixels. You can set the {@link easeljs.DisplayObject.snapToPixelEnabled}\n\t\t * property of display objects to false to enable/disable this behaviour on a per instance basis.\n\t\t * @type {Boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.snapToPixelEnabled = false;\n\n\t\t/**\n\t\t * Indicates whether the mouse is currently within the bounds of the canvas.\n\t\t * @type {Boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.mouseInBounds = false;\n\n\t\t/**\n\t\t * If true, tick callbacks will be called on all display objects on the stage prior to rendering to the canvas.\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.tickOnUpdate = true;\n\n\t\t/**\n\t\t * If true, mouse move events will continue to be called when the mouse leaves the target canvas.\n\t\t * See {@link easeljs.Stage#mouseInBounds}, and {@link easeljs.MouseEvent} x/y/rawX/rawY.\n\t\t * @type {Boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.mouseMoveOutside = false;\n\n\n\t\t/**\n\t\t * Prevents selection of other elements in the html page if the user clicks and drags, or double clicks on the canvas.\n\t\t * This works by calling `preventDefault()` on any mousedown events (or touch equivalent) originating on the canvas.\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.preventSelection = true;\n\n\t\t/**\n\t\t * The hitArea property is not supported for Stage.\n\t\t * @property hitArea\n\t\t * @override\n\t\t * @default null\n\t\t * @private\n\t\t */\n\n\t\t/**\n\t\t * Holds objects with data for each active pointer id. Each object has the following properties:\n\t\t * x, y, event, target, overTarget, overX, overY, inBounds, posEvtObj (native event that last updated position)\n\t\t * @type {Object}\n\t\t * @private\n\t\t */\n\t\tthis._pointerData = {};\n\n\t\t/**\n\t\t * Number of active pointers.\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._pointerCount = 0;\n\n\t\t/**\n\t\t * The ID of the primary pointer.\n\t\t * @type {String}\n\t\t * @private\n\t\t */\n\t\tthis._primaryPointerID = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._mouseOverIntervalID = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.Stage}\n\t\t */\n\t\tthis._nextStage = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.Stage}\n\t\t */\n\t\tthis._prevStage = null;\n\n\t\tthis.enableDOMEvents(true);\n\t}\n\n\t/**\n\t * Specifies a target stage that will have mouse/touch interactions relayed to it after this stage handles them.\n\t * This can be useful in cases where you have multiple layered canvases and want user interactions\n\t * events to pass through.\n\t *\n\t * MouseOver, MouseOut, RollOver, and RollOut interactions are also passed through using the mouse over settings\n\t * of the top-most stage, but are only processed if the target stage has mouse over interactions enabled.\n\t * Considerations when using roll over in relay targets:\n\t * \n\t *
The top-most (first) stage must have mouse over interactions enabled (via enableMouseOver)
\n\t *
All stages that wish to participate in mouse over interaction must enable them via enableMouseOver
\n\t *
All relay targets will share the frequency value of the top-most stage
\n\t * stage.enableDOMEvents(false);\n\t *\n\t * @type {easeljs.Stage}\n\t */\n\tget nextStage () { return this._nextStage; }\n\tset nextStage (stage) {\n\t\tif (this._nextStage) { this._nextStage._prevStage = null; }\n\t\tif (stage) { stage._prevStage = this; }\n\t\tthis._nextStage = stage;\n\t}\n\n// public methods:\n\t/**\n\t * Each time the update method is called, the stage will call {@link easeljs.Stage#tick}\n\t * unless {@link easeljs.Stage#tickOnupdate} is set to false,\n\t * and then render the display list to the canvas.\n\t *\n\t * @param {Object} [props] Props object to pass to `tick()`. Should usually be a {@link core.Ticker} event object, or similar object with a delta property.\n\t */\n\tupdate (props) {\n\t\tif (!this.canvas) { return; }\n\t\tif (this.tickOnUpdate) { this.tick(props); }\n\t\tif (this.dispatchEvent(\"drawstart\", false, true) === false) { return; }\n\t\tDisplayObject._snapToPixelEnabled = this.snapToPixelEnabled;\n\t\tlet r = this.drawRect, ctx = this.canvas.getContext(\"2d\");\n\t\tctx.setTransform(1, 0, 0, 1, 0, 0);\n\t\tif (this.autoClear) {\n\t\t\tif (r) { ctx.clearRect(r.x, r.y, r.width, r.height); }\n\t\t\telse { ctx.clearRect(0, 0, this.canvas.width+1, this.canvas.height+1); }\n\t\t}\n\t\tctx.save();\n\t\tif (this.drawRect) {\n\t\t\tctx.beginPath();\n\t\t\tctx.rect(r.x, r.y, r.width, r.height);\n\t\t\tctx.clip();\n\t\t}\n\t\tthis.updateContext(ctx);\n\t\tthis.draw(ctx, false);\n\t\tctx.restore();\n\t\tthis.dispatchEvent(\"drawend\");\n\t}\n\n\t/**\n\t * Propagates a tick event through the display list. This is automatically called by {@link easeljs.Stage#update}\n\t * unless {@link easeljs.Stage#tickOnUpdate} is set to false.\n\t *\n\t * If a props object is passed to `tick()`, then all of its properties will be copied to the event object that is\n\t * propagated to listeners.\n\t *\n\t * Some time-based features in EaselJS (for example {@link easeljs.Sprite#framerate} require that\n\t * a {@link core.Ticker#event:tick} event object (or equivalent object with a delta property) be\n\t * passed as the `props` parameter to `tick()`.\n\t *\n\t * @example\n\t * Ticker.on(\"tick\", (evt) => {\n\t * // clone the event object from Ticker, and add some custom data to it:\n\t * \t let data = evt.clone().set({ greeting: \"hello\", name: \"world\" });\n\t * \t // pass it to stage.update():\n\t * \t stage.update(data); // subsequently calls tick() with the same param\n\t * });\n\t *\n\t * shape.on(\"tick\", (evt) => {\n\t * console.log(evt.delta); // the delta property from the Ticker tick event object\n\t * \t console.log(evt.greeting, evt.name); // custom data: \"hello world\"\n\t * });\n\t *\n\t * @emits easeljs.Stage#event:tickstart\n\t * @emits easeljs.Stage#event:tickend\n\t * @param {Object} [props] An object with properties that should be copied to the event object. Should usually be a Ticker event object, or similar object with a delta property.\n\t */\n\ttick (props) {\n\t\tif (!this.tickEnabled || this.dispatchEvent(\"tickstart\", false, true) === false) { return; }\n\t\tlet evtObj = new Event(\"tick\");\n\t\tif (props) {\n\t\t\tfor (let n in props) {\n\t\t\t\tif (props.hasOwnProperty(n)) { evtObj[n] = props[n]; }\n\t\t\t}\n\t\t}\n\t\tthis._tick(evtObj);\n\t\tthis.dispatchEvent(\"tickend\");\n\t}\n\n\t/**\n\t * Default event handler that calls the Stage {@link easeljs.Stage#update} method when a {@link easeljs.DisplayObject#event:tick}\n\t * event is received. This allows you to register a Stage instance as a event listener on {@link core.Ticker} directly.\n\t * Note that if you subscribe to ticks using this pattern, then the tick event object will be passed through to\n\t * display object tick handlers, instead of `delta` and `paused` parameters.\n\t */\n\thandleEvent (evt) {\n\t\tif (evt.type === \"tick\") { this.update(evt); }\n\t}\n\n\t/**\n\t * Clears the target canvas. Useful if {@link easeljs.State#autoClear} is set to `false`.\n\t */\n\tclear () {\n\t\tif (!this.canvas) { return; }\n\t\tlet ctx = this.canvas.getContext(\"2d\");\n\t\tctx.setTransform(1, 0, 0, 1, 0, 0);\n\t\tctx.clearRect(0, 0, this.canvas.width+1, this.canvas.height+1);\n\t}\n\n\t/**\n\t * Returns a data url that contains a Base64-encoded image of the contents of the stage. The returned data url can\n\t * be specified as the src value of an image element.\n\t *\n\t * @param {String} [backgroundColor] The background color to be used for the generated image. Any valid CSS color\n\t * value is allowed. The default value is a transparent background.\n\t * @param {String} [mimeType=\"image/png\"] The MIME type of the image format to be create. If an unknown MIME type\n\t * is passed in, or if the browser does not support the specified MIME type, the default value will be used.\n\t * @return {String} a Base64 encoded image.\n\t */\n\ttoDataURL (backgroundColor, mimeType = \"image/png\") {\n\t\tlet data, ctx = this.canvas.getContext('2d'), w = this.canvas.width, h = this.canvas.height;\n\n\t\tif (backgroundColor) {\n\t\t\tdata = ctx.getImageData(0, 0, w, h);\n\t\t\tvar compositeOperation = ctx.globalCompositeOperation;\n\t\t\tctx.globalCompositeOperation = \"destination-over\";\n\n\t\t\tctx.fillStyle = backgroundColor;\n\t\t\tctx.fillRect(0, 0, w, h);\n\t\t}\n\n\t\tlet dataURL = this.canvas.toDataURL(mimeType);\n\n\t\tif (backgroundColor) {\n\t\t\tctx.putImageData(data, 0, 0);\n\t\t\tctx.globalCompositeOperation = compositeOperation;\n\t\t}\n\n\t\treturn dataURL;\n\t}\n\n\t/**\n\t * Enables or disables (by passing a frequency of 0) mouse over {@link easeljs.DisplayObject#event:mouseover}\n\t * and {@link easeljs.DisplayObject#event:mouseout} and roll over events {@link easeljs.DisplayObject#event:rollover}\n\t * and {@link easeljs.DisplayObject#event:rollout} for this stage's display list. These events can\n\t * be expensive to generate, so they are disabled by default. The frequency of the events can be controlled\n\t * independently of mouse move events via the optional `frequency` parameter.\n\t *\n\t * @example\n\t * const stage = new Stage(\"canvasId\");\n\t * stage.enableMouseOver(10); // 10 updates per second\n\t *\n\t * @param {Number} [frequency=20] Optional param specifying the maximum number of times per second to broadcast\n\t * mouse over/out events. Set to 0 to disable mouse over events completely. Maximum is 50. A lower frequency is less\n\t * responsive, but uses less CPU.\n\t */\n\tenableMouseOver (frequency = 20) {\n\t\tif (this._mouseOverIntervalID) {\n\t\t\tclearInterval(this._mouseOverIntervalID);\n\t\t\tthis._mouseOverIntervalID = null;\n\t\t\tif (frequency === 0) {\n\t\t\t\tthis._testMouseOver(true);\n\t\t\t}\n\t\t}\n\t\tif (frequency <= 0) { return; }\n\t\tthis._mouseOverIntervalID = setInterval(() => this._testMouseOver(), 1000/Math.min(50,frequency));\n\t}\n\n\t/**\n\t * Enables or disables the event listeners that stage adds to DOM elements (window, document and canvas). It is good\n\t * practice to disable events when disposing of a Stage instance, otherwise the stage will continue to receive\n\t * events from the page.\n\t * When changing the canvas property you must disable the events on the old canvas, and enable events on the\n\t * new canvas or mouse events will not work as expected.\n\t *\n\t * @example\n\t * stage.enableDOMEvents(false);\n\t * stage.canvas = anotherCanvas;\n\t * stage.enableDOMEvents(true);\n\t *\n\t * @param {Boolean} [enable=true] Indicates whether to enable or disable the events.\n\t */\n\tenableDOMEvents (enable = true) {\n\t\tlet ls = this._eventListeners;\n\t\tif (!enable && ls) {\n\t\t\tfor (let n in ls) {\n\t\t\t\tlet o = ls[n];\n\t\t\t\to.t.removeEventListener(n, o.f, false);\n\t\t\t}\n\t\t\tthis._eventListeners = null;\n\t\t} else if (enable && !ls && this.canvas) {\n\t\t\tlet t = window.addEventListener ? window : document;\n\t\t\tls = this._eventListeners = {\n\t\t\t\tmouseup: {t, f:e => this._handleMouseUp(e) },\n\t\t\t\tmousemove: {t, f:e => this._handleMouseMove(e) },\n\t\t\t\tdblclick: {t:this.canvas, f:e => this._handleDoubleClick(e) },\n\t\t\t\tmousedown: {t:this.canvas, f:e => this._handleMouseDown(e) }\n\t\t\t};\n\t\t\tfor (let n in ls) {\n\t\t\t\tlet o = ls[n];\n\t\t\t\to.t.addEventListener && o.t.addEventListener(n, o.f, false);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Stage instances cannot be cloned.\n\t * @throws Stage cannot be cloned\n\t * @override\n\t */\n\tclone () {\n\t\tthrow \"Stage cannot be cloned.\";\n\t}\n\n\t/**\n\t * @protected\n\t * @param {HTMLElement} e\n\t * @returns {Object}\n\t */\n\t_getElementRect (e) {\n\t\tlet bounds;\n\t\ttry { bounds = e.getBoundingClientRect(); } // this can fail on disconnected DOM elements in IE9\n\t\tcatch (err) { bounds = {top:e.offsetTop, left:e.offsetLeft, width:e.offsetWidth, height:e.offsetHeight}; }\n\n\t\tlet offX = (window.pageXOffset || document.scrollLeft || 0) - (document.clientLeft || document.body.clientLeft || 0);\n\t\tlet offY = (window.pageYOffset || document.scrollTop || 0) - (document.clientTop || document.body.clientTop || 0);\n\n\t\tlet styles = window.getComputedStyle ? getComputedStyle(e, null) : e.currentStyle; // IE <9 compatibility.\n\t\tlet padL = parseInt(styles.paddingLeft)+parseInt(styles.borderLeftWidth);\n\t\tlet padT = parseInt(styles.paddingTop)+parseInt(styles.borderTopWidth);\n\t\tlet padR = parseInt(styles.paddingRight)+parseInt(styles.borderRightWidth);\n\t\tlet padB = parseInt(styles.paddingBottom)+parseInt(styles.borderBottomWidth);\n\n\t\t// note: in some browsers bounds properties are read only.\n\t\treturn {\n\t\t\tleft: bounds.left+offX+padL,\n\t\t\tright: bounds.right+offX-padR,\n\t\t\ttop: bounds.top+offY+padT,\n\t\t\tbottom: bounds.bottom+offY-padB\n\t\t};\n\t}\n\n\t/**\n\t * @protected\n\t * @param {Number} id\n\t * @returns {Object}\n\t */\n\t_getPointerData (id) {\n\t\tlet data = this._pointerData[id];\n\t\tif (!data) { data = this._pointerData[id] = {x:0, y:0}; }\n\t\treturn data;\n\t}\n\n\t/**\n\t * @protected\n\t * @param {easeljs.MouseEvent} [e=window.event]\n\t */\n\t_handleMouseMove (e = window.event) {\n\t\tthis._handlePointerMove(-1, e, e.pageX, e.pageY);\n\t}\n\n\t/**\n\t * @emits {@link easeljs.DisplayObject#event:mouseleave}\n\t * @emits {@link easeljs.DisplayObject#event:mouseenter}\n\t * @emits {@link easeljs.DisplayObject#event:pressmove}\n\t * @emits {@link easeljs.Stage#event:stagemousemove}\n\t * @protected\n\t * @param {Number} id\n\t * @param {easeljs.MouseEvent | Event} e\n\t * @param {Number} pageX\n\t * @param {Number} pageY\n\t * @param {easeljs.Stage} owner Indicates that the event has already been captured & handled by the indicated stage.\n\t */\n\t_handlePointerMove (id, e, pageX, pageY, owner) {\n\t\tif (this._prevStage && owner === undefined) { return; } // redundant listener.\n\t\tif (!this.canvas) { return; }\n\t\tlet nextStage=this._nextStage, o=this._getPointerData(id);\n\n\t\tlet inBounds = o.inBounds;\n\t\tthis._updatePointerPosition(id, e, pageX, pageY);\n\t\tif (inBounds || o.inBounds || this.mouseMoveOutside) {\n\t\t\tif (id === -1 && o.inBounds === !inBounds) {\n\t\t\t\tthis._dispatchMouseEvent(this, (inBounds ? \"mouseleave\" : \"mouseenter\"), false, id, o, e);\n\t\t\t}\n\n\t\t\tthis._dispatchMouseEvent(this, \"stagemousemove\", false, id, o, e);\n\t\t\tthis._dispatchMouseEvent(o.target, \"pressmove\", true, id, o, e);\n\t\t}\n\n\t\tnextStage&&nextStage._handlePointerMove(id, e, pageX, pageY, null);\n\t}\n\n\t/**\n\t * @protected\n\t * @param {Number} id\n\t * @param {easeljs.MouseEvent | Event} e\n\t * @param {Number} pageX\n\t * @param {Number} pageY\n\t */\n\t_updatePointerPosition (id, e, pageX, pageY) {\n\t\tlet rect = this._getElementRect(this.canvas);\n\t\tpageX -= rect.left;\n\t\tpageY -= rect.top;\n\n\t\tlet w = this.canvas.width;\n\t\tlet h = this.canvas.height;\n\t\tpageX /= (rect.right-rect.left)/w;\n\t\tpageY /= (rect.bottom-rect.top)/h;\n\t\tlet o = this._getPointerData(id);\n\t\tif (o.inBounds = (pageX >= 0 && pageY >= 0 && pageX <= w-1 && pageY <= h-1)) {\n\t\t\to.x = pageX;\n\t\t\to.y = pageY;\n\t\t} else if (this.mouseMoveOutside) {\n\t\t\to.x = pageX < 0 ? 0 : (pageX > w-1 ? w-1 : pageX);\n\t\t\to.y = pageY < 0 ? 0 : (pageY > h-1 ? h-1 : pageY);\n\t\t}\n\n\t\to.posEvtObj = e;\n\t\to.rawX = pageX;\n\t\to.rawY = pageY;\n\n\t\tif (id === this._primaryPointerID || id === -1) {\n\t\t\tthis.mouseX = o.x;\n\t\t\tthis.mouseY = o.y;\n\t\t\tthis.mouseInBounds = o.inBounds;\n\t\t}\n\t}\n\n\t/**\n\t * @protected\n\t * @param {easeljs.MouseEvent} e\n\t */\n\t_handleMouseUp (e) {\n\t\tthis._handlePointerUp(-1, e, false);\n\t}\n\n\t/**\n\t * @emits {@link easeljs.Stage#event:stagemouseup}\n\t * @emits {@link easeljs.DisplayObject#event:click}\n\t * @emits {@link easeljs.DisplayObject#event:pressup}\n\t * @protected\n\t * @param {Number} id\n\t * @param {easeljs.MouseEvent | Event} e\n\t * @param {Boolean} clear\n\t * @param {easeljs.Stage} owner Indicates that the event has already been captured & handled by the indicated stage.\n\t */\n\t_handlePointerUp (id, e, clear, owner) {\n\t\tlet nextStage = this._nextStage, o = this._getPointerData(id);\n\t\tif (this._prevStage && owner === undefined) { return; } // redundant listener.\n\n\t\tlet target=null, oTarget = o.target;\n\t\tif (!owner && (oTarget || nextStage)) { target = this._getObjectsUnderPoint(o.x, o.y, null, true); }\n\n\t\tif (o.down) { this._dispatchMouseEvent(this, \"stagemouseup\", false, id, o, e, target); o.down = false; }\n\n\t\tif (target === oTarget) { this._dispatchMouseEvent(oTarget, \"click\", true, id, o, e); }\n\t\tthis._dispatchMouseEvent(oTarget, \"pressup\", true, id, o, e);\n\n\t\tif (clear) {\n\t\t\tif (id==this._primaryPointerID) { this._primaryPointerID = null; }\n\t\t\tdelete(this._pointerData[id]);\n\t\t} else { o.target = null; }\n\n\t\tnextStage&&nextStage._handlePointerUp(id, e, clear, owner || target && this);\n\t}\n\n\t/**\n\t * @protected\n\t * @param {easeljs.MouseEvent} e\n\t */\n\t_handleMouseDown (e) {\n\t\tthis._handlePointerDown(-1, e, e.pageX, e.pageY);\n\t}\n\n\t/**\n\t * @emits {@link easeljs.Stage#event:stagemousedown}\n\t * @emits {@link easeljs.DisplayObject#event:mousedown}\n\t * @protected\n\t * @param {Number} id\n\t * @param {easeljs.MouseEvent | Event} e\n\t * @param {Number} pageX\n\t * @param {Number} pageY\n\t * @param {easeljs.Stage} owner Indicates that the event has already been captured & handled by the indicated stage.\n\t */\n\t_handlePointerDown (id, e, pageX, pageY, owner) {\n\t\tif (this.preventSelection) { e.preventDefault(); }\n\t\tif (this._primaryPointerID == null || id === -1) { this._primaryPointerID = id; } // mouse always takes over.\n\n\t\tif (pageY != null) { this._updatePointerPosition(id, e, pageX, pageY); }\n\t\tlet target = null, nextStage = this._nextStage, o = this._getPointerData(id);\n\t\tif (!owner) { target = o.target = this._getObjectsUnderPoint(o.x, o.y, null, true); }\n\n\t\tif (o.inBounds) { this._dispatchMouseEvent(this, \"stagemousedown\", false, id, o, e, target); o.down = true; }\n\t\tthis._dispatchMouseEvent(target, \"mousedown\", true, id, o, e);\n\n\t\tnextStage&&nextStage._handlePointerDown(id, e, pageX, pageY, owner || target && this);\n\t}\n\n\t/**\n\t * @emits {@link easeljs.DisplayObject#event:mouseout}\n\t * @emits {@link easeljs.DisplayObject#event:rollout}\n\t * @emits {@link easeljs.DisplayObject#event:rollover}\n\t * @emits {@link easeljs.DisplayObject#event:mouseover}\n\t * @param {Boolean} clear If true, clears the mouseover / rollover (ie. no target)\n\t * @param {easeljs.Stage} owner Indicates that the event has already been captured & handled by the indicated stage.\n\t * @param {easeljs.Stage} eventTarget The stage that the cursor is actively over.\n\t * @protected\n\t */\n\t_testMouseOver (clear, owner, eventTarget) {\n\t\tif (this._prevStage && owner === undefined) { return; } // redundant listener.\n\n\t\tlet nextStage = this._nextStage;\n\t\tif (!this._mouseOverIntervalID) {\n\t\t\t// not enabled for mouseover, but should still relay the event.\n\t\t\tnextStage&&nextStage._testMouseOver(clear, owner, eventTarget);\n\t\t\treturn;\n\t\t}\n\t\tlet o = this._getPointerData(-1);\n\t\t// only update if the mouse position has changed. This provides a lot of optimization, but has some trade-offs.\n\t\tif (!o || (!clear && this.mouseX === this._mouseOverX && this.mouseY === this._mouseOverY && this.mouseInBounds)) { return; }\n\n\t\tlet e = o.posEvtObj;\n\t\tlet isEventTarget = eventTarget || e&&(e.target === this.canvas);\n\t\tlet target=null, common = -1, cursor=\"\";\n\n\t\tif (!owner && (clear || this.mouseInBounds && isEventTarget)) {\n\t\t\ttarget = this._getObjectsUnderPoint(this.mouseX, this.mouseY, null, true);\n\t\t\tthis._mouseOverX = this.mouseX;\n\t\t\tthis._mouseOverY = this.mouseY;\n\t\t}\n\n\t\tlet oldList = this._mouseOverTarget||[];\n\t\tlet oldTarget = oldList[oldList.length-1];\n\t\tlet list = this._mouseOverTarget = [];\n\n\t\t// generate ancestor list and check for cursor:\n\t\tlet t = target;\n\t\twhile (t) {\n\t\t\tlist.unshift(t);\n\t\t\tif (!cursor) { cursor = t.cursor; }\n\t\t\tt = t.parent;\n\t\t}\n\t\tthis.canvas.style.cursor = cursor;\n\t\tif (!owner && eventTarget) { eventTarget.canvas.style.cursor = cursor; }\n\n\t\t// find common ancestor:\n\t\tfor (let i=0,l=list.length; icommon; i--) {\n\t\t\tthis._dispatchMouseEvent(oldList[i], \"rollout\", false, -1, o, e, target);\n\t\t}\n\n\t\tfor (let i=list.length-1; i>common; i--) {\n\t\t\tthis._dispatchMouseEvent(list[i], \"rollover\", false, -1, o, e, oldTarget);\n\t\t}\n\n\t\tif (oldTarget != target) {\n\t\t\tthis._dispatchMouseEvent(target, \"mouseover\", true, -1, o, e, oldTarget);\n\t\t}\n\n\t\tnextStage&&nextStage._testMouseOver(clear, owner || target && this, eventTarget || isEventTarget && this);\n\t}\n\n\t/**\n\t * @emits {@link easeljs.DisplayObject#event:dblclick}\n\t * @protected\n\t * @param {easeljs.MouseEvent} e\n\t * @param {easeljs.Stage} owner Indicates that the event has already been captured & handled by the indicated stage.\n\t */\n\t_handleDoubleClick (e, owner) {\n\t\tlet target=null, nextStage=this._nextStage, o=this._getPointerData(-1);\n\t\tif (!owner) {\n\t\t\ttarget = this._getObjectsUnderPoint(o.x, o.y, null, true);\n\t\t\tthis._dispatchMouseEvent(target, \"dblclick\", true, -1, o, e);\n\t\t}\n\t\tnextStage&&nextStage._handleDoubleClick(e, owner || target && this);\n\t}\n\n\t/**\n\t * @protected\n\t * @param {easeljs.DisplayObject} target\n\t * @param {String} type\n\t * @param {Boolean} bubbles\n\t * @param {Number} pointerId\n\t * @param {Object} o\n\t * @param {easeljs.MouseEvent} [nativeEvent]\n\t * @param {easeljs.DisplayObject} [relatedTarget]\n\t */\n\t_dispatchMouseEvent (target, type, bubbles, pointerId, o, nativeEvent, relatedTarget) {\n\t\t// TODO: might be worth either reusing MouseEvent instances, or adding a willTrigger method to avoid GC.\n\t\tif (!target || (!bubbles && !target.hasEventListener(type))) { return; }\n\t\t/*\n\t\t// TODO: account for stage transformations?\n\t\tthis._mtx = this.getConcatenatedMatrix(this._mtx).invert();\n\t\tlet pt = this._mtx.transformPoint(o.x, o.y);\n\t\tlet evt = new MouseEvent(type, bubbles, false, pt.x, pt.y, nativeEvent, pointerId, pointerId==this._primaryPointerID || pointerId==-1, o.rawX, o.rawY);\n\t\t*/\n\t\tlet evt = new MouseEvent(type, bubbles, false, o.x, o.y, nativeEvent, pointerId, pointerId === this._primaryPointerID || pointerId === -1, o.rawX, o.rawY, relatedTarget);\n\t\ttarget.dispatchEvent(evt);\n\t}\n\n}\n\n/**\n * Dispatched when the user moves the mouse over the canvas.\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.Stage#stagemousemove\n * @since 0.6.0\n */\n/**\n * Dispatched when the user presses their left mouse button on the canvas.\n * You can use {@link easeljs.Stage#mouseInBounds} to check whether the mouse is currently within the stage bounds.\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.Stage#stagemousedown\n * @since 0.6.0\n */\n/**\n * Dispatched when the user the user presses somewhere on the stage, then releases the mouse button anywhere that the page can detect it (this varies slightly between browsers).\n * You can use {@link easeljs.Stage#mouseInBounds} to check whether the mouse is currently within the stage bounds.\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.Stage#stagemouseup\n * @since 0.6.0\n */\n/**\n * Dispatched when the mouse moves from within the canvas area (mouseInBounds === true) to outside it (mouseInBounds === false).\n * This is currently only dispatched for mouse input (not touch).\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.Stage#mouseleave\n * @since 0.7.0\n */\n/**\n * Dispatched when the mouse moves into the canvas area (mouseInBounds === false) from outside it (mouseInBounds === true).\n * This is currently only dispatched for mouse input (not touch).\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.Stage#mouseenter\n * @since 0.7.0\n */\n/**\n * Dispatched each update immediately before the tick event is propagated through the display list.\n * You can call preventDefault on the event object to cancel propagating the tick event.\n * @event easeljs.Stage#tickstart\n * @since 0.7.0\n */\n/**\n * Dispatched each update immediately after the tick event is propagated through the display list. Does not fire if\n * tickOnUpdate is false. Precedes the \"drawstart\" event.\n * @event easeljs.Stage#tickend\n * @since 0.7.0\n */\n/**\n * Dispatched each update immediately before the canvas is cleared and the display list is drawn to it.\n * You can call preventDefault on the event object to cancel the draw.\n * @event easeljs.Stage#drawstart\n * @since 0.7.0\n */\n/**\n * Dispatched each update immediately after the display list is drawn to the canvas and the canvas context is restored.\n * @event easeljs.Stage#drawend\n * @since 0.7.0\n */\n","/**\r\n * @license Canvas\r\n * Visit http://createjs.com/ for documentation, updates and examples.\r\n *\r\n * Copyright (c) 2017 gskinner.com, inc.\r\n *\r\n * Permission is hereby granted, free of charge, to any person\r\n * obtaining a copy of this software and associated documentation\r\n * files (the \"Software\"), to deal in the Software without\r\n * restriction, including without limitation the rights to use,\r\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n * copies of the Software, and to permit persons to whom the\r\n * Software is furnished to do so, subject to the following\r\n * conditions:\r\n *\r\n * The above copyright notice and this permission notice shall be\r\n * included in all copies or substantial portions of the Software.\r\n *\r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\r\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\r\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\r\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\r\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\r\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\r\n * OTHER DEALINGS IN THE SOFTWARE.\r\n */\r\n\r\n/**\r\n * Global utility for creating canvases.\r\n * @memberof easeljs\n * @name easeljs.createCanvas\n * @param {Number} [width=1]\n * @param {Number} [height=1]\r\n */\r\nexport default function createCanvas(width=1, height=1) {\n\tlet c;\n\tif (window.createjs !== undefined && window.createjs.createCanvas !== undefined) {\n\t\tc = window.createjs.createCanvas();\n\t}\n\tif (window.document !== undefined && window.document.createElement !== undefined) {\n\t\tc = document.createElement(\"canvas\");\n\t}\n\tif (c !== undefined) {\n\t\tc.width = width;\n\t\tc.height = height;\n\t\treturn c;\n\t}\n\n\tthrow \"Canvas not supported in this environment.\";\r\n}\r\n","/**\n * @license VideoBuffer\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2010 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport createCanvas from \"./Canvas\";\n\n/**\n * When an HTML video seeks, including when looping, there is an indeterminate period before a new frame is available.\n * This can result in the video blinking or flashing when it is drawn to a canvas. The VideoBuffer class resolves\n * this issue by drawing each frame to an off-screen canvas and preserving the prior frame during a seek.\n *\n * @example\n * let buffer = new VideoBuffer(video);\n * let bitmap = new Bitmap(buffer);\n *\n * @param {HTMLVideoElement} video The HTML video element to buffer.\n */\nexport default class VideoBuffer {\n\n constructor (video) {\n\n \t/**\n \t * Used by Bitmap to determine when the video buffer is ready to be drawn. Not intended for general use.\n \t * @protected\n \t * @type {Number}\n \t */\n \tthis.readyState = video.readyState;\n\n \t/**\n \t * @protected\n \t * @type {HTMLVideoElement}\n \t */\n \tthis._video = video;\n\n \t/**\n \t * @protected\n \t * @type {HTMLCanvasElement}\n \t */\n \tthis._canvas = null;\n\n \t/**\n \t * @protected\n \t * @type {Number}\n \t * @default -1\n \t */\n \tthis._lastTime = -1;\n\n \tif (this.readyState < 2) {\n video.addEventListener(\"canplaythrough\", this._videoReady.bind(this));\n }\n // {once: true} isn't supported everywhere, but its a non-critical optimization here.\n }\n\n /**\n * Gets an HTML canvas element showing the current video frame, or the previous frame if in a seek / loop.\n * Primarily for use by {@link easeljs.Bitmap}.\n */\n getImage () {\n \tif (this.readyState < 2) { return; }\n \tlet canvas = this._canvas, video = this._video;\n \tif (!canvas) {\n\t\t\tcanvas = this._canvas = createCanvas();\n \t\tcanvas.width = video.videoWidth;\n \t\tcanvas.height = video.videoHeight;\n \t}\n \tif (video.readyState >= 2 && video.currentTime !== this._lastTime) {\n \t\tconst ctx = canvas.getContext(\"2d\");\n \t\tctx.clearRect(0, 0, canvas.width, canvas.height);\n \t\tctx.drawImage(video, 0, 0, canvas.width, canvas.height);\n \t\tthis._lastTime = video.currentTime;\n \t}\n \treturn canvas;\n }\n\n /**\n * @protected\n */\n _videoReady () {\n \tthis.readyState = 2;\n }\n\n}\n","/**\n * @license Bitmap\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport DisplayObject from \"./DisplayObject\";\nimport VideoBuffer from \"../utils/VideoBuffer\";\n\n/**\n * A Bitmap represents an Image, Canvas, or Video in the display list. A Bitmap can be instantiated using an existing\n * HTML element, or a string.\n *\n * Notes:\n * \n *
When using a video source that may loop or seek, use a {@link easeljs.VideoBuffer} object to\n * blinking / flashing.\n *
When a string path or image tag that is not yet loaded is used, the stage may need to be redrawn before it\n * will be displayed.
\n *
Bitmaps with an SVG source currently will not respect an alpha value other than 0 or 1. To get around this,\n * the Bitmap can be cached.
\n *
Bitmaps with an SVG source will taint the canvas with cross-origin data, which prevents interactivity. This\n * happens in all browsers except recent Firefox builds.
\n *
Images loaded cross-origin will throw cross-origin security errors when interacted with using a mouse, using\n * methods such as `getObjectUnderPoint`, or using filters, or caching. You can get around this by setting\n * `crossOrigin` flags on your images before passing them to EaselJS, eg: `img.crossOrigin=\"Anonymous\";`
\n * \n *\n * @memberof easeljs\n * @extends easeljs.DisplayObject\n * @example\n * const bitmap = new Bitmap(\"imagePath.jpg\");\n *\n * @param {CanvasImageSource | String | Object} imageOrUri The source image to display. This can be a CanvasImageSource\n * (image, video, canvas), an object with a `getImage` method that returns a CanvasImageSource, or a string URL to an image.\n * If the latter, a new Image instance with the URL as its src will be used.\n */\nexport default class Bitmap extends DisplayObject {\n\n\tconstructor (imageOrUri) {\n\t\tsuper();\n\n\t\t/**\n\t\t * The source image to display. This can be a CanvasImageSource\n\t\t * (image, video, canvas), an object with a `getImage` method that returns a CanvasImageSource, or a string URL to an image.\n\t\t * If the latter, a new Image instance with the URL as its src will be used.\n\t\t * @property image\n\t\t * @type {CanvasImageSource | Object}\n\t\t */\n\t\tif (typeof imageOrUri === \"string\") {\n\t\t\tthis.image = document.createElement(\"img\");\n\t\t\tthis.image.src = imageOrUri;\n\t\t} else {\n\t\t\tthis.image = imageOrUri;\n\t\t}\n\n\t\t/**\n\t\t * Specifies an area of the source image to draw. If omitted, the whole image will be drawn.\n\t\t * Note that video sources must have a width / height set to work correctly with `sourceRect`.\n\t\t * @type {easeljs.Rectangle}\n\t\t * @default null\n\t\t */\n\t\tthis.sourceRect = null;\n\n\t\t/**\n\t\t * Set as compatible with WebGL.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._webGLRenderStyle = DisplayObject._StageGL_BITMAP;\n\t}\n\n\tisVisible () {\n\t\tlet image = this.image;\n\t\tlet hasContent = this.cacheCanvas || (image && (image.naturalWidth || image.getContext || image.readyState >= 2));\n\t\treturn !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && hasContent);\n\t}\n\n\tdraw (ctx, ignoreCache = false) {\n\t\tif (super.draw(ctx, ignoreCache)) { return true; }\n\t\tlet img = this.image, rect = this.sourceRect;\n\t\tif (img instanceof VideoBuffer) { img = img.getImage(); }\n\t\tif (img == null) { return true; }\n\t\tif (rect) {\n\t\t\t// some browsers choke on out of bound values, so we'll fix them:\n\t\t\tlet x1 = rect.x, y1 = rect.y, x2 = x1 + rect.width, y2 = y1 + rect.height, x = 0, y = 0, w = img.width, h = img.height;\n\t\t\tif (x1 < 0) { x -= x1; x1 = 0; }\n\t\t\tif (x2 > w) { x2 = w; }\n\t\t\tif (y1 < 0) { y -= y1; y1 = 0; }\n\t\t\tif (y2 > h) { y2 = h; }\n\t\t\tctx.drawImage(img, x1, y1, x2-x1, y2-y1, x, y, x2-x1, y2-y1);\n\t\t} else {\n\t\t\tctx.drawImage(img, 0, 0);\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Note, the doc sections below document using the specified APIs (from DisplayObject) from\n\t// Bitmap. This is why they have no method implementations.\n\n\t/**\n\t * Because the content of a Bitmap is already in a simple format, cache is unnecessary for Bitmap instances.\n\t * You should not cache Bitmap instances as it can degrade performance.\n\t *\n\t * However: If you want to use a filter on a Bitmap, you MUST cache it, or it will not work.\n\t * To see the API for caching, please visit the {@link easeljs.DisplayObject#cache} method.\n\t *\n\t * @alias easeljs.Bitmap#cache\n\t */\n\n\t/**\n\t * Because the content of a Bitmap is already in a simple format, cache is unnecessary for Bitmap instances.\n\t * You should not cache Bitmap instances as it can degrade performance.\n\t *\n\t * However: If you want to use a filter on a Bitmap, you MUST cache it, or it will not work.\n\t * To see the API for caching, please visit the {@link easeljs.DisplayObject#cache} method.\n\t *\n\t * @alias easeljs.Bitmap#updateCache\n\t */\n\n\t/**\n\t * Because the content of a Bitmap is already in a simple format, cache is unnecessary for Bitmap instances.\n\t * You should not cache Bitmap instances as it can degrade performance.\n\t *\n\t * However: If you want to use a filter on a Bitmap, you MUST cache it, or it will not work.\n\t * To see the API for caching, please visit the {@link easeljs.DisplayObject#cache} method.\n\t *\n\t * @alias easeljs.Bitmap#uncache\n\t */\n\n\tgetBounds () {\n\t\tlet rect = super.getBounds();\n\t\tif (rect) { return rect; }\n\t\tlet image = this.image, o = this.sourceRect || image;\n\t\tlet hasContent = (image && (image.naturalWidth || image.getContext || image.readyState >= 2));\n\t\treturn hasContent ? this._rectangle.setValues(0, 0, o.width, o.height) : null;\n\t}\n\n\t/**\n\t * Returns a clone of the Bitmap instance.\n\t * @param {Boolean} [node] Whether the underlying DOM element should be cloned as well.\n\t * @return {easeljs.Bitmap} A clone of the Bitmap instance.\n\t */\n\tclone (node) {\n\t\tlet img = this.image;\n\t\tif (img != null && node != null) { img = img.cloneNode(); }\n\t\tlet bmp = new Bitmap(img);\n\t\tif (this.sourceRect) { bmp.sourceRect = this.sourceRect.clone(); }\n\t\tthis._cloneProps(bmp);\n\t\treturn bmp;\n\t}\n\n}\n","/**\n * @license Sprite\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport DisplayObject from \"./DisplayObject\";\nimport { Event } from \"@createjs/core\";\n\n/**\n * Displays a frame or sequence of frames (ie. an animation) from a SpriteSheet instance. A sprite sheet is a series of\n * images (usually animation frames) combined into a single image. For example, an animation consisting of 8 100x100\n * images could be combined into a 400x200 sprite sheet (4 frames across by 2 high). You can display individual frames,\n * play frames as an animation, and even sequence animations together.\n *\n * @memberof easeljs\n * @extends easeljs.DisplayObject\n * @example\n * let sprite = new Sprite(spriteSheet);\n * sprite.gotoAndStop(\"frameName\");\n *\n * Until {@link easeljs.Sprite#gotoAndStop} or {@link easeljs.Sprite#gotoAndPlay} is called,\n * only the first defined frame defined in the sprite sheet will be displayed.\n *\n * @see {@link easeljs.SpriteSheet \"More information on setting up frames and animations.\"}\n * @param {SpriteSheet} spriteSheet The SpriteSheet instance to play back. This includes the source image(s), frame\n * dimensions, and frame data.\n * @param {String | Number} [frameOrAnimation] The frame number or animation to play initially.\n */\nexport default class Sprite extends DisplayObject {\n\n\tconstructor (spriteSheet, frameOrAnimation) {\n\t\tsuper();\n\n\t\t/**\n\t\t * The frame index that will be drawn when draw is called. Note that with some {@link easeljs.SpriteSheet}\n\t\t * definitions, this will advance non-sequentially. This will always be an integer value.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t * @readonly\n\t\t */\n\t\tthis.currentFrame = 0;\n\n\t\t/**\n\t\t * Returns the name of the currently playing animation.\n\t\t * @type {String}\n\t\t * @readonly\n\t\t */\n\t\tthis.currentAnimation = null;\n\n\t\t/**\n\t\t * Prevents the animation from advancing each tick automatically. For example, you could create a sprite\n\t\t * sheet of icons, set paused to true, and display the appropriate icon by setting `currentFrame`.\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.paused = true;\n\n\t\t/**\n\t\t * The SpriteSheet instance to play back. This includes the source image, frame dimensions, and frame data.\n\t\t * @type {easeljs.SpriteSheet}\n\t\t * @readonly\n\t\t */\n\t\tthis.spriteSheet = spriteSheet;\n\n\t\t/**\n\t\t * Specifies the current frame index within the currently playing animation. When playing normally, this will increase\n\t\t * from 0 to n-1, where n is the number of frames in the current animation.\n\t\t * This could be a non-integer value if using time-based playback, or if the animation's speed is not an integer.\n\t\t * @see {@link easeljs.Sprite#framerate}\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.currentAnimationFrame = 0;\n\n\t\t/**\n\t\t * By default Sprite instances advance one frame per tick. Specifying a framerate for the Sprite (or its related\n\t\t * SpriteSheet) will cause it to advance based on elapsed time between ticks as appropriate to maintain the target\n\t\t * framerate.\n\t\t *\n\t\t * For example, if a Sprite with a framerate of 10 is placed on a Stage being updated at 40fps, then the Sprite will\n\t\t * advance roughly one frame every 4 ticks. This will not be exact, because the time between each tick will\n\t\t * vary slightly between frames.\n\t\t *\n\t\t * This feature is dependent on the tick event object (or an object with an appropriate \"delta\" property) being\n\t\t * passed into {@link easeljs.Stage#update}.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.framerate = 0;\n\n\t\t/**\n\t\t * Current animation object.\n\t\t * @protected\n\t\t * @type {Object}\n\t\t * @default null\n\t\t */\n\t\tthis._animation = null;\n\n\t\t/**\n\t\t * Current frame index.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default null\n\t\t */\n\t\tthis._currentFrame = null;\n\n\t\t/**\n\t\t * Skips the next auto advance. Used by gotoAndPlay to avoid immediately jumping to the next frame\n\t\t * @protected\n\t\t * @type {Boolean}\n\t\t * @default false\n\t\t */\n\t\tthis._skipAdvance = false;\n\n\t\t/**\n\t\t * Set as compatible with WebGL.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 1\n\t\t */\n\t\tthis._webGLRenderStyle = DisplayObject._StageGL_SPRITE;\n\n\t\tif (frameOrAnimation != null) {\n\t\t\tthis.gotoAndPlay(frameOrAnimation);\n\t\t}\n\t}\n\n\tisVisible () {\n\t\tlet hasContent = this.cacheCanvas || this.spriteSheet.complete;\n\t\treturn !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && hasContent);\n\t}\n\n\tdraw (ctx, ignoreCache) {\n\t\tif (super.draw(ctx, ignoreCache)) { return true; }\n\t\tthis._normalizeFrame();\n\t\tlet o = this.spriteSheet.getFrame(this._currentFrame|0);\n\t\tif (!o) { return false; }\n\t\tlet rect = o.rect;\n\t\tif (rect.width && rect.height) { ctx.drawImage(o.image, rect.x, rect.y, rect.width, rect.height, -o.regX, -o.regY, rect.width, rect.height); }\n\t\treturn true;\n\t}\n\n\t// Note, the doc sections below document using the specified APIs (from DisplayObject) from\n\t// Bitmap. This is why they have no method implementations.\n\n\t/**\n\t * Because the content of a Sprite is already in a raster format, cache is unnecessary for Sprite instances.\n\t * You should not cache Sprite instances as it can degrade performance.\n\t * @name easeljs.Sprite#cache\n\t */\n\n\t/**\n\t * Because the content of a Sprite is already in a raster format, cache is unnecessary for Sprite instances.\n\t * You should not cache Sprite instances as it can degrade performance.\n\t * @name easeljs.Sprite#updateCache\n\t */\n\n\t/**\n\t * Because the content of a Sprite is already in a raster format, cache is unnecessary for Sprite instances.\n\t * You should not cache Sprite instances as it can degrade performance.\n\t * @name easeljs.Sprite#uncache\n\t */\n\n\t/**\n\t * Play (unpause) the current animation. The Sprite will be paused if either {@link easeljs.Sprite#stop}\n\t * or {@link easeljs.Sprite#gotoAndStop} is called. Single frame animations will remain unchanged.\n\t */\n\tplay () {\n\t\tthis.paused = false;\n\t}\n\n\t/**\n\t * Stop playing a running animation. The Sprite will be playing if {@link easeljs.Sprite#gotoAndPlay} is called.\n\t * Note that calling `gotoAndPlay()` or {@link easeljs.Sprite#play} will resume playback.\n\t */\n\tstop () {\n\t\tthis.paused = true;\n\t}\n\n\t/**\n\t * Sets paused to false and plays the specified animation name, named frame, or frame number.\n\t * @param {String | Number} frameOrAnimation The frame number or animation name that the playhead should move to\n\t * and begin playing.\n\t */\n\tgotoAndPlay (frameOrAnimation) {\n\t\tthis.paused = false;\n\t\tthis._skipAdvance = true;\n\t\tthis._goto(frameOrAnimation);\n\t}\n\n\t/**\n\t * Sets paused to true and seeks to the specified animation name, named frame, or frame number.\n\t * @param {String | Number} frameOrAnimation The frame number or animation name that the playhead should move to\n\t * and stop.\n\t */\n\tgotoAndStop (frameOrAnimation) {\n\t\tthis.paused = true;\n\t\tthis._goto(frameOrAnimation);\n\t}\n\n\t/**\n\t * Advances the playhead. This occurs automatically each tick by default.\n\t * @param {Number} [time] The amount of time in ms to advance by. Only applicable if framerate is set on the Sprite\n\t * or its SpriteSheet.\n\t*/\n\tadvance (time) {\n\t\tlet fps = this.framerate || this.spriteSheet.framerate;\n\t\tlet t = (fps && time != null) ? time/(1000/fps) : 1;\n\t\tthis._normalizeFrame(t);\n\t}\n\n\t/**\n\t * Returns a {@link easeljs.Rectangle} instance defining the bounds of the current frame relative to\n\t * the origin. For example, a 90 x 70 frame with `regX=50` and `regY=40` would return a\n\t * rectangle with [x=-50, y=-40, width=90, height=70]. This ignores transformations on the display object.\n\t *\n\t * @see {@link easeljs.SpriteSheet#frameBounds}\n\t * @return {easeljs.Rectangle} A Rectangle instance. Returns null if the frame does not exist, or the image is not fully loaded.\n\t */\n\tgetBounds () {\n\t\t// TODO: should this normalizeFrame?\n\t\treturn super.getBounds() || this.spriteSheet.getFrameBounds(this.currentFrame, this._rectangle);\n\t}\n\n\t/**\n\t * Returns a clone of the Sprite instance. Note that the same SpriteSheet is shared between cloned instances.\n\t * @return {easeljs.Sprite} a clone of the Sprite instance.\n\t */\n\tclone () {\n\t\treturn this._cloneProps(new Sprite(this.spriteSheet));\n\t}\n\n\t/**\n\t * @param {easeljs.Sprite} o\n\t * @return {easeljs.Sprite} o\n\t * @protected\n\t */\n\t_cloneProps (o) {\n\t\tsuper._cloneProps(o);\n\t\to.currentFrame = this.currentFrame;\n\t\to.currentAnimation = this.currentAnimation;\n\t\to.paused = this.paused;\n\t\to.currentAnimationFrame = this.currentAnimationFrame;\n\t\to.framerate = this.framerate;\n\n\t\to._animation = this._animation;\n\t\to._currentFrame = this._currentFrame;\n\t\to._skipAdvance = this._skipAdvance;\n\t\treturn o;\n\t}\n\n\t_tick (evtObj) {\n\t\tif (!this.paused) {\n\t\t\tif (!this._skipAdvance) { this.advance(evtObj&&evtObj.delta); }\n\t\t\tthis._skipAdvance = false;\n\t\t}\n\t\tsuper._tick(evtObj);\n\t}\n\n\t/**\n\t * Normalizes the current frame, advancing animations and dispatching callbacks as appropriate.\n\t * @protected\n\t * @param {Number} [frameDelta=0]\n\t */\n\t_normalizeFrame (frameDelta = 0) {\n\t\tlet animation = this._animation;\n\t\tlet paused = this.paused;\n\t\tlet frame = this._currentFrame;\n\n\t\tif (animation) {\n\t\t\tlet speed = animation.speed || 1;\n\t\t\tlet animFrame = this.currentAnimationFrame;\n\t\t\tlet l = animation.frames.length;\n\t\t\tif (animFrame + frameDelta * speed >= l) {\n\t\t\t\tlet next = animation.next;\n\t\t\t\tif (this._dispatchAnimationEnd(animation, frame, paused, next, l - 1)) {\n\t\t\t\t\t// something changed in the event stack, so we shouldn't make any more changes here.\n\t\t\t\t\treturn;\n\t\t\t\t} else if (next) {\n\t\t\t\t\t// sequence. Automatically calls _normalizeFrame again with the remaining frames.\n\t\t\t\t\treturn this._goto(next, frameDelta - (l - animFrame) / speed);\n\t\t\t\t} else {\n\t\t\t\t\t// end.\n\t\t\t\t\tthis.paused = true;\n\t\t\t\t\tanimFrame = animation.frames.length - 1;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tanimFrame += frameDelta * speed;\n\t\t\t}\n\t\t\tthis.currentAnimationFrame = animFrame;\n\t\t\tthis._currentFrame = animation.frames[animFrame | 0]\n\t\t} else {\n\t\t\tframe = (this._currentFrame += frameDelta);\n\t\t\tlet l = this.spriteSheet.getNumFrames();\n\t\t\tif (frame >= l && l > 0) {\n\t\t\t\tif (!this._dispatchAnimationEnd(animation, frame, paused, l - 1)) {\n\t\t\t\t\t// looped.\n\t\t\t\t\tif ((this._currentFrame -= l) >= l) { return this._normalizeFrame(); }\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tframe = this._currentFrame | 0;\n\t\tif (this.currentFrame != frame) {\n\t\t\tthis.currentFrame = frame;\n\t\t\tthis.dispatchEvent(\"change\");\n\t\t}\n\t};\n\n\t/**\n\t * Dispatches the \"animationend\" event. Returns true if a handler changed the animation (ex. calling {@link easlejs.Sprite#stop},\n\t * {@link easeljs.Sprite#gotoAndPlay}, etc.)\n\t * @param animation\n\t * @param frame\n\t * @param paused\n\t * @param next\n\t * @param end\n\t * @private\n\t */\n\t_dispatchAnimationEnd (animation, frame, paused, next, end) {\n\t\tlet name = animation ? animation.name : null;\n\t\tif (this.hasEventListener(\"animationend\")) {\n\t\t\tlet evt = new Event(\"animationend\");\n\t\t\tevt.name = name;\n\t\t\tevt.next = next;\n\t\t\tthis.dispatchEvent(evt);\n\t\t}\n\t\t// did the animation get changed in the event stack?:\n\t\tlet changed = (this._animation != animation || this._currentFrame != frame);\n\t\t// if the animation hasn't changed, but the sprite was paused, then we want to stick to the last frame:\n\t\tif (!changed && !paused && this.paused) { this.currentAnimationFrame = end; changed = true; }\n\t\treturn changed;\n\t}\n\n\t/**\n\t * Moves the playhead to the specified frame number or animation.\n\t * @param {String | Number} frameOrAnimation The frame number or animation that the playhead should move to.\n\t * @param {Number} [frame=0] The frame of the animation to go to. Defaults to 0.\n\t * @protected\n\t */\n\t_goto (frameOrAnimation, frame = 0) {\n\t\tthis.currentAnimationFrame = 0;\n\t\tif (isNaN(frameOrAnimation)) {\n\t\t\tlet data = this.spriteSheet.getAnimation(frameOrAnimation);\n\t\t\tif (data) {\n\t\t\t\tthis._animation = data;\n\t\t\t\tthis.currentAnimation = frameOrAnimation;\n\t\t\t\tthis._normalizeFrame(frame);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.currentAnimation = this._animation = null;\n\t\t\tthis._currentFrame = frameOrAnimation;\n\t\t\tthis._normalizeFrame();\n\t\t}\n\t}\n\n}\n\n/**\n * Dispatched when an animation reaches its ends.\n * @event easeljs.Sprite#animationend\n * @property {Object} target The object that dispatched the event.\n * @property {String} type The event type.\n * @property {String} name The name of the animation that just ended.\n * @property {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.\n * @since 0.6.0\n */\n\n/**\n * Dispatched any time the current frame changes. For example, this could be due to automatic advancement on a tick,\n * or calling gotoAndPlay() or gotoAndStop().\n * @event easeljs.Sprite#change\n * @property {Object} target The object that dispatched the event.\n * @property {String} type The event type.\n */\n","/**\n * @license BitmapText\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Container from \"./Container\";\nimport Sprite from \"./Sprite\";\n\n/**\n * Displays text using bitmap glyphs defined in a sprite sheet. Multi-line text is supported using new line characters,\n * but automatic wrapping is not supported. See the {@link easeljs.BitmapText#spriteSheet} property for more information on defining glyphs.\n *\n * Important: While BitmapText extends Container, it is not designed to be used as one.\n * As such, methods like addChild and removeChild are disabled.\n *\n * @memberof easeljs\n * @extends easeljs.Container\n *\n * @param {String} [text=\"\"] The text to display.\n * @param {SpriteSheet} [spriteSheet=null] The spritesheet that defines the character glyphs.\n */\nexport default class BitmapText extends Container {\n\n\tconstructor (text = \"\", spriteSheet = null) {\n\t\tsuper();\n\n\t\t/**\n\t\t * The text to display.\n\t\t * @type {String}\n\t\t * @default \"\"\n\t\t */\n\t\tthis.text = text;\n\n\t\t/**\n\t\t * A SpriteSheet instance that defines the glyphs for this bitmap text. Each glyph/character\n\t\t * should have a single frame animation defined in the sprite sheet named the same as\n\t\t * corresponding character.\n\t\t *\n\t\t * @example\n\t\t * // the following animation definition would indicate that the frame at index 0 of the spritesheet should be drawn for the \"A\" character.\n\t\t * \"A\": {frames: [0]}\n\t\t * // The short form is also acceptable:\n\t\t * \"A\": 0\n\t\t *\n\t\t * Note that if a character in the text is not found in the sprite sheet, it will also\n\t\t * try to use the alternate case (upper or lower).\n\t\t *\n\t\t * @see {@link easeljs.SpriteSheet}\n\t\t * @type {easeljs.SpriteSheet}\n\t\t * @default null\n\t\t */\n\t\tthis.spriteSheet = spriteSheet;\n\n\t\t/**\n\t\t * The height of each line of text. If 0, then it will use a line height calculated\n\t\t * by checking for the height of the \"1\", \"T\", or \"L\" character (in that order). If\n\t\t * those characters are not defined, it will use the height of the first frame of the\n\t\t * sprite sheet.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.lineHeight = 0;\n\n\t\t/**\n\t\t * This spacing (in pixels) will be added after each character in the output.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.letterSpacing = 0;\n\n\t\t/**\n\t\t * If a space character is not defined in the sprite sheet, then empty pixels equal to\n\t\t * spaceWidth will be inserted instead. If 0, then it will use a value calculated\n\t\t * by checking for the width of the \"1\", \"l\", \"E\", or \"A\" character (in that order). If\n\t\t * those characters are not defined, it will use the width of the first frame of the\n\t\t * sprite sheet.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.spaceWidth = 0;\n\n\t \t/**\n\t\t * @type {Object}\n\t\t * @protected\n\t\t */\n\t\tthis._oldProps = {text:0,spriteSheet:0,lineHeight:0,letterSpacing:0,spaceWidth:0};\n\n\t\t/**\n\t\t * Used to track the object which this class attached listeners to, helps optimize listener attachment.\n\t\t * @type {easeljs.Stage}\n\t\t * @protected\n\t\t */\n\t\tthis._oldStage = null;\n\n\t\t/**\n\t\t * The event listener proxy triggered drawing draw for special circumstances.\n\t\t * @type {Function}\n\t\t * @protected\n\t\t */\n\t\tthis._drawAction = null;\n\n\t}\n\n\tdraw (ctx, ignoreCache) {\n\t\tif (this.drawCache(ctx, ignoreCache)) { return; }\n\t\tthis._updateState();\n\t\tsuper.draw(ctx, ignoreCache);\n\t}\n\n\tgetBounds () {\n\t\tthis._updateText();\n\t\treturn super.getBounds();\n\t}\n\n\tisVisible () {\n\t\tlet hasContent = this.cacheCanvas || (this.spriteSheet && this.spriteSheet.complete && this.text);\n\t\treturn !!(this.visible && this.alpha > 0 && this.scaleX !== 0 && this.scaleY !== 0 && hasContent);\n\t}\n\n\tclone () {\n\t\treturn this._cloneProps(new BitmapText(this.text, this.spriteSheet));\n\t}\n\n\t/**\n\t * Disabled in BitmapText.\n\t */\n\taddChild () {}\n\n\t/**\n\t * Disabled in BitmapText.\n\t */\n\taddChildAt () {}\n\n\t/**\n\t * Disabled in BitmapText.\n\t */\n\tremoveChild () {}\n\n\t/**\n\t * Disabled in BitmapText.\n\t */\n\tremoveChildAt () {}\n\n\t/**\n\t * Disabled in BitmapText.\n\t */\n\tremoveAllChildren () {}\n\n\t_updateState () {\n\t\tthis._updateText();\n\t}\n\n \t/**\n\t * @param {easeljs.BitmapText} o\n\t * @return {easeljs.BitmapText}\n\t * @protected\n\t */\n\t_cloneProps (o) {\n\t\tsuper._cloneProps(o);\n\t\to.lineHeight = this.lineHeight;\n\t\to.letterSpacing = this.letterSpacing;\n\t\to.spaceWidth = this.spaceWidth;\n\t\treturn o;\n\t}\n\n\t/**\n\t * @param {String} character\n\t * @param {easeljs.SpriteSheet} spriteSheet\n\t * @return {Number}\n\t * @protected\n\t */\n\t_getFrameIndex (character, spriteSheet) {\n\t\tlet c, o = spriteSheet.getAnimation(character);\n\t\tif (!o) {\n\t\t\t(character != (c = character.toUpperCase())) || (character != (c = character.toLowerCase())) || (c = null);\n\t\t\tif (c) { o = spriteSheet.getAnimation(c); }\n\t\t}\n\t\treturn o && o.frames[0];\n\t}\n\n\t/**\n\t * @param {String} character\n\t * @param {easeljs.SpriteSheet} spriteSheet\n\t * @return {Object}\n\t * @protected\n\t */\n\t_getFrame (character, spriteSheet) {\n\t\tlet index = this._getFrameIndex(character, spriteSheet);\n\t\treturn index == null ? index : spriteSheet.getFrame(index);\n\t}\n\n\t/**\n\t * @param {easeljs.SpriteSheet} ss\n\t * @return {Number}\n\t * @protected\n\t */\n\t_getLineHeight (ss) {\n\t\tlet frame = this._getFrame(\"1\", ss) || this._getFrame(\"T\", ss) || this._getFrame(\"L\", ss) || ss.getFrame(0);\n\t\treturn frame ? frame.rect.height : 1;\n\t}\n\n\t/**\n\t * @param {easeljs.SpriteSheet} ss\n\t * @return {Number}\n\t * @protected\n\t */\n\t_getSpaceWidth (ss) {\n\t\tlet frame = this._getFrame(\"1\", ss) || this._getFrame(\"l\", ss) || this._getFrame(\"e\", ss) || this._getFrame(\"a\", ss) || ss.getFrame(0);\n\t\treturn frame ? frame.rect.width : 1;\n\t}\n\n\t_tick (evtObj) {\n\t\tlet stage = this.stage;\n\t\tstage && stage.on(\"drawstart\", this._updateText, this, true);\n\t\tsuper._tick(evtObj);\n\t}\n\n\t/**\n\t * @protected\n\t */\n\t_updateText () {\n\t\tlet x = 0, y = 0, o = this._oldProps, change = false, spaceW = this.spaceWidth, lineH = this.lineHeight, ss = this.spriteSheet;\n\t\tlet pool = BitmapText._spritePool, kids = this.children, childIndex = 0, numKids = kids.length, sprite;\n\n\t\tfor (let n in o) {\n\t\t\tif (o[n] != this[n]) {\n\t\t\t\to[n] = this[n];\n\t\t\t\tchange = true;\n\t\t\t}\n\t\t}\n\t\tif (!change) { return; }\n\n\t\tlet hasSpace = !!this._getFrame(\" \", ss);\n\t\tif (!hasSpace && !spaceW) { spaceW = this._getSpaceWidth(ss); }\n\t\tif (!lineH) { lineH = this._getLineHeight(ss); }\n\n\t\tfor (let i = 0, l = this.text.length; i < l; i++) {\n\t\t\tlet character = this.text.charAt(i);\n\t\t\tif (character === \" \" && !hasSpace) {\n\t\t\t\tx += spaceW;\n\t\t\t\tcontinue;\n\t\t\t} else if (character === \"\\n\" || character === \"\\r\") {\n\t\t\t\tif (character === \"\\r\" && this.text.charAt(i+1) === \"\\n\") { i++; } // crlf\n\t\t\t\tx = 0;\n\t\t\t\ty += lineH;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlet index = this._getFrameIndex(character, ss);\n\t\t\tif (index == null) { continue; }\n\n\t\t\tif (childIndex < numKids) {\n\t\t\t\tsprite = kids[childIndex];\n\t\t\t} else {\n\t\t\t\tkids.push(sprite = pool.length ? pool.pop() : new Sprite());\n\t\t\t\tsprite.parent = this;\n\t\t\t\tnumKids++;\n\t\t\t}\n\t\t\tsprite.spriteSheet = ss;\n\t\t\tsprite.gotoAndStop(index);\n\t\t\tsprite.x = x;\n\t\t\tsprite.y = y;\n\t\t\tchildIndex++;\n\n\t\t\tx += sprite.getBounds().width + this.letterSpacing;\n\t\t}\n\n\t\twhile (numKids > childIndex) {\n\t\t\t // faster than removeChild.\n\t\t\tpool.push(sprite = kids.pop());\n\t\t\tsprite.parent = null;\n\t\t\tnumKids--;\n\t\t}\n\t\tif (pool.length > BitmapText.maxPoolSize) { pool.length = BitmapText.maxPoolSize; }\n\t}\n\n}\n\n/**\n * BitmapText uses Sprite instances to draw text. To reduce the creation and destruction of instances (and thus garbage collection), it maintains\n * an internal object pool of sprite instances to reuse. Increasing this value can cause more sprites to be\n * retained, slightly increasing memory use, but reducing instantiation.\n * @type {Number}\n * @static\n * @default 100\n */\nBitmapText.maxPoolSize = 100;\n/**\n * Sprite object pool.\n * @type {Array}\n * @static\n * @private\n * @readonly\n */\nBitmapText._spritePool = [];\n","/**\n * @license DOMElement\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport DisplayObject from \"./DisplayObject\";\nimport DisplayProps from \"../geom/DisplayProps\";\n\n/**\n * This class is still experimental, and more advanced use is likely to be buggy. Please report bugs.\n *\n * A DOMElement allows you to associate a HTMLElement with the display list. It will be transformed\n * within the DOM as though it is child of the {{#crossLink \"Container\"}}{{/crossLink}} it is added to. However, it is\n * not rendered to canvas, and as such will retain whatever z-index it has relative to the canvas (ie. it will be\n * drawn in front of or behind the canvas).\n *\n * The position of a DOMElement is relative to their parent node in the DOM. It is recommended that\n * the DOM Object be added to a div that also contains the canvas so that they share the same position\n * on the page.\n *\n * DOMElement is useful for positioning HTML elements over top of canvas content, and for elements\n * that you want to display outside the bounds of the canvas. For example, a tooltip with rich HTML\n * content.\n *\n *
Mouse Interaction
\n *\n * DOMElement instances are not full EaselJS display objects, and do not participate in EaselJS mouse\n * events or support methods like hitTest. To get mouse events from a DOMElement, you must instead add handlers to\n * the htmlElement (note, this does not support EventDispatcher)\n *\n * var domElement = new createjs.DOMElement(htmlElement);\n * domElement.htmlElement.onclick = function() {\n * console.log(\"clicked\");\n * }\n *\n * Important: This class needs to be notified it is about to be drawn, this will happen automatically\n * if you call stage.update, calling stage.draw or disabling tickEnabled will miss important steps and it will render\n * stale information.\n *\n * @memberof easeljs\n * @extends DisplayObject\n * @param {HTMLElement | String} htmlElement A reference or id for the DOM element to manage.\n */\nexport default class DOMElement extends DisplayObject {\n\n\tconstructor (htmlElement) {\n\t\tsuper();\n\n\t\tif (typeof htmlElement === \"string\") { htmlElement = document.getElementById(htmlElement); }\n\t\tthis.mouseEnabled = false;\n\n\t\tlet style = htmlElement.style;\n\t\tstyle.position = \"absolute\";\n\t\tstyle.transformOrigin = style.WebkitTransformOrigin = style.msTransformOrigin = style.MozTransformOrigin = style.OTransformOrigin = \"0% 0%\";\n\n\t\t/**\n\t\t * The DOM object to manage.\n\t\t * @type {HTMLElement}\n\t\t */\n\t\tthis.htmlElement = htmlElement;\n\n\t\t/**\n\t\t * @type {easeljs.Matrix2D}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis._oldProps = null;\n\n\t\t/**\n\t\t * Used to track the object which this class attached listeners to, helps optimize listener attachment.\n\t\t * @type {easeljs.Stage}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis._oldStage = null;\n\t\t/**\n\t\t * The event listener proxy triggered drawing draw for special circumstances.\n\t\t * @type {Function}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis._drawAction = null;\n\t}\n\n\tisVisible () {\n\t\treturn this.htmlElement != null;\n\t}\n\n\tdraw (ctx, ignoreCache) {\n\t\t// this relies on the _tick method because draw isn't called if the parent is not visible.\n\t\t// the actual update happens in _handleDrawEnd\n\t\treturn true;\n\t}\n\n\t/**\n\t * Disabled in DOMElement.\n\t */\n\tcache () {}\n\n\t/**\n\t * Disabled in DOMElement.\n\t */\n\tuncache () {}\n\n\t/**\n\t * Disabled in DOMElement.\n\t */\n\tupdateCache () {}\n\n\t/**\n\t * Disabled in DOMElement.\n\t */\n\thitTest () {}\n\n\t/**\n\t * Disabled in DOMElement.\n\t */\n\tlocalToGlobal () {}\n\n\t/**\n\t * Disabled in DOMElement.\n\t */\n\tglobalToLocal () {}\n\n\t/**\n\t * Disabled in DOMElement.\n\t */\n\tlocalToLocal () {}\n\n\t/**\n\t * DOMElement cannot be cloned.\n\t * @throws DOMElement cannot be cloned\n\t */\n\tclone () {\n\t\tthrow \"DOMElement cannot be cloned.\";\n\t}\n\n\t_tick (evtObj) {\n\t\tlet stage = this.stage;\n\t\tif (stage != null && stage !== this._oldStage) {\n\t\t\tthis._drawAction && stage.off(\"drawend\", this._drawAction);\n\t\t\tthis._drawAction = stage.on(\"drawend\", this._handleDrawEnd, this);\n\t\t\tthis._oldStage = stage;\n\t\t}\n\t\tsuper._tick(evtObj);\n\t}\n\n\t/**\n\t * @param {core.Event} evt\n\t * @protected\n\t */\n\t_handleDrawEnd (evt) {\n\t\tlet o = this.htmlElement;\n\t\tif (!o) { return; }\n\t\tlet style = o.style;\n\n\t\tlet props = this.getConcatenatedDisplayProps(this._props), mtx = props.matrix;\n\n\t\tlet visibility = props.visible ? \"visible\" : \"hidden\";\n\t\tif (visibility != style.visibility) { style.visibility = visibility; }\n\t\tif (!props.visible) { return; }\n\n\t\tlet oldProps = this._oldProps, oldMtx = oldProps&&oldProps.matrix;\n\t\tlet n = 10000; // precision\n\n\t\tif (!oldMtx || !oldMtx.equals(mtx)) {\n\t\t\tlet str = \"matrix(\" + (mtx.a*n|0)/n +\",\"+ (mtx.b*n|0)/n +\",\"+ (mtx.c*n|0)/n +\",\"+ (mtx.d*n|0)/n +\",\"+ (mtx.tx+0.5|0);\n\t\t\tstyle.transform = style.WebkitTransform = style.OTransform = style.msTransform = str +\",\"+ (mtx.ty+0.5|0) +\")\";\n\t\t\tstyle.MozTransform = str +\"px,\"+ (mtx.ty+0.5|0) +\"px)\";\n\t\t\tif (!oldProps) { oldProps = this._oldProps = new DisplayProps(true, null); }\n\t\t\toldProps.matrix.copy(mtx);\n\t\t}\n\n\t\tif (oldProps.alpha != props.alpha) {\n\t\t\tstyle.opacity = \"\"+(props.alpha*n|0)/n;\n\t\t\toldProps.alpha = props.alpha;\n\t\t}\n\t}\n\n}\n\n/**\n * Interaction events should be added to `htmlElement`, and not the DOMElement instance, since DOMElement instances\n * are not full EaselJS display objects and do not participate in EaselJS mouse events.\n * @event easeljs.DOMElement#click\n */\n\n/**\n * Interaction events should be added to `htmlElement`, and not the DOMElement instance, since DOMElement instances\n * are not full EaselJS display objects and do not participate in EaselJS mouse events.\n * @event easeljs.DOMElement#dblClick\n */\n\n/**\n * Interaction events should be added to `htmlElement`, and not the DOMElement instance, since DOMElement instances\n * are not full EaselJS display objects and do not participate in EaselJS mouse events.\n * @event easeljs.DOMElement#mousedown\n */\n\n/**\n * Interaction events should be added to `htmlElement`, and not the DOMElement instance, since DOMElement instances\n * are not full EaselJS display objects and do not participate in EaselJS mouse events.\n * @event easeljs.DOMElement#mouseover\n */\n\n/**\n * Disabled in DOMElement.\n * @event easeljs.DOMElement#tick\n */\n","/**\n * @license Graphics\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport createCanvas from \"../utils/Canvas\";\n\n/**\n * The Graphics class exposes an easy to use API for generating vector drawing instructions and drawing them to a\n * specified context. Note that you can use Graphics without any dependency on the EaselJS framework by calling {@link easeljs.Graphics#draw}\n * directly, or it can be used with the {@link easeljs.Shape} object to draw vector graphics within the\n * context of an EaselJS display list.\n *\n * There are two approaches to working with Graphics object: calling methods on a Graphics instance (the \"Graphics API\"), or\n * instantiating Graphics command objects and adding them to the graphics queue via {@link easeljs.Graphics#append}.\n * The former abstracts the latter, simplifying beginning and ending paths, fills, and strokes.\n *\n *
Tiny API
\n * The Graphics class also includes a \"tiny API\", which is one or two-letter methods that are shortcuts for all of the\n * Graphics methods. These methods are great for creating compact instructions, and is used by the Toolkit for CreateJS\n * to generate readable code. All tiny methods are marked as protected, so you can view them by enabling protected\n * descriptions in the docs.\n *\n *
\n *\n * @example\n * var g = new createjs.Graphics();\n * g.setStrokeStyle(1);\n * g.beginStroke(\"#000000\");\n * g.beginFill(\"red\");\n * g.drawCircle(0,0,30);\n *\n * @example\n * // All drawing methods in Graphics return the Graphics instance, so they can be chained together.\n * graphics.beginStroke(\"red\").beginFill(\"blue\").drawRect(20, 20, 100, 50);\n *\n * @example\n * // Each graphics API call generates a command object (see below). The last command to be created can be accessed via .command\n * let fillCommand = graphics.beginFill(\"red\").command;\n * fillCommand.style = \"blue\";\n * // or change it to a bitmap fill:\n * fillCommand.bitmap(img);\n *\n * @example\n * // For more direct control of rendering, you can instantiate and append command objects to the graphics queue directly.\n * // In this case, you need to manage path creation manually, and ensure that fill/stroke is applied to a defined path:\n *\n * // start a new path. Graphics.beginCmd is a reusable BeginPath instance:\n * graphics.append(Graphics.beginCmd);\n * // we need to define the path before applying the fill:\n * let circle = new Graphics.Circle(0,0,30);\n * graphics.append(circle);\n * // fill the path we just defined:\n * let fill = new Graphics.Fill(\"red\");\n * graphics.append(fill);\n *\n * // These approaches can be used together, for example to insert a custom command:\n * graphics.beginFill(\"red\");\n * let customCommand = new CustomSpiralCommand(etc);\n * graphics.append(customCommand);\n * graphics.beginFill(\"blue\");\n * graphics.drawCircle(0, 0, 30);\n *\n * @example
Using the Tiny API
\n * graphics.s(\"red\").f(\"blue\").r(20, 20, 100, 50);\n *\n * @see {@link easeljs.Graphics#append}\n * @memberof easeljs\n */\nexport default class Graphics {\n\n\tconstructor () {\n\t\t/**\n\t\t * Holds a reference to the last command that was created or appended. For example, you could retain a reference\n\t\t * to a Fill command in order to dynamically update the color later by using:\n\t\t *\n\t\t * @example\n\t\t * let fill = graphics.beginFill(\"red\").command;\n\t\t * // update color later:\n\t\t * fill.style = \"yellow\";\n\t\t *\n\t\t * @type {Object}\n\t\t * @default null\n\t\t */\n\t\tthis.command = null;\n\n\n\t// private properties\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.Graphics.Stroke}\n\t\t */\n\t\tthis._stroke = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.Graphics.StrokeStyle}\n\t\t */\n\t\tthis._strokeStyle = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.Graphics.StrokeStyle}\n\t\t */\n\t\tthis._oldStrokeStyle = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.Graphics.StrokeDash}\n\t\t */\n\t\tthis._strokeDash = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.Graphics.StrokeDash}\n\t\t */\n\t\tthis._oldStrokeDash = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.Graphics.Fill}\n\t\t */\n\t\tthis._fill = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis._strokeIgnoreScale = false;\n\n\t\t/**\n\t\t * Indicates the last instruction index that was committed.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis._commitIndex = 0;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Array}\n\t\t */\n\t\tthis._instructions = [];\n\n\t\t/**\n\t\t * Uncommitted instructions.\n\t\t * @protected\n\t\t * @type {Array}\n\t\t */\n\t\tthis._activeInstructions = [];\n\n\t\t/**\n\t\t * This indicates that there have been changes to the activeInstruction list since the last updateInstructions call.\n\t\t * @protected\n\t\t * @type {Boolean}\n\t\t * @default false\n\t\t */\n\t\tthis._dirty = false;\n\n\t\t/**\n\t\t * Index to draw from if a store operation has happened.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis._storeIndex = 0;\n\n\t\t/**\n\t\t * Maps the familiar ActionScript `curveTo()` method to the functionally similar {@link easeljs.Graphics#quadraticCurveTo} method.\n\t\t * @param {Number} cpx\n\t\t * @param {Number} cpy\n\t\t * @param {Number} x\n\t\t * @param {Number} y\n\t\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t\t * @chainable\n\t\t */\n\t\tthis.curveTo = this.quadraticCurveTo;\n\n\t\t/**\n\t\t * Maps the familiar ActionScript `drawRect()` method to the functionally similar {@link easeljs.Graphics#rect} method.\n\t\t * @param {Number} x\n\t\t * @param {Number} y\n\t\t * @param {Number} w Width of the rectangle\n\t\t * @param {Number} h Height of the rectangle\n\t\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t\t * @chainable\n\t\t */\n\t\tthis.drawRect = this.rect;\n\n\t\t// tiny api\n\t\tthis.mt = this.moveTo;\n\t\tthis.lt = this.lineTo;\n\t\tthis.at = this.arcTo;\n\t\tthis.bt = this.bezierCurveTo;\n\t\tthis.qt = this.quadraticCurveTo;\n\t\tthis.a = this.arc;\n\t\tthis.r = this.rect;\n\t\tthis.cp = this.closePath;\n\t\tthis.c = this.clear;\n\t\tthis.f = this.beginFill;\n\t\tthis.lf = this.beginLinearGradientFill;\n\t\tthis.rf = this.beginRadialGradientFill;\n\t\tthis.bf = this.beginBitmapFill;\n\t\tthis.ef = this.endFill;\n\t\tthis.ss = this.setStrokeStyle;\n\t\tthis.sd = this.setStrokeDash;\n\t\tthis.s = this.beginStroke;\n\t\tthis.ls = this.beginLinearGradientStroke;\n\t\tthis.rs = this.beginRadialGradientStroke;\n\t\tthis.bs = this.beginBitmapStroke;\n\t\tthis.es = this.endStroke;\n\t\tthis.dr = this.drawRect;\n\t\tthis.rr = this.drawRoundRect;\n\t\tthis.rc = this.drawRoundRectComplex;\n\t\tthis.dc = this.drawCircle;\n\t\tthis.de = this.drawEllipse;\n\t\tthis.dp = this.drawPolyStar;\n\t\tthis.p = this.decodePath;\n\n\t\tthis.clear();\n\t}\n\n\t/**\n\t * Returns a CSS compatible color string based on the specified RGB numeric color values in the format\n\t * \"rgba(255,255,255,1.0)\", or if alpha is null then in the format \"rgb(255,255,255)\".\n\t * It also supports passing a single hex color value as the first param, and an optional alpha value as the second\n\t * param.\n\t *\n\t * @example\n\t * Graphics.getRGB(50, 100, 150, 0.5); // rgba(50,100,150,0.5)\n\t * Graphics.getRGB(0xFF00FF, 0.2); // rgba(255,0,255,0.2)\n\t *\n\t * @static\n\t * @param {Number} r The red component for the color, between 0 and 0xFF (255).\n\t * @param {Number} g The green component for the color, between 0 and 0xFF (255).\n\t * @param {Number} b The blue component for the color, between 0 and 0xFF (255).\n\t * @param {Number} [alpha] The alpha component for the color where 0 is fully transparent and 1 is fully opaque.\n\t * @return {String} A CSS compatible color string based on the specified RGB numeric color values in the format\n\t * \"rgba(255,255,255,1.0)\", or if alpha is null then in the format \"rgb(255,255,255)\".\n\t */\n\tstatic getRGB (r, g, b, alpha) {\n\t\tif (r != null && b == null) {\n\t\t\talpha = g;\n\t\t\tb = r&0xFF;\n\t\t\tg = r>>8&0xFF;\n\t\t\tr = r>>16&0xFF;\n\t\t}\n\t\tif (alpha == null) {\n\t\t\treturn `rgb(${r},${g},${b})`;\n\t\t} else {\n\t\t\treturn `rgba(${r},${g},${b},${alpha})`;\n\t\t}\n\t}\n\n\t/**\n\t * Returns a CSS compatible color string based on the specified HSL numeric color values in the format \"hsla(360,100,100,1.0)\",\n\t * or if alpha is null then in the format \"hsl(360,100,100)\".\n\t *\n\t * @example\n\t * Graphics.getHSL(150, 100, 70); // hsl(150,100,70)\n\t *\n\t * @static\n\t * @param {Number} hue The hue component for the color, between 0 and 360.\n\t * @param {Number} saturation The saturation component for the color, between 0 and 100.\n\t * @param {Number} lightness The lightness component for the color, between 0 and 100.\n\t * @param {Number} [alpha] The alpha component for the color where 0 is fully transparent and 1 is fully opaque.\n\t * @return {String} A CSS compatible color string based on the specified HSL numeric color values in the format\n\t * \"hsla(360,100,100,1.0)\", or if alpha is null then in the format \"hsl(360,100,100)\".\n\t */\n\tstatic getHSL (hue, saturation, lightness, alpha) {\n\t\tif (alpha == null) {\n\t\t\treturn `hsl(${hue % 360},${saturation}%,${lightness}%)`;\n\t\t} else {\n\t\t\treturn `hsl(${hue % 360},${saturation}%,${lightness}%,${alpha})`;\n\t\t}\n\t}\n\n\t/**\n\t * Returns the graphics instructions array. Each entry is a graphics command object (ex. Graphics.Fill, Graphics.Rect)\n\t * Modifying the returned array directly is not recommended, and is likely to result in unexpected behaviour.\n\t *\n\t * This property is mainly intended for introspection of the instructions (ex. for graphics export).\n\t * @type {Array}\n\t * @readonly\n\t */\n\tget instructions () {\n\t\tthis._updateInstructions();\n\t\treturn this._instructions;\n\t}\n\n\t/**\n\t * Returns true if this Graphics instance has no drawing commands.\n\t * @return {Boolean} Returns true if this Graphics instance has no drawing commands.\n\t */\n\tisEmpty () {\n\t\treturn !(this._instructions.length || this._activeInstructions.length);\n\t}\n\n\t/**\n\t * Draws the display object into the specified context ignoring its visible, alpha, shadow, and transform.\n\t * Returns true if the draw was handled (useful for overriding functionality).\n\t *\n\t * NOTE: This method is mainly for internal use, though it may be useful for advanced uses.\n\t *\n\t * @param {CanvasRenderingContext2D} ctx The canvas 2D context object to draw into.\n\t * @param {Object} data Optional data that is passed to graphics command exec methods. When called from a Shape instance, the shape passes itself as the data parameter. This can be used by custom graphic commands to insert contextual data.\n\t */\n\tdraw (ctx, data) {\n\t\tthis._updateInstructions();\n\t\tlet instr = this._instructions;\n\t\tconst l = instr.length;\n\t\tfor (let i = this._storeIndex; i < l; i++) {\n\t\t\tinstr[i].exec(ctx, data);\n\t\t}\n\t}\n\n\t/**\n\t * Draws only the path described for this Graphics instance, skipping any non-path instructions, including fill and\n\t * stroke descriptions. Used for `DisplayObject.mask` to draw the clipping path, for example.\n\t *\n\t * NOTE: This method is mainly for internal use, though it may be useful for advanced uses.\n\t *\n\t * @param {CanvasRenderingContext2D} ctx The canvas 2D context object to draw into.\n\t */\n\tdrawAsPath (ctx) {\n\t\tthis._updateInstructions();\n\t\tlet instr, instrs = this._instructions;\n\t\tconst l = instrs.length;\n\t\tfor (let i = this._storeIndex; i < l; i++) {\n\t\t\t// the first command is always a beginPath command.\n\t\t\tif ((instr = instrs[i]).path !== false) { instr.exec(ctx); }\n\t\t}\n\t}\n\n\t/**\n\t * Moves the drawing point to the specified position.\n\t * A tiny API method \"mt\" also exists.\n\t * @param {Number} x The x coordinate the drawing point should move to.\n\t * @param {Number} y The y coordinate the drawing point should move to.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls).\n\t * @chainable\n\t */\n\tmoveTo (x, y) {\n\t\treturn this.append(new MoveTo(x,y), true);\n\t}\n\n\t/**\n\t * Draws a line from the current drawing point to the specified position, which become the new current drawing\n\t * point. Note that you *must* call {@link easeljs.Graphics#moveTo} before the first `lineTo()`.\n\t * A tiny API method \"lt\" also exists.\n\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#complex-shapes-(paths) \"WHATWG spec\"}\n\t * @param {Number} x The x coordinate the drawing point should draw to.\n\t * @param {Number} y The y coordinate the drawing point should draw to.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tlineTo (x, y) {\n\t\treturn this.append(new LineTo(x,y));\n\t}\n\n\t/**\n\t * Draws an arc with the specified control points and radius.\n\t * A tiny API method \"at\" also exists.\n\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-arcto \"WHATWG spec\"}\n\t * @param {Number} x1\n\t * @param {Number} y1\n\t * @param {Number} x2\n\t * @param {Number} y2\n\t * @param {Number} radius\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tarcTo (x1, y1, x2, y2, radius) {\n\t\treturn this.append(new ArcTo(x1, y1, x2, y2, radius));\n\t}\n\n\t/**\n\t * Draws an arc defined by the radius, startAngle and endAngle arguments, centered at the position (x, y).\n\t * A tiny API method \"a\" also exists.\n\t *\n\t * @example\n\t * // draw a full circle with a radius of 20 centered at (100, 100)\n\t * arc(100, 100, 20, 0, Math.PI*2);\n\t *\n\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-arc \"WHATWG spec\"}\n\t * @param {Number} x\n\t * @param {Number} y\n\t * @param {Number} radius\n\t * @param {Number} startAngle Measured in radians.\n\t * @param {Number} endAngle Measured in radians.\n\t * @param {Boolean} anticlockwise\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tarc (x, y, radius, startAngle, endAngle, anticlockwise) {\n\t\treturn this.append(new Arc(x, y, radius, startAngle, endAngle, anticlockwise));\n\t}\n\n\t/**\n\t * Draws a quadratic curve from the current drawing point to (x, y) using the control point (cpx, cpy).\n\t * A tiny API method \"qt\" also exists.\n\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-quadraticcurveto \"WHATWG spec\"}\n\t * @param {Number} cpx\n\t * @param {Number} cpy\n\t * @param {Number} x\n\t * @param {Number} y\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tquadraticCurveTo (cpx, cpy, x, y) {\n\t\treturn this.append(new QuadraticCurveTo(cpx, cpy, x, y));\n\t}\n\n\t/**\n\t * Draws a bezier curve from the current drawing point to (x, y) using the control points (cp1x, cp1y) and (cp2x, cp2y).\n\t * A tiny API method \"bt\" also exists.\n\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-beziercurveto \"WHATWG spec\"}\n\t * @param {Number} cp1x\n\t * @param {Number} cp1y\n\t * @param {Number} cp2x\n\t * @param {Number} cp2y\n\t * @param {Number} x\n\t * @param {Number} y\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tbezierCurveTo (cp1x, cp1y, cp2x, cp2y, x, y) {\n\t\treturn this.append(new BezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y));\n\t}\n\n\t/**\n\t * Draws a rectangle at (x, y) with the specified width and height using the current fill and/or stroke.\n\t * A tiny API method \"r\" also exists.\n\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-rect \"WHATWG spec\"}\n\t * @param {Number} x\n\t * @param {Number} y\n\t * @param {Number} w Width of the rectangle\n\t * @param {Number} h Height of the rectangle\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\trect (x, y, w, h) {\n\t\treturn this.append(new Rect(x, y, w, h));\n\t}\n\n\t/**\n\t * Closes the current path, effectively drawing a line from the current drawing point to the first drawing point specified\n\t * since the fill or stroke was last set.\n\t * A tiny API method \"cp\" also exists.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tclosePath () {\n\t\treturn this._activeInstructions.length ? this.append(new ClosePath()) : this;\n\t}\n\n\t/**\n\t * Clears all drawing instructions, effectively resetting this Graphics instance. Any line and fill styles will need\n\t * to be redefined to draw shapes following a clear call.\n\t * A tiny API method \"c\" also exists.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tclear () {\n\t\tthis._instructions.length = this._activeInstructions.length = this._commitIndex = 0;\n\t\tthis._strokeStyle = this._oldStrokeStyle = this._stroke = this._fill = this._strokeDash = this._oldStrokeDash = null;\n\t\tthis._dirty = this._strokeIgnoreScale = false;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Begins a fill with the specified color. This ends the current sub-path.\n\t * A tiny API method \"f\" also exists.\n\t * @param {String} color A CSS compatible color value (ex. \"red\", \"#FF0000\", or \"rgba(255,0,0,0.5)\"). Setting to\n\t * null will result in no fill.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tbeginFill (color) {\n\t\treturn this._setFill(color ? new Fill(color) : null);\n\t}\n\n\t/**\n\t * Begins a linear gradient fill defined by the line (x0, y0) to (x1, y1).\n\t * A tiny API method \"lf\" also exists.\n\t *\n\t * @example
Define a black to white vertical gradient ranging from 20px to 120px, and draw a square to display it
\n\t * graphics.beginLinearGradientFill([\"#000\",\"#FFF\"], [0, 1], 0, 20, 0, 120).drawRect(20, 20, 120, 120);\n\t *\n\t * @param {Array} colors An array of CSS compatible color values. For example, [\"#F00\",\"#00F\"] would define a gradient\n\t * drawing from red to blue.\n\t * @param {Array} ratios An array of gradient positions which correspond to the colors. For example, [0.1, 0.9] would draw\n\t * the first color to 10% then interpolating to the second color at 90%.\n\t * @param {Number} x0 The position of the first point defining the line that defines the gradient direction and size.\n\t * @param {Number} y0 The position of the first point defining the line that defines the gradient direction and size.\n\t * @param {Number} x1 The position of the second point defining the line that defines the gradient direction and size.\n\t * @param {Number} y1 The position of the second point defining the line that defines the gradient direction and size.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tbeginLinearGradientFill (colors, ratios, x0, y0, x1, y1) {\n\t\treturn this._setFill(new Fill().linearGradient(colors, ratios, x0, y0, x1, y1));\n\t}\n\n\t/**\n\t * Begins a radial gradient fill. This ends the current sub-path.\n\t * A tiny API method \"rf\" also exists.\n\t *\n\t * @example
Define a red to blue radial gradient centered at (100, 100), with a radius of 50, and draw a circle to display it
\n\t * graphics.beginRadialGradientFill([\"#F00\",\"#00F\"], [0, 1], 100, 100, 0, 100, 100, 50).drawCircle(100, 100, 50);\n\t *\n\t * @param {Array} colors An array of CSS compatible color values. For example, [\"#F00\",\"#00F\"] would define\n\t * a gradient drawing from red to blue.\n\t * @param {Array} ratios An array of gradient positions which correspond to the colors. For example, [0.1,\n\t * 0.9] would draw the first color to 10% then interpolating to the second color at 90%.\n\t * @param {Number} x0 Center position of the inner circle that defines the gradient.\n\t * @param {Number} y0 Center position of the inner circle that defines the gradient.\n\t * @param {Number} r0 Radius of the inner circle that defines the gradient.\n\t * @param {Number} x1 Center position of the outer circle that defines the gradient.\n\t * @param {Number} y1 Center position of the outer circle that defines the gradient.\n\t * @param {Number} r1 Radius of the outer circle that defines the gradient.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tbeginRadialGradientFill (colors, ratios, x0, y0, r0, x1, y1, r1) {\n\t\treturn this._setFill(new Fill().radialGradient(colors, ratios, x0, y0, r0, x1, y1, r1));\n\t}\n\n\t/**\n\t * Begins a pattern fill using the specified image. This ends the current sub-path.\n\t * A tiny API method \"bf\" also exists.\n\t * @param {HTMLImageElement | HTMLCanvasElement | HTMLVideoElement} image The Image, Canvas, or Video object to use\n\t * as the pattern. Must be loaded prior to creating a bitmap fill, or the fill will be empty.\n\t * @param {String} repetition Optional. Indicates whether to repeat the image in the fill area. One of \"repeat\",\n\t * \"repeat-x\", \"repeat-y\", or \"no-repeat\". Defaults to \"repeat\". Note that Firefox does not support \"repeat-x\" or\n\t * \"repeat-y\" (latest tests were in FF 20.0), and will default to \"repeat\".\n\t * @param {easeljs.Matrix2D} matrix Optional. Specifies a transformation matrix for the bitmap fill. This transformation\n\t * will be applied relative to the parent transform.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tbeginBitmapFill (image, repetition, matrix) {\n\t\treturn this._setFill(new Fill(null, matrix).bitmap(image, repetition));\n\t}\n\n\t/**\n\t * Ends the current sub-path, and begins a new one with no fill. Functionally identical to `beginFill(null)`.\n\t * A tiny API method \"ef\" also exists.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tendFill () {\n\t\treturn this.beginFill();\n\t}\n\n\t/**\n\t * Sets the stroke style.\n\t * A tiny API method \"ss\" also exists.\n\t *\n\t * @example\n\t * graphics.setStrokeStyle(8,\"round\").beginStroke(\"#F00\");\n\t *\n\t * @param {Number} thickness The width of the stroke.\n\t * @param {String | Number} [caps=0] Indicates the type of caps to use at the end of lines. One of butt,\n\t * round, or square. Defaults to \"butt\". Also accepts the values 0 (butt), 1 (round), and 2 (square) for use with\n\t * the tiny API.\n\t * @param {String | Number} [joints=0] Specifies the type of joints that should be used where two lines meet.\n\t * One of bevel, round, or miter. Defaults to \"miter\". Also accepts the values 0 (miter), 1 (round), and 2 (bevel)\n\t * for use with the tiny API.\n\t * @param {Number} [miterLimit=10] If joints is set to \"miter\", then you can specify a miter limit ratio which\n\t * controls at what point a mitered joint will be clipped.\n\t * @param {Boolean} [ignoreScale=false] If true, the stroke will be drawn at the specified thickness regardless\n\t * of active transformations.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tsetStrokeStyle (thickness, caps = 0, joints = 0, miterLimit = 10, ignoreScale = false) {\n\t\tthis._updateInstructions(true);\n\t\tthis._strokeStyle = this.command = new StrokeStyle(thickness, caps, joints, miterLimit, ignoreScale);\n\n\t\t// ignoreScale lives on Stroke, not StrokeStyle, so we do a little trickery:\n\t\tif (this._stroke) { this._stroke.ignoreScale = ignoreScale; }\n\t\tthis._strokeIgnoreScale = ignoreScale;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets or clears the stroke dash pattern.\n\t * A tiny API method `sd` also exists.\n\t *\n\t * @example\n\t * graphics.setStrokeDash([20, 10], 0);\n\t *\n\t * @param {Array} [segments] An array specifying the dash pattern, alternating between line and gap.\n\t * For example, `[20,10]` would create a pattern of 20 pixel lines with 10 pixel gaps between them.\n\t * Passing null or an empty array will clear the existing stroke dash.\n\t * @param {Number} [offset=0] The offset of the dash pattern. For example, you could increment this value to create a \"marching ants\" effect.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tsetStrokeDash (segments, offset = 0) {\n\t\tthis._updateInstructions(true);\n\t\tthis._strokeDash = this.command = new StrokeDash(segments, offset);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Begins a stroke with the specified color. This ends the current sub-path.\n\t * A tiny API method \"s\" also exists.\n\t *\n\t * @param {String} color A CSS compatible color value (ex. \"#FF0000\", \"red\", or \"rgba(255,0,0,0.5)\"). Setting to\n\t * null will result in no stroke.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tbeginStroke (color) {\n\t\treturn this._setStroke(color ? new Stroke(color) : null);\n\t}\n\n\t/**\n\t * Begins a linear gradient stroke defined by the line (x0, y0) to (x1, y1). This ends the current sub-path.\n\t * A tiny API method \"ls\" also exists.\n\t *\n\t * @example
Define a black to white vertical gradient ranging from 20px to 120px, and draw a square to display it
\n\t * graphics.setStrokeStyle(10)\n\t * .beginLinearGradientStroke([\"#000\",\"#FFF\"], [0, 1], 0, 20, 0, 120)\n\t * .drawRect(20, 20, 120, 120);\n\t *\n\t * @param {Array} colors An array of CSS compatible color values. For example, [\"#F00\",\"#00F\"] would define\n\t * a gradient drawing from red to blue.\n\t * @param {Array} ratios An array of gradient positions which correspond to the colors. For example, [0.1,\n\t * 0.9] would draw the first color to 10% then interpolating to the second color at 90%.\n\t * @param {Number} x0 The position of the first point defining the line that defines the gradient direction and size.\n\t * @param {Number} y0 The position of the first point defining the line that defines the gradient direction and size.\n\t * @param {Number} x1 The position of the second point defining the line that defines the gradient direction and size.\n\t * @param {Number} y1 The position of the second point defining the line that defines the gradient direction and size.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tbeginLinearGradientStroke (colors, ratios, x0, y0, x1, y1) {\n\t\treturn this._setStroke(new Stroke().linearGradient(colors, ratios, x0, y0, x1, y1));\n\t}\n\n\t/**\n\t * Begins a radial gradient stroke. This ends the current sub-path.\n\t * A tiny API method \"rs\" also exists.\n\t *\n\t * @example
Define a red to blue radial gradient centered at (100, 100), with a radius of 50, and draw a rectangle to display it
\n\t * graphics.setStrokeStyle(10)\n\t * .beginRadialGradientStroke([\"#F00\",\"#00F\"], [0, 1], 100, 100, 0, 100, 100, 50)\n\t * .drawRect(50, 90, 150, 110);\n\t *\n\t * @param {Array} colors An array of CSS compatible color values. For example, [\"#F00\",\"#00F\"] would define\n\t * a gradient drawing from red to blue.\n\t * @param {Array} ratios An array of gradient positions which correspond to the colors. For example, [0.1,\n\t * 0.9] would draw the first color to 10% then interpolating to the second color at 90%, then draw the second color\n\t * to 100%.\n\t * @param {Number} x0 Center position of the inner circle that defines the gradient.\n\t * @param {Number} y0 Center position of the inner circle that defines the gradient.\n\t * @param {Number} r0 Radius of the inner circle that defines the gradient.\n\t * @param {Number} x1 Center position of the outer circle that defines the gradient.\n\t * @param {Number} y1 Center position of the outer circle that defines the gradient.\n\t * @param {Number} r1 Radius of the outer circle that defines the gradient.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tbeginRadialGradientStroke (colors, ratios, x0, y0, r0, x1, y1, r1) {\n\t\treturn this._setStroke(new Stroke().radialGradient(colors, ratios, x0, y0, r0, x1, y1, r1));\n\t}\n\n\t/**\n\t * Begins a pattern fill using the specified image. This ends the current sub-path. Note that unlike bitmap fills,\n\t * strokes do not currently support a matrix parameter due to limitations in the canvas API.\n\t * A tiny API method \"bs\" also exists.\n\t *\n\t * @param {HTMLImageElement | HTMLCanvasElement | HTMLVideoElement} image The Image, Canvas, or Video object to use\n\t * as the pattern. Must be loaded prior to creating a bitmap fill, or the fill will be empty.\n\t * @param {String} [repetition=\"repeat\"] Indicates whether to repeat the image in the fill area. One of\n\t * \"repeat\", \"repeat-x\", \"repeat-y\", or \"no-repeat\". Defaults to \"repeat\".\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tbeginBitmapStroke (image, repetition = \"repeat\") {\n\t\t// NOTE: matrix is not supported for stroke because transforms on strokes also affect the drawn stroke width.\n\t\treturn this._setStroke(new Stroke().bitmap(image, repetition));\n\t}\n\n\t/**\n\t * Ends the current sub-path, and begins a new one with no stroke. Functionally identical to `beginStroke(null)`.\n\t * A tiny API method \"es\" also exists.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tendStroke () {\n\t\treturn this.beginStroke();\n\t}\n\n\t/**\n\t * Draws a rounded rectangle with all corners with the specified radius.\n\t * @param {Number} x\n\t * @param {Number} y\n\t * @param {Number} w\n\t * @param {Number} h\n\t * @param {Number} radius Corner radius.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tdrawRoundRect (x, y, w, h, radius) {\n\t\treturn this.drawRoundRectComplex(x, y, w, h, radius, radius, radius, radius);\n\t}\n\n\t/**\n\t * Draws a rounded rectangle with different corner radii. Supports positive and negative corner radii.\n\t * A tiny API method \"rc\" also exists.\n\t * @param {Number} x The horizontal coordinate to draw the round rect.\n\t * @param {Number} y The vertical coordinate to draw the round rect.\n\t * @param {Number} w The width of the round rect.\n\t * @param {Number} h The height of the round rect.\n\t * @param {Number} radiusTL Top left corner radius.\n\t * @param {Number} radiusTR Top right corner radius.\n\t * @param {Number} radiusBR Bottom right corner radius.\n\t * @param {Number} radiusBL Bottom left corner radius.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tdrawRoundRectComplex (x, y, w, h, radiusTL, radiusTR, radiusBR, radiusBL) {\n\t\treturn this.append(new RoundRect(x, y, w, h, radiusTL, radiusTR, radiusBR, radiusBL));\n\t}\n\n\t/**\n\t * Draws a circle with the specified radius at (x, y).\n\t * A tiny API method \"dc\" also exists.\n\t *\n\t * @example\n\t * let g = new Graphics();\n\t * g.setStrokeStyle(1);\n\t * g.beginStroke(Graphics.getRGB(0,0,0));\n\t * g.beginFill(Graphics.getRGB(255,0,0));\n\t * g.drawCircle(0,0,3);\n\t * let s = new Shape(g);\n\t * s.x = 100;\n\t * s.y = 100;\n\t * stage.addChild(s);\n\t * stage.update();\n\t *\n\t * @param {Number} x x coordinate center point of circle.\n\t * @param {Number} y y coordinate center point of circle.\n\t * @param {Number} radius Radius of circle.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tdrawCircle (x, y, radius) {\n\t\treturn this.append(new Circle(x, y, radius));\n\t}\n\n\t/**\n\t * Draws an ellipse (oval) with a specified width (w) and height (h). Similar to {@link easels.Graphics#drawCircle},\n\t * except the width and height can be different.\n\t * A tiny API method \"de\" also exists.\n\t * @param {Number} x The left coordinate point of the ellipse. Note that this is different from {@link easels.Graphics#drawCircle}\n\t * which draws from center.\n\t * @param {Number} y The top coordinate point of the ellipse. Note that this is different from {@link easels.Graphics#drawCircle}\n\t * which draws from the center.\n\t * @param {Number} w The height (horizontal diameter) of the ellipse. The horizontal radius will be half of this\n\t * number.\n\t * @param {Number} h The width (vertical diameter) of the ellipse. The vertical radius will be half of this number.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tdrawEllipse (x, y, w, h) {\n\t\treturn this.append(new Ellipse(x, y, w, h));\n\t}\n\n\t/**\n\t * Draws a star if pointSize is greater than 0, or a regular polygon if pointSize is 0 with the specified number of points.\n\t * A tiny API method \"dp\" also exists.\n\t *\n\t * @example
Draw a 5 pointed star shape centered at 100, 100 and with a radius of 50
\n\t * graphics.beginFill(\"#FF0\").drawPolyStar(100, 100, 50, 5, 0.6, -90);\n\t * // Note: -90 makes the first point vertical\n\t *\n\t * @param {Number} x Position of the center of the shape.\n\t * @param {Number} y Position of the center of the shape.\n\t * @param {Number} radius The outer radius of the shape.\n\t * @param {Number} sides The number of points on the star or sides on the polygon.\n\t * @param {Number} pointSize The depth or \"pointy-ness\" of the star points. A pointSize of 0 will draw a regular\n\t * polygon (no points), a pointSize of 1 will draw nothing because the points are infinitely pointy.\n\t * @param {Number} angle The angle of the first point / corner. For example a value of 0 will draw the first point\n\t * directly to the right of the center.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tdrawPolyStar (x, y, radius, sides, pointSize, angle) {\n\t\treturn this.append(new PolyStar(x, y, radius, sides, pointSize, angle));\n\t}\n\n\t/**\n\t * Appends a graphics command object to the graphics queue. Command objects expose an \"exec\" method\n\t * that accepts two parameters: the Context2D to operate on, and an arbitrary data object passed into\n\t * {@link easeljs.Graphics#draw}. The latter will usually be the Shape instance that called draw.\n\t *\n\t * This method is used internally by Graphics methods, such as drawCircle, but can also be used directly to insert\n\t * built-in or custom graphics commands.\n\t *\n\t * @example\n\t * // attach data to our shape, so we can access it during the draw:\n\t * shape.color = \"red\";\n\t *\n\t * // append a Circle command object:\n\t * shape.graphics.append(new Graphics.Circle(50, 50, 30));\n\t *\n\t * // append a custom command object with an exec method that sets the fill style\n\t * // based on the shape's data, and then fills the circle.\n\t * shape.graphics.append({\n\t * exec: (ctx, shape) => {\n\t * ctx.fillStyle = shape.color;\n\t * ctx.fill();\n\t * }\n\t * });\n\t *\n\t * @param {Object} command A graphics command object exposing an \"exec\" method.\n\t * @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.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tappend (command, clean) {\n\t\tthis._activeInstructions.push(command);\n\t\tthis.command = command;\n\t\tif (!clean) { this._dirty = true; }\n\t\treturn this;\n\t}\n\n\t/**\n\t * Decodes a compact encoded path string into a series of draw instructions.\n\t * This format is not intended to be human readable, and is meant for use by authoring tools.\n\t * The format uses a base64 character set, with each character representing 6 bits, to define a series of draw\n\t * commands.\n\t *\n\t * Each command is comprised of a single \"header\" character followed by a variable number of alternating x and y\n\t * position values. Reading the header bits from left to right (most to least significant): bits 1 to 3 specify the\n\t * type of operation (0-moveTo, 1-lineTo, 2-quadraticCurveTo, 3-bezierCurveTo, 4-closePath, 5-7 unused). Bit 4\n\t * indicates whether position values use 12 bits (2 characters) or 18 bits (3 characters), with a one indicating the\n\t * latter. Bits 5 and 6 are currently unused.\n\t *\n\t * Following the header is a series of 0 (closePath), 2 (moveTo, lineTo), 4 (quadraticCurveTo), or 6 (bezierCurveTo)\n\t * parameters. These parameters are alternating x/y positions represented by 2 or 3 characters (as indicated by the\n\t * 4th bit in the command char). These characters consist of a 1 bit sign (1 is negative, 0 is positive), followed\n\t * by an 11 (2 char) or 17 (3 char) bit integer value. All position values are in tenths of a pixel. Except in the\n\t * case of move operations which are absolute, this value is a delta from the previous x or y position (as\n\t * appropriate).\n\t *\n\t * For example, the string \"A3cAAMAu4AAA\" represents a line starting at -150,0 and ending at 150,0.\n\t * A - bits 000000. First 3 bits (000) indicate a moveTo operation. 4th bit (0) indicates 2 chars per\n\t * parameter.\n\t * n0 - 110111011100. Absolute x position of -150.0px. First bit indicates a negative value, remaining bits\n\t * indicate 1500 tenths of a pixel.\n\t * AA - 000000000000. Absolute y position of 0.\n\t * I - 001100. First 3 bits (001) indicate a lineTo operation. 4th bit (1) indicates 3 chars per parameter.\n\t * Au4 - 000000101110111000. An x delta of 300.0px, which is added to the previous x value of -150.0px to\n\t * provide an absolute position of +150.0px.\n\t * AAA - 000000000000000000. A y delta value of 0.\n\t *\n\t * A tiny API method \"p\" also exists.\n\t *\n\t * @param {String} str The path string to decode.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tdecodePath (str) {\n\t\tlet instructions = [this.moveTo, this.lineTo, this.quadraticCurveTo, this.bezierCurveTo, this.closePath];\n\t\tlet paramCount = [2, 2, 4, 6, 0];\n\t\tlet i = 0;\n\t\tconst l = str.length;\n\t\tlet params = [];\n\t\tlet x = 0, y = 0;\n\t\tlet base64 = Graphics._BASE_64;\n\n\t\twhile (i < l) {\n\t\t\tlet c = str.charAt(i);\n\t\t\tlet n = base64[c];\n\t\t\tlet fi = n>>3; // highest order bits 1-3 code for operation.\n\t\t\tlet f = instructions[fi];\n\t\t\t// check that we have a valid instruction & that the unused bits are empty:\n\t\t\tif (!f || (n&3)) { throw `Bad path data (@${i}):c`; }\n\t\t\tconst pl = paramCount[fi];\n\t\t\tif (!fi) { x=y=0; } // move operations reset the position.\n\t\t\tparams.length = 0;\n\t\t\ti++;\n\t\t\tlet charCount = (n>>2&1)+2; // 4th header bit indicates number size for this operation.\n\t\t\tfor (let p = 0; p < pl; p++) {\n\t\t\t\tlet num = base64[str.charAt(i)];\n\t\t\t\tlet sign = (num>>5) ? -1 : 1;\n\t\t\t\tnum = ((num&31)<<6)|(base64[str.charAt(i+1)]);\n\t\t\t\tif (charCount === 3) { num = (num<<6)|(base64[str.charAt(i+2)]); }\n\t\t\t\tnum = sign*num/10;\n\t\t\t\tif (p%2) { x = (num += x); }\n\t\t\t\telse { y = (num += y); }\n\t\t\t\tparams[p] = num;\n\t\t\t\ti += charCount;\n\t\t\t}\n\t\t\tf.apply(this, params);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Stores all graphics commands so they won't be executed in future draws. Calling store() a second time adds to\n\t * the existing store. This also affects `drawAsPath()`.\n\t *\n\t * This is useful in cases where you are creating vector graphics in an iterative manner (ex. generative art), so\n\t * that only new graphics need to be drawn (which can provide huge performance benefits), but you wish to retain all\n\t * of the vector instructions for later use (ex. scaling, modifying, or exporting).\n\t *\n\t * Note that calling store() will force the active path (if any) to be ended in a manner similar to changing\n\t * the fill or stroke.\n\t *\n\t * For example, consider a application where the user draws lines with the mouse. As each line segment (or collection of\n\t * segments) are added to a Shape, it can be rasterized using {@link easeljs.DisplayObject#updateCache},\n\t * and then stored, so that it can be redrawn at a different scale when the application is resized, or exported to SVGraphics.\n\t *\n\t * @example\n\t * // set up cache:\n\t * shape.cache(0,0,500,500,scale);\n\t *\n\t * // when the user drags, draw a new line:\n\t * shape.graphics.moveTo(oldX,oldY).lineTo(newX,newY);\n\t * // then draw it into the existing cache:\n\t * shape.updateCache(\"source-over\");\n\t * // store the new line, so it isn't redrawn next time:\n\t * shape.store();\n\t *\n\t * // then, when the window resizes, we can re-render at a different scale:\n\t * // first, unstore all our lines:\n\t * shape.unstore();\n\t * // then cache using the new scale:\n\t * shape.cache(0,0,500,500,newScale);\n\t * // finally, store the existing commands again:\n\t * shape.store();\n\t *\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tstore () {\n\t\tthis._updateInstructions(true);\n\t\tthis._storeIndex = this._instructions.length;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Unstores any graphics commands that were previously stored using {@link easeljs.Graphics#store}\n\t * so that they will be executed in subsequent draw calls.\n\t *\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tunstore () {\n\t\tthis._storeIndex = 0;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns a clone of this Graphics instance. Note that the individual command objects are not cloned.\n\t * @return {easeljs.Graphics} A clone of the current Graphics instance.\n\t */\n\tclone () {\n\t\tlet o = new Graphics();\n\t\to.command = this.command;\n\t\to._stroke = this._stroke;\n\t\to._strokeStyle = this._strokeStyle;\n\t\to._strokeDash = this._strokeDash;\n\t\to._strokeIgnoreScale = this._strokeIgnoreScale;\n\t\to._fill = this._fill;\n\t\to._instructions = this._instructions.slice();\n\t\to._commitIndex = this._commitIndex;\n\t\to._activeInstructions = this._activeInstructions.slice();\n\t\to._dirty = this._dirty;\n\t\to._storeIndex = this._storeIndex;\n\t\treturn o;\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name}]`;\n\t}\n\n\t/**\n\t * @param {Boolean} commit\n\t * @protected\n\t */\n\t_updateInstructions (commit) {\n\t\tlet instr = this._instructions, active = this._activeInstructions, commitIndex = this._commitIndex;\n\n\t\tif (this._dirty && active.length) {\n\t\t\tinstr.length = commitIndex; // remove old, uncommitted commands\n\t\t\tinstr.push(Graphics.beginCmd);\n\n\t\t\tconst l = active.length, ll = instr.length;\n\t\t\tinstr.length = ll+l;\n\t\t\tfor (let i = 0; i < l; i++) { instr[i+ll] = active[i]; }\n\n\t\t\tif (this._fill) { instr.push(this._fill); }\n\t\t\tif (this._stroke) {\n\t\t\t\t// doesn't need to be re-applied if it hasn't changed.\n\t\t\t\tif (this._strokeDash !== this._oldStrokeDash) {\n\t\t\t\t\tinstr.push(this._strokeDash);\n\t\t\t\t}\n\t\t\t\tif (this._strokeStyle !== this._oldStrokeStyle) {\n\t\t\t\t\tinstr.push(this._strokeStyle);\n\t\t\t\t}\n\t\t\t\tif (commit) {\n\t\t\t\t\tthis._oldStrokeDash = this._strokeDash;\n\t\t\t\t\tthis._oldStrokeStyle = this._strokeStyle;\n\t\t\t\t}\n\t\t\t\tinstr.push(this._stroke);\n\t\t\t}\n\n\t\t\tthis._dirty = false;\n\t\t}\n\n\t\tif (commit) {\n\t\t\tactive.length = 0;\n\t\t\tthis._commitIndex = instr.length;\n\t\t}\n\t};\n\n\t/**\n\t * @param {easeljs.Graphics.Fill} fill\n\t * @protected\n\t */\n\t_setFill (fill) {\n\t\tthis._updateInstructions(true);\n\t\tthis.command = this._fill = fill;\n\t\treturn this;\n\t}\n\n\t/**\n\t * @param {easeljs.Graphics.Stroke} stroke\n\t * @protected\n\t */\n\t_setStroke (stroke) {\n\t\tthis._updateInstructions(true);\n\t\tif (this.command = this._stroke = stroke) {\n\t\t\tstroke.ignoreScale = this._strokeIgnoreScale;\n\t\t}\n\t\treturn this;\n\t}\n\n\tstatic get LineTo () { return LineTo; }\n\tstatic get MoveTo () { return MoveTo; }\n\tstatic get ArcTo () { return ArcTo; }\n\tstatic get Arc () { return Arc; }\n\tstatic get QuadraticCurveTo () { return QuadraticCurveTo; }\n\tstatic get BezierCurveTo () { return BezierCurveTo; }\n\tstatic get Rect () { return Rect; }\n\tstatic get ClosePath () { return ClosePath; }\n\tstatic get BeginPath () { return BeginPath; }\n\tstatic get Fill () { return Fill; }\n\tstatic get Stroke () { return Stroke; }\n\tstatic get StrokeStyle () { return StrokeStyle; }\n\tstatic get StrokeDash () { return StrokeDash; }\n\tstatic get RoundRect () { return RoundRect; }\n\tstatic get Circle () { return Circle; }\n\tstatic get Ellipse () { return Ellipse; }\n\tstatic get PolyStar () { return PolyStar; }\n\n}\n\n/**\n * @see {@link easeljs.Graphics#lineTo}\n * @alias easeljs.Graphics.LineTo\n * @param {Number} x\n * @param {Number} y\n */\nclass LineTo {\n\tconstructor (x, y) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.x = x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y = y;\n\t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n\texec (ctx) {\n\t\tctx.lineTo(this.x, this.y);\n\t}\n}\n\n/**\n * @see {@link easeljs.Graphics#moveTo}\n * @alias easeljs.Graphics.MoveTo\n * @param {Number} x\n * @param {Number} y\n */\nclass MoveTo {\n \tconstructor (x, y) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n \t\tthis.x = x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y = y;\n \t}\n\t/**\n\t * @param {CanvasRenderingContext2D} ctx\n\t */\n \texec (ctx) {\n \t\tctx.moveTo(this.x, this.y);\n \t}\n}\n\n\n/**\n * @see {@link easeljs.Graphics#arcTo}\n * @alias easeljs.Graphics.ArcTo\n * @param {Number} x1\n * @param {Number} y1\n * @param {Number} x2\n * @param {Number} y2\n * @param {Number} radius\n */\nclass ArcTo {\n \tconstructor (x1, y1, x2, y2, radius) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.x1 = x1;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y1 = y1;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.x2 = x2;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y2 = y2;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.radius = radius;\n \t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tctx.arcTo(this.x1, this.y1, this.x2, this.y2, this.radius);\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#arc}\n * @alias easeljs.Graphics.Arc\n * @param {Number} x\n * @param {Number} y\n * @param {Number} radius\n * @param {Number} startAngle\n * @param {Number} endAngle\n * @param {Boolean} [anticlockwise=false]\n */\nclass Arc {\n \tconstructor (x, y, radius, startAngle, endAngle, anticlockwise = false) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.x = x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y = y;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.radius = radius;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.startAngle = startAngle;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.endAngle = endAngle;\n\t\t/**\n\t\t * @type {Boolean}\n\t\t */\n\t \tthis.anticlockwise = anticlockwise;\n \t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tctx.arc(this.x, this.y, this.radius, this.startAngle, this.endAngle, this.anticlockwise);\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#quadraticCurveTo}\n * @alias easeljs.Graphics.QuadraticCurveTo\n * @param {Number} cpx\n * @param {Number} cpy\n * @param {Number} x\n * @param {Number} y\n */\nclass QuadraticCurveTo {\n \tconstructor (cpx, cpy, x, y) {\n\t\t/**\n\t\t * @property cpx\n\t\t * @type Number\n\t\t */\n\t \tthis.cpx = cpx;\n\t\t/**\n\t\t * @property cpy\n\t\t * @type Number\n\t\t */\n\t\tthis.cpy = cpy;\n\t\t/**\n\t\t * @property x\n\t\t * @type Number\n\t\t */\n\t \tthis.x = x;\n\t\t/**\n\t\t * @property y\n\t\t * @type Number\n\t\t */\n\t\tthis.y = y;\n \t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tctx.quadraticCurveTo(this.cpx, this.cpy, this.x, this.y);\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#bezierCurveTo}\n * @alias easeljs.Graphics.BezierCurveTo\n * @param {Number} cp1x\n * @param {Number} cp1y\n * @param {Number} cp2x\n * @param {Number} cp2y\n * @param {Number} x\n * @param {Number} y\n */\nclass BezierCurveTo {\n \tconstructor (cp1x, cp1y, cp2x, cp2y, x, y) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.cp1x = cp1x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.cp1y = cp1y;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.cp2x = cp2x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.cp2y = cp2y;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.x = x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y = y;\n \t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tctx.bezierCurveTo(this.cp1x, this.cp1y, this.cp2x, this.cp2y, this.x, this.y);\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#rect}\n * @alias easeljs.Graphics.Rect\n * @param {Number} x\n * @param {Number} y\n * @param {Number} w\n * @param {Number} h\n */\nclass Rect {\n \tconstructor (x, y, w, h) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.x = x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y = y;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.w = w;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.h = h;\n \t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tctx.rect(this.x, this.y, this.w, this.h);\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#closePath}\n * @alias easeljs.Graphics.ClosePath\n */\nclass ClosePath {\n \tconstructor () { }\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tctx.closePath();\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#beginPath}\n * @alias easeljs.Graphics.BeginPath\n */\nclass BeginPath {\n \tconstructor () { }\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tctx.beginPath();\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#beginFill}\n * @alias easeljs.Graphics.Fill\n * @param {Object} style A valid Context2D fillStyle.\n * @param {Matrix2D} matrix\n */\nclass Fill {\n\tconstructor (style, matrix) {\n\t\t/**\n\t\t * A valid Context2D fillStyle.\n\t\t * @type {Object}\n\t\t */\n\t\tthis.style = style;\n\t\t/**\n\t\t * @type {easeljs.Matrix2D}\n\t\t */\n\t\tthis.matrix = matrix;\n\t\t/**\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis.path = false;\n\t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n\texec (ctx) {\n\t\tif (!this.style) { return; }\n\t\tctx.fillStyle = this.style;\n\t\tlet mtx = this.matrix;\n\t\tif (mtx) { ctx.save(); ctx.transform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx, mtx.ty); }\n\t\tctx.fill();\n\t\tif (mtx) { ctx.restore(); }\n\t}\n\t/**\n\t * Creates a linear gradient style and assigns it to {@link easeljs.Graphics.Fill#style}.\n\t * @see {@link easeljs.Graphics#beginLinearGradientFill}\n\t * @param {Array} colors\n\t * @param {Array} ratios\n\t * @param {Number} x0\n\t * @param {Number} y0\n\t * @param {Number} x1\n\t * @param {Number} y1\n\t * @return {easeljs.Graphics.Fill} Returns this Fill object for chaining or assignment.\n\t */\n\tlinearGradient (colors, ratios, x0, y0, x1, y1) {\n\t\tlet o = this.style = Graphics._ctx.createLinearGradient(x0, y0, x1, y1);\n\t\tconst l = colors.length;\n\t\tfor (let i = 0; i < l; i++) { o.addColorStop(ratios[i], colors[i]); }\n\t\to.props = {colors, ratios, x0, y0, x1, y1, type:\"linear\"};\n\t\treturn this;\n\t}\n\t/**\n\t * Creates a linear gradient style and assigns it to {@link easeljs.Graphics.Fill#style}.\n\t * @see {@link easeljs.Graphics#beginRadialGradientFill}\n\t * @param {Array} colors\n\t * @param {Array} ratios\n\t * @param {Number} x0\n\t * @param {Number} y0\n\t * @param {Number} r0\n\t * @param {Number} x1\n\t * @param {Number} y1\n\t * @param {Number} r1\n\t * @return {easeljs.Graphics.Fill} Returns this Fill object for chaining or assignment.\n\t */\n\tradialGradient (colors, ratios, x0, y0, r0, x1, y1, r1) {\n\t\tlet o = this.style = Graphics._ctx.createRadialGradient(x0, y0, r0, x1, y1, r1);\n\t\tconst l = colors.length;\n\t\tfor (let i = 0; i < l; i++) { o.addColorStop(ratios[i], colors[i]); }\n\t\to.props = {colors, ratios, x0, y0, r0, x1, y1, r1, type: \"radial\"};\n\t\treturn this;\n\t}\n\t/**\n\t * Creates a linear gradient style and assigns it to {@link easeljs.Graphics.Fill#style}.\n\t * @see {@link easeljs.Graphics#beginBitmapFill}\n\t * @param {HTMLImageElement | HTMLCanvasElement | HTMLVideoElement} image Must be loaded prior to creating a bitmap fill, or the fill will be empty.\n\t * @param {String} [repetition=\"\"] One of: repeat, repeat-x, repeat-y, or no-repeat.\n\t * @return {easeljs.Graphics.Fill} Returns this Fill object for chaining or assignment.\n\t */\n\tbitmap (image, repetition = \"\") {\n\t\tif (image.naturalWidth || image.getContext || image.readyState >= 2) {\n\t\t\tlet o = this.style = Graphics._ctx.createPattern(image, repetition);\n\t\t\to.props = {image, repetition, type: \"bitmap\"};\n\t\t}\n\t\treturn this;\n\t}\n}\n\n/**\n * @see {@link easeljs.Graphics#beginStroke}\n * @alias easeljs.Graphics.Stroke\n * @extends easeljs.Graphics.Fill\n * @param {Object} style A valid Context2D fillStyle.\n * @param {Boolean} ignoreScale\n */\nclass Stroke extends Fill {\n\tconstructor (style, ignoreScale) {\n\t\tsuper();\n\t\t/**\n\t\t * A valid Context2D strokeStyle.\n\t\t * @type {Object}\n\t\t */\n\t\tthis.style = style;\n\t\t/**\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis.ignoreScale = ignoreScale;\n\t\t/**\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis.path = false;\n\t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @override\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n\texec (ctx) {\n\t\tif (!this.style) { return; }\n\t\tctx.strokeStyle = this.style;\n\t\tif (this.ignoreScale) { ctx.save(); ctx.setTransform(1,0,0,1,0,0); }\n\t\tctx.stroke();\n\t\tif (this.ignoreScale) { ctx.restore(); }\n\t}\n}\n\n/**\n * @see {@link easeljs.Graphics#setStrokeStyle}\n * @alias easeljs.Graphics.StrokeStyle\n * @param {Number} [width=1]\n * @param {String} [caps=butt]\n * @param {String} [joints=miter]\n * @param {Number} [miterLimit=10]\n * @param {Boolean} [ignoreScale=false]\n */\nclass StrokeStyle {\n\tconstructor (width=1, caps=\"butt\", joints=\"miter\", miterLimit=10, ignoreScale=false) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.width = width;\n\t\t/**\n\t\t * One of: butt, round, square\n\t\t * @type {String}\n\t\t */\n\t\tthis.caps = caps;\n\t\t/**\n\t\t * One of: round, bevel, miter\n\t\t * @type {String}\n\t\t */\n\t\tthis.joints = joints;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.miterLimit = miterLimit;\n\t\t/**\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis.ignoreScale = ignoreScale;\n\t\t/**\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis.path = false;\n\t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n\texec (ctx) {\n\t\tctx.lineWidth = this.width;\n\t\tctx.lineCap = (isNaN(this.caps) ? this.caps : Graphics._STROKE_CAPS_MAP[this.caps]);\n\t\tctx.lineJoin = (isNaN(this.joints) ? this.joints : Graphics._STROKE_JOINTS_MAP[this.joints]);\n\t\tctx.miterLimit = this.miterLimit;\n\t\tctx.ignoreScale = this.ignoreScale;\n\t}\n}\n\n/**\n * @see {@link easeljs.Graphics#setStrokeDash}\n * @alias easeljs.Graphics.StrokeDash\n * @param {Array} [segments=[]]\n * @param {Number} [offset=0]\n */\nclass StrokeDash {\n \tconstructor (segments=[], offset=0) {\n\t\t/**\n\t\t * @type {Array}\n\t\t */\n\t \tthis.segments = segments;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.offset = offset;\n \t}\n\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tif (ctx.setLineDash) { // feature detection.\n\t \t\tctx.setLineDash(this.segments);\n\t \t\tctx.lineDashOffset = this.offset;\n\t \t}\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#drawRoundRectComplex}\n * @alias easeljs.Graphics.RoundRect\n * @param {Number} x\n * @param {Number} y\n * @param {Number} w\n * @param {Number} h\n * @param {Number} radiusTL\n * @param {Number} radiusTR\n * @param {Number} radiusBR\n * @param {Number} radiusBL\n */\nclass RoundRect {\n \tconstructor (x, y, w, h, radiusTL, radiusTR, radiusBR, radiusBL) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.x = x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y = y;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.w = w;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.h = h;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.radiusTL = radiusTL;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.radiusTR = radiusTR;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.radiusBR = radiusBR;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.radiusBL = radiusBL;\n \t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tlet max = (this.w max) { rTL = max; }\n\t \tif (rTR < 0) { rTR *= (mTR=-1); }\n\t \tif (rTR > max) { rTR = max; }\n\t \tif (rBR < 0) { rBR *= (mBR=-1); }\n\t \tif (rBR > max) { rBR = max; }\n\t \tif (rBL < 0) { rBL *= (mBL=-1); }\n\t \tif (rBL > max) { rBL = max; }\n\n\t \tctx.moveTo(x+w-rTR, y);\n\t \tctx.arcTo(x+w+rTR*mTR, y-rTR*mTR, x+w, y+rTR, rTR);\n\t \tctx.lineTo(x+w, y+h-rBR);\n\t \tctx.arcTo(x+w+rBR*mBR, y+h+rBR*mBR, x+w-rBR, y+h, rBR);\n\t \tctx.lineTo(x+rBL, y+h);\n\t \tctx.arcTo(x-rBL*mBL, y+h+rBL*mBL, x, y+h-rBL, rBL);\n\t \tctx.lineTo(x, y+rTL);\n\t \tctx.arcTo(x-rTL*mTL, y-rTL*mTL, x+rTL, y, rTL);\n\t \tctx.closePath();\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#drawCircle}\n * @alias easeljs.Graphics.Circle\n * @param {Number} x\n * @param {Number} y\n * @param {Number} radius\n */\nclass Circle {\n \tconstructor (x, y, radius) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.x = x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y = y;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.radius = radius;\n \t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tctx.arc(this.x, this.y, this.radius, 0, Math.PI*2);\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#drawEllipse}\n * @alias easeljs.Graphics.Ellipse\n * @param {Number} x\n * @param {Number} y\n * @param {Number} w\n * @param {Number} h\n */\nclass Ellipse {\n \tconstructor (x, y, w, h) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.x = x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y = y;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.w = w;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.h = h;\n \t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tlet x = this.x, y = this.y;\n\t \tlet w = this.w, h = this.h;\n\n\t \tlet k = 0.5522848;\n\t \tlet ox = (w / 2) * k;\n\t \tlet oy = (h / 2) * k;\n\t \tlet xe = x + w;\n\t \tlet ye = y + h;\n\t \tlet xm = x + w / 2;\n\t \tlet ym = y + h / 2;\n\n\t \tctx.moveTo(x, ym);\n\t \tctx.bezierCurveTo(x, ym-oy, xm-ox, y, xm, y);\n\t \tctx.bezierCurveTo(xm+ox, y, xe, ym-oy, xe, ym);\n\t \tctx.bezierCurveTo(xe, ym+oy, xm+ox, ye, xm, ye);\n\t \tctx.bezierCurveTo(xm-ox, ye, x, ym+oy, x, ym);\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#drawPolyStar}\n * @alias easeljs.Graphics.PolyStar\n * @param {Number} x\n * @param {Number} y\n * @param {Number} radius\n * @param {Number} sides\n * @param {Number} [pointSize=0]\n * @param {Number} [angle=0]\n */\nclass PolyStar {\n \tconstructor (x, y, radius, sides, pointSize=0, angle=0) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.x = x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y = y;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.radius = radius;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.sides = sides;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.pointSize = pointSize;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.angle = angle;\n \t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tlet x = this.x, y = this.y;\n\t \tlet radius = this.radius;\n\t \tlet angle = this.angle/180*Math.PI;\n\t \tlet sides = this.sides;\n\t \tlet ps = 1-this.pointSize;\n\t \tlet a = Math.PI/sides;\n\n\t \tctx.moveTo(x+Math.cos(angle)*radius, y+Math.sin(angle)*radius);\n\t \tfor (let i = 0; i < sides; i++) {\n\t \t\tangle += a;\n\t \t\tif (ps != 1) {\n\t \t\t\tctx.lineTo(x+Math.cos(angle)*radius*ps, y+Math.sin(angle)*radius*ps);\n\t \t\t}\n\t \t\tangle += a;\n\t \t\tctx.lineTo(x+Math.cos(angle)*radius, y+Math.sin(angle)*radius);\n\t \t}\n\t \tctx.closePath();\n \t}\n}\n\n/**\n * A reusable instance of {@link easeljs.Graphics.BeginPath} to avoid unnecessary instantiation.\n * @static\n * @readonly\n * @type {easeljs.Graphics.BeginPath}\n */\nGraphics.beginCmd = new BeginPath();\n/**\n * Map of Base64 characters to values. Used by {@link easeljs.Graphics#decodePath}.\n * @static\n * @readonly\n * @protected\n * @type {Object}\n */\nGraphics._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};\n/**\n * Maps numeric values for the caps parameter of {@link easeljs.Graphics#setStrokeStyle} to\n * corresponding string values. This is primarily for use with the tiny API. \n * The mappings are as follows:\n *
\n *
0 to \"butt\"
\n *
1 to \"round\"
\n *
2 to \"square\".
\n *
\n *\n * @example
Set line caps to \"square\"
\n * graphics.ss(16, 2);\n *\n * @static\n * @readonly\n * @protected\n * @type {Array}\n */\nGraphics._STROKE_CAPS_MAP = [\"butt\",\"round\",\"square\"];\n/**\n * Maps numeric values for the joints parameter of {@link easeljs.Graphics#setStrokeStyle} to\n * corresponding string values. This is primarily for use with the tiny API. \n * The mappings are as follows:\n *
\n *
0 to \"miter\"
\n *
1 to \"round\"
\n *
2 to \"bevel\".
\n *
\n *\n * @example
Set the line joints to \"bevel\"
\n * graphics.ss(16, 0, 2);\n *\n * @static\n * @readonly\n * @protected\n * @type {Array}\n */\nGraphics._STROKE_JOINTS_MAP = [\"miter\", \"round\", \"bevel\"];\n/**\n * @static\n * @readonly\n * @protected\n * @type {CanvasRenderingContext2D}\n */\nGraphics._ctx = createCanvas().getContext(\"2d\");\n","/**\n * @license MovieClip\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Container from \"./Container\";\nimport DisplayObject from \"./DisplayObject\";\nimport { Tween, Timeline } from \"@createjs/tweenjs\";\n\n/**\n * The MovieClip class associates a TweenJS Timeline with an EaselJS {@link easeljs.Container}. It allows\n * you to create objects which encapsulate timeline animations, state changes, and synched actions. Due to the\n * complexities inherent in correctly setting up a MovieClip, it is largely intended for tool output and is not included\n * in the main EaselJS library.\n *\n * Currently MovieClip only works properly if it is tick based (as opposed to time based) though some concessions have\n * been made to support time-based timelines in the future.\n *\n * It is recommended to use `tween.to()` to animate and set properties (use no duration to have it set\n * immediately), and the `tween.wait()` method to create delays between animations. Note that using the\n * `tween.set()` method to affect properties will likely not provide the desired result.\n *\n * @memberof easeljs\n * @example
Animate two shapes back and forth
\n * let stage = new Stage(\"canvas\");\n * Ticker.addEventListener(\"tick\", stage);\n *\n * let mc = new MovieClip(null, 0, true, {start:20});\n * stage.addChild(mc);\n *\n * let child1 = new Shape(\n * new Graphics().beginFill(\"#999999\").drawCircle(30,30,30)\n * );\n * let child2 = new Shape(\n * new Graphics().beginFill(\"#5a9cfb\").drawCircle(30,30,30)\n * );\n *\n * mc.timeline.addTween(\n * Tween.get(child1).to({x:0}).to({x:60}, 50).to({x:0}, 50)\n * );\n * mc.timeline.addTween(\n * Tween.get(child2).to({x:60}).to({x:0}, 50).to({x:60}, 50)\n * );\n *\n * mc.gotoAndPlay(\"start\");\n *\n * @extends easeljs.Container\n * @param {Object} [props] The configuration properties to apply to this instances.\n * This object will also be passed into the Timeline instance associated with this MovieClip.\n * See the documentation for Timeline for a list of supported props.\n */\nexport default class MovieClip extends Container {\n\n\tconstructor (props) {\n\t\tsuper();\n\t\t!MovieClip.inited && MovieClip.init();\n\n\t\t/**\n\t\t * Controls how this MovieClip advances its time. Must be one of 0 (INDEPENDENT), 1 (SINGLE_FRAME), or 2 (SYNCHED).\n\t\t * See each constant for a description of the behaviour.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.mode = props.mode != null ? props.mode : MovieClip.INDEPENDENT;\n\n\t\t/**\n\t\t * Specifies what the first frame to play in this movieclip, or the only frame to display if mode is SINGLE_FRAME.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.startPosition = props.startPosition != null ? props.startPosition : 0;\n\n\t\t/**\n * Specifies how many times this MovieClip should loop. A value of -1 indicates it should loop indefinitely. A value of\n * 1 would cause it to loop once (ie. play a total of twice).\n * @property loop\n\t\t * @type {Number}\n\t\t * @default -1\n\t\t */\n\t\tif (typeof props.loop === \"number\") {\n\t\t\tthis.loop = props.loop;\n\t\t} else if (props.loop === false) {\n\t\t\tthis.loop = 0;\n\t\t} else {\n\t\t\tthis.loop = -1;\n\t\t}\n\n\t\t/**\n\t\t * The current frame of the movieclip.\n\t\t * @type Number\n\t\t * @default 0\n\t\t * @readonly\n\t\t */\n\t\tthis.currentFrame = 0;\n\n\t\t/**\n * The TweenJS Timeline that is associated with this MovieClip. This is created automatically when the MovieClip\n * instance is initialized. Animations are created by adding TweenJS Tween\n * instances to the timeline.\n *\n * Elements can be added and removed from the timeline by toggling an \"_off\" property\n * using the `tweenInstance.to()` method. Note that using `Tween.set` is not recommended to\n * create MovieClip animations. The following example will toggle the target off on frame 0, and then back on for\n * frame 1. You can use the \"visible\" property to achieve the same effect.\n *\n * @example\n * let tween = Tween.get(target).to({x:0}).to({x:100}, 30);\n * let mc = new MovieClip();\n * mc.timeline.addTween(tween);\n *\n * @example\n * Tween.get(target).to({_off:false})\n * .wait(1).to({_off:true})\n * .wait(1).to({_off:false});\n *\n * @type {easeljs.Timeline}\n\t\t */\n\t\tthis.timeline = new Timeline(Object.assign({ useTicks: true, paused: true }, props));\n\n\t\t/**\n\t\t * If true, the MovieClip's position will not advance when ticked.\n\t\t * @type {Boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.paused = props.paused != null ? props.paused : false;\n\n\t\t/**\n\t\t * If true, actions in this MovieClip's tweens will be run when the playhead advances.\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.actionsEnabled = true;\n\n\t\t/**\n\t\t * If true, the MovieClip will automatically be reset to its first frame whenever the timeline adds\n\t\t * it back onto the display list. This only applies to MovieClip instances with mode=INDEPENDENT.\n\t\t *
\n\t\t * For example, if you had a character animation with a \"body\" child MovieClip instance\n\t\t * with different costumes on each frame, you could set `body.autoReset = false`, so that\n\t\t * you can manually change the frame it is on, without worrying that it will be reset\n\t\t * automatically.\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.autoReset = true;\n\n\t\t/**\n\t\t * An array of bounds for each frame in the MovieClip. This is mainly intended for tool output.\n\t\t * @type {Array}\n\t\t */\n\t\tthis.frameBounds = this.frameBounds || props.frameBounds; // frameBounds are set on the prototype in Animate.\n\n\t\t/**\n\t\t * By default MovieClip instances advance one frame per tick. Specifying a framerate for the MovieClip\n\t\t * will cause it to advance based on elapsed time between ticks as appropriate to maintain the target\n\t\t * framerate.\n\t\t *\n\t\t * For example, if a MovieClip with a framerate of 10 is placed on a Stage being updated at 40fps, then the MovieClip will\n\t\t * advance roughly one frame every 4 ticks. This will not be exact, because the time between each tick will\n\t\t * vary slightly between frames.\n\t\t *\n\t\t * This feature is dependent on the tick event object (or an object with an appropriate \"delta\" property) being\n\t\t * passed into {@link easeljs.Stage#update}.\n\t\t * @type {Number}\n\t\t * @default null\n\t\t */\n\t\tthis.framerate = null;\n\n\t\t/**\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t * @private\n\t\t */\n\t\tthis._synchOffset = 0;\n\n\t\t/**\n\t\t * @type {Number}\n\t\t * @default -1\n\t\t * @private\n\t\t */\n\t\tthis._rawPosition = -1; // TODO: evaluate using a ._reset Boolean prop instead of -1.\n\n\t\t/**\n\t\t * The time remaining from the previous tick, only applicable when .framerate is set.\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._t = 0;\n\n\t\t/**\n\t\t * List of display objects that are actively being managed by the MovieClip.\n\t\t * @type {Object}\n\t\t * @private\n\t\t */\n\t\tthis._managed = {};\n\n\t\t/**\n\t\t * @type {Function}\n\t\t * @private\n\t\t */\n\t\tthis._bound_resolveState = this._resolveState.bind(this);\n\t}\n\n\tstatic init () {\n\t\tif (MovieClip.inited) { return; }\n\t\t// plugins introduce some overhead to Tween, so we only install this if an MC is instantiated.\n\t\tMovieClipPlugin.install();\n\t\tMovieClip.inited = true;\n\t}\n\n\t// TODO: can we just proxy `get currentFrame` to timeline.position as well? Ditto for `get loop` (or just remove entirely).\n\t//\n\t/**\n\t * Returns an array of objects with label and position (aka frame) properties, sorted by position.\n\t * @see {@link tweenjs.Timeline#labels}\n\t * @type {Array}\n\t * @readonly\n\t */\n\tget labels () {\n\t\treturn this.timeline.labels;\n\t}\n\n\t/**\n\t * Returns the name of the label on or immediately before the current frame.\n\t * @see {@link tweenjs.Timeline#currentLabel}\n\t * for more information.\n\t * @type {String}\n\t * @readonly\n\t */\n\tget currentLabel () {\n\t\treturn this.timeline.currentLabel;\n\t}\n\n\t /**\n \t * Returns the duration of this MovieClip in seconds or ticks.\n \t * @see {@link tweenjs.Timeline#duration}\n \t * @type {Number}\n \t * @readonly\n \t */\n \tget duration () {\n\t\treturn this.timeline.duration;\n\t}\n\n\t/**\n\t * Returns the duration of this MovieClip in seconds or ticks. Identical to {@link easeljs.MovieClip#duration}\n\t * and provided for Adobe Flash/Animate API compatibility.\n\t * @see {@link tweenjs.Timeline#duration}\n\t * @type {Number}\n\t * @readonly\n\t */\n\tget totalFrames () {\n\t\treturn this.duration;\n\t}\n\n\tisVisible () {\n\t\t// children are placed in draw, so we can't determine if we have content.\n\t\treturn !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0);\n\t}\n\n\tdraw (ctx, ignoreCache) {\n\t\t// draw to cache first:\n\t\tif (this.drawCache(ctx, ignoreCache)) { return true; }\n this._updateState();\n\t\tsuper.draw(ctx, ignoreCache);\n\t\treturn true;\n\t}\n\n\t/**\n\t * Sets paused to false.\n\t */\n\tplay () {\n\t\tthis.paused = false;\n\t}\n\n\t/**\n\t * Sets paused to true.\n\t */\n\tstop () {\n\t\tthis.paused = true;\n\t}\n\n\t/**\n\t * Advances this movie clip to the specified position or label and plays the timeline.\n\t * @param {String | Number} positionOrLabel The animation name or frame number to go to.\n\t */\n\tgotoAndPlay (positionOrLabel) {\n\t\tthis.play();\n\t\tthis._goto(positionOrLabel);\n\t}\n\n\t/**\n\t * Advances this movie clip to the specified position or label and stops the timeline.\n\t * @param {String | Number} positionOrLabel The animation or frame name to go to.\n\t */\n\tgotoAndStop (positionOrLabel) {\n\t\tthis.stop();\n\t\tthis._goto(positionOrLabel);\n\t}\n\n\t/**\n\t * Advances the playhead. This occurs automatically each tick by default.\n\t * @param {Number} [time] The amount of time in ms to advance by. Only applicable if framerate is set.\n\t*/\n\tadvance (time) {\n\t\tif (this.mode !== MovieClip.INDEPENDENT) { return; } // update happens in draw for synched clips\n\t\t// if this MC doesn't have a framerate, hunt ancestors for one:\n\t\tlet o = this, fps = o.framerate;\n\t\twhile ((o = o.parent) && fps === null) {\n\t\t\tif (o.mode === MovieClip.INDEPENDENT) { fps = o._framerate; }\n\t\t}\n\t\tthis._framerate = fps;\n\n\t\tif (this.paused) { return; }\n\t\t// calculate how many frames to advance:\n\t\tlet t = (fps !== null && fps !== -1 && time !== null) ? time / (1000 / fps) + this._t : 1;\n\t\tlet frames = t | 0;\n\t\tthis._t = t - frames; // leftover time, save to add to next advance.\n\n\t\twhile (frames--) {\n\t\t\tthis._updateTimeline(this._rawPosition + 1, false);\n\t\t}\n\t}\n\n\t/**\n\t * MovieClip instances cannot be cloned.\n\t * @throws MovieClip cannot be cloned.\n\t */\n\tclone () {\n\t\t// TODO: add support for this? Need to clone the Timeline & retarget tweens - pretty complex.\n\t\tthrow \"MovieClip cannot be cloned.\";\n\t}\n\n\t_updateState () {\n\t\tif (this._rawPosition === -1 || this.mode !== MovieClip.INDEPENDENT) { this._updateTimeline(-1); }\n\t}\n\n\t_tick (evtObj) {\n\t\tthis.advance(evtObj && evtObj.delta);\n\t\tsuper._tick(evtObj);\n\t}\n\n\t/**\n\t * @param {String | Number} positionOrLabel The animation name or frame number to go to.\n\t * @protected\n\t */\n\t_goto (positionOrLabel) {\n\t\tlet pos = this.timeline.resolve(positionOrLabel);\n\t\tif (pos == null) { return; }\n\t\tthis._t = 0;\n\t\tthis._updateTimeline(pos, true);\n\t}\n\n\t/**\n\t * @private\n\t */\n\t_reset () {\n\t\tthis._rawPosition = -1;\n\t\tthis._t = this.currentFrame = 0;\n\t\tthis.paused = false;\n\t}\n\n\t/**\n\t * @param {Number} rawPosition\n\t * @param {Boolean} jump Indicates whether this update is due to jumping (via gotoAndXX) to a new position.\n\t * @protected\n\t */\n\t_updateTimeline (rawPosition, jump) {\n\t\tlet synced = this.mode !== MovieClip.INDEPENDENT, tl = this.timeline;\n\t\tif (synced) { rawPosition = this.startPosition + (this.mode === MovieClip.SINGLE_FRAME ? 0 : this._synchOffset); }\n\t\tif (rawPosition < 1) { rawPosition = 0; }\n\t\tif (this._rawPosition === rawPosition && !synced) { return; }\n\t\tthis._rawPosition = rawPosition;\n\n\t\t// update timeline position, ignoring actions if this is a graphic.\n\t\ttl.loop = this.loop; // TODO: should we maintain this on MovieClip, or just have it on timeline?\n\t\ttl.setPosition(rawPosition, synced || !this.actionsEnabled, jump, this._bound_resolveState);\n\t}\n\n\t/**\n\t * Renders position 0 without running actions or updating _rawPosition.\n\t * Primarily used by Animate CC to build out the first frame in the constructor of MC symbols.\n\t * NOTE: not tested when run after the MC advances past the first frame.\n\t * @protected\n\t */\n\t_renderFirstFrame () {\n\t\tconst tl = this.timeline, pos = tl.rawPosition;\n\t\ttl.setPosition(0, true, true, this._bound_resolveState);\n\t\ttl.rawPosition = pos;\n\t}\n\n\t/**\n\t * Runs via a callback after timeline property updates and before actions.\n\t * @protected\n\t */\n\t_resolveState () {\n\t\tlet tl = this.timeline;\n\t\tthis.currentFrame = tl.position;\n\n\t\tfor (let n in this._managed) { this._managed[n] = 1; }\n\n\t\tlet tweens = tl.tweens;\n\t\tfor (let tween of tweens) {\n\t\t\tlet target = tween.target;\n\t\t\tif (target === this || tween.passive) { continue; } // TODO: this assumes the actions tween from Animate has `this` as the target. Likely a better approach.\n\t\t\tlet offset = tween._stepPosition;\n\n\t\t\tif (target instanceof DisplayObject) {\n\t\t\t\t// motion tween.\n\t\t\t\tthis._addManagedChild(target, offset);\n\t\t\t} else {\n\t\t\t\t// state tween.\n\t\t\t\tthis._setState(target.state, offset);\n\t\t\t}\n\t\t}\n\n\t\tlet kids = this.children;\n\t\tfor (let i=kids.length-1; i>=0; i--) {\n\t\t\tlet id = kids[i].id;\n\t\t\tif (this._managed[id] === 1) {\n\t\t\t\tthis.removeChildAt(i);\n\t\t\t\tdelete(this._managed[id]);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @param {Array} state\n\t * @param {Number} offset\n\t * @protected\n\t */\n\t_setState (state, offset) {\n\t\tif (!state) { return; }\n\t\tfor (let i = state.length - 1; i >= 0; i--) {\n\t\t\tlet o = state[i];\n\t\t\tlet target = o.t;\n\t\t\tlet props = o.p;\n\t\t\tfor (let n in props) { target[n] = props[n]; }\n\t\t\tthis._addManagedChild(target, offset);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a child to the timeline, and sets it up as a managed child.\n\t * @param {easeljs.MovieClip} child The child MovieClip to manage\n\t * @param {Number} offset\n\t * @private\n\t */\n\t_addManagedChild (child, offset) {\n\t\tif (child._off) { return; }\n\t\tthis.addChildAt(child, 0);\n\n\t\tif (child instanceof MovieClip) {\n\t\t\tchild._synchOffset = offset;\n\t\t\t// TODO: this does not precisely match Adobe Flash/Animate, which loses track of the clip if it is renamed or removed from the timeline, which causes it to reset.\n // TODO: should also reset when MovieClip loops, though that will be a bit tricky to detect.\n\t\t\tif (child.mode === MovieClip.INDEPENDENT && child.autoReset && !this._managed[child.id]) { child._reset(); }\n\t\t}\n\t\tthis._managed[child.id] = 2;\n\t}\n\n\t/**\n\t * @param {easeljs.Matrix2D} matrix\n\t * @param {Boolean} ignoreTransform\n\t * @return {easeljs.Rectangle}\n\t * @protected\n\t */\n\t_getBounds (matrix, ignoreTransform) {\n\t\tlet bounds = this.getBounds();\n\t\tif (!bounds && this.frameBounds) { bounds = this._rectangle.copy(this.frameBounds[this.currentFrame]); }\n\t\tif (bounds) { return this._transformBounds(bounds, matrix, ignoreTransform); }\n\t\treturn super._getBounds(matrix, ignoreTransform);\n\t}\n\n}\n\n/**\n * The MovieClip will advance independently of its parent, even if its parent is paused.\n * This is the default mode.\n * @static\n * @type {String}\n * @default independent\n * @readonly\n */\nMovieClip.INDEPENDENT = \"independent\";\n/**\n * The MovieClip will only display a single frame (as determined by the startPosition property).\n * @static\n * @type {String}\n * @default single\n * @readonly\n */\nMovieClip.SINGLE_FRAME = \"single\";\n/**\n * The MovieClip will be advanced only when its parent advances and will be synched to the position of\n * the parent MovieClip.\n * @static\n * @type {String}\n * @default synched\n * @readonly\n */\nMovieClip.SYNCHED = \"synched\";\n/**\n * Has the MovieClipPlugin been installed to TweenJS yet?\n * @static\n * @type {Boolean}\n * @default false\n * @readonly\n */\nMovieClip.inited = false;\n\n/**\n * This plugin works with TweenJS to prevent the startPosition property from tweening.\n * @todo update to new plugin model\n * @static\n * @inner\n */\nclass MovieClipPlugin {\n\n\tconstructor () {\n\t\tthrow \"MovieClipPlugin cannot be instantiated.\";\n\t}\n\n\t/**\n\t * @private\n\t */\n\tstatic install () {\n\t\tTween.installPlugin(MovieClipPlugin);\n\t}\n\n\t/**\n\t * @param {tweenjs.Tween} tween\n\t * @param {String} prop\n\t * @param {String|Number|Boolean} value\n\t * @private\n\t */\n\tstatic init (tween, prop, value) {\n\t\treturn value;\n\t}\n\n\t/**\n\t * @param {tweenjs.Tween} tween\n\t * @param {String} prop\n\t * @param {String | Number | Boolean} value\n\t * @param {Array} startValues\n\t * @param {Array} endValues\n\t * @param {Number} ratio\n\t * @param {Object} wait\n\t * @param {Object} end\n\t * @return {*}\n\t */\n\tstatic tween (tween, prop, value, startValues, endValues, ratio, wait, end) {\n\t\tif (!(tween.target instanceof MovieClip)) { return value; }\n\t\treturn (ratio === 1 ? endValues[prop] : startValues[prop]);\n\t}\n\n}\n\n/**\n * @static\n * @type {Number}\n * @default 100\n * @readonly\n */\nMovieClipPlugin.priority = 100;\n","/**\n * @license Shape\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport DisplayObject from \"./DisplayObject\";\nimport Graphics from \"./Graphics\";\n\n/**\n * A Shape allows you to display vector art in the display list. It composites a {@link easeljs.Graphics}\n * instance which exposes all of the vector drawing methods. The Graphics instance can be shared between multiple Shape\n * instances to display the same vector graphics with different positions or transforms.\n *\n * If the vector art will not change between draws, you may want to use the {@link easeljs.DisplayObject#cache}\n * method to reduce the rendering cost.\n *\n * @memberof easeljs\n * @example\n * var graphics = new Graphics().beginFill(\"#ff0000\").drawRect(0, 0, 100, 100);\n * var shape = new Shape(graphics);\n * // Alternatively use can also use the graphics property of the Shape class to renderer the same as above.\n * var shape = new Shape();\n * shape.graphics.beginFill(\"#ff0000\").drawRect(0, 0, 100, 100);\n *\n * @extends easeljs.DisplayObject\n * @param {easeljs.Graphics} [graphics] The graphics instance to display. If null, a new Graphics instance will be created.\n */\nexport default class Shape extends DisplayObject {\n\n\tconstructor (graphics = new Graphics()) {\n\t\tsuper();\n\n\t\t/**\n\t\t * The graphics instance to display.\n\t\t * @type {easeljs.Graphics}\n\t\t */\n\t\tthis.graphics = graphics;\n\t}\n\n\tisVisible () {\n\t\tlet hasContent = this.cacheCanvas || (this.graphics && !this.graphics.isEmpty());\n\t\treturn !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && hasContent);\n\t}\n\n\tdraw (ctx, ignoreCache = false) {\n\t\tif (super.draw(ctx, ignoreCache)) { return true; }\n\t\tthis.graphics.draw(ctx, this);\n\t\treturn true;\n\t}\n\n\t/**\n\t * Returns a clone of this Shape. Some properties that are specific to this instance's current context are reverted to\n\t * their defaults (for example .parent).\n\t * @override\n\t * @param {Boolean} [recursive=false] If true, this Shape's {@link easeljs.Graphics} instance will also be\n\t * cloned. If false, the Graphics instance will be shared with the new Shape.\n\t */\n\tclone (recursive = false) {\n\t\tlet g = (recursive && this.graphics) ? this.graphics.clone() : this.graphics;\n\t\treturn this._cloneProps(new Shape(g));\n\t}\n\n}\n","/**\n * @license SpriteSheet\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPliED, INCLUDING BUT NOT liMITED TO THE WARRANTIES\n * OF MERCHANTABIliTY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HolDERS BE liABLE FOR ANY CLAIM, DAMAGES OR OTHER liABIliTY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEAliNGS IN THE SOFTWARE.\n */\n\nimport { EventDispatcher, Event } from \"@createjs/core\";\nimport Rectangle from \"../geom/Rectangle\";\n\n/**\n * Encapsulates the properties and methods associated with a sprite sheet. A sprite sheet is a series of images (usually\n * animation frames) combined into a larger image (or images). For example, an animation consisting of eight 100x100\n * images could be combined into a single 400x200 sprite sheet (4 frames across by 2 high).\n * \n * The data passed to the SpriteSheet constructor defines:\n * \n * \t
The source image or images to use.
\n * \t
The positions of individual image frames.
\n * \t
Sequences of frames that form named animations. Optional.
\n * \t
The target playback framerate. Optional.
\n * \n *\n *
SpriteSheet Format
\n * SpriteSheets are an object with two required properties (`images` and `frames`), and two optional properties\n * (`framerate` and `animations`). This makes them easy to define in javascript code, or in JSON.\n *\n *
images
\n * An array of source images. Images can be either an HTMlimage\n * instance, or a uri to an image. The former is recommended to control preloading.\n *\n * \timages: [image1, \"path/to/image2.png\"],\n *\n *
frames
\n * Defines the individual frames. There are two supported formats for frame data:\n * When all of the frames are the same size (in a grid), use an object with `width`, `height`, `regX`, `regY`,\n * and `count` properties.\n *\n *
\n *
`width` & `height` are required and specify the dimensions of the frames
\n *
`regX` & `regY` indicate the registration point or \"origin\" of the frames
\n *
`spacing` indicate the spacing between frames
\n *
`margin` specify the margin around the image(s)
\n *
`count` allows you to specify the total number of frames in the spritesheet; if omitted, this will\n * be calculated based on the dimensions of the source images and the frames. Frames will be assigned\n * indexes based on their position in the source images (left to right, top to bottom).
\n *
\n *\n * \tframes: {width:64, height:64, count:20, regX: 32, regY:64, spacing:0, margin:0}\n *\n * If the frames are of different sizes, use an array of frame definitions. Each definition is itself an array\n * with 4 required and 3 optional entries, in the order:\n *\n *
\n *
The first four, `x`, `y`, `width`, and `height` are required and define the frame rectangle.
\n *
The fifth, `imageIndex`, specifies the index of the source image (defaults to 0)
\n *
The last two, `regX` and `regY` specify the registration point of the frame
\n * Optional. An object defining sequences of frames to play as named animations. Each property corresponds to an\n * animation of the same name. Each animation must specify the frames to play, and may\n * also include a relative playback `speed` (ex. 2 would playback at double speed, 0.5 at half), and\n * the name of the `next` animation to sequence to after it completes.\n *\n * There are three formats supported for defining the frames in an animation, which can be mixed and matched as appropriate:\n * \n * \t
for a single frame animation, you can simply specify the frame index\n *\n * \t\tanimations: {\n * \t\t\tsit: 7\n * \t\t}\n *\n *
\n *
\n * for an animation of consecutive frames, you can use an array with two required, and two optional entries\n * \t\tin the order: `start`, `end`, `next`, and `speed`. This will play the frames from start to end inclusive.\n *\n * \t\tanimations: {\n * \t\t\t// start, end, next*, speed*\n * \t\t\trun: [0, 8],\n * \t\t\tjump: [9, 12, \"run\", 2]\n * \t\t}\n *\n *
\n *
\n * for non-consecutive frames, you can use an object with a `frames` property defining an array of frame\n * indexes to play in order. The object can also specify `next` and `speed` properties.\n *\n * \t\tanimations: {\n * \t\t\twalk: {\n * \t\t\t\tframes: [1,2,3,3,2,1]\n * \t\t\t},\n * \t\t\tshoot: {\n * \t\t\t\tframes: [1,4,5,6],\n * \t\t\t\tnext: \"walk\",\n * \t\t\t\tspeed: 0.5\n * \t\t\t}\n * \t\t}\n *\n *
\n * \n * Note: the `speed` property was added in EaselJS 0.7.0. Earlier versions had a `frequency`\n * property instead, which was the inverse of `speed`. For example, a value of \"4\" would be 1/4 normal speed in\n * earlier versions, but is 4x normal speed in EaselJS 0.7.0+.\n *\n *
framerate
\n * Optional. Indicates the default framerate to play this spritesheet at in frames per second. See\n * {{#crossLink \"SpriteSheet/framerate:property\"}}{{/crossLink}} for more information.\n *\n * \t\tframerate: 20\n *\n * Note that the Sprite framerate will only work if the stage update method is provided with the {{#crossLink \"Ticker/tick:event\"}}{{/crossLink}}\n * event generated by the {{#crossLink \"Ticker\"}}{{/crossLink}}.\n *\n * \t\tcreatejs.Ticker.on(\"tick\", handleTick);\n * \t\tfunction handleTick(event) {\n *\t\t\tstage.update(event);\n *\t\t}\n *\n *
Example
\n * To define a simple sprite sheet, with a single image \"sprites.jpg\" arranged in a regular 50x50 grid with three\n * animations: \"stand\" showing the first frame, \"run\" looping frame 1-5 inclusive, and \"jump\" playing frame 6-8 and\n * sequencing back to run.\n *\n * \t\tvar data = {\n * \t\t\timages: [\"sprites.jpg\"],\n * \t\t\tframes: {width:50, height:50},\n * \t\t\tanimations: {\n * \t\t\t\tstand:0,\n * \t\t\t\trun:[1,5],\n * \t\t\t\tjump:[6,8,\"run\"]\n * \t\t\t}\n * \t\t};\n * \t\tvar spriteSheet = new createjs.SpriteSheet(data);\n * \t\tvar animation = new createjs.Sprite(spriteSheet, \"run\");\n *\n *
Generating SpriteSheet Images
\n * Spritesheets can be created manually by combining images in PhotoShop, and specifying the frame size or\n * coordinates manually, however there are a number of tools that facilitate this.\n *
\n *
Exporting SpriteSheets or HTML5 content from Adobe Flash/Animate supports the EaselJS SpriteSheet format.
SWF animations in Adobe Flash/Animate can be exported to SpriteSheets using
\n *
\n *\n *
Cross Origin Issues
\n * Warning: Images loaded cross-origin will throw cross-origin security errors when interacted with\n * using:\n *
\n *
a mouse
\n *
methods such as {{#crossLink \"Container/getObjectUnderPoint\"}}{{/crossLink}}
\n *
Filters (see {{#crossLink \"Filter\"}}{{/crossLink}})
\n *
caching (see {{#crossLink \"DisplayObject/cache\"}}{{/crossLink}})
\n *
\n * You can get around this by setting `crossOrigin` property on your images before passing them to EaselJS, or\n * setting the `crossOrigin` property on PreloadJS' LoadQueue or LoadItems.\n *\n * \t\tvar image = new Image();\n * \t\timg.crossOrigin=\"Anonymous\";\n * \t\timg.src = \"http://server-with-CORS-support.com/path/to/image.jpg\";\n *\n * If you pass string paths to SpriteSheets, they will not work cross-origin. The server that stores the image must\n * support cross-origin requests, or this will not work. For more information, check out\n * CORS overview on MDN.\n *\n * @memberof easeljs\n * @extends core.EventDispatcher\n * @param {Object} data An object describing the SpriteSheet data.\n */\nexport default class SpriteSheet extends EventDispatcher {\n\n\tconstructor (data) {\n\t\tsuper();\n\n\t\t/**\n\t\t * Indicates whether all images are finished loading.\n\t\t * @type {Boolean}\n\t\t * @readonly\n\t\t */\n\t\tthis.complete = true;\n\n\t\t/**\n\t\t * Specifies the framerate to use by default for Sprite instances using the SpriteSheet. See the Sprite class\n\t\t * {@link easeljs.Sprite#framerate} for more information.\n\t\t * @type Number\n\t\t */\n\t\tthis.framerate = 0;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Array}\n\t\t */\n\t\tthis._animations = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Array}\n\t\t */\n\t\tthis._frames = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Array}\n\t\t */\n\t\tthis._images = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Object}\n\t\t */\n\t\tthis._data = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._loadCount = 0;\n\n\t\t// only used for simple frame defs:\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._frameHeight = 0;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._frameWidth = 0;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._numFrames = 0;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._regX = 0;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._regY = 0;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._spacing = 0;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._margin = 0;\n\n\t\tthis._parseData(data);\n\t}\n\n\t/**\n\t * Returns an array of all available animation names available on this sprite sheet as strings.\n\t * @type {Array}\n\t * @readonly\n\t */\n\tget animations () {\n\t\treturn this._animations.slice();\n\t}\n\n\t/**\n\t * Returns the total number of frames in the specified animation, or in the whole sprite\n\t * sheet if the animation param is omitted. Returns 0 if the spritesheet relies on calculated frame counts, and\n\t * the images have not been fully loaded.\n\t * @param {String} animation The name of the animation to get a frame count for.\n\t * @return {Number} The number of frames in the animation, or in the entire sprite sheet if the animation param is omitted.\n\t */\n\tgetNumFrames (animation) {\n\t\tif (animation == null) {\n\t\t\treturn this._frames ? this._frames.length : this._numFrames || 0;\n\t\t} else {\n\t\t\tlet data = this._data[animation];\n\t\t\tif (data == null) { return 0; }\n\t\t\telse { return data.frames.length; }\n\t\t}\n\t}\n\n\t/**\n\t * Returns an object defining the specified animation. The returned object contains:\n\t *
\n\t * \t
frames: an array of the frame ids in the animation
\n\t * \t
speed: the playback speed for this animation
\n\t * \t
name: the name of the animation
\n\t * \t
next: the default animation to play next. If the animation loops, the name and next property will be the same.
\n\t *
\n\t * @param {String} name The name of the animation to get.\n\t * @return {Object} a generic object with frames, speed, name, and next properties.\n\t */\n\tgetAnimation (name) {\n\t\treturn this._data[name];\n\t}\n\n\t/**\n\t * Returns an object specifying the image and source rect of the specified frame. The returned object has:\n\t *
\n\t * \t
an image property holding a reference to the image object in which the frame is found
\n\t * \t
a rect property containing a Rectangle instance which defines the boundaries for the frame within that image.
\n\t * \t
A regX and regY property corresponding to the regX/Y values for the frame.\n\t *
\n\t * @param {Number} frameIndex The index of the frame.\n\t * @return {Object} a generic object with image and rect properties. Returns null if the frame does not exist.\n\t */\n\tgetFrame (frameIndex) {\n\t\tlet frame;\n\t\tif (this._frames && (frame = this._frames[frameIndex])) { return frame; }\n\t\treturn null;\n\t}\n\n\t/**\n\t * Returns a {@link easeljs.Rectangle} instance defining the bounds of the specified frame relative\n\t * to the origin.\n\t *\n\t * @param {Number} frameIndex The index of the frame.\n\t * @param {easeljs.Rectangle} [rectangle] A Rectangle instance to copy the values into. By default a new instance is created.\n\t * @return {easeljs.Rectangle} A Rectangle instance. Returns null if the frame does not exist, or the image is not fully loaded.\n\t */\n\tgetFrameBounds (frameIndex, rectangle = new Rectangle()) {\n\t\tlet frame = this.getFrame(frameIndex);\n\t\treturn frame ? rectangle.setValues(-frame.regX, -frame.regY, frame.rect.width, frame.rect.height) : null;\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name}]`;\n\t}\n\n\t/**\n\t * SpriteSheet cannot be cloned. A SpriteSheet can be shared by multiple Sprite instances without cloning it.\n\t * @override\n\t * @throws SpriteSheet cannot be cloned.\n\t */\n\tclone () {\n\t\tthrow \"SpriteSheet cannot be cloned.\";\n\t}\n\n\t/**\n\t * @param {Object} data An object describing the SpriteSheet data.\n\t * @protected\n\t */\n\t_parseData (data) {\n\t\tif (data == null) { return; }\n\t\tthis.framerate = data.framerate||0;\n\n\t\t// parse images:\n\t\tif (data.images) {\n\t\t\tfor (let img of data.images) {\n\t\t\t\tlet a = this._images = [];\n\t\t\t\tlet src;\n\t\t\t\tif (typeof img === \"string\") {\n\t\t\t\t\tsrc = img;\n\t\t\t\t\timg = document.createElement(\"img\");\n\t\t\t\t\timg.src = src;\n\t\t\t\t}\n\t\t\t\ta.push(img);\n\t\t\t\tif (!img.getContext && !img.naturalWidth) {\n\t\t\t\t\tthis._loadCount++;\n\t\t\t\t\tthis.complete = false;\n\t\t\t\t\timg.onload = () => this._handleImageLoad(src);\n\t\t\t\t\timg.onerror = () => this._handleImageError(src);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// parse frames:\n\t\tif (data.frames != null) {\n\t\t\tif (Array.isArray(data.frames)) {\n\t\t\t\tthis._frames = [];\n\t\t\t\tfor (let arr of data.frames) {\n\t\t\t\t\tthis._frames.push({image:this._images[arr[4]?arr[4]:0], rect:new Rectangle(arr[0],arr[1],arr[2],arr[3]), regX:arr[5]||0, regY:arr[6]||0 });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlet o = data.frames;\n\t\t\t\tthis._frameWidth = o.width;\n\t\t\t\tthis._frameHeight = o.height;\n\t\t\t\tthis._regX = o.regX||0;\n\t\t\t\tthis._regY = o.regY||0;\n\t\t\t\tthis._spacing = o.spacing||0;\n\t\t\t\tthis._margin = o.margin||0;\n\t\t\t\tthis._numFrames = o.count;\n\t\t\t\tif (this._loadCount === 0) { this._calculateFrames(); }\n\t\t\t}\n\t\t}\n\n\t\t// parse animations:\n\t\tthis._animations = [];\n\t\tif (data.animations != null) {\n\t\t\tthis._data = {};\n\t\t\tlet o = data.animations;\n\t\t\tfor (let name in o) {\n\t\t\t\tlet anim = { name };\n\t\t\t\tlet obj = o[name];\n\t\t\t\tlet a;\n\t\t\t\tif (typeof obj === \"number\") { // single frame\n\t\t\t\t\ta = anim.frames = [obj];\n\t\t\t\t} else if (Array.isArray(obj)) { // simple\n\t\t\t\t\tif (obj.length === 1) { anim.frames = [obj[0]]; }\n\t\t\t\t\telse {\n\t\t\t\t\t\tanim.speed = obj[3];\n\t\t\t\t\t\tanim.next = obj[2];\n\t\t\t\t\t\ta = anim.frames = [];\n\t\t\t\t\t\tfor (let i=obj[0];i<=obj[1];i++) {\n\t\t\t\t\t\t\ta.push(i);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else { // complex\n\t\t\t\t\tanim.speed = obj.speed;\n\t\t\t\t\tanim.next = obj.next;\n\t\t\t\t\tlet frames = obj.frames;\n\t\t\t\t\ta = anim.frames = (typeof frames === \"number\") ? [frames] : frames.slice(0);\n\t\t\t\t}\n\t\t\t\tif (anim.next === true || anim.next === undefined) { anim.next = name; } // loop\n\t\t\t\tif (anim.next === false || (a.length < 2 && anim.next === name)) { anim.next = null; } // stop\n\t\t\t\tif (!anim.speed) { anim.speed = 1; }\n\t\t\t\tthis._animations.push(name);\n\t\t\t\tthis._data[name] = anim;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @emits easeljs.SpriteSheet#event:complete\n\t * @protected\n\t * @param {Object} src\n\t */\n\t _handleImageLoad (src) {\n\t\tif (--this._loadCount === 0) {\n\t\t\tthis._calculateFrames();\n\t\t\tthis.complete = true;\n\t\t\tthis.dispatchEvent(\"complete\");\n\t\t}\n\t}\n\n\t/**\n\t * @emits easeljs.SpriteSheet#event:complete\n\t * @emits easeljs.SpriteSheet#event:error\n\t * @protected\n\t * @param {Object} src\n\t */\n\t_handleImageError (src) {\n\t\tlet errorEvent = new Event(\"error\");\n\t\terrorEvent.src = src;\n\t\tthis.dispatchEvent(errorEvent);\n\n\t\t// Complete is still dispatched.\n\t\tif (--this._loadCount === 0) {\n\t\t\tthis.dispatchEvent(\"complete\");\n\t\t}\n\t}\n\n\t/**\n\t * @protected\n\t */\n\t_calculateFrames () {\n\t\tif (this._frames || this._frameWidth === 0) { return; }\n\n\t\tthis._frames = [];\n\n\t\tlet maxFrames = this._numFrames || 100000; // if we go over this, something is wrong.\n\t\tlet frameCount = 0, frameWidth = this._frameWidth, frameHeight = this._frameHeight;\n\t\tlet spacing = this._spacing, margin = this._margin;\n\n\t\timgLoop:\n\t\tfor (let i=0, imgs=this._images, l=imgs.length; i= maxFrames) { break imgLoop; }\n\t\t\t\t\tframeCount++;\n\t\t\t\t\tthis._frames.push({\n\t\t\t\t\t\timage: img,\n\t\t\t\t\t\trect: new Rectangle(x, y, frameWidth, frameHeight),\n\t\t\t\t\t\tregX: this._regX,\n\t\t\t\t\t\tregY: this._regY\n\t\t\t\t\t});\n\t\t\t\t\tx += frameWidth+spacing;\n\t\t\t\t}\n\t\t\t\ty += frameHeight+spacing;\n\t\t\t}\n\t\t}\n\t\tthis._numFrames = frameCount;\n\t}\n\n}\n\n/**\n * Dispatched when all images are loaded. Note that this only fires if the images\n * were not fully loaded when the sprite sheet was initialized. You should check the complete property\n * to prior to adding a listener. Ex.\n *\n * \tvar sheet = new createjs.SpriteSheet(data);\n * \tif (!sheet.complete) {\n * \t\t// not preloaded, listen for the complete event:\n * \t\tsheet.addEventListener(\"complete\", handler);\n * \t}\n *\n * @event easeljs.SpriteSheet#complete\n * @property {Object} target The object that dispatched the event.\n * @property {String} type The event type.\n * @since 0.6.0\n */\n\n/**\n * Dispatched when getFrame is called with a valid frame index. This is primarily intended for use by {@link easeljs.SpriteSheetBuilder}\n * when doing on-demand rendering.\n * @event easeljs.SpriteSheet#getframe\n * @property {Number} index The frame index.\n * @property {Object} frame The frame object that getFrame will return.\n */\n\n/**\n * Dispatched when an image encounters an error. A SpriteSheet will dispatch an error event for each image that\n * encounters an error, and will still dispatch a {@link easeljs.SpriteSheet#event:complete}\n * event once all images are finished processing, even if an error is encountered.\n * @event easeljs.SpriteSheet#error\n * @property {String} src The source of the image that failed to load.\n * @since 0.8.2\n */\n","/**\n * @license Text\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport DisplayObject from \"./DisplayObject\";\nimport createCanvas from \"../utils/Canvas\";\n\n/**\n * Display one or more lines of dynamic text (not user editable) in the display list. Line wrapping support (using the\n * lineWidth) is very basic, wrapping on spaces and tabs only. Note that as an alternative to Text, you can position HTML\n * text above or below the canvas relative to items in the display list using the {@link easeljs.DisplayObject#localToGlobal}\n * method, or using {@link easeljs.DOMElement}.\n *\n * Please note that Text does not support HTML text, and can only display one font style at a time. To use\n * multiple font styles, you will need to create multiple text instances, and position them manually.\n *\n * CreateJS Text supports web fonts (the same rules as Canvas). The font must be loaded and supported by the browser\n * before it can be displayed.\n *\n * Note: Text can be expensive to generate, so cache instances where possible. Be aware that not all\n * browsers will render Text exactly the same.\n *\n * @memberof easeljs\n * @extends easeljs.DisplayObject\n * @example\n * let text = new Text(\"Hello World\", \"20px Arial\", \"#ff7700\");\n * text.x = 100;\n * text.textBaseline = \"alphabetic\";\n *\n * @param {String} [text] The text to display.\n * @param {String} [font] The font style to use. Any valid value for the CSS font attribute is acceptable (ex. \"bold\n * 36px Arial\").\n * @param {String} [color] The color to draw the text in. Any valid value for the CSS color attribute is acceptable (ex.\n * \"#F00\", \"red\", or \"#FF0000\").\n */\nexport default class Text extends DisplayObject {\n\n\tconstructor (text, font, color) {\n\t\tsuper();\n\n\t\t/**\n\t\t * The text to display.\n\t\t * @type {String}\n\t\t */\n\t\tthis.text = text;\n\n\t\t/**\n\t\t * The font style to use. Any valid value for the CSS font attribute is acceptable (ex. \"bold 36px Arial\").\n\t\t * @type {String}\n\t\t */\n\t\tthis.font = font;\n\n\t\t/**\n\t\t * The color to draw the text in. Any valid value for the CSS color attribute is acceptable (ex. \"#F00\"). Default is \"#000\".\n\t\t * It will also accept valid canvas fillStyle values.\n\t\t * @type {String}\n\t\t */\n\t\tthis.color = color;\n\n\t\t/**\n\t\t * The horizontal text alignment. Any of \"start\", \"end\", \"left\", \"right\", and \"center\".\n\t\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#text-styles \"WHATWG spec\"}\n\t\t * @type {String}\n\t\t * @default left\n\t\t */\n\t\tthis.textAlign = \"left\";\n\n\t\t/**\n\t\t * The vertical alignment point on the font. Any of \"top\", \"hanging\", \"middle\", \"alphabetic\", \"ideographic\", or \"bottom\".\n\t\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#text-styles \"WHATWG spec\"}\n\t\t * @type {String}\n\t\t * @default top\n\t\t*/\n\t\tthis.textBaseline = \"top\";\n\n\t\t/**\n\t\t * The maximum width to draw the text. If maxWidth is specified (not null), the text will be condensed or\n\t\t * shrunk to make it fit in this width.\n\t\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#text-styles \"WHATWG spec\"}\n\t\t * @type {Number}\n\t\t*/\n\t\tthis.maxWidth = null;\n\n\t\t/**\n\t\t * If greater than 0, the text will be drawn as a stroke (outline) of the specified width.\n\t\t * @type {Number}\n\t\t */\n\t\tthis.outline = 0;\n\n\t\t/**\n\t\t * Indicates the line height (vertical distance between baselines) for multi-line text. If null or 0,\n\t\t * the value of getMeasuredLineHeight is used.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.lineHeight = 0;\n\n\t\t/**\n\t\t * Indicates the maximum width for a line of text before it is wrapped to multiple lines. If null,\n\t\t * the text will not be wrapped.\n\t\t * @type {Number}\n\t\t */\n\t\tthis.lineWidth = null;\n\t}\n\n \tisVisible () {\n \t\tlet hasContent = this.cacheCanvas || (this.text != null && this.text !== \"\");\n \t\treturn !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && hasContent);\n \t}\n\n \tdraw (ctx, ignoreCache) {\n \t\tif (super.draw(ctx, ignoreCache)) { return true; }\n\n \t\tlet col = this.color || \"#000\";\n \t\tif (this.outline) { ctx.strokeStyle = col; ctx.lineWidth = this.outline*1; }\n \t\telse { ctx.fillStyle = col; }\n\n \t\tthis._drawText(this._prepContext(ctx));\n \t\treturn true;\n \t}\n\n \t/**\n \t * Returns the measured, untransformed width of the text without wrapping. Use getBounds for a more robust value.\n \t * @return {Number} The measured, untransformed width of the text.\n \t */\n \tgetMeasuredWidth () {\n \t\treturn this._getMeasuredWidth(this.text);\n \t}\n\n \t/**\n \t * Returns an approximate line height of the text, ignoring the lineHeight property. This is based on the measured\n \t * width of a \"M\" character multiplied by 1.2, which provides an approximate line height for most fonts.\n \t * @return {Number} an approximate line height of the text, ignoring the lineHeight property. This is\n \t * based on the measured width of a \"M\" character multiplied by 1.2, which approximates em for most fonts.\n \t */\n \tgetMeasuredLineHeight () {\n \t\treturn this._getMeasuredWidth(\"M\")*1.2;\n \t}\n\n \t/**\n \t * Returns the approximate height of multi-line text by multiplying the number of lines against either the\n \t * `lineHeight` (if specified) or {@link easeljs.Text#getMeasuredLineHeight}. Note that\n \t * this operation requires the text flowing logic to run, which has an associated CPU cost.\n \t * @return {Number} The approximate height of the untransformed multi-line text.\n \t */\n \tgetMeasuredHeight () {\n \t\treturn this._drawText(null, {}).height;\n \t}\n\n \tgetBounds () {\n \t\tlet rect = super.getBounds();\n \t\tif (rect) { return rect; }\n \t\tif (this.text == null || this.text === \"\") { return null; }\n \t\tlet o = this._drawText(null, {});\n \t\tlet w = (this.maxWidth && this.maxWidth < o.width) ? this.maxWidth : o.width;\n \t\tlet x = w * Text.H_OFFSETS[this.textAlign||\"left\"];\n \t\tlet lineHeight = this.lineHeight||this.getMeasuredLineHeight();\n \t\tlet y = lineHeight * Text.V_OFFSETS[this.textBaseline||\"top\"];\n \t\treturn this._rectangle.setValues(x, y, w, o.height);\n \t}\n\n \t/**\n \t * Returns an object with width, height, and lines properties. The width and height are the visual width and height\n \t * of the drawn text. The lines property contains an array of strings, one for\n \t * each line of text that will be drawn, accounting for line breaks and wrapping. These strings have trailing\n \t * whitespace removed.\n \t * @return {Object} An object with width, height, and lines properties.\n \t */\n \tgetMetrics () {\n \t\tlet o = {lines:[]};\n \t\to.lineHeight = this.lineHeight || this.getMeasuredLineHeight();\n \t\to.vOffset = o.lineHeight * Text.V_OFFSETS[this.textBaseline||\"top\"];\n \t\treturn this._drawText(null, o, o.lines);\n \t}\n\n \t/**\n \t * Returns a clone of the Text instance.\n \t * @return {easeljs.Text} a clone of the Text instance.\n \t */\n \tclone () {\n \t\treturn this._cloneProps(new Text(this.text, this.font, this.color));\n \t}\n\n \t/**\n \t * Returns a string representation of this object.\n \t * @override\n \t * @return {String} a string representation of the instance.\n \t */\n \ttoString () {\n \t\treturn `[${this.constructor.name} (text=${this.text.length > 20 ? `${this.text.substr(0, 17)}...` : this.text})]`;\n \t}\n\n \t/**\n \t * @param {easeljs.Text} o\n \t * @protected\n \t * @return {easeljs.Text} o\n \t */\n \t_cloneProps (o) {\n \t\tsuper._cloneProps(o);\n \t\to.textAlign = this.textAlign;\n \t\to.textBaseline = this.textBaseline;\n \t\to.maxWidth = this.maxWidth;\n \t\to.outline = this.outline;\n \t\to.lineHeight = this.lineHeight;\n \t\to.lineWidth = this.lineWidth;\n \t\treturn o;\n \t}\n\n \t/**\n \t * @param {CanvasRenderingContext2D} ctx\n \t * @return {CanvasRenderingContext2D}\n \t * @protected\n \t */\n \t_prepContext (ctx) {\n \t\tctx.font = this.font||\"10px sans-serif\";\n \t\tctx.textAlign = this.textAlign||\"left\";\n \t\tctx.textBaseline = this.textBaseline||\"top\";\n\t\tctx.lineJoin = \"miter\";\n\t\tctx.miterLimit = 2.5;\n\t\treturn ctx;\n\t}\n\n\t/**\n\t * Draws multiline text.\n\t * @param {CanvasRenderingContext2D} ctx\n\t * @param {Object} o\n\t * @param {Array} lines\n\t * @return {Object}\n\t * @protected\n\t */\n \t_drawText (ctx, o, lines) {\n \t\tconst paint = !!ctx;\n \t\tif (!paint) {\n \t\t\tctx = Text._ctx;\n \t\t\tctx.save();\n \t\t\tthis._prepContext(ctx);\n \t\t}\n \t\tlet lineHeight = this.lineHeight||this.getMeasuredLineHeight();\n\n \t\tlet maxW = 0, count = 0;\n \t\tlet hardLines = String(this.text).split(/(?:\\r\\n|\\r|\\n)/);\n \t\tfor (let str of hardLines) {\n \t\t\tlet w = null;\n\n \t\t\tif (this.lineWidth != null && (w = ctx.measureText(str).width) > this.lineWidth) {\n \t\t\t\t// text wrapping:\n \t\t\t\tlet words = str.split(/(\\s)/);\n \t\t\t\tstr = words[0];\n \t\t\t\tw = ctx.measureText(str).width;\n\n\t\t\t\tconst l = words.length;\n \t\t\t\tfor (let i=1; i this.lineWidth) {\n \t\t\t\t\t\tif (paint) { this._drawTextLine(ctx, str, count*lineHeight); }\n \t\t\t\t\t\tif (lines) { lines.push(str); }\n \t\t\t\t\t\tif (w > maxW) { maxW = w; }\n \t\t\t\t\t\tstr = words[i+1];\n \t\t\t\t\t\tw = ctx.measureText(str).width;\n \t\t\t\t\t\tcount++;\n \t\t\t\t\t} else {\n \t\t\t\t\t\tstr += words[i] + words[i+1];\n \t\t\t\t\t\tw += wordW;\n \t\t\t\t\t}\n \t\t\t\t}\n \t\t\t}\n\n \t\t\tif (paint) { this._drawTextLine(ctx, str, count*lineHeight); }\n \t\t\tif (lines) { lines.push(str); }\n \t\t\tif (o && w == null) { w = ctx.measureText(str).width; }\n \t\t\tif (w > maxW) { maxW = w; }\n \t\t\tcount++;\n \t\t}\n\n \t\tif (o) {\n \t\t\to.width = maxW;\n \t\t\to.height = count*lineHeight;\n \t\t}\n \t\tif (!paint) { ctx.restore(); }\n \t\treturn o;\n \t}\n\n \t/**\n \t * @param {CanvasRenderingContext2D} ctx\n \t * @param {String} text\n \t * @param {Number} y\n \t * @protected\n \t */\n \t_drawTextLine (ctx, text, y) {\n \t\t// Chrome 17 will fail to draw the text if the last param is included but null, so we feed it a large value instead:\n \t\tif (this.outline) { ctx.strokeText(text, 0, y, this.maxWidth||0xFFFF); }\n \t\telse { ctx.fillText(text, 0, y, this.maxWidth||0xFFFF); }\n \t}\n\n \t/**\n \t * @param {String} text\n \t * @protected\n \t */\n \t_getMeasuredWidth (text) {\n \t\tlet ctx = Text._ctx;\n \t\tctx.save();\n \t\tlet w = this._prepContext(ctx).measureText(text).width;\n \t\tctx.restore();\n \t\treturn w;\n \t}\n\n}\n\n/**\n * Lookup table for the ratio to offset bounds x calculations based on the textAlign property.\n * @type {Object}\n * @readonly\n * @static\n */\nText.H_OFFSETS = {start: 0, left: 0, center: -0.5, end: -1, right: -1};\n/**\n * Lookup table for the ratio to offset bounds y calculations based on the textBaseline property.\n * @type {Object}\n * @readonly\n * @static\n */\nText.V_OFFSETS = {top: 0, hanging: -0.01, middle: -0.4, alphabetic: -0.8, ideographic: -0.85, bottom: -1};\n\n/**\n * @property _ctx\n * @type {CanvasRenderingContext2D}\n * @private\n * @static\n */\nText._ctx = createCanvas().getContext(\"2d\");\n","/**\n * @license AlphaMapFilter\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Filter from \"./Filter\";\n\n/**\n * Applies a greyscale alpha map image (or canvas) to the target, such that the alpha channel of the result will\n * be copied from the red channel of the map, and the RGB channels will be copied from the target.\n *\n * Generally, it is recommended that you use {@link easeljs.AlphaMaskFilter}, because it has much better performance.\n *\n * @memberof easeljs\n * @extends easeljs.Filter\n * @example *\n * let box = new Shape();\n * box.graphics.beginLinearGradientFill([\"#ff0000\", \"#0000ff\"], [0, 1], 0, 0, 0, 100)\n * box.graphics.drawRect(0, 0, 100, 100);\n * box.cache(0, 0, 100, 100);\n * let bmp = new Bitmap(\"path/to/image.jpg\");\n * bmp.filters = [ new AlphaMapFilter(box.cacheCanvas) ];\n * bmp.cache(0, 0, 100, 100);\n *\n * @param {HTMLImageElement | HTMLCanvasElement} alphaMap The greyscale image (or canvas) to use as the alpha value for the\n * result. This should be exactly the same dimensions as the target.\n */\nexport default class AlphaMapFilter extends Filter {\n\n\tconstructor (alphaMap) {\n\t\tsuper();\n\n\t\t/**\n\t\t * The greyscale image (or canvas) to use as the alpha value for the result. This should be exactly the same\n\t\t * dimensions as the target.\n\t\t * @type {HTMLImageElement | HTMLCanvasElement}\n\t\t */\n\t\tthis.alphaMap = alphaMap;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {HTMLImageElement | HTMLCanvasElement}\n\t\t * @default null\n\t\t */\n\t\tthis._alphaMap = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Uint8ClampedArray}\n\t\t * @default null\n\t\t */\n\t\tthis._mapData = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {*}\n\t\t * @default null\n\t\t */\n\t\tthis._mapTexture = null;\n\n\t\tthis.FRAG_SHADER_BODY = `\n\t\t\tuniform sampler2D uAlphaSampler;\n\n\t\t\tvoid main (void) {\n\t\t\t\tvec4 color = texture2D(uSampler, vRenderCoord);\n\t\t\t\tvec4 alphaMap = texture2D(uAlphaSampler, vTextureCoord);\n\n\t\t\t\t// some image formats can have transparent white rgba(1,1,1, 0) when put on the GPU, this means we need a slight tweak\n\t\t\t\t// using ceil ensure that the colour will be used so long as it exists but pure transparency will be treated black\n\t\t\t\tgl_FragColor = vec4(color.rgb, color.a * (alphaMap.r * ceil(alphaMap.a)));\n\t\t\t}\n\t\t`;\n\t}\n\n\t/**\n\t * @todo docs\n\t * @param {*} gl\n\t * @param {*} stage\n\t * @param {*} shaderProgram\n\t */\n\tshaderParamSetup (gl, stage, shaderProgram) {\n\t\tif (!this._mapTexture) { this._mapTexture = gl.createTexture(); }\n\n\t\tgl.activeTexture(gl.TEXTURE1);\n\t\tgl.bindTexture(gl.TEXTURE_2D, this._mapTexture);\n\t\tstage.setTextureParams(gl);\n\t\tgl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this.alphaMap);\n\n\t\tgl.uniform1i(\n\t\t\tgl.getUniformLocation(shaderProgram, \"uAlphaSampler\"),\n\t\t\t1\n\t\t);\n\t}\n\n\t/**\n\t * @return {easeljs.AlphaMapFilter}\n\t */\n\tclone () {\n\t\tlet o = new AlphaMapFilter(this.alphaMap);\n\t\to._alphaMap = this._alphaMap;\n\t\to._mapData = this._mapData;\n\t\treturn o;\n\t}\n\n\t_applyFilter (imageData) {\n\t\tif (!this.alphaMap) { return true; }\n\t\tif (!this._prepAlphaMap()) { return false; }\n\n\t\t// TODO: update to support scenarios where the target has different dimensions.\n\t\tlet data = imageData.data;\n\t\tlet map = this._mapData;\n\t\tconst l = data.length;\n\t\tfor (let i=0; iIMPORTANT NOTE: This filter currently does not support the targetCtx, or targetX/Y parameters correctly.\n *\n * @memberof easeljs\n * @extends easeljs.Filter\n * @example\n * var box = new Shape();\n * box.graphics.beginLinearGradientFill([\"#000000\", \"rgba(0, 0, 0, 0)\"], [0, 1], 0, 0, 100, 100)\n * box.graphics.drawRect(0, 0, 100, 100);\n * box.cache(0, 0, 100, 100);\n * var bmp = new Bitmap(\"path/to/image.jpg\");\n * bmp.filters = [ new AlphaMaskFilter(box.cacheCanvas) ];\n * bmp.cache(0, 0, 100, 100);\n *\n * @param {HTMLImageElement | HTMLCanvasElement} mask\n */\nexport default class AlphaMaskFilter extends Filter {\n\n\tconstructor (mask) {\n\t\tsuper();\n\n\t\t/**\n\t\t * The image (or canvas) to use as the mask.\n\t\t * @type {HTMLImageElement | HTMLCanvasElement}\n\t\t */\n\t\tthis.mask = mask;\n\n\t\tthis.usesContext = true;\n\n\t\tthis.FRAG_SHADER_BODY = `\n\t\t\tuniform sampler2D uAlphaSampler;\n\n\t\t\tvoid main (void) {\n\t\t\t\tvec4 color = texture2D(uSampler, vRenderCoord);\n\t\t\t\tvec4 alphaMap = texture2D(uAlphaSampler, vTextureCoord);\n\n\t\t\t\tgl_FragColor = vec4(color.rgb, color.a * alphaMap.a);\n\t\t\t}\n\t\t`;\n\t}\n\n\t/**\n\t * Applies the filter to the specified context.\n\t *\n\t * IMPORTANT NOTE: This filter currently does not support the targetCtx, or targetX/Y parameters correctly.\n\t * @param {CanvasRenderingContext2D} ctx The 2D context to use as the source.\n\t * @param {Number} x The x position to use for the source rect.\n\t * @param {Number} y The y position to use for the source rect.\n\t * @param {Number} width The width to use for the source rect.\n\t * @param {Number} height The height to use for the source rect.\n\t * @param {CanvasRenderingContext2D} [targetCtx] NOT SUPPORTED IN THIS FILTER. The 2D context to draw the result to. Defaults to the context passed to ctx.\n\t * @param {Number} [targetX] NOT SUPPORTED IN THIS FILTER. The x position to draw the result to. Defaults to the value passed to x.\n\t * @param {Number} [targetY] NOT SUPPORTED IN THIS FILTER. The y position to draw the result to. Defaults to the value passed to y.\n\t * @return {Boolean} If the filter was applied successfully.\n\t */\n\tapplyFilter (ctx, x, y, width, height, targetCtx, targetX, targetY) {\n\t\tif (!this.mask) { return true; }\n\t\ttargetCtx = targetCtx || ctx;\n\t\tif (targetX == null) { targetX = x; }\n\t\tif (targetY == null) { targetY = y; }\n\n\t\ttargetCtx.save();\n\t\tif (ctx != targetCtx) {\n\t\t\t// TODO: support targetCtx and targetX/Y\n\t\t\t// clearRect, then draw the ctx in?\n\t\t\treturn false;\n\t\t}\n\n\t\ttargetCtx.globalCompositeOperation = \"destination-in\";\n\t\ttargetCtx.drawImage(this.mask, targetX, targetY);\n\t\ttargetCtx.restore();\n\t\treturn true;\n\t}\n\n\t/**\n\t * @return {easeljs.AlphaMaskFilter}\n\t */\n\tclone () {\n\t\treturn new AlphaMaskFilter(this.mask);\n\t}\n\n\t/**\n\t * @todo docs\n\t * @param {*} gl\n\t * @param {*} stage\n\t * @param {*} shaderProgram\n\t */\n\tshaderParamSetup (gl, stage, shaderProgram) {\n\t\tif(!this._mapTexture) { this._mapTexture = gl.createTexture(); }\n\n\t\tgl.activeTexture(gl.TEXTURE1);\n\t\tgl.bindTexture(gl.TEXTURE_2D, this._mapTexture);\n\t\tstage.setTextureParams(gl);\n\t\tgl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this.mask);\n\n\t\tgl.uniform1i(\n\t\t\tgl.getUniformLocation(shaderProgram, \"uAlphaSampler\"),\n\t\t\t1\n\t\t);\n\t}\n\n}\n","/**\n * @license BlurFilter\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * BoxBlur Algorithm by Mario Klingemann, quasimondo.com\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Filter from \"./Filter\";\nimport Rectangle from \"../geom/Rectangle\";\n\n/**\n * Applies a box blur to DisplayObjects. Note that this filter is fairly CPU intensive, particularly if the quality is\n * set higher than 1.\n *\n * @memberof easeljs\n * @extends easeljs.Filter\n * @example\n * let shape = new Shape().set({x:100,y:100});\n * shape.graphics.beginFill(\"#ff0000\").drawCircle(0,0,50);\n * let blurFilter = new BlurFilter(5, 5, 1);\n * shape.filters = [blurFilter];\n * let bounds = blurFilter.getBounds();\n * shape.cache(-50+bounds.x, -50+bounds.y, 100+bounds.width, 100+bounds.height);\n *\n * @param {Number} [blurX=0] The horizontal blur radius in pixels.\n * @param {Number} [blurY=0] The vertical blur radius in pixels.\n * @param {Number} [quality=1] The number of blur iterations.\n */\nexport default class BlurFilter extends Filter {\n\n\tconstructor (blurX = 0, blurY = 0, quality = 1) {\n\t\tsuper();\n\n\t\t/**\n\t\t * @protected\n\t\t * @default 0\n\t\t * @type {Number}\n\t\t */\n\t\tthis._blurX = blurX;\n\t\t/**\n\t\t * @protected\n\t\t * @type {Array}\n\t\t */\n\t\tthis._blurXTable = [];\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default null\n\t\t */\n\t\tthis._lastBlurX = null;\n\n\t\t/**\n\t\t * @default 0\n\t\t * @type {Number}\n\t\t */\n\t\tthis._blurY = blurY;\n\t\t/**\n\t\t * @protected\n\t\t * @type {Array}\n\t\t */\n\t\tthis._blurYTable = [];\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default null\n\t\t */\n\t\tthis._lastBlurY = null;\n\n\t\t/**\n\t\t * Number of blur iterations. For example, a value of 1 will produce a rough blur. A value of 2 will produce a\n\t\t * smoother blur, but take twice as long to run.\n\t\t * @default 1\n\t\t * @type {Number}\n\t\t */\n\t\tthis._quality = (isNaN(quality) || quality < 1) ? 1 : quality;\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default null\n\t\t */\n\t\tthis._lastQuality = null;\n\n\t\tthis.FRAG_SHADER_TEMPLATE = `\n\t\t\tuniform float xWeight[{{blurX}}];\n\t\t\tuniform float yWeight[{{blurY}}];\n\t\t\tuniform vec2 textureOffset;\n\t\t\tvoid main (void) {\n\t\t\t\tvec4 color = vec4(0.0);\n\n\t\t\t\tfloat xAdj = ({{blurX}}.0-1.0)/2.0;\n\t\t\t\tfloat yAdj = ({{blurY}}.0-1.0)/2.0;\n\t\t\t\tvec2 sampleOffset;\n\n\t\t\t\tfor(int i=0; i<{{blurX}}; i++) {\n\t\t\t\t\tfor(int j=0; j<{{blurY}}; j++) {\n\t\t\t\t\t\tsampleOffset = vRenderCoord + (textureOffset * vec2(float(i)-xAdj, float(j)-yAdj));\n\t\t\t\t\t\tcolor += texture2D(uSampler, sampleOffset) * (xWeight[i] * yWeight[j]);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = color.rgba;\n\t\t\t}\n\t\t`;\n\t}\n\n\t/**\n\t * Horizontal blur radius in pixels.\n\t * @type {Number}\n\t */\n\tget blurX () { return this._blurX; }\n\tset blurX (blurX) {\n\t\tif (isNaN(blurX) || blurX < 0) { blurX = 0; }\n\t\tthis._blurX = blurX;\n\t}\n\n\t/**\n\t * Vertical blur radius in pixels.\n\t * @type {Number}\n\t */\n\tget blurY () { return this._blurY; }\n\tset blurY (blurY) {\n\t\tif (isNaN(blurY) || blurY < 0) { blurY = 0; }\n\t\tthis._blurY = blurY;\n\t}\n\n\t/**\n\t * Number of blur iterations. For example, a value of 1 will produce a rough blur. A value of 2 will produce a\n\t * smoother blur, but take twice as long to run.\n\t * @type {Number}\n\t */\n\tget quality () { return this._quality | 0; }\n\tset quality (quality) {\n\t\tif (isNaN(quality) || quality < 0) { quality = 0; }\n\t\tthis._quality = quality;\n\t}\n\n\t/**\n\t * @protected\n\t * @type {*}\n\t */\n\tget _buildShader () {\n\t\tconst xChange = this._lastBlurX !== this._blurX;\n\t\tconst yChange = this._lastBlurY !== this._blurY;\n\t\tconst qChange = this._lastQuality !== this._quality;\n\t\tif (xChange || yChange || qChange) {\n\t\t\t\tif (xChange || qChange) { this._blurXTable = this._getTable(this._blurX * this._quality); }\n\t\t\t\tif (yChange || qChange) { this._blurYTable = this._getTable(this._blurY * this._quality); }\n\t\t\t\tthis._updateShader();\n\t\t\t\tthis._lastBlurX = this._blurX;\n\t\t\t\tthis._lastBlurY = this._blurY;\n\t\t\t\tthis._lastQuality = this._quality;\n\t\t\t\treturn undefined; // force a rebuild\n\t\t}\n\t\treturn this._compiledShader;\n\t}\n\tset _builtShader (value) { this._compiledShader = value; }\n\n\tshaderParamSetup (gl, stage, shaderProgram) {\n\t\t// load the normalized gaussian weight tables\n\t\tgl.uniform1fv(\n\t\t\tgl.getUniformLocation(shaderProgram, \"xWeight\"),\n\t\t\tthis._blurXTable\n\t\t);\n\t\tgl.uniform1fv(\n\t\t\tgl.getUniformLocation(shaderProgram, \"yWeight\"),\n\t\t\tthis._blurYTable\n\t\t);\n\n\t\t// what is the size of a single pixel in -1, 1 (webGL) space\n\t\tgl.uniform2f(\n\t\t\tgl.getUniformLocation(shaderProgram, \"textureOffset\"),\n\t\t\t2/(stage._viewportWidth*this._quality), 2/(stage._viewportHeight*this._quality)\n\t\t);\n\t}\n\n\tgetBounds (rect) {\n\t\tlet x = this.blurX|0, y = this.blurY| 0;\n\t\tif (x <= 0 && y <= 0) { return rect; }\n\t\tlet q = Math.pow(this.quality, 0.2);\n\t\treturn (rect || new Rectangle()).pad(y*q+1,x*q+1,y*q+1,x*q+1);\n\t}\n\n\t/**\n\t * @return {easeljs.BlurFilter}\n\t */\n\tclone () {\n\t\treturn new BlurFilter(this.blurX, this.blurY, this.quality);\n\t}\n\n\t_updateShader () {\n\t\tlet result = this.FRAG_SHADER_TEMPLATE;\n\t\tresult = result.replace(/{{blurX}}/g, this._blurXTable.length.toFixed(0));\n\t\tresult = result.replace(/{{blurY}}/g, this._blurYTable.length.toFixed(0));\n\t\tthis.FRAG_SHADER_BODY = result;\n\t}\n\n\t_getTable (spread) {\n\t\tconst EDGE = 4.2;\n\t\tif (spread <= 1) { return [1]; }\n\n\t\tlet result = [];\n\t\tlet count = Math.ceil(spread*2);\n\t\tcount += (count%2)?0:1;\n\t\tlet adjust = (count/2)|0;\n\t\tfor (let i = -adjust; i<=adjust; i++) {\n\t\t\tlet x = (i/adjust)*EDGE;\n\t\t\tresult.push(1/Math.sqrt(2*Math.PI) * Math.pow(Math.E, -(Math.pow(x,2)/4)));\n\t\t}\n\t\tlet factor = result.reduce((a, b) => a + b, 0);\n\t\treturn result.map(currentValue => currentValue / factor);\n\t}\n\n\t_applyFilter (imageData) {\n\t\tlet radiusX = this._blurX >> 1;\n\t\tif (isNaN(radiusX) || radiusX < 0) return false;\n\t\tlet radiusY = this._blurY >> 1;\n\t\tif (isNaN(radiusY) || radiusY < 0) return false;\n\t\tif (radiusX === 0 && radiusY === 0) return false;\n\n\t\tlet iterations = this.quality;\n\t\tif (isNaN(iterations) || iterations < 1) iterations = 1;\n\t\titerations |= 0;\n\t\tif (iterations > 3) iterations = 3;\n\t\tif (iterations < 1) iterations = 1;\n\n\t\tlet px = imageData.data;\n\t\tlet x=0, y=0, i=0, p=0, yp=0, yi=0, yw=0, r=0, g=0, b=0, a=0, pr=0, pg=0, pb=0, pa=0;\n\n\t\tlet divx = (radiusX + radiusX + 1) | 0;\n\t\tlet divy = (radiusY + radiusY + 1) | 0;\n\t\tlet w = imageData.width | 0;\n\t\tlet h = imageData.height | 0;\n\n\t\tlet w1 = (w - 1) | 0;\n\t\tlet h1 = (h - 1) | 0;\n\t\tlet rxp1 = (radiusX + 1) | 0;\n\t\tlet ryp1 = (radiusY + 1) | 0;\n\n\t\tlet ssx = {r:0,b:0,g:0,a:0};\n\t\tlet sx = ssx;\n\t\tfor ( i = 1; i < divx; i++ )\n\t\t{\n\t\t\tsx = sx.n = {r:0,b:0,g:0,a:0};\n\t\t}\n\t\tsx.n = ssx;\n\n\t\tlet ssy = {r:0,b:0,g:0,a:0};\n\t\tlet sy = ssy;\n\t\tfor ( i = 1; i < divy; i++ )\n\t\t{\n\t\t\tsy = sy.n = {r:0,b:0,g:0,a:0};\n\t\t}\n\t\tsy.n = ssy;\n\n\t\tlet si = null;\n\n\n\t\tlet mtx = BlurFilter.MUL_TABLE[radiusX] | 0;\n\t\tlet stx = BlurFilter.SHG_TABLE[radiusX] | 0;\n\t\tlet mty = BlurFilter.MUL_TABLE[radiusY] | 0;\n\t\tlet sty = BlurFilter.SHG_TABLE[radiusY] | 0;\n\n\t\twhile (iterations-- > 0) {\n\n\t\t\tyw = yi = 0;\n\t\t\tlet ms = mtx;\n\t\t\tlet ss = stx;\n\t\t\tfor (y = h; --y > -1;) {\n\t\t\t\tr = rxp1 * (pr = px[(yi) | 0]);\n\t\t\t\tg = rxp1 * (pg = px[(yi + 1) | 0]);\n\t\t\t\tb = rxp1 * (pb = px[(yi + 2) | 0]);\n\t\t\t\ta = rxp1 * (pa = px[(yi + 3) | 0]);\n\n\t\t\t\tsx = ssx;\n\n\t\t\t\tfor( i = rxp1; --i > -1; )\n\t\t\t\t{\n\t\t\t\t\tsx.r = pr;\n\t\t\t\t\tsx.g = pg;\n\t\t\t\t\tsx.b = pb;\n\t\t\t\t\tsx.a = pa;\n\t\t\t\t\tsx = sx.n;\n\t\t\t\t}\n\n\t\t\t\tfor( i = 1; i < rxp1; i++ )\n\t\t\t\t{\n\t\t\t\t\tp = (yi + ((w1 < i ? w1 : i) << 2)) | 0;\n\t\t\t\t\tr += ( sx.r = px[p]);\n\t\t\t\t\tg += ( sx.g = px[p+1]);\n\t\t\t\t\tb += ( sx.b = px[p+2]);\n\t\t\t\t\ta += ( sx.a = px[p+3]);\n\n\t\t\t\t\tsx = sx.n;\n\t\t\t\t}\n\n\t\t\t\tsi = ssx;\n\t\t\t\tfor ( x = 0; x < w; x++ )\n\t\t\t\t{\n\t\t\t\t\tpx[yi++] = (r * ms) >>> ss;\n\t\t\t\t\tpx[yi++] = (g * ms) >>> ss;\n\t\t\t\t\tpx[yi++] = (b * ms) >>> ss;\n\t\t\t\t\tpx[yi++] = (a * ms) >>> ss;\n\n\t\t\t\t\tp = ((yw + ((p = x + radiusX + 1) < w1 ? p : w1)) << 2);\n\n\t\t\t\t\tr -= si.r - ( si.r = px[p]);\n\t\t\t\t\tg -= si.g - ( si.g = px[p+1]);\n\t\t\t\t\tb -= si.b - ( si.b = px[p+2]);\n\t\t\t\t\ta -= si.a - ( si.a = px[p+3]);\n\n\t\t\t\t\tsi = si.n;\n\n\t\t\t\t}\n\t\t\t\tyw += w;\n\t\t\t}\n\n\t\t\tms = mty;\n\t\t\tss = sty;\n\t\t\tfor (x = 0; x < w; x++) {\n\t\t\t\tyi = (x << 2) | 0;\n\n\t\t\t\tr = (ryp1 * (pr = px[yi])) | 0;\n\t\t\t\tg = (ryp1 * (pg = px[(yi + 1) | 0])) | 0;\n\t\t\t\tb = (ryp1 * (pb = px[(yi + 2) | 0])) | 0;\n\t\t\t\ta = (ryp1 * (pa = px[(yi + 3) | 0])) | 0;\n\n\t\t\t\tsy = ssy;\n\t\t\t\tfor( i = 0; i < ryp1; i++ )\n\t\t\t\t{\n\t\t\t\t\tsy.r = pr;\n\t\t\t\t\tsy.g = pg;\n\t\t\t\t\tsy.b = pb;\n\t\t\t\t\tsy.a = pa;\n\t\t\t\t\tsy = sy.n;\n\t\t\t\t}\n\n\t\t\t\typ = w;\n\n\t\t\t\tfor( i = 1; i <= radiusY; i++ )\n\t\t\t\t{\n\t\t\t\t\tyi = ( yp + x ) << 2;\n\n\t\t\t\t\tr += ( sy.r = px[yi]);\n\t\t\t\t\tg += ( sy.g = px[yi+1]);\n\t\t\t\t\tb += ( sy.b = px[yi+2]);\n\t\t\t\t\ta += ( sy.a = px[yi+3]);\n\n\t\t\t\t\tsy = sy.n;\n\n\t\t\t\t\tif( i < h1 )\n\t\t\t\t\t{\n\t\t\t\t\t\typ += w;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tyi = x;\n\t\t\t\tsi = ssy;\n\t\t\t\tif ( iterations > 0 )\n\t\t\t\t{\n\t\t\t\t\tfor ( y = 0; y < h; y++ )\n\t\t\t\t\t{\n\t\t\t\t\t\tp = yi << 2;\n\t\t\t\t\t\tpx[p+3] = pa =(a * ms) >>> ss;\n\t\t\t\t\t\tif ( pa > 0 )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpx[p] = ((r * ms) >>> ss );\n\t\t\t\t\t\t\tpx[p+1] = ((g * ms) >>> ss );\n\t\t\t\t\t\t\tpx[p+2] = ((b * ms) >>> ss );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tpx[p] = px[p+1] = px[p+2] = 0\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tp = ( x + (( ( p = y + ryp1) < h1 ? p : h1 ) * w )) << 2;\n\n\t\t\t\t\t\tr -= si.r - ( si.r = px[p]);\n\t\t\t\t\t\tg -= si.g - ( si.g = px[p+1]);\n\t\t\t\t\t\tb -= si.b - ( si.b = px[p+2]);\n\t\t\t\t\t\ta -= si.a - ( si.a = px[p+3]);\n\n\t\t\t\t\t\tsi = si.n;\n\n\t\t\t\t\t\tyi += w;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor ( y = 0; y < h; y++ )\n\t\t\t\t\t{\n\t\t\t\t\t\tp = yi << 2;\n\t\t\t\t\t\tpx[p+3] = pa =(a * ms) >>> ss;\n\t\t\t\t\t\tif ( pa > 0 )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpa = 255 / pa;\n\t\t\t\t\t\t\tpx[p] = ((r * ms) >>> ss ) * pa;\n\t\t\t\t\t\t\tpx[p+1] = ((g * ms) >>> ss ) * pa;\n\t\t\t\t\t\t\tpx[p+2] = ((b * ms) >>> ss ) * pa;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tpx[p] = px[p+1] = px[p+2] = 0\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tp = ( x + (( ( p = y + ryp1) < h1 ? p : h1 ) * w )) << 2;\n\n\t\t\t\t\t\tr -= si.r - ( si.r = px[p]);\n\t\t\t\t\t\tg -= si.g - ( si.g = px[p+1]);\n\t\t\t\t\t\tb -= si.b - ( si.b = px[p+2]);\n\t\t\t\t\t\ta -= si.a - ( si.a = px[p+3]);\n\n\t\t\t\t\t\tsi = si.n;\n\n\t\t\t\t\t\tyi += w;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\treturn true;\n\t}\n\n}\n\n/**\n * Array of multiply values for blur calculations.\n * @type {Array}\n * @protected\n * @readonly\n * @static\n */\nBlurFilter.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];\n/**\n * Array of shift values for blur calculations.\n * @type {Array}\n * @protected\n * @static\n */\nBlurFilter.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];\n","/**\n * @license ColorFilter\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Filter from \"./Filter\";\n\n/**\n * Applies a color transform to DisplayObjects.\n *\n * @memberof easeljs\n * @extends easeljs.Filter\n * @example\n * let shape = new Shape().set({ x: 100, y: 100 });\n * shape.graphics.beginFill(\"#ff0000\").drawCircle(0,0,50);\n * shape.filters = [ new ColorFilter(0,0,0,1, 0,0,255,0) ];\n * shape.cache(-50, -50, 100, 100);\n *\n * @param {Number} [redMultiplier=1] The amount to multiply against the red channel. This is a range between 0 and 1.\n * @param {Number} [greenMultiplier=1] The amount to multiply against the green channel. This is a range between 0 and 1.\n * @param {Number} [blueMultiplier=1] The amount to multiply against the blue channel. This is a range between 0 and 1.\n * @param {Number} [alphaMultiplier=1] The amount to multiply against the alpha channel. This is a range between 0 and 1.\n * @param {Number} [redOffset=0] The amount to add to the red channel after it has been multiplied. This is a range\n * between -255 and 255.\n * @param {Number} [greenOffset=0] The amount to add to the green channel after it has been multiplied. This is a range\n * between -255 and 255.\n * @param {Number} [blueOffset=0] The amount to add to the blue channel after it has been multiplied. This is a range\n * between -255 and 255.\n * @param {Number} [alphaOffset=0] The amount to add to the alpha channel after it has been multiplied. This is a range\n * between -255 and 255.\n */\nexport default class ColorFilter extends Filter {\n\n\tconstructor (redMultiplier = 1, greenMultiplier = 1, blueMultiplier = 1, alphaMultiplier = 1, redOffset = 0, greenOffset = 0, blueOffset = 0, alphaOffset = 0) {\n\t\tsuper();\n\n\t\t/**\n\t\t * Red channel multiplier.\n\t\t * @type {Number}\n\t\t */\n\t\tthis.redMultiplier = redMultiplier;\n\n\t\t/**\n\t\t * Green channel multiplier.\n\t\t * @type {Number}\n\t\t */\n\t\tthis.greenMultiplier = greenMultiplier;\n\n\t\t/**\n\t\t * Blue channel multiplier.\n\t\t * @type {Number}\n\t\t */\n\t\tthis.blueMultiplier = blueMultiplier;\n\n\t\t/**\n\t\t * Alpha channel multiplier.\n\t\t * @type {Number}\n\t\t */\n\t\tthis.alphaMultiplier = alphaMultiplier;\n\n\t\t/**\n\t\t * Red channel offset (added to value).\n\t\t * @type {Number}\n\t\t */\n\t\tthis.redOffset = redOffset;\n\n\t\t/**\n\t\t * Green channel offset (added to value).\n\t\t * @type {Number}\n\t\t */\n\t\tthis.greenOffset = greenOffset;\n\n\t\t/**\n\t\t * Blue channel offset (added to value).\n\t\t * @type {Number}\n\t\t */\n\t\tthis.blueOffset = blueOffset;\n\n\t\t/**\n\t\t * Alpha channel offset (added to value).\n\t\t * @type {Number}\n\t\t */\n\t\tthis.alphaOffset = alphaOffset;\n\n\t\tthis.FRAG_SHADER_BODY = `\n\t\t\tuniform vec4 uColorMultiplier;\n\t\t\tuniform vec4 uColorOffset;\n\n\t\t\tvoid main (void) {\n\t\t\t\tvec4 color = texture2D(uSampler, vRenderCoord);\n\n\t\t\t\tgl_FragColor = (color * uColorMultiplier) + uColorOffset;\n\t\t\t}\n\t\t`;\n\n\t}\n\n\tshaderParamSetup (gl, stage, shaderProgram) {\n\t\tgl.uniform4f(\n\t\t\tgl.getUniformLocation(shaderProgram, \"uColorMultiplier\"),\n\t\t\tthis.redMultiplier, this.greenMultiplier, this.blueMultiplier, this.alphaMultiplier\n\t\t);\n\n\t\tgl.uniform4f(\n\t\t\tgl.getUniformLocation(shaderProgram, \"uColorOffset\"),\n\t\t\tthis.redOffset/255, this.greenOffset/255, this.blueOffset/255, this.alphaOffset/255\n\t\t);\n\t}\n\n\t/**\n\t * @return {easeljs.ColorFilter}\n\t */\n\tclone () {\n\t\treturn new ColorFilter(\n\t\t\tthis.redMultiplier, this.greenMultiplier, this.blueMultiplier, this.alphaMultiplier,\n\t\t\tthis.redOffset, this.greenOffset, this.blueOffset, this.alphaOffset\n\t\t);\n\t}\n\n\t_applyFilter (imageData) {\n\t\tlet data = imageData.data;\n\t\tconst l = data.length;\n\t\tfor (let i=0; i 0) ? 3*value/100 : value/100);\n\t\tlet lumR = 0.3086;\n\t\tlet lumG = 0.6094;\n\t\tlet lumB = 0.0820;\n\t\tthis._multiplyMatrix([\n\t\t\tlumR*(1-x)+x,lumG*(1-x),lumB*(1-x),0,0,\n\t\t\tlumR*(1-x),lumG*(1-x)+x,lumB*(1-x),0,0,\n\t\t\tlumR*(1-x),lumG*(1-x),lumB*(1-x)+x,0,0,\n\t\t\t0,0,0,1,0,\n\t\t\t0,0,0,0,1\n\t\t]);\n\t\treturn this;\n\t}\n\n\n\t/**\n\t * Adjusts the hue of the pixel color.\n\t * @param {Number} value A value between -180 & 180.\n\t * @return {easeljs.ColorMatrix} The ColorMatrix instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tadjustHue (value) {\n\t\tif (value === 0 || isNaN(value)) { return this; }\n\t\tvalue = this._cleanValue(value, 180)/180*Math.PI;\n\t\tlet cosVal = Math.cos(value);\n\t\tlet sinVal = Math.sin(value);\n\t\tlet lumR = 0.213;\n\t\tlet lumG = 0.715;\n\t\tlet lumB = 0.072;\n\t\tthis._multiplyMatrix([\n\t\t\tlumR+cosVal*(1-lumR)+sinVal*(-lumR),lumG+cosVal*(-lumG)+sinVal*(-lumG),lumB+cosVal*(-lumB)+sinVal*(1-lumB),0,0,\n\t\t\tlumR+cosVal*(-lumR)+sinVal*(0.143),lumG+cosVal*(1-lumG)+sinVal*(0.140),lumB+cosVal*(-lumB)+sinVal*(-0.283),0,0,\n\t\t\tlumR+cosVal*(-lumR)+sinVal*(-(1-lumR)),lumG+cosVal*(-lumG)+sinVal*(lumG),lumB+cosVal*(1-lumB)+sinVal*(lumB),0,0,\n\t\t\t0,0,0,1,0,\n\t\t\t0,0,0,0,1\n\t\t]);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Concatenates (multiplies) the specified matrix with this one.\n\t * @param {Array} matrix An array or ColorMatrix instance.\n\t * @return {easeljs.ColorMatrix} The ColorMatrix instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tconcat (matrix) {\n\t\tmatrix = this._fixMatrix(matrix);\n\t\tif (matrix.length != ColorMatrix.LENGTH) { return this; }\n\t\tthis._multiplyMatrix(matrix);\n\t\treturn this;\n\t}\n\n\t/**\n\t * @return {easeljs.ColorMatrix} A clone of this ColorMatrix.\n\t */\n\tclone () {\n\t\treturn (new ColorMatrix()).copy(this);\n\t}\n\n\t/**\n\t * Return a length 25 (5x5) array instance containing this matrix's values.\n\t * @return {Array} An array holding this matrix's values.\n\t */\n\ttoArray () {\n\t\tconst arr = [];\n\t\tconst l = ColorMatrix.LENGTH;\n\t\tfor (let i=0; i ColorMatrix.LENGTH) {\n\t\t\tmatrix = matrix.slice(0, ColorMatrix.LENGTH);\n\t\t}\n\t\treturn matrix;\n\t}\n\n}\n\n/**\n * Array of delta values for contrast calculations.\n * @type {Array}\n * @protected\n * @readonly\n * @static\n */\nColorMatrix.DELTA_INDEX = Object.freeze([\n \t0, 0.01, 0.02, 0.04, 0.05, 0.06, 0.07, 0.08, 0.1, 0.11,\n \t0.12, 0.14, 0.15, 0.16, 0.17, 0.18, 0.20, 0.21, 0.22, 0.24,\n \t0.25, 0.27, 0.28, 0.30, 0.32, 0.34, 0.36, 0.38, 0.40, 0.42,\n \t0.44, 0.46, 0.48, 0.5, 0.53, 0.56, 0.59, 0.62, 0.65, 0.68,\n \t0.71, 0.74, 0.77, 0.80, 0.83, 0.86, 0.89, 0.92, 0.95, 0.98,\n \t1.0, 1.06, 1.12, 1.18, 1.24, 1.30, 1.36, 1.42, 1.48, 1.54,\n \t1.60, 1.66, 1.72, 1.78, 1.84, 1.90, 1.96, 2.0, 2.12, 2.25,\n \t2.37, 2.50, 2.62, 2.75, 2.87, 3.0, 3.2, 3.4, 3.6, 3.8,\n \t4.0, 4.3, 4.7, 4.9, 5.0, 5.5, 6.0, 6.5, 6.8, 7.0,\n \t7.3, 7.5, 7.8, 8.0, 8.4, 8.7, 9.0, 9.4, 9.6, 9.8,\n \t10.0\n]);\n/**\n * Identity matrix values.\n * @type {Array}\n * @protected\n * @readonly\n * @static\n */\nColorMatrix.IDENTITY_MATRIX = Object.freeze([\n \t1,0,0,0,0,\n \t0,1,0,0,0,\n \t0,0,1,0,0,\n \t0,0,0,1,0,\n \t0,0,0,0,1\n]);\n/**\n * The constant length of a color matrix.\n * @type {Number}\n * @protected\n * @readonly\n * @static\n */\nColorMatrix.LENGTH = 25;\n","/**\n * @license ColorMatrixFilter\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Filter from \"./Filter\";\n\n/**\n * Allows you to carry out complex color operations such as modifying saturation, brightness, or inverting. See the\n * {@link easeljs.ColorMatrix} for more information on changing colors. For an easier color transform,\n * consider the {@link easeljs.ColorFilter}.\n *\n *\n * @memberof easeljs\n * @extends easeljs.Filter\n * @example\n * let shape = new Shape().set({ x: 100, y: 100 });\n * shape.graphics.beginFill(\"#ff0000\").drawCircle(0, 0, 50);\n * let matrix = new ColorMatrix().adjustHue(180).adjustSaturation(100);\n * shape.filters = [ new ColorMatrixFilter(matrix) ];\n * shape.cache(-50, -50, 100, 100);\n *\n * @param {Array | easeljs.ColorMatrix} matrix A 4x5 matrix describing the color operation to perform.\n */\nexport default class ColorMatrixFilter extends Filter {\n\n\tconstructor (matrix) {\n\t\tsuper();\n\n\t\t/**\n\t\t * A 4x5 matrix describing the color operation to perform.\n\t\t * @type {Array | easeljs.ColorMatrix}\n\t\t */\n\t\tthis.matrix = matrix;\n\n\t\tthis.FRAG_SHADER_BODY = `\n\t\t\tuniform mat4 uColorMatrix;\n\t\t\tuniform vec4 uColorMatrixOffset;\n\n\t\t\tvoid main (void) {\n\t\t\t\tvec4 color = texture2D(uSampler, vRenderCoord);\n\n\t\t\t\tmat4 m = uColorMatrix;\n\t\t\t\tvec4 newColor = vec4(0,0,0,0);\n\t\t\t\tnewColor.r = color.r*m[0][0] + color.g*m[0][1] + color.b*m[0][2] + color.a*m[0][3];\n\t\t\t\tnewColor.g = color.r*m[1][0] + color.g*m[1][1] + color.b*m[1][2] + color.a*m[1][3];\n\t\t\t\tnewColor.b = color.r*m[2][0] + color.g*m[2][1] + color.b*m[2][2] + color.a*m[2][3];\n\t\t\t\tnewColor.a = color.r*m[3][0] + color.g*m[3][1] + color.b*m[3][2] + color.a*m[3][3];\n\n\t\t\t\tgl_FragColor = newColor + uColorMatrixOffset;\n\t\t\t}\n\t\t`;\n\t}\n\n\tshaderParamSetup (gl, stage, shaderProgram) {\n\t\tlet mat = this.matrix;\n\t\tlet colorMatrix = new Float32Array([\n\t\t\tmat[0],mat[1],mat[2],mat[3],\n\t\t\tmat[5],mat[6],mat[7],mat[8],\n\t\t\tmat[10],mat[11],mat[12],mat[13],\n\t\t\tmat[15],mat[16],mat[17],mat[18]\n\t\t]);\n\n\t\tgl.uniformMatrix4fv(\n\t\t\tgl.getUniformLocation(shaderProgram, \"uColorMatrix\"),\n\t\t\tfalse, colorMatrix\n\t\t);\n\t\tgl.uniform4f(\n\t\t\tgl.getUniformLocation(shaderProgram, \"uColorMatrixOffset\"),\n\t\t\tmat[4]/255, mat[9]/255, mat[14]/255, mat[19]/255\n\t\t);\n\t}\n\n\t/**\n\t * @return {easeljs.ColorMatrixFilter}\n\t */\n\tclone () {\n\t\treturn new ColorMatrixFilter(this.matrix);\n\t}\n\n\t_applyFilter (imageData) {\n\t\tlet data = imageData.data;\n\t\tconst l = data.length;\n\t\tlet r,g,b,a;\n\t\tlet mtx = this.matrix;\n\t\tlet m0 = mtx[0], m1 = mtx[1], m2 = mtx[2], m3 = mtx[3], m4 = mtx[4];\n\t\tlet m5 = mtx[5], m6 = mtx[6], m7 = mtx[7], m8 = mtx[8], m9 = mtx[9];\n\t\tlet m10 = mtx[10], m11 = mtx[11], m12 = mtx[12], m13 = mtx[13], m14 = mtx[14];\n\t\tlet m15 = mtx[15], m16 = mtx[16], m17 = mtx[17], m18 = mtx[18], m19 = mtx[19];\n\n\t\tfor (let i=0; i {\n * // clicked\n * }));\n *\n * @param {easeljs.Sprite | easeljs.MovieClip} target The instance to manage.\n * @param {String} [outLabel=\"out\"] The label or animation to go to when the user rolls out of the button.\n * @param {String} [overLabel=\"over\"] The label or animation to go to when the user rolls over the button.\n * @param {String} [downLabel=\"down\"] The label or animation to go to when the user presses the button.\n * @param {Boolean} [play=false] If the helper should call \"gotoAndPlay\" or \"gotoAndStop\" on the button when changing\n * states.\n * @param {easeljs.DisplayObject} [hitArea] An optional item to use as the hit state for the button. If this is not defined,\n * then the button's visible states will be used instead. Note that the same instance as the \"target\" argument can be\n * used for the hitState.\n * @param {String} [hitLabel] The label or animation on the hitArea instance that defines the hitArea bounds. If this is\n * null, then the default state of the hitArea will be used.\n */\nexport default class ButtonHelper {\n\n\tconstructor (target, outLabel = \"out\", overLabel = \"over\", downLabel = \"down\", play = false, hitArea, hitLabel) {\n\t\tif (!target.addEventListener) { return; }\n\n\t\t/**\n\t\t * The target for this button helper.\n\t\t * @type {easeljs.MovieClip | easeljs.Sprite}\n\t\t * @readonly\n\t\t */\n\t\tthis.target = target;\n\n\t\t/**\n\t\t * The label name or frame number to display when the user mouses out of the target.\n\t\t * @default \"over\"\n\t\t * @type {String | Number}\n\t\t */\n\t\tthis.overLabel = overLabel;\n\n\t\t/**\n\t\t * The label name or frame number to display when the user mouses over the target.\n\t\t * @default \"out\"\n\t\t * @type {String | Number}\n\t\t */\n\t\tthis.outLabel = outLabel;\n\n\t\t/**\n\t\t * The label name or frame number to display when the user presses on the target.\n\t\t * @default \"down\"\n\t\t * @type {String | Number}\n\t\t */\n\t\tthis.downLabel = downLabel == null;\n\n\t\t/**\n\t\t * If true, then ButtonHelper will call gotoAndPlay, if false, it will use gotoAndStop.\n\t\t * @default false\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis.play = play;\n\n\t\t/**\n\t\t * @type {Boolean}\n\t\t * @protected\n\t\t */\n\t\tthis._isPressed = false;\n\n\t\t/**\n\t\t * @type {Boolean}\n\t\t * @protected\n\t\t */\n\t\tthis._isOver = false;\n\n\t\t/**\n\t\t * @type {Boolean}\n\t\t * @protected\n\t\t */\n\t\tthis._enabled = false;\n\n\t\ttarget.mouseChildren = false; // prevents issues when children are removed from the display list when state changes.\n\t\tthis.enabled = true;\n\t\tthis.handleEvent({});\n\t\tif (hitArea) {\n\t\t\tif (hitLabel) {\n\t\t\t\thitArea.actionsEnabled = false;\n\t\t\t\thitArea.gotoAndStop&&hitArea.gotoAndStop(hitLabel);\n\t\t\t}\n\t\t\ttarget.hitArea = hitArea;\n\t\t}\n\t}\n\n\t/**\n\t * Enables or disables the button functionality on the target.\n\t * @type {Boolean}\n\t */\n\tget enabled () { return this._enabled; }\n\tset enabled (enabled) {\n\t\tif (enabled === this._enabled) { return; }\n\t\tlet o = this.target;\n\t\tthis._enabled = enabled;\n\t\tif (enabled) {\n\t\t\to.cursor = \"pointer\";\n\t\t\to.addEventListener(\"rollover\", this);\n\t\t\to.addEventListener(\"rollout\", this);\n\t\t\to.addEventListener(\"mousedown\", this);\n\t\t\to.addEventListener(\"pressup\", this);\n\t\t\tif (o._reset) { o.__reset = o._reset; o._reset = this._reset;}\n\t\t} else {\n\t\t\to.cursor = null;\n\t\t\to.removeEventListener(\"rollover\", this);\n\t\t\to.removeEventListener(\"rollout\", this);\n\t\t\to.removeEventListener(\"mousedown\", this);\n\t\t\to.removeEventListener(\"pressup\", this);\n\t\t\tif (o.__reset) { o._reset = o.__reset; delete(o.__reset); }\n\t\t}\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name}]`;\n\t}\n\n\t/**\n\t * @param {Object} evt The mouse event to handle.\n\t * @protected\n\t */\n\thandleEvent (evt) {\n\t\tlet label, t = this.target, type = evt.type;\n\t\tif (type === \"mousedown\") {\n\t\t\tthis._isPressed = true;\n\t\t\tlabel = this.downLabel;\n\t\t} else if (type === \"pressup\") {\n\t\t\tthis._isPressed = false;\n\t\t\tlabel = this._isOver ? this.overLabel : this.outLabel;\n\t\t} else if (type === \"rollover\") {\n\t\t\tthis._isOver = true;\n\t\t\tlabel = this._isPressed ? this.downLabel : this.overLabel;\n\t\t} else { // rollout and default\n\t\t\tthis._isOver = false;\n\t\t\tlabel = this._isPressed ? this.overLabel : this.outLabel;\n\t\t}\n\t\tif (this.play) {\n\t\t\tt.gotoAndPlay&&t.gotoAndPlay(label);\n\t\t} else {\n\t\t\tt.gotoAndStop&&t.gotoAndStop(label);\n\t\t}\n\t}\n\n\t/**\n\t * Injected into target. Preserves the paused state through a reset.\n\t * @protected\n\t */\n\t_reset () {\n\t\t// TODO: explore better ways to handle this issue. This is hacky & disrupts object signatures.\n\t\tlet p = this.paused;\n\t\tthis.__reset();\n\t\tthis.paused = p;\n\t}\n\n}\n","/**\n * @license Touch\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * Global utility for working with multi-touch enabled devices in EaselJS. Currently supports W3C Touch API (iOS and\n * modern Android browser) and the Pointer API (IE), including ms-prefixed events in IE10, and unprefixed in IE11.\n *\n * Ensure that you {{#crossLink \"Touch/disable\"}}{{/crossLink}} touch when cleaning up your application. You do not have\n * to check if touch is supported to enable it, as it will fail gracefully if it is not supported.\n *\n * Note: It is important to disable Touch on a stage that you are no longer using:\n *\n * @memberof easeljs\n * @name easeljs.Touch\n * @example\n * let stage = new Stage(\"canvasId\");\n * Touch.enable(stage);\n */\nexport default {\n\n\t/**\n\t * Returns `true` if touch is supported in the current browser.\n\t * @return {Boolean} Indicates whether touch is supported in the current browser.\n\t */\n\tisSupported () {\n\t\treturn\t!!(('ontouchstart' in window) // iOS & Android\n\t\t\t|| (window.MSPointerEvent && window.navigator.msMaxTouchPoints > 0) // IE10\n\t\t\t|| (window.PointerEvent && window.navigator.maxTouchPoints > 0)); // IE11+\n\t},\n\n\t/**\n\t * Enables touch interaction for the specified EaselJS {@link easeljs.Stage}. Currently supports iOS\n\t * (and compatible browsers, such as modern Android browsers), and IE10/11. Supports both single touch and\n\t * multi-touch modes. Extends the EaselJS {@link easeljs.MouseEvent} model, but without support for\n\t * double click or over/out events.\n\t * @param {easeljs.Stage} stage The Stage to enable touch on.\n\t * @param {Boolean} [singleTouch=false] If `true`, only a single touch will be active at a time.\n\t * @param {Boolean} [allowDefault=false] If `true`, then default gesture actions (ex. scrolling, zooming) will be\n\t * allowed when the user is interacting with the target canvas.\n\t * @return {Boolean} Returns `true` if touch was successfully enabled on the target stage.\n\t */\n\tenable (stage, singleTouch = false, allowDefault = false) {\n\t\tif (!stage || !stage.canvas || !this.isSupported()) { return false; }\n\t\tif (stage.__touch) { return true; }\n\n\t\t// inject required properties on stage:\n\t\tstage.__touch = {pointers:{}, multitouch:!singleTouch, preventDefault:!allowDefault, count:0};\n\n\t\t// note that in the future we may need to disable the standard mouse event model before adding\n\t\t// these to prevent duplicate calls. It doesn't seem to be an issue with iOS devices though.\n\t\tif ('ontouchstart' in window) { this._IOS_enable(stage); }\n\t\telse if (window.PointerEvent || window.MSPointerEvent) { this._IE_enable(stage); }\n\t\treturn true;\n\t},\n\n\t/**\n\t * Removes all listeners that were set up when calling `Touch.enable()` on a stage.\n\t * @param {easeljs.Stage} stage The Stage to disable touch on.\n\t */\n\tdisable (stage) {\n\t\tif (!stage) { return; }\n\t\tif ('ontouchstart' in window) { this._IOS_disable(stage); }\n\t\telse if (window.PointerEvent || window.MSPointerEvent) { this._IE_disable(stage); }\n\t\tdelete stage.__touch;\n\t},\n\n\t/**\n\t * @private\n\t * @param {easeljs.Stage} stage\n\t */\n\t_IOS_enable (stage) {\n\t\tlet canvas = stage.canvas;\n\t\tlet f = stage.__touch.f = e => this._IOS_handleEvent(stage, e);\n\t\tcanvas.addEventListener(\"touchstart\", f, false);\n\t\tcanvas.addEventListener(\"touchmove\", f, false);\n\t\tcanvas.addEventListener(\"touchend\", f, false);\n\t\tcanvas.addEventListener(\"touchcancel\", f, false);\n\t},\n\n\t/**\n\t * @private\n\t * @param {easeljs.Stage} stage\n\t */\n\t_IOS_disable (stage) {\n\t\tlet canvas = stage.canvas;\n\t\tif (!canvas) { return; }\n\t\tlet f = stage.__touch.f;\n\t\tcanvas.removeEventListener(\"touchstart\", f, false);\n\t\tcanvas.removeEventListener(\"touchmove\", f, false);\n\t\tcanvas.removeEventListener(\"touchend\", f, false);\n\t\tcanvas.removeEventListener(\"touchcancel\", f, false);\n\t},\n\n\t/**\n\t * @private\n\t * @param {easeljs.Stage} stage\n\t * @param {Object} e The event to handle\n\t */\n\t_IOS_handleEvent (stage, e) {\n\t\tif (!stage) { return; }\n\t\tif (stage.__touch.preventDefault) { e.preventDefault&&e.preventDefault(); }\n\t\tlet touches = e.changedTouches;\n\t\tlet type = e.type;\n\t\tconst l = touches.length;\n\t\tfor (let touch of touches) {\n\t\t\tlet id = touch.identifier;\n\t\t\tif (touch.target != stage.canvas) { continue; }\n\n\t\t\tif (type === \"touchstart\") {\n\t\t\t\tthis._handleStart(stage, id, e, touch.pageX, touch.pageY);\n\t\t\t} else if (type === \"touchmove\") {\n\t\t\t\tthis._handleMove(stage, id, e, touch.pageX, touch.pageY);\n\t\t\t} else if (type === \"touchend\" || type === \"touchcancel\") {\n\t\t\t\tthis._handleEnd(stage, id, e);\n\t\t\t}\n\t\t}\n\t},\n\n\t/**\n\t * @private\n\t * @param {easeljs.Stage} stage\n\t */\n\t_IE_enable (stage) {\n\t\tlet canvas = stage.canvas;\n\t\tlet f = stage.__touch.f = e => this._IE_handleEvent(stage,e);\n\n\t\tif (window.PointerEvent === undefined) {\n\t\t\tcanvas.addEventListener(\"MSPointerDown\", f, false);\n\t\t\twindow.addEventListener(\"MSPointerMove\", f, false);\n\t\t\twindow.addEventListener(\"MSPointerUp\", f, false);\n\t\t\twindow.addEventListener(\"MSPointerCancel\", f, false);\n\t\t\tif (stage.__touch.preventDefault) { canvas.style.msTouchAction = \"none\"; }\n\t\t} else {\n\t\t\tcanvas.addEventListener(\"pointerdown\", f, false);\n\t\t\twindow.addEventListener(\"pointermove\", f, false);\n\t\t\twindow.addEventListener(\"pointerup\", f, false);\n\t\t\twindow.addEventListener(\"pointercancel\", f, false);\n\t\t\tif (stage.__touch.preventDefault) { canvas.style.touchAction = \"none\"; }\n\n\t\t}\n\t\tstage.__touch.activeIDs = {};\n\t},\n\n\t/**\n\t * @private\n\t * @param {easeljs.Stage} stage\n\t */\n\t_IE_disable (stage) {\n\t\tlet f = stage.__touch.f;\n\n\t\tif (window.PointerEvent === undefined) {\n\t\t\twindow.removeEventListener(\"MSPointerMove\", f, false);\n\t\t\twindow.removeEventListener(\"MSPointerUp\", f, false);\n\t\t\twindow.removeEventListener(\"MSPointerCancel\", f, false);\n\t\t\tif (stage.canvas) {\n\t\t\t\tstage.canvas.removeEventListener(\"MSPointerDown\", f, false);\n\t\t\t}\n\t\t} else {\n\t\t\twindow.removeEventListener(\"pointermove\", f, false);\n\t\t\twindow.removeEventListener(\"pointerup\", f, false);\n\t\t\twindow.removeEventListener(\"pointercancel\", f, false);\n\t\t\tif (stage.canvas) {\n\t\t\t\tstage.canvas.removeEventListener(\"pointerdown\", f, false);\n\t\t\t}\n\t\t}\n\t},\n\n\t/**\n\t * @private\n\t * @param {easeljs.Stage} stage\n\t * @param {Object} e The event to handle.\n\t */\n\t_IE_handleEvent (stage, e) {\n\t\tif (!stage) { return; }\n\t\tif (stage.__touch.preventDefault) { e.preventDefault && e.preventDefault(); }\n\t\tlet type = e.type;\n\t\tlet id = e.pointerId;\n\t\tlet ids = stage.__touch.activeIDs;\n\n\t\tif (type === \"MSPointerDown\" || type === \"pointerdown\") {\n\t\t\tif (e.srcElement != stage.canvas) { return; }\n\t\t\tids[id] = true;\n\t\t\tthis._handleStart(stage, id, e, e.pageX, e.pageY);\n\t\t} else if (ids[id]) { // it's an id we're watching\n\t\t\tif (type === \"MSPointerMove\" || type === \"pointermove\") {\n\t\t\t\tthis._handleMove(stage, id, e, e.pageX, e.pageY);\n\t\t\t} else if (type === \"MSPointerUp\" || type === \"MSPointerCancel\"\n\t\t\t\t\t|| type === \"pointerup\" || type === \"pointercancel\") {\n\t\t\t\tdelete(ids[id]);\n\t\t\t\tthis._handleEnd(stage, id, e);\n\t\t\t}\n\t\t}\n\t},\n\n\t/**\n\t * @private\n\t * @param {easeljs.Stage} stage\n\t * @param {String | Number} id\n\t * @param {Object} e\n\t * @param {Number} x\n\t * @param {Number} y\n\t */\n\t_handleStart (stage, id, e, x, y) {\n\t\tlet props = stage.__touch;\n\t\tif (!props.multitouch && props.count) { return; }\n\t\tlet ids = props.pointers;\n\t\tif (ids[id]) { return; }\n\t\tids[id] = true;\n\t\tprops.count++;\n\t\tstage._handlePointerDown(id, e, x, y);\n\t},\n\n\t/**\n\t * @private\n\t * @param {easeljs.Stage} stage\n\t * @param {String | Number} id\n\t * @param {Object} e\n\t * @param {Number} x\n\t * @param {Number} y\n\t */\n\t_handleMove (stage, id, e, x, y) {\n\t\tif (!stage.__touch.pointers[id]) { return; }\n\t\tstage._handlePointerMove(id, e, x, y);\n\t},\n\n\t/**\n\t * @private\n\t * @param {easeljs.Stage} stage\n\t * @param {String | Number} id\n\t * @param {Object} e\n\t */\n\t_handleEnd (stage, id, e) {\n\t\t// TODO: cancel should be handled differently for proper UI (ex. an up would trigger a click, a cancel would more closely resemble an out).\n\t\tlet props = stage.__touch;\n\t\tlet ids = props.pointers;\n\t\tif (!ids[id]) { return; }\n\t\tprops.count--;\n\t\tstage._handlePointerUp(id, e, true);\n\t\tdelete(ids[id]);\n\t}\n\n}\n","/**\n * @license SpriteSheetBuilder\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport { EventDispatcher, Event } from \"@createjs/core\";\nimport Rectangle from \"../geom/Rectangle\";\nimport SpriteSheet from \"../display/SpriteSheet\";\n\n/**\n * The SpriteSheetBuilder allows you to generate {@link easeljs.SpriteSheet} instances at run time\n * from any display object. This can allow you to maintain your assets as vector graphics (for low file size), and\n * render them at run time as SpriteSheets for better performance.\n *\n * SpriteSheets can be built either synchronously, or asynchronously, so that large SpriteSheets can be generated\n * without locking the UI.\n *\n * Note that the \"images\" used in the generated SpriteSheet are actually canvas elements, and that they will be\n * sized to the nearest power of 2 up to the value of {@link easeljs.SpriteSheetBuilder#maxWidth}\n * or {@link easeljs.SpriteSheetBuilder#maxHeight}.\n *\n * @memberof easeljs\n * @extends core.EventDispatcher\n *\n * @param {Number} [framerate=0] The {{#crossLink \"SpriteSheet/framerate:property\"}}{{/crossLink}} of\n * {@link easeljs.SpriteSheet} instances that are created.\n */\nexport default class SpriteSheetBuilder extends EventDispatcher {\n\n\tconstructor (framerate = 0) {\n\t\tsuper();\n\n\t\t/**\n\t\t * The maximum width for the images (not individual frames) in the generated SpriteSheet. It is recommended to\n\t\t * use a power of 2 for this value (ex. 1024, 2048, 4096). If the frames cannot all fit within the max\n\t\t * dimensions, then additional images will be created as needed.\n\t\t * @type {Number}\n\t\t * @default 2048\n\t\t*/\n\t\tthis.maxWidth = 2048;\n\n\t\t/**\n\t\t * The maximum height for the images (not individual frames) in the generated SpriteSheet. It is recommended to\n\t\t * use a power of 2 for this value (ex. 1024, 2048, 4096). If the frames cannot all fit within the max\n\t\t * dimensions, then additional images will be created as needed.\n\t\t * @type {Number}\n\t\t * @default 2048\n\t\t */\n\t\tthis.maxHeight = 2048;\n\n\t\t/**\n\t\t * The SpriteSheet that was generated. This will be null before a build is completed successfully.\n\t\t * @type {easeljs.SpriteSheet}\n\t\t */\n\t\tthis.spriteSheet = null;\n\n\t\t/**\n\t\t * The scale to apply when drawing all frames to the SpriteSheet. This is multiplied against any scale specified\n\t\t * in the addFrame call. This can be used, for example, to generate a SpriteSheet at run time that is tailored\n\t\t * to the a specific device resolution (ex. tablet vs mobile).\n\t\t * @type {Number}\n\t\t * @default 1\n\t\t */\n\t\tthis.scale = 1;\n\n\t\t/**\n\t\t* The padding to use between frames. This is helpful to preserve antialiasing on drawn vector content.\n\t\t* @type {Number}\n\t\t* @default 1\n\t\t*/\n\t\tthis.padding = 1;\n\n\t\t/**\n\t\t * A number from 0.01 to 0.99 that indicates what percentage of time the builder can use. This can be\n\t\t * thought of as the number of seconds per second the builder will use. For example, with a timeSlice value of 0.3,\n\t\t * the builder will run 20 times per second, using approximately 15ms per build (30% of available time, or 0.3s per second).\n\t\t * Defaults to 0.3.\n\t\t * @type {Number}\n\t\t * @default 0.3\n\t\t */\n\t\tthis.timeSlice = 0.3;\n\n\t\t/**\n\t\t * A value between 0 and 1 that indicates the progress of a build, or -1 if a build has not\n\t\t * been initiated.\n\t\t * @type {Number}\n\t\t * @default -1\n\t\t * @readonly\n\t\t */\n\t\tthis.progress = -1;\n\n\t\t/**\n\t\t * A {@link easeljs.SpriteSheet#framerate} value that will be passed to new SpriteSheet instances that are\n\t\t * created. If no framerate is specified (or it is 0), then SpriteSheets will use the {@link core.Ticker} framerate.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.framerate = framerate;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Array}\n\t\t */\n\t\tthis._frames = [];\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Array}\n\t\t */\n\t\tthis._animations = {};\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Array}\n\t\t */\n\t\tthis._data = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._nextFrameIndex = 0;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._index = 0;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._timerID = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._scale = 1;\n\t}\n\n\t/**\n\t * Adds a frame to the {@link easeljs.SpriteSheet}. Note that the frame will not be drawn until you\n\t * call {@link easeljs.SpriteSheetBuilder#build} method. The optional setup params allow you to have\n\t * a function run immediately before the draw occurs. For example, this allows you to add a single source multiple\n\t * times, but manipulate it or its children to change it to generate different frames.\n\t *\n\t * Note that the source's transformations (x, y, scale, rotate, alpha) will be ignored, except for regX/Y. To apply\n\t * transforms to a source object and have them captured in the SpriteSheet, simply place it into a {@link easeljs.Container}\n\t * and pass in the Container as the source.\n\t * @param {easeljs.DisplayObject} source The source {{#crossLink \"DisplayObject\"}}{{/crossLink}} to draw as the frame.\n\t * @param {easeljs.Rectangle} [sourceRect] A {{#crossLink \"Rectangle\"}}{{/crossLink}} defining the portion of the\n\t * source to draw to the frame. If not specified, it will look for a `getBounds` method, bounds property, or\n\t * `nominalBounds` property on the source to use. If one is not found, the frame will be skipped.\n\t * @param {Number} [scale=1] Optional. The scale to draw this frame at. Default is 1.\n\t * @param {Function} [setupFunction] A function to call immediately before drawing this frame. It will be called with two parameters: the source, and setupData.\n\t * @param {Object} [setupData] Arbitrary setup data to pass to setupFunction as the second parameter.\n\t * @return {Number} The index of the frame that was just added, or null if a sourceRect could not be determined.\n\t */\n\taddFrame (source, sourceRect, scale = 1, setupFunction, setupData) {\n\t\tif (this._data) { throw SpriteSheetBuilder.ERR_RUNNING; }\n\t\tlet rect = sourceRect||source.bounds||source.nominalBounds||(source.getBounds&&source.getBounds());\n\t\tif (!rect) { return null; }\n\t\treturn this._frames.push({ source, sourceRect: rect, scale, funct: setupFunction, data: setupData, index: this._frames.length, height: rect.height*scale }) - 1;\n\t}\n\n\t/**\n\t * Adds an animation that will be included in the created {@link easeljs.SpriteSheet}.\n\t * @param {String} name The name for the animation.\n\t * @param {Array} frames An array of frame indexes that comprise the animation. Ex. [3,6,5] would describe an animation\n\t * that played frame indexes 3, 6, and 5 in that order.\n\t * @param {String} [next] Specifies the name of the animation to continue to after this animation ends. You can\n\t * also pass false to have the animation stop when it ends. By default it will loop to the start of the same animation.\n\t * @param {Number} [speed] Specifies a frame advance speed for this animation. For example, a value of 0.5 would\n\t * cause the animation to advance every second tick. Note that earlier versions used `frequency` instead, which had\n\t * the opposite effect.\n\t */\n\taddAnimation (name, frames, next, speed) {\n\t\tif (this._data) { throw SpriteSheetBuilder.ERR_RUNNING; }\n\t\tthis._animations[name] = { frames, next, speed };\n\t}\n\n\t/**\n\t * This will take a {@link easeljs.MovieClip} instance, and add its frames and labels to this\n\t * builder. Labels will be added as an animation running from the label index to the next label. For example, if\n\t * there is a label named \"foo\" at frame 0 and a label named \"bar\" at frame 10, in a MovieClip with 15 frames, it\n\t * will add an animation named \"foo\" that runs from frame index 0 to 9, and an animation named \"bar\" that runs from\n\t * frame index 10 to 14.\n\t *\n\t * Note that this will iterate through the full MovieClip with {@link easeljs.MovieClip#actionsEnabled}\n\t * set to `false`, ending on the last frame.\n\t * @param {easeljs.MovieClip} source The source MovieClip instance to add to the SpriteSheet.\n\t * @param {easeljs.Rectangle} [sourceRect] A Rectangle defining the portion of the source to\n\t * draw to the frame. If not specified, it will look for a {{#crossLink \"DisplayObject/getBounds\"}}{{/crossLink}}\n\t * method, `frameBounds` Array, `bounds` property, or `nominalBounds` property on the source to use. If one is not\n\t * found, the MovieClip will be skipped.\n\t * @param {Number} [scale=1] The scale to draw the movie clip at.\n\t * @param {Function} [setupFunction] A function to call immediately before drawing each frame. It will be called\n\t * with three parameters: the source, setupData, and the frame index.\n\t * @param {Object} [setupData] Arbitrary setup data to pass to setupFunction as the second parameter.\n\t * @param {Function} [labelFunction] This method will be called for each MovieClip label that is added with four\n\t * parameters: the label name, the source MovieClip instance, the starting frame index (in the movieclip timeline)\n\t * and the end index. It must return a new name for the label/animation, or `false` to exclude the label.\n\t */\n\taddMovieClip (source, sourceRect, scale = 1, setupFunction, setupData, labelFunction) {\n\t\tif (this._data) { throw SpriteSheetBuilder.ERR_RUNNING; }\n\t\tlet rects = source.frameBounds;\n\t\tlet rect = sourceRect||source.bounds||source.nominalBounds||(source.getBounds&&source.getBounds());\n\t\tif (!rect && !rects) { return; }\n\n\t\tlet baseFrameIndex = this._frames.length;\n\t\tconst duration = source.timeline.duration;\n\t\tfor (let i=0; i a.index-b.index);\n\t\t\tfor (let i=0,l=lbls.length; i this._run(), 50-Math.max(0.01, Math.min(0.99, this.timeSlice||0.3))*50);\n\t}\n\n\t/**\n\t * Stops the current asynchronous build.\n\t */\n\tstopAsync () {\n\t\tclearTimeout(this._timerID);\n\t\tthis._data = null;\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @override\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name}]`;\n\t}\n\n\t/**\n\t * @protected\n\t */\n\t_startBuild () {\n\t\tlet pad = this.padding||0;\n\t\tthis.progress = 0;\n\t\tthis.spriteSheet = null;\n\t\tthis._index = 0;\n\t\tthis._scale = this.scale;\n\t\tlet dataFrames = [];\n\t\tthis._data = {\n\t\t\timages: [],\n\t\t\tframes: dataFrames,\n\t\t\tframerate: this.framerate,\n\t\t\tanimations: this._animations // TODO: should we \"clone\" _animations in case someone adds more animations after a build?\n\t\t};\n\n\t\tlet frames = this._frames.slice();\n\t\tframes.sort((a, b) => (a.height<=b.height) ? -1 : 1);\n\n\t\tif (frames[frames.length-1].height+pad*2 > this.maxHeight) { throw SpriteSheetBuilder.ERR_DIMENSIONS; }\n\t\tlet y=0, x=0;\n\t\tlet img = 0;\n\t\twhile (frames.length) {\n\t\t\tlet o = this._fillRow(frames, y, img, dataFrames, pad);\n\t\t\tif (o.w > x) { x = o.w; }\n\t\t\ty += o.h;\n\t\t\tif (!o.h || !frames.length) {\n\t\t\t\tlet canvas = window.createjs&&createjs.createCanvas?createjs.createCanvas():document.createElement(\"canvas\");\n\t\t\t\tcanvas.width = this._getSize(x,this.maxWidth);\n\t\t\t\tcanvas.height = this._getSize(y,this.maxHeight);\n\t\t\t\tthis._data.images[img] = canvas;\n\t\t\t\tif (!o.h) {\n\t\t\t\t\tx=y=0;\n\t\t\t\t\timg++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * @protected\n\t * @return {Number} The width & height of the row.\n\t */\n\t_setupMovieClipFrame (source, data) {\n\t\tlet ae = source.actionsEnabled;\n\t\tsource.actionsEnabled = false;\n\t\tsource.gotoAndStop(data.i);\n\t\tsource.actionsEnabled = ae;\n\t\tdata.f&&data.f(source, data.d, data.i);\n\t}\n\n\t/**\n\t * @protected\n\t * @return {Number} The width & height of the row.\n\t */\n\t_getSize (size, max) {\n\t\tlet pow = 4;\n\t\twhile (Math.pow(2, ++pow) < size) {}\n\t\treturn Math.min(max, Math.pow(2, pow));\n\t};\n\n\t/**\n\t * @protected\n\t * @param {Array} frames\n\t * @param {Number} y\n\t * @param {HTMLImageElement} img\n\t * @param {Object} dataFrames\n\t * @param {Number} pad\n\t * @return {Number} The width & height of the row.\n\t */\n\t_fillRow (frames, y, img, dataFrames, pad) {\n\t\tlet w = this.maxWidth;\n\t\tlet maxH = this.maxHeight;\n\t\ty += pad;\n\t\tlet h = maxH-y;\n\t\tlet x = pad;\n\t\tlet height = 0;\n\t\tfor (let i=frames.length-1; i>=0; i--) {\n\t\t\tlet frame = frames[i];\n\t\t\tlet sc = this._scale*frame.scale;\n\t\t\tlet rect = frame.sourceRect;\n\t\t\tlet source = frame.source;\n\t\t\tlet rx = Math.floor(sc*rect.x-pad);\n\t\t\tlet ry = Math.floor(sc*rect.y-pad);\n\t\t\tlet rh = Math.ceil(sc*rect.height+pad*2);\n\t\t\tlet rw = Math.ceil(sc*rect.width+pad*2);\n\t\t\tif (rw > w) { throw SpriteSheetBuilder.ERR_DIMENSIONS; }\n\t\t\tif (rh > h || x+rw > w) { continue; }\n\t\t\tframe.img = img;\n\t\t\tframe.rect = new Rectangle(x,y,rw,rh);\n\t\t\theight = height || rh;\n\t\t\tframes.splice(i,1);\n\t\t\tdataFrames[frame.index] = [x,y,rw,rh,img,Math.round(-rx+sc*source.regX-pad),Math.round(-ry+sc*source.regY-pad)];\n\t\t\tx += rw;\n\t\t}\n\t\treturn {w:x, h:height};\n\t}\n\n\t/**\n\t * @protected\n\t */\n\t_endBuild () {\n\t\tthis.spriteSheet = new SpriteSheet(this._data);\n\t\tthis._data = null;\n\t\tthis.progress = 1;\n\t\tthis.dispatchEvent(\"complete\");\n\t}\n\n\t/**\n\t * @protected\n\t */\n\t_run () {\n\t\tlet ts = Math.max(0.01, Math.min(0.99, this.timeSlice||0.3))*50;\n\t\tlet t = (new Date()).getTime()+ts;\n\t\tlet complete = false;\n\t\twhile (t > (new Date()).getTime()) {\n\t\t\tif (!this._drawNext()) { complete = true; break; }\n\t\t}\n\t\tif (complete) {\n\t\t\tthis._endBuild();\n\t\t} else {\n\t\t\tthis._timerID = setTimeout(() => this._run(), 50-ts);\n\t\t}\n\t\tlet p = this.progress = this._index/this._frames.length;\n\t\tif (this.hasEventListener(\"progress\")) {\n\t\t\tlet evt = new Event(\"progress\");\n\t\t\tevt.progress = p;\n\t\t\tthis.dispatchEvent(evt);\n\t\t}\n\t}\n\n\t/**\n\t * @protected\n\t * @return {Boolean} Returns false if this is the last draw.\n\t */\n\t_drawNext () {\n\t\tlet frame = this._frames[this._index];\n\t\tlet sc = frame.scale*this._scale;\n\t\tlet rect = frame.rect;\n\t\tlet sourceRect = frame.sourceRect;\n\t\tlet canvas = this._data.images[frame.img];\n\t\tlet ctx = canvas.getContext(\"2d\");\n\t\tframe.funct&&frame.funct(frame.source, frame.data);\n\t\tctx.save();\n\t\tctx.beginPath();\n\t\tctx.rect(rect.x, rect.y, rect.width, rect.height);\n\t\tctx.clip();\n\t\tctx.translate(Math.ceil(rect.x-sourceRect.x*sc), Math.ceil(rect.y-sourceRect.y*sc));\n\t\tctx.scale(sc,sc);\n\t\tframe.source.draw(ctx); // display object will draw itself.\n\t\tctx.restore();\n\t\treturn (++this._index) < this._frames.length;\n\t}\n\n}\n\n/**\n * @static\n * @readonly\n * @protected\n * @type {String}\n */\nSpriteSheetBuilder.ERR_DIMENSIONS = \"frame dimensions exceed max spritesheet dimensions\";\n/**\n * @static\n * @readonly\n * @protected\n * @type {String}\n */\nSpriteSheetBuilder.ERR_RUNNING = \"a build is already running\";\n\n/**\n * Dispatched when a build completes.\n * @event easeljs.SpriteSheetBuilder#complete\n * @property {Object} target The object that dispatched the event.\n * @property {String} type The event type.\n * @since 0.6.0\n */\n\n/**\n * Dispatched when an asynchronous build has progress.\n * @event easeljs.SpriteSheetBuilder#progress\n * @property {Object} target The object that dispatched the event.\n * @property {String} type The event type.\n * @property {Number} progress The current progress value (0-1).\n * @since 0.6.0\n */\n","/*\n* @license SpriteSheetUtils\n* Visit http://createjs.com/ for documentation, updates and examples.\n*\n* Copyright (c) 2017 gskinner.com, inc.\n*\n* Permission is hereby granted, free of charge, to any person\n* obtaining a copy of this software and associated documentation\n* files (the \"Software\"), to deal in the Software without\n* restriction, including without limitation the rights to use,\n* copy, modify, merge, publish, distribute, sublicense, and/or sell\n* copies of the Software, and to permit persons to whom the\n* Software is furnished to do so, subject to the following\n* conditions:\n*\n* The above copyright notice and this permission notice shall be\n* included in all copies or substantial portions of the Software.\n*\n* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n* OTHER DEALINGS IN THE SOFTWARE.\n*/\n\nimport createCanvas from \"./Canvas\";\n\n/**\n * The SpriteSheetUtils class is a collection of static methods for working with {{#crossLink \"SpriteSheet\"}}{{/crossLink}}s.\n * A sprite sheet is a series of images (usually animation frames) combined into a single image on a regular grid. For\n * example, an animation consisting of 8 100x100 images could be combined into a 400x200 sprite sheet (4 frames across\n * by 2 high). The SpriteSheetUtils class uses a static interface and should not be instantiated.\n *\n * @memberof easeljs\n * @name easeljs.SpriteSheetUtils\n */\nexport default {\n\n\t/**\n\t * @protected\n\t * @type {HTMLCanvasElement | Object}\n\t */\n\t_workingCanvas: createCanvas(),\n\n\t/**\n\t * @protected\n\t * @type {CanvasRenderingContext2D}\n\t */\n\tget _workingContext () { return this._workingCanvas.getContext(\"2d\"); },\n\n\t/**\n\t * Returns a single frame of the specified sprite sheet as a new PNG image. An example of when this may be useful is\n\t * to use a spritesheet frame as the source for a bitmap fill.\n\t *\n\t * WARNING: In almost all cases it is better to display a single frame using a {@link easeljs.Sprite}\n\t * with a {@link easeljs.Sprite#gotoAndStop} call than it is to slice out a frame using this\n\t * method and display it with a Bitmap instance. You can also crop an image using the {@link easeljs.Bitmap#sourceRect}\n\t * property of {@link easeljs.Bitmap}.\n\t *\n\t * The extractFrame method may cause cross-domain warnings since it accesses pixels directly on the canvas.\n\t *\n\t * @param {easeljs.SpriteSheet} spriteSheet The SpriteSheet instance to extract a frame from.\n\t * @param {Number | String} frameOrAnimation The frame number or animation name to extract. If an animation\n\t * name is specified, only the first frame of the animation will be extracted.\n\t * @return {HTMLImageElement} a single frame of the specified sprite sheet as a new PNG image.\n\t */\n\textractFrame (spriteSheet, frameOrAnimation) {\n\t\tif (isNaN(frameOrAnimation)) {\n\t\t\tframeOrAnimation = spriteSheet.getAnimation(frameOrAnimation).frames[0];\n\t\t}\n\t\tlet data = spriteSheet.getFrame(frameOrAnimation);\n\t\tif (!data) { return null; }\n\t\tlet r = data.rect;\n\t\tlet canvas = this._workingCanvas;\n\t\tcanvas.width = r.width;\n\t\tcanvas.height = r.height;\n\t\tthis._workingContext.drawImage(data.image, r.x, r.y, r.width, r.height, 0, 0, r.width, r.height);\n\t\tlet img = document.createElement(\"img\");\n\t\timg.src = canvas.toDataURL(\"image/png\");\n\t\treturn img;\n\t},\n\n\t/**\n\t * @protected\n\t * @param {easeljs.SpriteSheet} spriteSheet\n\t * @param {Number} count\n\t * @param {Number} h\n\t * @param {Number} v\n\t */\n\t_flip (spriteSheet, count, h, v) {\n\t\tlet imgs = spriteSheet._images;\n\t\tlet canvas = this._workingCanvas;\n\t\tlet ctx = this._workingContext;\n\t\tconst il = imgs.length/count;\n\t\tfor (let i=0; i {\n\t\t\tif (a.element._drawID === stage._drawID) { return 1; }\n\t\t\tif (a.element._drawID < b.element._drawID) { return -1; }\n\t\t\treturn 0;\n\t\t});\n\n\t\tconst l = output.length;\n\t\tfor (let i=0; i= 0 && !eventObj.propagationStopped; i--) {
+ list[i]._dispatchEvent(eventObj, 1 + (i == 0));
+ }
+ for (i = 1; i < l && !eventObj.propagationStopped; i++) {
+ list[i]._dispatchEvent(eventObj, 3);
+ }
+ }
+ return !eventObj.defaultPrevented;
+ };
+ _proto.hasEventListener = function hasEventListener(type) {
+ var listeners = this._listeners,
+ captureListeners = this._captureListeners;
+ return !!(listeners && listeners[type] || captureListeners && captureListeners[type]);
+ };
+ _proto.willTrigger = function willTrigger(type) {
+ var o = this;
+ while (o) {
+ if (o.hasEventListener(type)) {
+ return true;
+ }
+ o = o.parent;
+ }
+ return false;
+ };
+ _proto.toString = function toString() {
+ return "[" + (this.constructor.name + this.name ? " " + this.name : "") + "]";
+ };
+ _proto._dispatchEvent = function _dispatchEvent(eventObj, eventPhase) {
+ var listeners = eventPhase === 1 ? this._captureListeners : this._listeners;
+ if (eventObj && listeners) {
+ var arr = listeners[eventObj.type];
+ var l;
+ if (!arr || (l = arr.length) === 0) {
+ return;
+ }
+ try {
+ eventObj.currentTarget = this;
+ } catch (e) {}
+ try {
+ eventObj.eventPhase = eventPhase;
+ } catch (e) {}
+ eventObj.removed = false;
+ arr = arr.slice();
+ for (var i = 0; i < l && !eventObj.immediatePropagationStopped; i++) {
+ var o = arr[i];
+ if (o.handleEvent) {
+ o.handleEvent(eventObj);
+ } else {
+ o(eventObj);
+ }
+ if (eventObj.removed) {
+ this.off(eventObj.type, o, eventPhase === 1);
+ eventObj.removed = false;
+ }
+ }
+ }
+ };
+ return EventDispatcher;
+}();
+
+function _defineProperties(target, props) {
+ for (var i = 0; i < props.length; i++) {
+ var descriptor = props[i];
+ descriptor.enumerable = descriptor.enumerable || false;
+ descriptor.configurable = true;
+ if ("value" in descriptor) descriptor.writable = true;
+ Object.defineProperty(target, descriptor.key, descriptor);
+ }
+}
+
+function _createClass(Constructor, protoProps, staticProps) {
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
+ if (staticProps) _defineProperties(Constructor, staticProps);
+ return Constructor;
+}
+
+function _inheritsLoose(subClass, superClass) {
+ subClass.prototype = Object.create(superClass.prototype);
+ subClass.prototype.constructor = subClass;
+ subClass.__proto__ = superClass;
+}
+
+function _assertThisInitialized(self) {
+ if (self === void 0) {
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
+ }
+
+ return self;
+}
+
+var Ticker =
+function (_EventDispatcher) {
+ _inheritsLoose(Ticker, _EventDispatcher);
+ _createClass(Ticker, null, [{
+ key: "RAF_SYNCHED",
+ get: function get() {
+ return "synched";
+ }
+ }, {
+ key: "RAF",
+ get: function get() {
+ return "raf";
+ }
+ }, {
+ key: "TIMEOUT",
+ get: function get() {
+ return "timeout";
+ }
+ }]);
+ function Ticker(name) {
+ var _this;
+ _this = _EventDispatcher.call(this) || this;
+ _this.name = name;
+ _this.timingMode = Ticker.TIMEOUT;
+ _this.maxDelta = 0;
+ _this.paused = false;
+ _this._inited = false;
+ _this._startTime = 0;
+ _this._pausedTime = 0;
+ _this._ticks = 0;
+ _this._pausedTicks = 0;
+ _this._interval = 50;
+ _this._lastTime = 0;
+ _this._times = null;
+ _this._tickTimes = null;
+ _this._timerId = null;
+ _this._raf = true;
+ return _this;
+ }
+ var _proto = Ticker.prototype;
+ _proto.init = function init() {
+ if (this._inited) {
+ return;
+ }
+ this._inited = true;
+ this._times = [];
+ this._tickTimes = [];
+ this._startTime = this._getTime();
+ this._times.push(this._lastTime = 0);
+ this._setupTick();
+ };
+ _proto.reset = function reset() {
+ if (this._raf) {
+ var f = window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.oCancelAnimationFrame || window.msCancelAnimationFrame;
+ f && f(this._timerId);
+ } else {
+ clearTimeout(this._timerId);
+ }
+ this.removeAllEventListeners("tick");
+ this._timerId = this._times = this._tickTimes = null;
+ this._startTime = this._lastTime = this._ticks = 0;
+ this._inited = false;
+ };
+ _proto.addEventListener = function addEventListener(type, listener, useCapture) {
+ !this._inited && this.init();
+ return _EventDispatcher.prototype.addEventListener.call(this, type, listener, useCapture);
+ };
+ _proto.getMeasuredTickTime = function getMeasuredTickTime(ticks) {
+ if (ticks === void 0) {
+ ticks = null;
+ }
+ var times = this._tickTimes;
+ if (!times || times.length < 1) {
+ return -1;
+ }
+ ticks = Math.min(times.length, ticks || this.framerate | 0);
+ return times.reduce(function (a, b) {
+ return a + b;
+ }, 0) / ticks;
+ };
+ _proto.getMeasuredFPS = function getMeasuredFPS(ticks) {
+ if (ticks === void 0) {
+ ticks = null;
+ }
+ var times = this._times;
+ if (!times || times.length < 2) {
+ return -1;
+ }
+ ticks = Math.min(times.length - 1, ticks || this.framerate | 0);
+ return 1000 / ((times[0] - times[ticks]) / ticks);
+ };
+ _proto.getTime = function getTime(runTime) {
+ if (runTime === void 0) {
+ runTime = false;
+ }
+ return this._startTime ? this._getTime() - (runTime ? this._pausedTime : 0) : -1;
+ };
+ _proto.getEventTime = function getEventTime(runTime) {
+ if (runTime === void 0) {
+ runTime = false;
+ }
+ return this._startTime ? (this._lastTime || this._startTime) - (runTime ? this._pausedTime : 0) : -1;
+ };
+ _proto.getTicks = function getTicks(pauseable) {
+ if (pauseable === void 0) {
+ pauseable = false;
+ }
+ return this._ticks - (pauseable ? this._pausedTicks : 0);
+ };
+ _proto._handleSynch = function _handleSynch() {
+ this._timerId = null;
+ this._setupTick();
+ if (this._getTime() - this._lastTime >= (this._interval - 1) * 0.97) {
+ this._tick();
+ }
+ };
+ _proto._handleRAF = function _handleRAF() {
+ this._timerId = null;
+ this._setupTick();
+ this._tick();
+ };
+ _proto._handleTimeout = function _handleTimeout() {
+ this._timerId = null;
+ this._setupTick();
+ this._tick();
+ };
+ _proto._setupTick = function _setupTick() {
+ if (this._timerId != null) {
+ return;
+ }
+ var mode = this.timingMode || this._raf && Ticker.RAF;
+ if (mode === Ticker.RAF_SYNCHED || mode === Ticker.RAF) {
+ var f = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame;
+ if (f) {
+ this._timerId = f(mode === Ticker.RAF ? this._handleRAF.bind(this) : this._handleSynch.bind(this));
+ this._raf = true;
+ return;
+ }
+ }
+ this._raf = false;
+ this._timerId = setTimeout(this._handleTimeout.bind(this), this._interval);
+ };
+ _proto._tick = function _tick() {
+ var paused = this.paused,
+ time = this._getTime(),
+ elapsedTime = time - this._lastTime;
+ this._lastTime = time;
+ this._ticks++;
+ if (paused) {
+ this._pausedTicks++;
+ this._pausedTime += elapsedTime;
+ }
+ if (this.hasEventListener("tick")) {
+ var event = new Event("tick");
+ var maxDelta = this.maxDelta;
+ event.delta = maxDelta && elapsedTime > maxDelta ? maxDelta : elapsedTime;
+ event.paused = paused;
+ event.time = time;
+ event.runTime = time - this._pausedTime;
+ this.dispatchEvent(event);
+ }
+ this._tickTimes.unshift(this._getTime() - time);
+ while (this._tickTimes.length > 100) {
+ this._tickTimes.pop();
+ }
+ this._times.unshift(time);
+ while (this._times.length > 100) {
+ this._times.pop();
+ }
+ };
+ _proto._getTime = function _getTime() {
+ var now = window.performance && window.performance.now;
+ return (now && now.call(performance) || new Date().getTime()) - this._startTime;
+ };
+ Ticker.on = function on(type, listener, scope, once, data, useCapture) {
+ return _instance.on(type, listener, scope, once, data, useCapture);
+ };
+ Ticker.removeEventListener = function removeEventListener(type, listener, useCapture) {
+ _instance.removeEventListener(type, listener, useCapture);
+ };
+ Ticker.off = function off(type, listener, useCapture) {
+ _instance.off(type, listener, useCapture);
+ };
+ Ticker.removeAllEventListeners = function removeAllEventListeners(type) {
+ _instance.removeAllEventListeners(type);
+ };
+ Ticker.dispatchEvent = function dispatchEvent(eventObj, bubbles, cancelable) {
+ return _instance.dispatchEvent(eventObj, bubbles, cancelable);
+ };
+ Ticker.hasEventListener = function hasEventListener(type) {
+ return _instance.hasEventListener(type);
+ };
+ Ticker.willTrigger = function willTrigger(type) {
+ return _instance.willTrigger(type);
+ };
+ Ticker.toString = function toString() {
+ return _instance.toString();
+ };
+ Ticker.init = function init() {
+ _instance.init();
+ };
+ Ticker.reset = function reset() {
+ _instance.reset();
+ };
+ Ticker.addEventListener = function addEventListener(type, listener, useCapture) {
+ _instance.addEventListener(type, listener, useCapture);
+ };
+ Ticker.getMeasuredTickTime = function getMeasuredTickTime(ticks) {
+ return _instance.getMeasuredTickTime(ticks);
+ };
+ Ticker.getMeasuredFPS = function getMeasuredFPS(ticks) {
+ return _instance.getMeasuredFPS(ticks);
+ };
+ Ticker.getTime = function getTime(runTime) {
+ return _instance.getTime(runTime);
+ };
+ Ticker.getEventTime = function getEventTime(runTime) {
+ return _instance.getEventTime(runTime);
+ };
+ Ticker.getTicks = function getTicks(pauseable) {
+ return _instance.getTicks(pauseable);
+ };
+ _createClass(Ticker, [{
+ key: "interval",
+ get: function get() {
+ return this._interval;
+ },
+ set: function set(interval) {
+ this._interval = interval;
+ if (!this._inited) {
+ return;
+ }
+ this._setupTick();
+ }
+ }, {
+ key: "framerate",
+ get: function get() {
+ return 1000 / this._interval;
+ },
+ set: function set(framerate) {
+ this.interval = 1000 / framerate;
+ }
+ }], [{
+ key: "interval",
+ get: function get() {
+ return _instance.interval;
+ },
+ set: function set(interval) {
+ _instance.interval = interval;
+ }
+ }, {
+ key: "framerate",
+ get: function get() {
+ return _instance.framerate;
+ },
+ set: function set(framerate) {
+ _instance.framerate = framerate;
+ }
+ }, {
+ key: "name",
+ get: function get() {
+ return _instance.name;
+ },
+ set: function set(name) {
+ _instance.name = name;
+ }
+ }, {
+ key: "timingMode",
+ get: function get() {
+ return _instance.timingMode;
+ },
+ set: function set(timingMode) {
+ _instance.timingMode = timingMode;
+ }
+ }, {
+ key: "maxDelta",
+ get: function get() {
+ return _instance.maxDelta;
+ },
+ set: function set(maxDelta) {
+ _instance.maxDelta = maxDelta;
+ }
+ }, {
+ key: "paused",
+ get: function get() {
+ return _instance.paused;
+ },
+ set: function set(paused) {
+ _instance.paused = paused;
+ }
+ }]);
+ return Ticker;
+}(EventDispatcher);
+var _instance = new Ticker("createjs.global");
+
+var StageGL = function StageGL() {
+ throw new Error("\n\t\t\tStageGL is not currently supported on the EaselJS 2.0 branch.\n\t\t\tEnd of Q1 2018 is targetted for StageGL support.\n\t\t\tFollow @CreateJS on Twitter for updates.\n\t\t");
+};
+
+var Shadow =
+function () {
+ function Shadow(color, offsetX, offsetY, blur) {
+ if (color === void 0) {
+ color = "black";
+ }
+ if (offsetX === void 0) {
+ offsetX = 0;
+ }
+ if (offsetY === void 0) {
+ offsetY = 0;
+ }
+ if (blur === void 0) {
+ blur = 0;
+ }
+ this.color = color;
+ this.offsetX = offsetX;
+ this.offsetY = offsetY;
+ this.blur = blur;
+ }
+ var _proto = Shadow.prototype;
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + "]";
+ };
+ _proto.clone = function clone() {
+ return new Shadow(this.color, this.offsetX, this.offsetY, this.blur);
+ };
+ return Shadow;
+}();
+Shadow.identity = new Shadow("transparent");
+
+var _nextId = 0;
+function uid() {
+ return _nextId++;
+}
+
+var Point =
+function () {
+ function Point(x, y) {
+ this.setValues(x, y);
+ }
+ var _proto = Point.prototype;
+ _proto.setValues = function setValues(x, y) {
+ if (x === void 0) {
+ x = 0;
+ }
+ if (y === void 0) {
+ y = 0;
+ }
+ this.x = x;
+ this.y = y;
+ return this;
+ };
+ _proto.copy = function copy(point) {
+ this.x = point.x;
+ this.y = point.y;
+ return this;
+ };
+ _proto.clone = function clone() {
+ return new Point(this.x, this.y);
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + " (x=" + this.x + " y=" + this.y + ")]";
+ };
+ return Point;
+}();
+
+var Matrix2D =
+function () {
+ function Matrix2D(a, b, c, d, tx, ty) {
+ this.setValues(a, b, c, d, tx, ty);
+ }
+ var _proto = Matrix2D.prototype;
+ _proto.setValues = function setValues(a, b, c, d, tx, ty) {
+ if (a === void 0) {
+ a = 1;
+ }
+ if (b === void 0) {
+ b = 0;
+ }
+ if (c === void 0) {
+ c = 0;
+ }
+ if (d === void 0) {
+ d = 1;
+ }
+ if (tx === void 0) {
+ tx = 0;
+ }
+ if (ty === void 0) {
+ ty = 0;
+ }
+ this.a = a;
+ this.b = b;
+ this.c = c;
+ this.d = d;
+ this.tx = tx;
+ this.ty = ty;
+ return this;
+ };
+ _proto.append = function append(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;
+ };
+ _proto.prepend = function prepend(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;
+ };
+ _proto.appendMatrix = function appendMatrix(matrix) {
+ return this.append(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);
+ };
+ _proto.prependMatrix = function prependMatrix(matrix) {
+ return this.prepend(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);
+ };
+ _proto.appendTransform = function appendTransform(x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) {
+ var r, cos, sin;
+ if (rotation % 360) {
+ r = rotation * Matrix2D.DEG_TO_RAD;
+ cos = Math.cos(r);
+ sin = Math.sin(r);
+ } else {
+ cos = 1;
+ sin = 0;
+ }
+ if (skewX || skewY) {
+ 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) {
+ this.tx -= regX * this.a + regY * this.c;
+ this.ty -= regX * this.b + regY * this.d;
+ }
+ return this;
+ };
+ _proto.prependTransform = function prependTransform(x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) {
+ var r, cos, sin;
+ if (rotation % 360) {
+ r = rotation * Matrix2D.DEG_TO_RAD;
+ cos = Math.cos(r);
+ sin = Math.sin(r);
+ } else {
+ cos = 1;
+ sin = 0;
+ }
+ if (regX || regY) {
+ this.tx -= regX;
+ this.ty -= regY;
+ }
+ if (skewX || skewY) {
+ 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;
+ };
+ _proto.rotate = function rotate(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;
+ };
+ _proto.skew = function skew(skewX, skewY) {
+ skewX *= Matrix2D.DEG_TO_RAD;
+ skewY *= Matrix2D.DEG_TO_RAD;
+ this.append(Math.cos(skewY), Math.sin(skewY), -Math.sin(skewX), Math.cos(skewX), 0, 0);
+ return this;
+ };
+ _proto.scale = function scale(x, y) {
+ this.a *= x;
+ this.b *= x;
+ this.c *= y;
+ this.d *= y;
+ return this;
+ };
+ _proto.translate = function translate(x, y) {
+ this.tx += this.a * x + this.c * y;
+ this.ty += this.b * x + this.d * y;
+ return this;
+ };
+ _proto.identity = function identity() {
+ this.a = this.d = 1;
+ this.b = this.c = this.tx = this.ty = 0;
+ return this;
+ };
+ _proto.invert = function invert() {
+ 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;
+ };
+ _proto.isIdentity = function isIdentity() {
+ return this.tx === 0 && this.ty === 0 && this.a === 1 && this.b === 0 && this.c === 0 && this.d === 1;
+ };
+ _proto.equals = function equals(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;
+ };
+ _proto.transformPoint = function transformPoint(x, y, pt) {
+ if (pt === void 0) {
+ pt = new Point();
+ }
+ pt.x = x * this.a + y * this.c + this.tx;
+ pt.y = x * this.b + y * this.d + this.ty;
+ return pt;
+ };
+ _proto.decompose = function decompose(target) {
+ if (target === void 0) {
+ 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) {
+ 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;
+ };
+ _proto.copy = function copy(matrix) {
+ return this.setValues(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);
+ };
+ _proto.clone = function clone() {
+ return new Matrix2D(this.a, this.b, this.c, this.d, this.tx, this.ty);
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + " (a=" + this.a + " b=" + this.b + " c=" + this.c + " d=" + this.d + " tx=" + this.tx + " ty=" + this.ty + ")]";
+ };
+ return Matrix2D;
+}();
+Matrix2D.DEG_TO_RAD = Math.PI / 180;
+Matrix2D.identity = new Matrix2D();
+
+var DisplayProps =
+function () {
+ function DisplayProps(visible, alpha, shadow, compositeOperation, matrix) {
+ this.setValues(visible, alpha, shadow, compositeOperation, matrix);
+ }
+ var _proto = DisplayProps.prototype;
+ _proto.setValues = function setValues(visible, alpha, shadow, compositeOperation, matrix) {
+ if (visible === void 0) {
+ visible = true;
+ }
+ if (alpha === void 0) {
+ alpha = 1;
+ }
+ this.visible = visible;
+ this.alpha = alpha;
+ this.shadow = shadow;
+ this.compositeOperation = compositeOperation;
+ this.matrix = matrix || this.matrix && this.matrix.identity() || new Matrix2D();
+ return this;
+ };
+ _proto.append = function append(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;
+ };
+ _proto.prepend = function prepend(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;
+ };
+ _proto.identity = function identity() {
+ this.visible = true;
+ this.alpha = 1;
+ this.shadow = this.compositeOperation = null;
+ this.matrix.identity();
+ return this;
+ };
+ _proto.clone = function clone() {
+ return new DisplayProps(this.alpha, this.shadow, this.compositeOperation, this.visible, this.matrix.clone());
+ };
+ return DisplayProps;
+}();
+
+var Rectangle =
+function () {
+ function Rectangle(x, y, width, height) {
+ this.setValues(x, y, width, height);
+ }
+ var _proto = Rectangle.prototype;
+ _proto.setValues = function setValues(x, y, width, height) {
+ if (x === void 0) {
+ x = 0;
+ }
+ if (y === void 0) {
+ y = 0;
+ }
+ if (width === void 0) {
+ width = 0;
+ }
+ if (height === void 0) {
+ height = 0;
+ }
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ return this;
+ };
+ _proto.extend = function extend(x, y, width, height) {
+ if (width === void 0) {
+ width = 0;
+ }
+ if (height === void 0) {
+ height = 0;
+ }
+ if (x + width > this.x + this.width) {
+ this.width = x + width - this.x;
+ }
+ if (y + height > this.y + this.height) {
+ this.height = y + height - this.y;
+ }
+ if (x < this.x) {
+ this.width += this.x - x;
+ this.x = x;
+ }
+ if (y < this.y) {
+ this.height += this.y - y;
+ this.y = y;
+ }
+ return this;
+ };
+ _proto.pad = function pad(top, left, bottom, right) {
+ this.x -= left;
+ this.y -= top;
+ this.width += left + right;
+ this.height += top + bottom;
+ return this;
+ };
+ _proto.copy = function copy(rect) {
+ return this.setValues(rect.x, rect.y, rect.width, rect.height);
+ };
+ _proto.contains = function contains(x, y, width, height) {
+ if (width === void 0) {
+ width = 0;
+ }
+ if (height === void 0) {
+ height = 0;
+ }
+ return x >= this.x && x + width <= this.x + this.width && y >= this.y && y + height <= this.y + this.height;
+ };
+ _proto.union = function union(rect) {
+ return this.clone().extend(rect.x, rect.y, rect.width, rect.height);
+ };
+ _proto.intersection = function intersection(rect) {
+ var x1 = rect.x,
+ y1 = rect.y,
+ x2 = x1 + rect.width,
+ y2 = y1 + rect.height;
+ if (this.x > x1) {
+ x1 = this.x;
+ }
+ if (this.y > y1) {
+ y1 = this.y;
+ }
+ if (this.x + this.width < x2) {
+ x2 = this.x + this.width;
+ }
+ if (this.y + this.height < y2) {
+ y2 = this.y + this.height;
+ }
+ return x2 <= x1 || y2 <= y1 ? null : new Rectangle(x1, y1, x2 - x1, y2 - y1);
+ };
+ _proto.intersects = function intersects(rect) {
+ return rect.x <= this.x + this.width && this.x <= rect.x + rect.width && rect.y <= this.y + this.height && this.y <= rect.y + rect.height;
+ };
+ _proto.isEmpty = function isEmpty() {
+ return this.width <= 0 || this.height <= 0;
+ };
+ _proto.clone = function clone() {
+ return new Rectangle(this.x, this.y, this.width, this.height);
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + " (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + ")]";
+ };
+ return Rectangle;
+}();
+
+var Filter =
+function () {
+ function Filter() {
+ this.usesContext = false;
+ this._multiPass = null;
+ this.VTX_SHADER_BODY = null;
+ this.FRAG_SHADER_BODY = null;
+ }
+ var _proto = Filter.prototype;
+ _proto.getBounds = function getBounds(rect) {};
+ _proto.shaderParamSetup = function shaderParamSetup(gl, stage, shaderProgram) {};
+ _proto.applyFilter = function applyFilter(ctx, x, y, width, height, targetCtx, targetX, targetY) {
+ targetCtx = targetCtx || ctx;
+ if (targetX == null) {
+ targetX = x;
+ }
+ if (targetY == null) {
+ targetY = y;
+ }
+ try {
+ var imageData = ctx.getImageData(x, y, width, height);
+ if (this._applyFilter(imageData)) {
+ targetCtx.putImageData(imageData, targetX, targetY);
+ return true;
+ }
+ } catch (e) {}
+ return false;
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + "]";
+ };
+ _proto.clone = function clone() {
+ return new Filter();
+ };
+ _proto._applyFilter = function _applyFilter(imageData) {};
+ return Filter;
+}();
+
+var BitmapCache =
+function (_Filter) {
+ _inheritsLoose(BitmapCache, _Filter);
+ function BitmapCache() {
+ var _this;
+ _this = _Filter.call(this) || this;
+ _this.width = undefined;
+ _this.height = undefined;
+ _this.x = undefined;
+ _this.y = undefined;
+ _this.scale = 1;
+ _this.offX = 0;
+ _this.offY = 0;
+ _this.cacheID = 0;
+ _this._filterOffX = 0;
+ _this._filterOffY = 0;
+ _this._cacheDataURLID = 0;
+ _this._cacheDataURL = null;
+ _this._drawWidth = 0;
+ _this._drawHeight = 0;
+ _this._boundRect = new Rectangle();
+ return _this;
+ }
+ BitmapCache.getFilterBounds = function getFilterBounds(target, output) {
+ if (output === void 0) {
+ output = new Rectangle();
+ }
+ var filters = target.filters;
+ var filterCount = filters && filters.length;
+ if (!!filterCount <= 0) {
+ return output;
+ }
+ for (var i = 0; i < filterCount; i++) {
+ var f = filters[i];
+ if (!f || !f.getBounds) {
+ continue;
+ }
+ var test = f.getBounds();
+ if (!test) {
+ continue;
+ }
+ if (i == 0) {
+ output.setValues(test.x, test.y, test.width, test.height);
+ } else {
+ output.extend(test.x, test.y, test.width, test.height);
+ }
+ }
+ return output;
+ };
+ var _proto = BitmapCache.prototype;
+ _proto.define = function define(target, x, y, width, height, scale, options) {
+ if (x === void 0) {
+ x = 0;
+ }
+ if (y === void 0) {
+ y = 0;
+ }
+ if (width === void 0) {
+ width = 1;
+ }
+ if (height === void 0) {
+ height = 1;
+ }
+ if (scale === void 0) {
+ scale = 1;
+ }
+ if (!target) {
+ throw "No symbol to cache";
+ }
+ this._options = options;
+ this._useWebGL = options !== undefined;
+ this.target = target;
+ this.width = width >= 1 ? width : 1;
+ this.height = height >= 1 ? height : 1;
+ this.x = x;
+ this.y = y;
+ this.scale = scale;
+ this.update();
+ };
+ _proto.update = function update(compositeOperation) {
+ if (!this.target) {
+ throw "define() must be called before update()";
+ }
+ var filterBounds = BitmapCache.getFilterBounds(this.target);
+ var surface = this.target.cacheCanvas;
+ this._drawWidth = Math.ceil(this.width * this.scale) + filterBounds.width;
+ this._drawHeight = Math.ceil(this.height * this.scale) + filterBounds.height;
+ if (!surface || this._drawWidth != surface.width || this._drawHeight != surface.height) {
+ this._updateSurface();
+ }
+ this._filterOffX = filterBounds.x;
+ this._filterOffY = filterBounds.y;
+ this.offX = this.x * this.scale + this._filterOffX;
+ this.offY = this.y * this.scale + this._filterOffY;
+ this._drawToCache(compositeOperation);
+ this.cacheID = this.cacheID ? this.cacheID + 1 : 1;
+ };
+ _proto.release = function release() {
+ var stage = this.target.stage;
+ if (this._useWebGL && this._webGLCache) {
+ if (!this._webGLCache.isCacheControlled) {
+ if (this.__lastRT) {
+ this.__lastRT = undefined;
+ }
+ if (this.__rtA) {
+ this._webGLCache._killTextureObject(this.__rtA);
+ }
+ if (this.__rtB) {
+ this._webGLCache._killTextureObject(this.__rtB);
+ }
+ if (this.target && this.target.cacheCanvas) {
+ this._webGLCache._killTextureObject(this.target.cacheCanvas);
+ }
+ }
+ this._webGLCache = false;
+ } else if (stage instanceof StageGL) {
+ stage.releaseTexture(this.target.cacheCanvas);
+ }
+ this.target = this.target.cacheCanvas = null;
+ this.cacheID = this._cacheDataURLID = this._cacheDataURL = undefined;
+ this.width = this.height = this.x = this.y = this.offX = this.offY = 0;
+ this.scale = 1;
+ };
+ _proto.getCacheDataURL = function getCacheDataURL() {
+ var cacheCanvas = this.target && this.target.cacheCanvas;
+ if (!cacheCanvas) {
+ return null;
+ }
+ if (this.cacheID != this._cacheDataURLID) {
+ this._cacheDataURLID = this.cacheID;
+ this._cacheDataURL = cacheCanvas.toDataURL ? cacheCanvas.toDataURL() : null;
+ }
+ return this._cacheDataURL;
+ };
+ _proto.draw = function draw(ctx) {
+ if (!this.target) {
+ return false;
+ }
+ ctx.drawImage(this.target.cacheCanvas, this.x + this._filterOffX / this.scale, this.y + this._filterOffY / this.scale, this._drawWidth / this.scale, this._drawHeight / this.scale);
+ return true;
+ };
+ _proto.getBounds = function getBounds() {
+ var scale = this.scale;
+ return this._boundRect.setValue(this._filterOffX / scale, this._filterOffY / scale, this.width / scale, this.height / scale);
+ };
+ _proto._updateSurface = function _updateSurface() {
+ var surface;
+ if (!this._useWebGL) {
+ surface = this.target.cacheCanvas;
+ if (!surface) {
+ surface = this.target.cacheCanvas = window.createjs && createjs.createCanvas ? createjs.createCanvas() : document.createElement("canvas");
+ }
+ surface.width = this._drawWidth;
+ surface.height = this._drawHeight;
+ return;
+ }
+ if (!this._webGLCache) {
+ if (this._options.useGL === "stage") {
+ if (!(this.target.stage != null && this.target.stage.isWebGL)) {
+ throw "Cannot use 'stage' for cache because the object's parent stage is " + (this.target.stage != null ? "non WebGL." : "not set, please addChild to the correct stage.");
+ }
+ this.target.cacheCanvas = true;
+ this._webGLCache = this.target.stage;
+ } else if (this._options.useGL === "new") {
+ this.target.cacheCanvas = document.createElement("canvas");
+ this._webGLCache = new StageGL(this.target.cacheCanvas, {
+ antialias: true,
+ transparent: true,
+ autoPurge: -1
+ });
+ this._webGLCache.isCacheControlled = true;
+ } else {
+ throw "Invalid option provided to useGL, expected ['stage', 'new', StageGL, undefined], got " + this._options.useGL;
+ }
+ }
+ var stageGL = this._webGLCache;
+ surface = this.target.cacheCanvas;
+ if (stageGL.isCacheControlled) {
+ surface.width = this._drawWidth;
+ surface.height = this._drawHeight;
+ stageGL.updateViewport(this._drawWidth, this._drawHeight);
+ }
+ if (this.target.filters) {
+ stageGL.getTargetRenderTexture(this.target, this._drawWidth, this._drawHeight);
+ stageGL.getTargetRenderTexture(this.target, this._drawWidth, this._drawHeight);
+ } else if (!stageGL.isCacheControlled) {
+ stageGL.getTargetRenderTexture(this.target, this._drawWidth, this._drawHeight);
+ }
+ };
+ _proto._drawToCache = function _drawToCache(compositeOperation) {
+ var target = this.target;
+ var surface = target.cacheCanvas;
+ var webGL = this._webGLCache;
+ if (!this._useWebGL || !webGL) {
+ var ctx = surface.getContext("2d");
+ if (!compositeOperation) {
+ ctx.clearRect(0, 0, this._drawWidth + 1, this._drawHeight + 1);
+ }
+ ctx.save();
+ ctx.globalCompositeOperation = compositeOperation;
+ ctx.setTransform(this.scale, 0, 0, this.scale, -this._filterOffX, -this._filterOffY);
+ ctx.translate(-this.x, -this.y);
+ target.draw(ctx, true);
+ ctx.restore();
+ if (target.filters && target.filters.length) {
+ this._applyFilters(target);
+ }
+ surface._invalid = true;
+ return;
+ }
+ this._webGLCache.cacheDraw(target, target.filters, this);
+ surface = this.target.cacheCanvas;
+ surface.width = this._drawWidth;
+ surface.height = this._drawHeight;
+ surface._invalid = true;
+ };
+ _proto._applyFilters = function _applyFilters() {
+ var surface = this.target.cacheCanvas;
+ var filters = this.target.filters;
+ var w = this._drawWidth;
+ var h = this._drawHeight;
+ var data = surface.getContext("2d").getImageData(0, 0, w, h);
+ var l = filters.length;
+ for (var i = 0; i < l; i++) {
+ filters[i]._applyFilter(data);
+ }
+ surface.getContext("2d").putImageData(data, 0, 0);
+ };
+ return BitmapCache;
+}(Filter);
+
+var DisplayObject =
+function (_EventDispatcher) {
+ _inheritsLoose(DisplayObject, _EventDispatcher);
+ function DisplayObject() {
+ var _this;
+ _this = _EventDispatcher.call(this) || this;
+ _this.alpha = 1;
+ _this.cacheCanvas = null;
+ _this.bitmapCache = null;
+ _this.id = uid();
+ _this.mouseEnabled = true;
+ _this.tickEnabled = true;
+ _this.name = null;
+ _this.parent = null;
+ _this.regX = 0;
+ _this.regY = 0;
+ _this.rotation = 0;
+ _this.scaleX = 1;
+ _this.scaleY = 1;
+ _this.skewX = 0;
+ _this.skewY = 0;
+ _this.shadow = null;
+ _this.visible = true;
+ _this.x = 0;
+ _this.y = 0;
+ _this.transformMatrix = null;
+ _this.compositeOperation = null;
+ _this.snapToPixel = true;
+ _this.filters = null;
+ _this.mask = null;
+ _this.hitArea = null;
+ _this.cursor = null;
+ _this._props = new DisplayProps();
+ _this._rectangle = new Rectangle();
+ _this._bounds = null;
+ _this._webGLRenderStyle = DisplayObject._StageGL_NONE;
+ return _this;
+ }
+ var _proto = DisplayObject.prototype;
+ _proto.isVisible = function isVisible() {
+ return !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0);
+ };
+ _proto.draw = function draw(ctx, ignoreCache) {
+ if (ignoreCache === void 0) {
+ ignoreCache = false;
+ }
+ return this.drawCache(ctx, ignoreCache);
+ };
+ _proto.drawCache = function drawCache(ctx, ignoreCache) {
+ if (ignoreCache === void 0) {
+ ignoreCache = false;
+ }
+ var cache = this.bitmapCache;
+ if (cache && !ignoreCache) {
+ return cache.draw(ctx);
+ }
+ return false;
+ };
+ _proto.updateContext = function updateContext(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);
+ }
+ };
+ _proto.cache = function cache(x, y, width, height, scale, options) {
+ if (scale === void 0) {
+ scale = 1;
+ }
+ if (!this.bitmapCache) {
+ this.bitmapCache = new BitmapCache();
+ }
+ this.bitmapCache.define(this, x, y, width, height, scale, options);
+ };
+ _proto.updateCache = function updateCache(compositeOperation) {
+ if (!this.bitmapCache) {
+ throw "No cache found. cache() must be called before updateCache()";
+ }
+ this.bitmapCache.update(compositeOperation);
+ };
+ _proto.uncache = function uncache() {
+ if (this.bitmapCache) {
+ this.bitmapCache.release();
+ this.bitmapCache = undefined;
+ }
+ };
+ _proto.getCacheDataURL = function getCacheDataURL() {
+ return this.bitmapCache ? this.bitmapCache.getDataURL() : null;
+ };
+ _proto.localToGlobal = function localToGlobal(x, y, pt) {
+ if (pt === void 0) {
+ pt = new Point();
+ }
+ return this.getConcatenatedMatrix(this._props.matrix).transformPoint(x, y, pt);
+ };
+ _proto.globalToLocal = function globalToLocal(x, y, pt) {
+ if (pt === void 0) {
+ pt = new Point();
+ }
+ return this.getConcatenatedMatrix(this._props.matrix).invert().transformPoint(x, y, pt);
+ };
+ _proto.localToLocal = function localToLocal(x, y, target, pt) {
+ pt = this.localToGlobal(x, y, pt);
+ return target.globalToLocal(pt.x, pt.y, pt);
+ };
+ _proto.setTransform = function setTransform(x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) {
+ if (x === void 0) {
+ x = 0;
+ }
+ if (y === void 0) {
+ y = 0;
+ }
+ if (scaleX === void 0) {
+ scaleX = 1;
+ }
+ if (scaleY === void 0) {
+ scaleY = 1;
+ }
+ if (rotation === void 0) {
+ rotation = 0;
+ }
+ if (skewX === void 0) {
+ skewX = 0;
+ }
+ if (skewY === void 0) {
+ skewY = 0;
+ }
+ if (regX === void 0) {
+ regX = 0;
+ }
+ if (regY === void 0) {
+ regY = 0;
+ }
+ this.x = x;
+ this.y = y;
+ this.scaleX = scaleX;
+ this.scaleY = scaleY;
+ this.rotation = rotation;
+ this.skewX = skewX;
+ this.skewY = skewY;
+ this.regX = regX;
+ this.regY = regY;
+ return this;
+ };
+ _proto.getMatrix = function getMatrix(matrix) {
+ var o = this,
+ mtx = matrix && matrix.identity() || new Matrix2D();
+ return o.transformMatrix ? mtx.copy(o.transformMatrix) : mtx.appendTransform(o.x, o.y, o.scaleX, o.scaleY, o.rotation, o.skewX, o.skewY, o.regX, o.regY);
+ };
+ _proto.getConcatenatedMatrix = function getConcatenatedMatrix(matrix) {
+ var o = this,
+ mtx = this.getMatrix(matrix);
+ while (o = o.parent) {
+ mtx.prependMatrix(o.getMatrix(o._props.matrix));
+ }
+ return mtx;
+ };
+ _proto.getConcatenatedDisplayProps = function getConcatenatedDisplayProps(props) {
+ props = props ? props.identity() : new DisplayProps();
+ var o = this,
+ mtx = o.getMatrix(props.matrix);
+ do {
+ props.prepend(o.visible, o.alpha, o.shadow, o.compositeOperation);
+ if (o != this) {
+ mtx.prependMatrix(o.getMatrix(o._props.matrix));
+ }
+ } while (o = o.parent);
+ return props;
+ };
+ _proto.hitTest = function hitTest(x, y) {
+ var ctx = DisplayObject._hitTestContext;
+ ctx.setTransform(1, 0, 0, 1, -x, -y);
+ this.draw(ctx);
+ var hit = this._testHit(ctx);
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
+ ctx.clearRect(0, 0, 2, 2);
+ return hit;
+ };
+ _proto.set = function set(props) {
+ for (var n in props) {
+ this[n] = props[n];
+ }
+ return this;
+ };
+ _proto.getBounds = function getBounds() {
+ if (this._bounds) {
+ return this._rectangle.copy(this._bounds);
+ }
+ var cacheCanvas = this.cacheCanvas;
+ if (cacheCanvas) {
+ var scale = this._cacheScale;
+ return this._rectangle.setValues(this._cacheOffsetX, this._cacheOffsetY, cacheCanvas.width / scale, cacheCanvas.height / scale);
+ }
+ return null;
+ };
+ _proto.getTransformedBounds = function getTransformedBounds() {
+ return this._getBounds();
+ };
+ _proto.setBounds = function setBounds(x, y, width, height) {
+ if (x == null) {
+ this._bounds = null;
+ }
+ this._bounds = (this._bounds || new Rectangle()).setValues(x, y, width, height);
+ };
+ _proto.clone = function clone() {
+ return this._cloneProps(new DisplayObject());
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + (this.name ? " (name=" + this.name + ")" : "") + "]";
+ };
+ _proto._cloneProps = function _cloneProps(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;
+ return o;
+ };
+ _proto._applyShadow = function _applyShadow(ctx, shadow) {
+ if (shadow === void 0) {
+ shadow = Shadow.identity;
+ }
+ shadow = shadow;
+ ctx.shadowColor = shadow.color;
+ ctx.shadowOffsetX = shadow.offsetX;
+ ctx.shadowOffsetY = shadow.offsetY;
+ ctx.shadowBlur = shadow.blur;
+ };
+ _proto._tick = function _tick(evtObj) {
+ var ls = this._listeners;
+ if (ls && ls["tick"]) {
+ evtObj.target = null;
+ evtObj.propagationStopped = evtObj.immediatePropagationStopped = false;
+ this.dispatchEvent(evtObj);
+ }
+ };
+ _proto._testHit = function _testHit(ctx) {
+ try {
+ return ctx.getImageData(0, 0, 1, 1).data[3] > 1;
+ } catch (e) {
+ if (!DisplayObject.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 false;
+ }
+ };
+ _proto._getBounds = function _getBounds(matrix, ignoreTransform) {
+ return this._transformBounds(this.getBounds(), matrix, ignoreTransform);
+ };
+ _proto._transformBounds = function _transformBounds(bounds, matrix, ignoreTransform) {
+ if (!bounds) {
+ return bounds;
+ }
+ var x = bounds.x,
+ y = bounds.y,
+ width = bounds.width,
+ height = bounds.height;
+ var mtx = this._props.matrix;
+ mtx = ignoreTransform ? mtx.identity() : this.getMatrix(mtx);
+ if (x || y) {
+ mtx.appendTransform(0, 0, 1, 1, 0, 0, 0, -x, -y);
+ }
+ if (matrix) {
+ mtx.prependMatrix(matrix);
+ }
+ var x_a = width * mtx.a,
+ x_b = width * mtx.b;
+ var y_c = height * mtx.c,
+ y_d = height * mtx.d;
+ var tx = mtx.tx,
+ ty = mtx.ty;
+ var minX = tx,
+ maxX = tx,
+ minY = ty,
+ maxY = ty;
+ if ((x = x_a + tx) < minX) {
+ minX = x;
+ } else if (x > maxX) {
+ maxX = x;
+ }
+ if ((x = x_a + y_c + tx) < minX) {
+ minX = x;
+ } else if (x > maxX) {
+ maxX = x;
+ }
+ if ((x = y_c + tx) < minX) {
+ minX = x;
+ } else if (x > maxX) {
+ maxX = x;
+ }
+ if ((y = x_b + ty) < minY) {
+ minY = y;
+ } else if (y > maxY) {
+ maxY = y;
+ }
+ if ((y = x_b + y_d + ty) < minY) {
+ minY = y;
+ } else if (y > maxY) {
+ maxY = y;
+ }
+ if ((y = y_d + ty) < minY) {
+ minY = y;
+ } else if (y > maxY) {
+ maxY = y;
+ }
+ return bounds.setValues(minX, minY, maxX - minX, maxY - minY);
+ };
+ _proto._hasMouseEventListener = function _hasMouseEventListener() {
+ var evts = DisplayObject._MOUSE_EVENTS;
+ for (var i = 0, l = evts.length; i < l; i++) {
+ if (this.hasEventListener(evts[i])) {
+ return true;
+ }
+ }
+ return !!this.cursor;
+ };
+ _createClass(DisplayObject, [{
+ key: "stage",
+ get: function get() {
+ var o = this;
+ while (o.parent) {
+ o = o.parent;
+ }
+ if (/^\[Stage(GL)?(\s\(name=\w+\))?\]$/.test(o.toString())) {
+ return o;
+ }
+ return null;
+ }
+ }, {
+ key: "scale",
+ set: function set(value) {
+ this.scaleX = this.scaleY = value;
+ },
+ get: function get() {
+ return this.scaleX;
+ }
+ }]);
+ return DisplayObject;
+}(EventDispatcher);
+{
+ var canvas = window.createjs && createjs.createCanvas ? createjs.createCanvas() : document.createElement("canvas");
+ if (canvas.getContext) {
+ DisplayObject._hitTestCanvas = canvas;
+ DisplayObject._hitTestContext = canvas.getContext("2d");
+ canvas.width = canvas.height = 1;
+ }
+}
+DisplayObject._MOUSE_EVENTS = ["click", "dblclick", "mousedown", "mouseout", "mouseover", "pressmove", "pressup", "rollout", "rollover"];
+DisplayObject.suppressCrossDomainErrors = false;
+DisplayObject.snapToPixelEnabled = false;
+DisplayObject._StageGL_NONE = 0;
+DisplayObject._StageGL_SPRITE = 1;
+DisplayObject._StageGL_BITMAP = 2;
+
+var Container =
+function (_DisplayObject) {
+ _inheritsLoose(Container, _DisplayObject);
+ function Container() {
+ var _this;
+ _this = _DisplayObject.call(this) || this;
+ _this.children = [];
+ _this.mouseChildren = true;
+ _this.tickChildren = true;
+ return _this;
+ }
+ var _proto = Container.prototype;
+ _proto.isVisible = function isVisible() {
+ var hasContent = this.cacheCanvas || this.children.length;
+ return !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && hasContent);
+ };
+ _proto.draw = function draw(ctx, ignoreCache) {
+ if (ignoreCache === void 0) {
+ ignoreCache = false;
+ }
+ if (_DisplayObject.prototype.draw.call(this, ctx, ignoreCache)) {
+ return true;
+ }
+ var list = this.children.slice();
+ for (var i = 0, l = list.length; i < l; i++) {
+ var child = list[i];
+ if (!child.isVisible()) {
+ continue;
+ }
+ ctx.save();
+ child.updateContext(ctx);
+ child.draw(ctx);
+ ctx.restore();
+ }
+ return true;
+ };
+ _proto.addChild = function addChild() {
+ var l = arguments.length;
+ if (l === 0) {
+ return null;
+ }
+ var child = arguments.length <= 0 ? undefined : arguments[0];
+ if (l > 1) {
+ for (var i = 0; i < l; i++) {
+ child = this.addChild(i < 0 || arguments.length <= i ? undefined : arguments[i]);
+ }
+ return child;
+ }
+ var parent = child.parent,
+ silent = parent === this;
+ parent && parent._removeChildAt(parent.children.indexOf(child), silent);
+ child.parent = this;
+ this.children.push(child);
+ if (!silent) {
+ child.dispatchEvent("added");
+ }
+ return child;
+ };
+ _proto.addChildAt = function addChildAt() {
+ for (var _len = arguments.length, children = new Array(_len), _key = 0; _key < _len; _key++) {
+ children[_key] = arguments[_key];
+ }
+ var l = children.length;
+ if (l === 0) {
+ return null;
+ }
+ var index = children.pop();
+ if (index < 0 || index > this.children.length) {
+ return children[l - 2];
+ }
+ if (l > 2) {
+ for (var i = 0; i < l - 1; i++) {
+ this.addChildAt(children[i], index++);
+ }
+ return children[l - 2];
+ }
+ var child = children[0];
+ var parent = child.parent,
+ silent = parent === this;
+ parent && parent._removeChildAt(parent.children.indexOf(child), silent);
+ child.parent = this;
+ this.children.splice(index++, 0, child);
+ if (!silent) {
+ child.dispatchEvent("added");
+ }
+ return child;
+ };
+ _proto.removeChild = function removeChild() {
+ var l = arguments.length;
+ if (l === 0) {
+ return true;
+ }
+ if (l > 1) {
+ var good = true;
+ for (var i = 0; i < l; i++) {
+ good = good && this.removeChild(i < 0 || arguments.length <= i ? undefined : arguments[i]);
+ }
+ return good;
+ }
+ return this._removeChildAt(this.children.indexOf(arguments.length <= 0 ? undefined : arguments[0]));
+ };
+ _proto.removeChildAt = function removeChildAt() {
+ for (var _len2 = arguments.length, indexes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
+ indexes[_key2] = arguments[_key2];
+ }
+ var l = indexes.length;
+ if (l === 0) {
+ return true;
+ }
+ if (l > 1) {
+ indexes.sort(function (a, b) {
+ return b - a;
+ });
+ var good = true;
+ for (var i = 0; i < l; i++) {
+ good = good && this._removeChildAt(indexes[i]);
+ }
+ return good;
+ }
+ return this._removeChildAt(indexes[0]);
+ };
+ _proto.removeAllChildren = function removeAllChildren() {
+ var kids = this.children;
+ while (kids.length) {
+ this._removeChildAt(0);
+ }
+ };
+ _proto.getChildAt = function getChildAt(index) {
+ return this.children[index];
+ };
+ _proto.getChildByName = function getChildByName(name) {
+ var kids = this.children;
+ var l = kids.length;
+ for (var i = 0; i < l; i++) {
+ if (kids[i].name === name) {
+ return kids[i];
+ }
+ }
+ return null;
+ };
+ _proto.sortChildren = function sortChildren(sortFunction) {
+ this.children.sort(sortFunction);
+ };
+ _proto.getChildIndex = function getChildIndex(child) {
+ return this.children.indexOf(child);
+ };
+ _proto.swapChildrenAt = function swapChildrenAt(index1, index2) {
+ var kids = this.children;
+ var o1 = kids[index1];
+ var o2 = kids[index2];
+ if (!o1 || !o2) {
+ return;
+ }
+ kids[index1] = o2;
+ kids[index2] = o1;
+ };
+ _proto.swapChildren = function swapChildren(child1, child2) {
+ var kids = this.children;
+ var l = kids.length;
+ var index1, index2;
+ for (var i = 0; i < l; i++) {
+ if (kids[i] === child1) {
+ index1 = i;
+ }
+ if (kids[i] === child2) {
+ index2 = i;
+ }
+ if (index1 != null && index2 != null) {
+ break;
+ }
+ }
+ if (i === l) {
+ return;
+ }
+ kids[index1] = child2;
+ kids[index2] = child1;
+ };
+ _proto.setChildIndex = function setChildIndex(child, index) {
+ var kids = this.children;
+ var l = kids.length;
+ if (child.parent != this || index < 0 || index >= l) {
+ return;
+ }
+ for (var i = 0; i < l; i++) {
+ if (kids[i] === child) {
+ break;
+ }
+ }
+ if (i === l || i === index) {
+ return;
+ }
+ kids.splice(i, 1);
+ kids.splice(index, 0, child);
+ };
+ _proto.contains = function contains(child) {
+ while (child) {
+ if (child === this) {
+ return true;
+ }
+ child = child.parent;
+ }
+ return false;
+ };
+ _proto.hitTest = function hitTest(x, y) {
+ return this.getObjectUnderPoint(x, y) != null;
+ };
+ _proto.getObjectsUnderPoint = function getObjectsUnderPoint(x, y, mode) {
+ if (mode === void 0) {
+ mode = 0;
+ }
+ var arr = [];
+ var pt = this.localToGlobal(x, y);
+ this._getObjectsUnderPoint(pt.x, pt.y, arr, mode > 0, mode === 1);
+ return arr;
+ };
+ _proto.getObjectUnderPoint = function getObjectUnderPoint(x, y, mode) {
+ if (mode === void 0) {
+ mode = 0;
+ }
+ var pt = this.localToGlobal(x, y);
+ return this._getObjectsUnderPoint(pt.x, pt.y, null, mode > 0, mode === 1);
+ };
+ _proto.getBounds = function getBounds() {
+ return this._getBounds(null, true);
+ };
+ _proto.getTransformedBounds = function getTransformedBounds() {
+ return this._getBounds();
+ };
+ _proto.clone = function clone(recursive) {
+ if (recursive === void 0) {
+ recursive = false;
+ }
+ var o = this._cloneProps(new Container());
+ if (recursive) {
+ this._cloneChildren(o);
+ }
+ return o;
+ };
+ _proto._tick = function _tick(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);
+ }
+ }
+ }
+ _DisplayObject.prototype._tick.call(this, evtObj);
+ };
+ _proto._cloneChildren = function _cloneChildren(o) {
+ if (o.children.length) {
+ o.removeAllChildren();
+ }
+ var arr = o.children;
+ var l = this.children.length;
+ for (var i = 0; i < l; i++) {
+ var clone = this.children[i].clone(true);
+ clone.parent = o;
+ arr.push(clone);
+ }
+ };
+ _proto._removeChildAt = function _removeChildAt(index, silent) {
+ if (silent === void 0) {
+ silent = false;
+ }
+ if (index < 0 || index > this.children.length - 1) {
+ return false;
+ }
+ var child = this.children[index];
+ if (child) {
+ child.parent = null;
+ }
+ this.children.splice(index, 1);
+ if (!silent) {
+ child.dispatchEvent("removed");
+ }
+ return true;
+ };
+ _proto._getObjectsUnderPoint = function _getObjectsUnderPoint(x, y, arr, mouse, activeListener, currentDepth) {
+ if (currentDepth === void 0) {
+ currentDepth = 0;
+ }
+ if (!currentDepth && !this._testMask(this, x, y)) {
+ return null;
+ }
+ var mtx,
+ ctx = DisplayObject._hitTestContext;
+ activeListener = activeListener || mouse && this._hasMouseEventListener();
+ var children = this.children;
+ var l = children.length;
+ for (var i = l - 1; i >= 0; i--) {
+ var child = children[i];
+ var hitArea = child.hitArea;
+ if (!child.visible || !hitArea && !child.isVisible() || mouse && !child.mouseEnabled) {
+ continue;
+ }
+ if (!hitArea && !this._testMask(child, x, y)) {
+ continue;
+ }
+ if (!hitArea && child instanceof Container) {
+ var result = child._getObjectsUnderPoint(x, y, arr, mouse, activeListener, currentDepth + 1);
+ if (!arr && result) {
+ return mouse && !this.mouseChildren ? this : result;
+ }
+ } else {
+ if (mouse && !activeListener && !child._hasMouseEventListener()) {
+ continue;
+ }
+ var props = child.getConcatenatedDisplayProps(child._props);
+ mtx = props.matrix;
+ if (hitArea) {
+ mtx.appendMatrix(hitArea.getMatrix(hitArea._props.matrix));
+ props.alpha = hitArea.alpha;
+ }
+ ctx.globalAlpha = props.alpha;
+ ctx.setTransform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx - x, mtx.ty - y);
+ (hitArea || child).draw(ctx);
+ if (!this._testHit(ctx)) {
+ continue;
+ }
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
+ ctx.clearRect(0, 0, 2, 2);
+ if (arr) {
+ arr.push(child);
+ } else {
+ return mouse && !this.mouseChildren ? this : child;
+ }
+ }
+ }
+ return null;
+ };
+ _proto._testMask = function _testMask(target, x, y) {
+ var mask = target.mask;
+ if (!mask || !mask.graphics || mask.graphics.isEmpty()) {
+ return true;
+ }
+ var mtx = this._props.matrix,
+ parent = target.parent;
+ mtx = parent ? parent.getConcatenatedMatrix(mtx) : mtx.identity();
+ mtx = mask.getMatrix(mask._props.matrix).prependMatrix(mtx);
+ var ctx = DisplayObject._hitTestContext;
+ ctx.setTransform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx - x, mtx.ty - y);
+ mask.graphics.drawAsPath(ctx);
+ ctx.fillStyle = "#000";
+ ctx.fill();
+ if (!this._testHit(ctx)) {
+ return false;
+ }
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
+ ctx.clearRect(0, 0, 2, 2);
+ return true;
+ };
+ _proto._getBounds = function _getBounds(matrix, ignoreTransform) {
+ var bounds = _DisplayObject.prototype.getBounds.call(this);
+ if (bounds) {
+ return this._transformBounds(bounds, matrix, ignoreTransform);
+ }
+ var mtx = this._props.matrix;
+ mtx = ignoreTransform ? mtx.identity() : this.getMatrix(mtx);
+ if (matrix) {
+ mtx.prependMatrix(matrix);
+ }
+ var l = this.children.length;
+ var rect = null;
+ for (var i = 0; i < l; i++) {
+ var child = this.children[i];
+ if (!child.visible || !(bounds = child._getBounds(mtx))) {
+ continue;
+ }
+ if (rect) {
+ rect.extend(bounds.x, bounds.y, bounds.width, bounds.height);
+ } else {
+ rect = bounds.clone();
+ }
+ }
+ return rect;
+ };
+ _createClass(Container, [{
+ key: "numChildren",
+ get: function get() {
+ return this.children.length;
+ }
+ }]);
+ return Container;
+}(DisplayObject);
+
+var MouseEvent =
+function (_Event) {
+ _inheritsLoose(MouseEvent, _Event);
+ function MouseEvent(type, bubbles, cancelable, stageX, stageY, nativeEvent, pointerID, primary, rawX, rawY, relatedTarget) {
+ var _this;
+ _this = _Event.call(this, type, bubbles, cancelable) || this;
+ _this.stageX = stageX;
+ _this.stageY = stageY;
+ _this.rawX = rawX == null ? stageX : rawX;
+ _this.rawY = rawY == null ? stageY : rawY;
+ _this.nativeEvent = nativeEvent;
+ _this.pointerID = pointerID;
+ _this.primary = !!primary;
+ _this.relatedTarget = relatedTarget;
+ return _this;
+ }
+ var _proto = MouseEvent.prototype;
+ _proto.clone = function clone() {
+ return new MouseEvent(this.type, this.bubbles, this.cancelable, this.stageX, this.stageY, this.nativeEvent, this.pointerID, this.primary, this.rawX, this.rawY);
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + " (type=" + this.type + " stageX=" + this.stageX + " stageY=" + this.stageY + ")]";
+ };
+ _createClass(MouseEvent, [{
+ key: "localX",
+ get: function get() {
+ return this.currentTarget.globalToLocal(this.rawX, this.rawY).x;
+ }
+ }, {
+ key: "localY",
+ get: function get() {
+ return this.currentTarget.globalToLocal(this.rawX, this.rawY).y;
+ }
+ }, {
+ key: "isTouch",
+ get: function get() {
+ return this.pointerID !== -1;
+ }
+ }]);
+ return MouseEvent;
+}(Event);
+
+var Stage =
+function (_Container) {
+ _inheritsLoose(Stage, _Container);
+ function Stage(canvas) {
+ var _this;
+ _this = _Container.call(this) || this;
+ _this.autoClear = true;
+ _this.canvas = typeof canvas === "string" ? document.getElementById(canvas) : canvas;
+ _this.mouseX = 0;
+ _this.mouseY = 0;
+ _this.drawRect = null;
+ _this.snapToPixelEnabled = false;
+ _this.mouseInBounds = false;
+ _this.tickOnUpdate = true;
+ _this.mouseMoveOutside = false;
+ _this.preventSelection = true;
+ _this._pointerData = {};
+ _this._pointerCount = 0;
+ _this._primaryPointerID = null;
+ _this._mouseOverIntervalID = null;
+ _this._nextStage = null;
+ _this._prevStage = null;
+ _this.enableDOMEvents(true);
+ return _this;
+ }
+ var _proto = Stage.prototype;
+ _proto.update = function update(props) {
+ if (!this.canvas) {
+ return;
+ }
+ if (this.tickOnUpdate) {
+ this.tick(props);
+ }
+ if (this.dispatchEvent("drawstart", false, true) === false) {
+ return;
+ }
+ DisplayObject._snapToPixelEnabled = this.snapToPixelEnabled;
+ var r = this.drawRect,
+ ctx = this.canvas.getContext("2d");
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
+ if (this.autoClear) {
+ if (r) {
+ ctx.clearRect(r.x, r.y, r.width, r.height);
+ } else {
+ ctx.clearRect(0, 0, this.canvas.width + 1, this.canvas.height + 1);
+ }
+ }
+ ctx.save();
+ if (this.drawRect) {
+ ctx.beginPath();
+ ctx.rect(r.x, r.y, r.width, r.height);
+ ctx.clip();
+ }
+ this.updateContext(ctx);
+ this.draw(ctx, false);
+ ctx.restore();
+ this.dispatchEvent("drawend");
+ };
+ _proto.tick = function tick(props) {
+ if (!this.tickEnabled || this.dispatchEvent("tickstart", false, true) === false) {
+ return;
+ }
+ var evtObj = new Event("tick");
+ if (props) {
+ for (var n in props) {
+ if (props.hasOwnProperty(n)) {
+ evtObj[n] = props[n];
+ }
+ }
+ }
+ this._tick(evtObj);
+ this.dispatchEvent("tickend");
+ };
+ _proto.handleEvent = function handleEvent(evt) {
+ if (evt.type === "tick") {
+ this.update(evt);
+ }
+ };
+ _proto.clear = function clear() {
+ 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);
+ };
+ _proto.toDataURL = function toDataURL(backgroundColor, mimeType) {
+ if (mimeType === void 0) {
+ mimeType = "image/png";
+ }
+ 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);
+ if (backgroundColor) {
+ ctx.putImageData(data, 0, 0);
+ ctx.globalCompositeOperation = compositeOperation;
+ }
+ return dataURL;
+ };
+ _proto.enableMouseOver = function enableMouseOver(frequency) {
+ var _this2 = this;
+ if (frequency === void 0) {
+ frequency = 20;
+ }
+ if (this._mouseOverIntervalID) {
+ clearInterval(this._mouseOverIntervalID);
+ this._mouseOverIntervalID = null;
+ if (frequency === 0) {
+ this._testMouseOver(true);
+ }
+ }
+ if (frequency <= 0) {
+ return;
+ }
+ this._mouseOverIntervalID = setInterval(function () {
+ return _this2._testMouseOver();
+ }, 1000 / Math.min(50, frequency));
+ };
+ _proto.enableDOMEvents = function enableDOMEvents(enable) {
+ var _this3 = this;
+ if (enable === void 0) {
+ enable = true;
+ }
+ var ls = this._eventListeners;
+ if (!enable && ls) {
+ for (var n in ls) {
+ var o = ls[n];
+ o.t.removeEventListener(n, o.f, false);
+ }
+ this._eventListeners = null;
+ } else if (enable && !ls && this.canvas) {
+ var t = window.addEventListener ? window : document;
+ ls = this._eventListeners = {
+ mouseup: {
+ t: t,
+ f: function f(e) {
+ return _this3._handleMouseUp(e);
+ }
+ },
+ mousemove: {
+ t: t,
+ f: function f(e) {
+ return _this3._handleMouseMove(e);
+ }
+ },
+ dblclick: {
+ t: this.canvas,
+ f: function f(e) {
+ return _this3._handleDoubleClick(e);
+ }
+ },
+ mousedown: {
+ t: this.canvas,
+ f: function f(e) {
+ return _this3._handleMouseDown(e);
+ }
+ }
+ };
+ for (var _n in ls) {
+ var _o = ls[_n];
+ _o.t.addEventListener && _o.t.addEventListener(_n, _o.f, false);
+ }
+ }
+ };
+ _proto.clone = function clone() {
+ throw "Stage cannot be cloned.";
+ };
+ _proto._getElementRect = function _getElementRect(e) {
+ var bounds;
+ try {
+ bounds = e.getBoundingClientRect();
+ }
+ catch (err) {
+ bounds = {
+ top: e.offsetTop,
+ left: e.offsetLeft,
+ width: e.offsetWidth,
+ height: e.offsetHeight
+ };
+ }
+ var offX = (window.pageXOffset || document.scrollLeft || 0) - (document.clientLeft || document.body.clientLeft || 0);
+ var offY = (window.pageYOffset || document.scrollTop || 0) - (document.clientTop || document.body.clientTop || 0);
+ var styles = window.getComputedStyle ? getComputedStyle(e, null) : e.currentStyle;
+ var padL = parseInt(styles.paddingLeft) + parseInt(styles.borderLeftWidth);
+ var padT = parseInt(styles.paddingTop) + parseInt(styles.borderTopWidth);
+ var padR = parseInt(styles.paddingRight) + parseInt(styles.borderRightWidth);
+ var padB = parseInt(styles.paddingBottom) + parseInt(styles.borderBottomWidth);
+ return {
+ left: bounds.left + offX + padL,
+ right: bounds.right + offX - padR,
+ top: bounds.top + offY + padT,
+ bottom: bounds.bottom + offY - padB
+ };
+ };
+ _proto._getPointerData = function _getPointerData(id) {
+ var data = this._pointerData[id];
+ if (!data) {
+ data = this._pointerData[id] = {
+ x: 0,
+ y: 0
+ };
+ }
+ return data;
+ };
+ _proto._handleMouseMove = function _handleMouseMove(e) {
+ if (e === void 0) {
+ e = window.event;
+ }
+ this._handlePointerMove(-1, e, e.pageX, e.pageY);
+ };
+ _proto._handlePointerMove = function _handlePointerMove(id, e, pageX, pageY, owner) {
+ if (this._prevStage && owner === undefined) {
+ return;
+ }
+ if (!this.canvas) {
+ return;
+ }
+ var nextStage = this._nextStage,
+ o = this._getPointerData(id);
+ var inBounds = o.inBounds;
+ this._updatePointerPosition(id, e, pageX, pageY);
+ if (inBounds || o.inBounds || this.mouseMoveOutside) {
+ if (id === -1 && o.inBounds === !inBounds) {
+ this._dispatchMouseEvent(this, inBounds ? "mouseleave" : "mouseenter", false, id, o, e);
+ }
+ this._dispatchMouseEvent(this, "stagemousemove", false, id, o, e);
+ this._dispatchMouseEvent(o.target, "pressmove", true, id, o, e);
+ }
+ nextStage && nextStage._handlePointerMove(id, e, pageX, pageY, null);
+ };
+ _proto._updatePointerPosition = function _updatePointerPosition(id, e, pageX, pageY) {
+ var rect = this._getElementRect(this.canvas);
+ pageX -= rect.left;
+ pageY -= rect.top;
+ var w = this.canvas.width;
+ var h = this.canvas.height;
+ pageX /= (rect.right - rect.left) / w;
+ pageY /= (rect.bottom - rect.top) / h;
+ var o = this._getPointerData(id);
+ if (o.inBounds = pageX >= 0 && pageY >= 0 && pageX <= w - 1 && pageY <= h - 1) {
+ o.x = pageX;
+ o.y = pageY;
+ } else if (this.mouseMoveOutside) {
+ o.x = pageX < 0 ? 0 : pageX > w - 1 ? w - 1 : pageX;
+ o.y = pageY < 0 ? 0 : pageY > h - 1 ? h - 1 : pageY;
+ }
+ o.posEvtObj = e;
+ o.rawX = pageX;
+ o.rawY = pageY;
+ if (id === this._primaryPointerID || id === -1) {
+ this.mouseX = o.x;
+ this.mouseY = o.y;
+ this.mouseInBounds = o.inBounds;
+ }
+ };
+ _proto._handleMouseUp = function _handleMouseUp(e) {
+ this._handlePointerUp(-1, e, false);
+ };
+ _proto._handlePointerUp = function _handlePointerUp(id, e, clear, owner) {
+ var nextStage = this._nextStage,
+ o = this._getPointerData(id);
+ if (this._prevStage && owner === undefined) {
+ return;
+ }
+ var target = null,
+ oTarget = o.target;
+ if (!owner && (oTarget || nextStage)) {
+ target = this._getObjectsUnderPoint(o.x, o.y, null, true);
+ }
+ if (o.down) {
+ this._dispatchMouseEvent(this, "stagemouseup", false, id, o, e, target);
+ o.down = false;
+ }
+ if (target === oTarget) {
+ this._dispatchMouseEvent(oTarget, "click", true, id, o, e);
+ }
+ this._dispatchMouseEvent(oTarget, "pressup", true, id, o, e);
+ if (clear) {
+ if (id == this._primaryPointerID) {
+ this._primaryPointerID = null;
+ }
+ delete this._pointerData[id];
+ } else {
+ o.target = null;
+ }
+ nextStage && nextStage._handlePointerUp(id, e, clear, owner || target && this);
+ };
+ _proto._handleMouseDown = function _handleMouseDown(e) {
+ this._handlePointerDown(-1, e, e.pageX, e.pageY);
+ };
+ _proto._handlePointerDown = function _handlePointerDown(id, e, pageX, pageY, owner) {
+ if (this.preventSelection) {
+ e.preventDefault();
+ }
+ if (this._primaryPointerID == null || id === -1) {
+ this._primaryPointerID = id;
+ }
+ if (pageY != null) {
+ this._updatePointerPosition(id, e, pageX, pageY);
+ }
+ var target = null,
+ nextStage = this._nextStage,
+ o = this._getPointerData(id);
+ if (!owner) {
+ target = o.target = this._getObjectsUnderPoint(o.x, o.y, null, true);
+ }
+ if (o.inBounds) {
+ this._dispatchMouseEvent(this, "stagemousedown", false, id, o, e, target);
+ o.down = true;
+ }
+ this._dispatchMouseEvent(target, "mousedown", true, id, o, e);
+ nextStage && nextStage._handlePointerDown(id, e, pageX, pageY, owner || target && this);
+ };
+ _proto._testMouseOver = function _testMouseOver(clear, owner, eventTarget) {
+ if (this._prevStage && owner === undefined) {
+ return;
+ }
+ var nextStage = this._nextStage;
+ if (!this._mouseOverIntervalID) {
+ nextStage && nextStage._testMouseOver(clear, owner, eventTarget);
+ return;
+ }
+ var o = this._getPointerData(-1);
+ if (!o || !clear && this.mouseX === this._mouseOverX && this.mouseY === this._mouseOverY && this.mouseInBounds) {
+ return;
+ }
+ var e = o.posEvtObj;
+ var isEventTarget = eventTarget || e && e.target === this.canvas;
+ var target = null,
+ common = -1,
+ cursor = "";
+ if (!owner && (clear || this.mouseInBounds && isEventTarget)) {
+ target = this._getObjectsUnderPoint(this.mouseX, this.mouseY, null, true);
+ this._mouseOverX = this.mouseX;
+ this._mouseOverY = this.mouseY;
+ }
+ var oldList = this._mouseOverTarget || [];
+ var oldTarget = oldList[oldList.length - 1];
+ var list = this._mouseOverTarget = [];
+ var t = target;
+ while (t) {
+ list.unshift(t);
+ if (!cursor) {
+ cursor = t.cursor;
+ }
+ t = t.parent;
+ }
+ this.canvas.style.cursor = cursor;
+ if (!owner && eventTarget) {
+ eventTarget.canvas.style.cursor = cursor;
+ }
+ for (var i = 0, l = list.length; i < l; i++) {
+ if (list[i] != oldList[i]) {
+ break;
+ }
+ common = i;
+ }
+ if (oldTarget != target) {
+ this._dispatchMouseEvent(oldTarget, "mouseout", true, -1, o, e, target);
+ }
+ for (var _i = oldList.length - 1; _i > common; _i--) {
+ this._dispatchMouseEvent(oldList[_i], "rollout", false, -1, o, e, target);
+ }
+ for (var _i2 = list.length - 1; _i2 > common; _i2--) {
+ this._dispatchMouseEvent(list[_i2], "rollover", false, -1, o, e, oldTarget);
+ }
+ if (oldTarget != target) {
+ this._dispatchMouseEvent(target, "mouseover", true, -1, o, e, oldTarget);
+ }
+ nextStage && nextStage._testMouseOver(clear, owner || target && this, eventTarget || isEventTarget && this);
+ };
+ _proto._handleDoubleClick = function _handleDoubleClick(e, owner) {
+ var target = null,
+ nextStage = this._nextStage,
+ o = this._getPointerData(-1);
+ if (!owner) {
+ target = this._getObjectsUnderPoint(o.x, o.y, null, true);
+ this._dispatchMouseEvent(target, "dblclick", true, -1, o, e);
+ }
+ nextStage && nextStage._handleDoubleClick(e, owner || target && this);
+ };
+ _proto._dispatchMouseEvent = function _dispatchMouseEvent(target, type, bubbles, pointerId, o, nativeEvent, relatedTarget) {
+ if (!target || !bubbles && !target.hasEventListener(type)) {
+ return;
+ }
+ var evt = new MouseEvent(type, bubbles, false, o.x, o.y, nativeEvent, pointerId, pointerId === this._primaryPointerID || pointerId === -1, o.rawX, o.rawY, relatedTarget);
+ target.dispatchEvent(evt);
+ };
+ _createClass(Stage, [{
+ key: "nextStage",
+ get: function get() {
+ return this._nextStage;
+ },
+ set: function set(stage) {
+ if (this._nextStage) {
+ this._nextStage._prevStage = null;
+ }
+ if (stage) {
+ stage._prevStage = this;
+ }
+ this._nextStage = stage;
+ }
+ }]);
+ return Stage;
+}(Container);
+
+function createCanvas(width, height) {
+ if (width === void 0) {
+ width = 1;
+ }
+ if (height === void 0) {
+ height = 1;
+ }
+ var c;
+ if (window.createjs !== undefined && window.createjs.createCanvas !== undefined) {
+ c = window.createjs.createCanvas();
+ }
+ if (window.document !== undefined && window.document.createElement !== undefined) {
+ c = document.createElement("canvas");
+ }
+ if (c !== undefined) {
+ c.width = width;
+ c.height = height;
+ return c;
+ }
+ throw "Canvas not supported in this environment.";
+}
+
+var VideoBuffer =
+function () {
+ function VideoBuffer(video) {
+ this.readyState = video.readyState;
+ this._video = video;
+ this._canvas = null;
+ this._lastTime = -1;
+ if (this.readyState < 2) {
+ video.addEventListener("canplaythrough", this._videoReady.bind(this));
+ }
+ }
+ var _proto = VideoBuffer.prototype;
+ _proto.getImage = function getImage() {
+ if (this.readyState < 2) {
+ return;
+ }
+ var canvas = this._canvas,
+ video = this._video;
+ if (!canvas) {
+ canvas = this._canvas = createCanvas();
+ canvas.width = video.videoWidth;
+ canvas.height = video.videoHeight;
+ }
+ if (video.readyState >= 2 && video.currentTime !== this._lastTime) {
+ var ctx = canvas.getContext("2d");
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+ ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
+ this._lastTime = video.currentTime;
+ }
+ return canvas;
+ };
+ _proto._videoReady = function _videoReady() {
+ this.readyState = 2;
+ };
+ return VideoBuffer;
+}();
+
+var Bitmap =
+function (_DisplayObject) {
+ _inheritsLoose(Bitmap, _DisplayObject);
+ function Bitmap(imageOrUri) {
+ var _this;
+ _this = _DisplayObject.call(this) || this;
+ if (typeof imageOrUri === "string") {
+ _this.image = document.createElement("img");
+ _this.image.src = imageOrUri;
+ } else {
+ _this.image = imageOrUri;
+ }
+ _this.sourceRect = null;
+ _this._webGLRenderStyle = DisplayObject._StageGL_BITMAP;
+ return _this;
+ }
+ var _proto = Bitmap.prototype;
+ _proto.isVisible = function isVisible() {
+ var image = this.image;
+ var hasContent = this.cacheCanvas || image && (image.naturalWidth || image.getContext || image.readyState >= 2);
+ return !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && hasContent);
+ };
+ _proto.draw = function draw(ctx, ignoreCache) {
+ if (ignoreCache === void 0) {
+ ignoreCache = false;
+ }
+ if (_DisplayObject.prototype.draw.call(this, ctx, ignoreCache)) {
+ return true;
+ }
+ var img = this.image,
+ rect = this.sourceRect;
+ if (img instanceof VideoBuffer) {
+ img = img.getImage();
+ }
+ if (img == null) {
+ return true;
+ }
+ if (rect) {
+ var x1 = rect.x,
+ y1 = rect.y,
+ x2 = x1 + rect.width,
+ y2 = y1 + rect.height,
+ x = 0,
+ y = 0,
+ w = img.width,
+ h = img.height;
+ if (x1 < 0) {
+ x -= x1;
+ x1 = 0;
+ }
+ if (x2 > w) {
+ x2 = w;
+ }
+ if (y1 < 0) {
+ y -= y1;
+ y1 = 0;
+ }
+ if (y2 > h) {
+ y2 = h;
+ }
+ ctx.drawImage(img, x1, y1, x2 - x1, y2 - y1, x, y, x2 - x1, y2 - y1);
+ } else {
+ ctx.drawImage(img, 0, 0);
+ }
+ return true;
+ };
+ _proto.getBounds = function getBounds() {
+ var rect = _DisplayObject.prototype.getBounds.call(this);
+ if (rect) {
+ return rect;
+ }
+ var image = this.image,
+ o = this.sourceRect || image;
+ var hasContent = image && (image.naturalWidth || image.getContext || image.readyState >= 2);
+ return hasContent ? this._rectangle.setValues(0, 0, o.width, o.height) : null;
+ };
+ _proto.clone = function clone(node) {
+ var img = this.image;
+ if (img != null && node != null) {
+ img = img.cloneNode();
+ }
+ var bmp = new Bitmap(img);
+ if (this.sourceRect) {
+ bmp.sourceRect = this.sourceRect.clone();
+ }
+ this._cloneProps(bmp);
+ return bmp;
+ };
+ return Bitmap;
+}(DisplayObject);
+
+var Sprite =
+function (_DisplayObject) {
+ _inheritsLoose(Sprite, _DisplayObject);
+ function Sprite(spriteSheet, frameOrAnimation) {
+ var _this;
+ _this = _DisplayObject.call(this) || this;
+ _this.currentFrame = 0;
+ _this.currentAnimation = null;
+ _this.paused = true;
+ _this.spriteSheet = spriteSheet;
+ _this.currentAnimationFrame = 0;
+ _this.framerate = 0;
+ _this._animation = null;
+ _this._currentFrame = null;
+ _this._skipAdvance = false;
+ _this._webGLRenderStyle = DisplayObject._StageGL_SPRITE;
+ if (frameOrAnimation != null) {
+ _this.gotoAndPlay(frameOrAnimation);
+ }
+ return _this;
+ }
+ var _proto = Sprite.prototype;
+ _proto.isVisible = function isVisible() {
+ var hasContent = this.cacheCanvas || this.spriteSheet.complete;
+ return !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && hasContent);
+ };
+ _proto.draw = function draw(ctx, ignoreCache) {
+ if (_DisplayObject.prototype.draw.call(this, 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;
+ };
+ _proto.play = function play() {
+ this.paused = false;
+ };
+ _proto.stop = function stop() {
+ this.paused = true;
+ };
+ _proto.gotoAndPlay = function gotoAndPlay(frameOrAnimation) {
+ this.paused = false;
+ this._skipAdvance = true;
+ this._goto(frameOrAnimation);
+ };
+ _proto.gotoAndStop = function gotoAndStop(frameOrAnimation) {
+ this.paused = true;
+ this._goto(frameOrAnimation);
+ };
+ _proto.advance = function advance(time) {
+ var fps = this.framerate || this.spriteSheet.framerate;
+ var t = fps && time != null ? time / (1000 / fps) : 1;
+ this._normalizeFrame(t);
+ };
+ _proto.getBounds = function getBounds() {
+ return _DisplayObject.prototype.getBounds.call(this) || this.spriteSheet.getFrameBounds(this.currentFrame, this._rectangle);
+ };
+ _proto.clone = function clone() {
+ return this._cloneProps(new Sprite(this.spriteSheet));
+ };
+ _proto._cloneProps = function _cloneProps(o) {
+ _DisplayObject.prototype._cloneProps.call(this, 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;
+ };
+ _proto._tick = function _tick(evtObj) {
+ if (!this.paused) {
+ if (!this._skipAdvance) {
+ this.advance(evtObj && evtObj.delta);
+ }
+ this._skipAdvance = false;
+ }
+ _DisplayObject.prototype._tick.call(this, evtObj);
+ };
+ _proto._normalizeFrame = function _normalizeFrame(frameDelta) {
+ if (frameDelta === void 0) {
+ frameDelta = 0;
+ }
+ var animation = this._animation;
+ var paused = this.paused;
+ var frame = this._currentFrame;
+ if (animation) {
+ var speed = animation.speed || 1;
+ var animFrame = this.currentAnimationFrame;
+ var l = animation.frames.length;
+ if (animFrame + frameDelta * speed >= l) {
+ var next = animation.next;
+ if (this._dispatchAnimationEnd(animation, frame, paused, next, l - 1)) {
+ return;
+ } else if (next) {
+ return this._goto(next, frameDelta - (l - animFrame) / speed);
+ } else {
+ 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;
+ var _l = this.spriteSheet.getNumFrames();
+ if (frame >= _l && _l > 0) {
+ if (!this._dispatchAnimationEnd(animation, frame, paused, _l - 1)) {
+ if ((this._currentFrame -= _l) >= _l) {
+ return this._normalizeFrame();
+ }
+ }
+ }
+ }
+ frame = this._currentFrame | 0;
+ if (this.currentFrame != frame) {
+ this.currentFrame = frame;
+ this.dispatchEvent("change");
+ }
+ };
+ _proto._dispatchAnimationEnd = function _dispatchAnimationEnd(animation, frame, paused, next, end) {
+ var name = animation ? animation.name : null;
+ if (this.hasEventListener("animationend")) {
+ var evt = new Event("animationend");
+ evt.name = name;
+ evt.next = next;
+ this.dispatchEvent(evt);
+ }
+ var changed = this._animation != animation || this._currentFrame != frame;
+ if (!changed && !paused && this.paused) {
+ this.currentAnimationFrame = end;
+ changed = true;
+ }
+ return changed;
+ };
+ _proto._goto = function _goto(frameOrAnimation, frame) {
+ if (frame === void 0) {
+ frame = 0;
+ }
+ 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();
+ }
+ };
+ return Sprite;
+}(DisplayObject);
+
+var BitmapText =
+function (_Container) {
+ _inheritsLoose(BitmapText, _Container);
+ function BitmapText(text, spriteSheet) {
+ var _this;
+ if (text === void 0) {
+ text = "";
+ }
+ if (spriteSheet === void 0) {
+ spriteSheet = null;
+ }
+ _this = _Container.call(this) || this;
+ _this.text = text;
+ _this.spriteSheet = spriteSheet;
+ _this.lineHeight = 0;
+ _this.letterSpacing = 0;
+ _this.spaceWidth = 0;
+ _this._oldProps = {
+ text: 0,
+ spriteSheet: 0,
+ lineHeight: 0,
+ letterSpacing: 0,
+ spaceWidth: 0
+ };
+ _this._oldStage = null;
+ _this._drawAction = null;
+ return _this;
+ }
+ var _proto = BitmapText.prototype;
+ _proto.draw = function draw(ctx, ignoreCache) {
+ if (this.drawCache(ctx, ignoreCache)) {
+ return;
+ }
+ this._updateState();
+ _Container.prototype.draw.call(this, ctx, ignoreCache);
+ };
+ _proto.getBounds = function getBounds() {
+ this._updateText();
+ return _Container.prototype.getBounds.call(this);
+ };
+ _proto.isVisible = function isVisible() {
+ var hasContent = this.cacheCanvas || this.spriteSheet && this.spriteSheet.complete && this.text;
+ return !!(this.visible && this.alpha > 0 && this.scaleX !== 0 && this.scaleY !== 0 && hasContent);
+ };
+ _proto.clone = function clone() {
+ return this._cloneProps(new BitmapText(this.text, this.spriteSheet));
+ };
+ _proto.addChild = function addChild() {};
+ _proto.addChildAt = function addChildAt() {};
+ _proto.removeChild = function removeChild() {};
+ _proto.removeChildAt = function removeChildAt() {};
+ _proto.removeAllChildren = function removeAllChildren() {};
+ _proto._updateState = function _updateState() {
+ this._updateText();
+ };
+ _proto._cloneProps = function _cloneProps(o) {
+ _Container.prototype._cloneProps.call(this, o);
+ o.lineHeight = this.lineHeight;
+ o.letterSpacing = this.letterSpacing;
+ o.spaceWidth = this.spaceWidth;
+ return o;
+ };
+ _proto._getFrameIndex = function _getFrameIndex(character, spriteSheet) {
+ var c,
+ o = spriteSheet.getAnimation(character);
+ if (!o) {
+ character != (c = character.toUpperCase()) || character != (c = character.toLowerCase()) || (c = null);
+ if (c) {
+ o = spriteSheet.getAnimation(c);
+ }
+ }
+ return o && o.frames[0];
+ };
+ _proto._getFrame = function _getFrame(character, spriteSheet) {
+ var index = this._getFrameIndex(character, spriteSheet);
+ return index == null ? index : spriteSheet.getFrame(index);
+ };
+ _proto._getLineHeight = function _getLineHeight(ss) {
+ var frame = this._getFrame("1", ss) || this._getFrame("T", ss) || this._getFrame("L", ss) || ss.getFrame(0);
+ return frame ? frame.rect.height : 1;
+ };
+ _proto._getSpaceWidth = function _getSpaceWidth(ss) {
+ var frame = this._getFrame("1", ss) || this._getFrame("l", ss) || this._getFrame("e", ss) || this._getFrame("a", ss) || ss.getFrame(0);
+ return frame ? frame.rect.width : 1;
+ };
+ _proto._tick = function _tick(evtObj) {
+ var stage = this.stage;
+ stage && stage.on("drawstart", this._updateText, this, true);
+ _Container.prototype._tick.call(this, evtObj);
+ };
+ _proto._updateText = function _updateText() {
+ var x = 0,
+ y = 0,
+ o = this._oldProps,
+ change = false,
+ spaceW = this.spaceWidth,
+ lineH = this.lineHeight,
+ ss = this.spriteSheet;
+ var pool = BitmapText._spritePool,
+ kids = this.children,
+ childIndex = 0,
+ numKids = kids.length,
+ sprite;
+ for (var n in o) {
+ if (o[n] != this[n]) {
+ o[n] = this[n];
+ change = true;
+ }
+ }
+ if (!change) {
+ return;
+ }
+ var hasSpace = !!this._getFrame(" ", ss);
+ if (!hasSpace && !spaceW) {
+ spaceW = this._getSpaceWidth(ss);
+ }
+ if (!lineH) {
+ lineH = this._getLineHeight(ss);
+ }
+ for (var i = 0, l = this.text.length; i < l; i++) {
+ var character = this.text.charAt(i);
+ if (character === " " && !hasSpace) {
+ x += spaceW;
+ continue;
+ } else if (character === "\n" || character === "\r") {
+ if (character === "\r" && this.text.charAt(i + 1) === "\n") {
+ i++;
+ }
+ x = 0;
+ y += lineH;
+ continue;
+ }
+ var index = this._getFrameIndex(character, ss);
+ if (index == null) {
+ continue;
+ }
+ if (childIndex < numKids) {
+ sprite = kids[childIndex];
+ } else {
+ kids.push(sprite = pool.length ? pool.pop() : new Sprite());
+ sprite.parent = this;
+ numKids++;
+ }
+ sprite.spriteSheet = ss;
+ sprite.gotoAndStop(index);
+ sprite.x = x;
+ sprite.y = y;
+ childIndex++;
+ x += sprite.getBounds().width + this.letterSpacing;
+ }
+ while (numKids > childIndex) {
+ pool.push(sprite = kids.pop());
+ sprite.parent = null;
+ numKids--;
+ }
+ if (pool.length > BitmapText.maxPoolSize) {
+ pool.length = BitmapText.maxPoolSize;
+ }
+ };
+ return BitmapText;
+}(Container);
+BitmapText.maxPoolSize = 100;
+BitmapText._spritePool = [];
+
+var DOMElement =
+function (_DisplayObject) {
+ _inheritsLoose(DOMElement, _DisplayObject);
+ function DOMElement(htmlElement) {
+ var _this;
+ _this = _DisplayObject.call(this) || this;
+ if (typeof htmlElement === "string") {
+ htmlElement = document.getElementById(htmlElement);
+ }
+ _this.mouseEnabled = false;
+ var style = htmlElement.style;
+ style.position = "absolute";
+ style.transformOrigin = style.WebkitTransformOrigin = style.msTransformOrigin = style.MozTransformOrigin = style.OTransformOrigin = "0% 0%";
+ _this.htmlElement = htmlElement;
+ _this._oldProps = null;
+ _this._oldStage = null;
+ _this._drawAction = null;
+ return _this;
+ }
+ var _proto = DOMElement.prototype;
+ _proto.isVisible = function isVisible() {
+ return this.htmlElement != null;
+ };
+ _proto.draw = function draw(ctx, ignoreCache) {
+ return true;
+ };
+ _proto.cache = function cache() {};
+ _proto.uncache = function uncache() {};
+ _proto.updateCache = function updateCache() {};
+ _proto.hitTest = function hitTest() {};
+ _proto.localToGlobal = function localToGlobal() {};
+ _proto.globalToLocal = function globalToLocal() {};
+ _proto.localToLocal = function localToLocal() {};
+ _proto.clone = function clone() {
+ throw "DOMElement cannot be cloned.";
+ };
+ _proto._tick = function _tick(evtObj) {
+ var stage = this.stage;
+ if (stage != null && stage !== this._oldStage) {
+ this._drawAction && stage.off("drawend", this._drawAction);
+ this._drawAction = stage.on("drawend", this._handleDrawEnd, this);
+ this._oldStage = stage;
+ }
+ _DisplayObject.prototype._tick.call(this, evtObj);
+ };
+ _proto._handleDrawEnd = function _handleDrawEnd(evt) {
+ var o = this.htmlElement;
+ if (!o) {
+ return;
+ }
+ var style = o.style;
+ var props = this.getConcatenatedDisplayProps(this._props),
+ mtx = props.matrix;
+ var visibility = props.visible ? "visible" : "hidden";
+ if (visibility != style.visibility) {
+ style.visibility = visibility;
+ }
+ if (!props.visible) {
+ return;
+ }
+ var oldProps = this._oldProps,
+ oldMtx = oldProps && oldProps.matrix;
+ var n = 10000;
+ if (!oldMtx || !oldMtx.equals(mtx)) {
+ var str = "matrix(" + (mtx.a * n | 0) / n + "," + (mtx.b * n | 0) / n + "," + (mtx.c * n | 0) / n + "," + (mtx.d * n | 0) / n + "," + (mtx.tx + 0.5 | 0);
+ style.transform = style.WebkitTransform = style.OTransform = style.msTransform = str + "," + (mtx.ty + 0.5 | 0) + ")";
+ style.MozTransform = str + "px," + (mtx.ty + 0.5 | 0) + "px)";
+ if (!oldProps) {
+ oldProps = this._oldProps = new DisplayProps(true, null);
+ }
+ oldProps.matrix.copy(mtx);
+ }
+ if (oldProps.alpha != props.alpha) {
+ style.opacity = "" + (props.alpha * n | 0) / n;
+ oldProps.alpha = props.alpha;
+ }
+ };
+ return DOMElement;
+}(DisplayObject);
+
+var Graphics =
+function () {
+ function Graphics() {
+ this.command = null;
+ this._stroke = null;
+ this._strokeStyle = null;
+ this._oldStrokeStyle = null;
+ this._strokeDash = null;
+ this._oldStrokeDash = null;
+ this._fill = null;
+ this._strokeIgnoreScale = false;
+ this._commitIndex = 0;
+ this._instructions = [];
+ this._activeInstructions = [];
+ this._dirty = false;
+ this._storeIndex = 0;
+ this.curveTo = this.quadraticCurveTo;
+ this.drawRect = this.rect;
+ this.mt = this.moveTo;
+ this.lt = this.lineTo;
+ this.at = this.arcTo;
+ this.bt = this.bezierCurveTo;
+ this.qt = this.quadraticCurveTo;
+ this.a = this.arc;
+ this.r = this.rect;
+ this.cp = this.closePath;
+ this.c = this.clear;
+ this.f = this.beginFill;
+ this.lf = this.beginLinearGradientFill;
+ this.rf = this.beginRadialGradientFill;
+ this.bf = this.beginBitmapFill;
+ this.ef = this.endFill;
+ this.ss = this.setStrokeStyle;
+ this.sd = this.setStrokeDash;
+ this.s = this.beginStroke;
+ this.ls = this.beginLinearGradientStroke;
+ this.rs = this.beginRadialGradientStroke;
+ this.bs = this.beginBitmapStroke;
+ this.es = this.endStroke;
+ this.dr = this.drawRect;
+ this.rr = this.drawRoundRect;
+ this.rc = this.drawRoundRectComplex;
+ this.dc = this.drawCircle;
+ this.de = this.drawEllipse;
+ this.dp = this.drawPolyStar;
+ this.p = this.decodePath;
+ this.clear();
+ }
+ Graphics.getRGB = function getRGB(r, g, b, alpha) {
+ if (r != null && b == null) {
+ alpha = g;
+ b = r & 0xFF;
+ g = r >> 8 & 0xFF;
+ r = r >> 16 & 0xFF;
+ }
+ if (alpha == null) {
+ return "rgb(" + r + "," + g + "," + b + ")";
+ } else {
+ return "rgba(" + r + "," + g + "," + b + "," + alpha + ")";
+ }
+ };
+ Graphics.getHSL = function getHSL(hue, saturation, lightness, alpha) {
+ if (alpha == null) {
+ return "hsl(" + hue % 360 + "," + saturation + "%," + lightness + "%)";
+ } else {
+ return "hsl(" + hue % 360 + "," + saturation + "%," + lightness + "%," + alpha + ")";
+ }
+ };
+ var _proto = Graphics.prototype;
+ _proto.isEmpty = function isEmpty() {
+ return !(this._instructions.length || this._activeInstructions.length);
+ };
+ _proto.draw = function draw(ctx, data) {
+ this._updateInstructions();
+ var instr = this._instructions;
+ var l = instr.length;
+ for (var i = this._storeIndex; i < l; i++) {
+ instr[i].exec(ctx, data);
+ }
+ };
+ _proto.drawAsPath = function drawAsPath(ctx) {
+ this._updateInstructions();
+ var instr,
+ instrs = this._instructions;
+ var l = instrs.length;
+ for (var i = this._storeIndex; i < l; i++) {
+ if ((instr = instrs[i]).path !== false) {
+ instr.exec(ctx);
+ }
+ }
+ };
+ _proto.moveTo = function moveTo(x, y) {
+ return this.append(new MoveTo(x, y), true);
+ };
+ _proto.lineTo = function lineTo(x, y) {
+ return this.append(new LineTo(x, y));
+ };
+ _proto.arcTo = function arcTo(x1, y1, x2, y2, radius) {
+ return this.append(new ArcTo(x1, y1, x2, y2, radius));
+ };
+ _proto.arc = function arc(x, y, radius, startAngle, endAngle, anticlockwise) {
+ return this.append(new Arc(x, y, radius, startAngle, endAngle, anticlockwise));
+ };
+ _proto.quadraticCurveTo = function quadraticCurveTo(cpx, cpy, x, y) {
+ return this.append(new QuadraticCurveTo(cpx, cpy, x, y));
+ };
+ _proto.bezierCurveTo = function bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
+ return this.append(new BezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y));
+ };
+ _proto.rect = function rect(x, y, w, h) {
+ return this.append(new Rect(x, y, w, h));
+ };
+ _proto.closePath = function closePath() {
+ return this._activeInstructions.length ? this.append(new ClosePath()) : this;
+ };
+ _proto.clear = function clear() {
+ this._instructions.length = this._activeInstructions.length = this._commitIndex = 0;
+ this._strokeStyle = this._oldStrokeStyle = this._stroke = this._fill = this._strokeDash = this._oldStrokeDash = null;
+ this._dirty = this._strokeIgnoreScale = false;
+ return this;
+ };
+ _proto.beginFill = function beginFill(color) {
+ return this._setFill(color ? new Fill(color) : null);
+ };
+ _proto.beginLinearGradientFill = function beginLinearGradientFill(colors, ratios, x0, y0, x1, y1) {
+ return this._setFill(new Fill().linearGradient(colors, ratios, x0, y0, x1, y1));
+ };
+ _proto.beginRadialGradientFill = function beginRadialGradientFill(colors, ratios, x0, y0, r0, x1, y1, r1) {
+ return this._setFill(new Fill().radialGradient(colors, ratios, x0, y0, r0, x1, y1, r1));
+ };
+ _proto.beginBitmapFill = function beginBitmapFill(image, repetition, matrix) {
+ return this._setFill(new Fill(null, matrix).bitmap(image, repetition));
+ };
+ _proto.endFill = function endFill() {
+ return this.beginFill();
+ };
+ _proto.setStrokeStyle = function setStrokeStyle(thickness, caps, joints, miterLimit, ignoreScale) {
+ if (caps === void 0) {
+ caps = 0;
+ }
+ if (joints === void 0) {
+ joints = 0;
+ }
+ if (miterLimit === void 0) {
+ miterLimit = 10;
+ }
+ if (ignoreScale === void 0) {
+ ignoreScale = false;
+ }
+ this._updateInstructions(true);
+ this._strokeStyle = this.command = new StrokeStyle(thickness, caps, joints, miterLimit, ignoreScale);
+ if (this._stroke) {
+ this._stroke.ignoreScale = ignoreScale;
+ }
+ this._strokeIgnoreScale = ignoreScale;
+ return this;
+ };
+ _proto.setStrokeDash = function setStrokeDash(segments, offset) {
+ if (offset === void 0) {
+ offset = 0;
+ }
+ this._updateInstructions(true);
+ this._strokeDash = this.command = new StrokeDash(segments, offset);
+ return this;
+ };
+ _proto.beginStroke = function beginStroke(color) {
+ return this._setStroke(color ? new Stroke(color) : null);
+ };
+ _proto.beginLinearGradientStroke = function beginLinearGradientStroke(colors, ratios, x0, y0, x1, y1) {
+ return this._setStroke(new Stroke().linearGradient(colors, ratios, x0, y0, x1, y1));
+ };
+ _proto.beginRadialGradientStroke = function beginRadialGradientStroke(colors, ratios, x0, y0, r0, x1, y1, r1) {
+ return this._setStroke(new Stroke().radialGradient(colors, ratios, x0, y0, r0, x1, y1, r1));
+ };
+ _proto.beginBitmapStroke = function beginBitmapStroke(image, repetition) {
+ if (repetition === void 0) {
+ repetition = "repeat";
+ }
+ return this._setStroke(new Stroke().bitmap(image, repetition));
+ };
+ _proto.endStroke = function endStroke() {
+ return this.beginStroke();
+ };
+ _proto.drawRoundRect = function drawRoundRect(x, y, w, h, radius) {
+ return this.drawRoundRectComplex(x, y, w, h, radius, radius, radius, radius);
+ };
+ _proto.drawRoundRectComplex = function drawRoundRectComplex(x, y, w, h, radiusTL, radiusTR, radiusBR, radiusBL) {
+ return this.append(new RoundRect(x, y, w, h, radiusTL, radiusTR, radiusBR, radiusBL));
+ };
+ _proto.drawCircle = function drawCircle(x, y, radius) {
+ return this.append(new Circle(x, y, radius));
+ };
+ _proto.drawEllipse = function drawEllipse(x, y, w, h) {
+ return this.append(new Ellipse(x, y, w, h));
+ };
+ _proto.drawPolyStar = function drawPolyStar(x, y, radius, sides, pointSize, angle) {
+ return this.append(new PolyStar(x, y, radius, sides, pointSize, angle));
+ };
+ _proto.append = function append(command, clean) {
+ this._activeInstructions.push(command);
+ this.command = command;
+ if (!clean) {
+ this._dirty = true;
+ }
+ return this;
+ };
+ _proto.decodePath = function decodePath(str) {
+ var instructions = [this.moveTo, this.lineTo, this.quadraticCurveTo, this.bezierCurveTo, this.closePath];
+ var paramCount = [2, 2, 4, 6, 0];
+ var i = 0;
+ var l = str.length;
+ var params = [];
+ var x = 0,
+ y = 0;
+ var base64 = Graphics._BASE_64;
+ while (i < l) {
+ var c = str.charAt(i);
+ var n = base64[c];
+ var fi = n >> 3;
+ var f = instructions[fi];
+ if (!f || n & 3) {
+ throw "Bad path data (@" + i + "):c";
+ }
+ var pl = paramCount[fi];
+ if (!fi) {
+ x = y = 0;
+ }
+ params.length = 0;
+ i++;
+ var charCount = (n >> 2 & 1) + 2;
+ for (var p = 0; p < pl; p++) {
+ var num = base64[str.charAt(i)];
+ var sign = num >> 5 ? -1 : 1;
+ num = (num & 31) << 6 | base64[str.charAt(i + 1)];
+ if (charCount === 3) {
+ num = num << 6 | base64[str.charAt(i + 2)];
+ }
+ num = sign * num / 10;
+ if (p % 2) {
+ x = num += x;
+ } else {
+ y = num += y;
+ }
+ params[p] = num;
+ i += charCount;
+ }
+ f.apply(this, params);
+ }
+ return this;
+ };
+ _proto.store = function store() {
+ this._updateInstructions(true);
+ this._storeIndex = this._instructions.length;
+ return this;
+ };
+ _proto.unstore = function unstore() {
+ this._storeIndex = 0;
+ return this;
+ };
+ _proto.clone = function clone() {
+ var o = new Graphics();
+ o.command = this.command;
+ o._stroke = this._stroke;
+ o._strokeStyle = this._strokeStyle;
+ o._strokeDash = this._strokeDash;
+ o._strokeIgnoreScale = this._strokeIgnoreScale;
+ o._fill = this._fill;
+ o._instructions = this._instructions.slice();
+ o._commitIndex = this._commitIndex;
+ o._activeInstructions = this._activeInstructions.slice();
+ o._dirty = this._dirty;
+ o._storeIndex = this._storeIndex;
+ return o;
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + "]";
+ };
+ _proto._updateInstructions = function _updateInstructions(commit) {
+ var instr = this._instructions,
+ active = this._activeInstructions,
+ commitIndex = this._commitIndex;
+ if (this._dirty && active.length) {
+ instr.length = commitIndex;
+ instr.push(Graphics.beginCmd);
+ var l = active.length,
+ ll = instr.length;
+ instr.length = ll + l;
+ for (var i = 0; i < l; i++) {
+ instr[i + ll] = active[i];
+ }
+ if (this._fill) {
+ instr.push(this._fill);
+ }
+ if (this._stroke) {
+ if (this._strokeDash !== this._oldStrokeDash) {
+ instr.push(this._strokeDash);
+ }
+ if (this._strokeStyle !== this._oldStrokeStyle) {
+ instr.push(this._strokeStyle);
+ }
+ if (commit) {
+ this._oldStrokeDash = this._strokeDash;
+ this._oldStrokeStyle = this._strokeStyle;
+ }
+ instr.push(this._stroke);
+ }
+ this._dirty = false;
+ }
+ if (commit) {
+ active.length = 0;
+ this._commitIndex = instr.length;
+ }
+ };
+ _proto._setFill = function _setFill(fill) {
+ this._updateInstructions(true);
+ this.command = this._fill = fill;
+ return this;
+ };
+ _proto._setStroke = function _setStroke(stroke) {
+ this._updateInstructions(true);
+ if (this.command = this._stroke = stroke) {
+ stroke.ignoreScale = this._strokeIgnoreScale;
+ }
+ return this;
+ };
+ _createClass(Graphics, [{
+ key: "instructions",
+ get: function get() {
+ this._updateInstructions();
+ return this._instructions;
+ }
+ }], [{
+ key: "LineTo",
+ get: function get() {
+ return LineTo;
+ }
+ }, {
+ key: "MoveTo",
+ get: function get() {
+ return MoveTo;
+ }
+ }, {
+ key: "ArcTo",
+ get: function get() {
+ return ArcTo;
+ }
+ }, {
+ key: "Arc",
+ get: function get() {
+ return Arc;
+ }
+ }, {
+ key: "QuadraticCurveTo",
+ get: function get() {
+ return QuadraticCurveTo;
+ }
+ }, {
+ key: "BezierCurveTo",
+ get: function get() {
+ return BezierCurveTo;
+ }
+ }, {
+ key: "Rect",
+ get: function get() {
+ return Rect;
+ }
+ }, {
+ key: "ClosePath",
+ get: function get() {
+ return ClosePath;
+ }
+ }, {
+ key: "BeginPath",
+ get: function get() {
+ return BeginPath;
+ }
+ }, {
+ key: "Fill",
+ get: function get() {
+ return Fill;
+ }
+ }, {
+ key: "Stroke",
+ get: function get() {
+ return Stroke;
+ }
+ }, {
+ key: "StrokeStyle",
+ get: function get() {
+ return StrokeStyle;
+ }
+ }, {
+ key: "StrokeDash",
+ get: function get() {
+ return StrokeDash;
+ }
+ }, {
+ key: "RoundRect",
+ get: function get() {
+ return RoundRect;
+ }
+ }, {
+ key: "Circle",
+ get: function get() {
+ return Circle;
+ }
+ }, {
+ key: "Ellipse",
+ get: function get() {
+ return Ellipse;
+ }
+ }, {
+ key: "PolyStar",
+ get: function get() {
+ return PolyStar;
+ }
+ }]);
+ return Graphics;
+}();
+var LineTo =
+function () {
+ function LineTo(x, y) {
+ this.x = x;
+ this.y = y;
+ }
+ var _proto2 = LineTo.prototype;
+ _proto2.exec = function exec(ctx) {
+ ctx.lineTo(this.x, this.y);
+ };
+ return LineTo;
+}();
+var MoveTo =
+function () {
+ function MoveTo(x, y) {
+ this.x = x;
+ this.y = y;
+ }
+ var _proto3 = MoveTo.prototype;
+ _proto3.exec = function exec(ctx) {
+ ctx.moveTo(this.x, this.y);
+ };
+ return MoveTo;
+}();
+var ArcTo =
+function () {
+ function ArcTo(x1, y1, x2, y2, radius) {
+ this.x1 = x1;
+ this.y1 = y1;
+ this.x2 = x2;
+ this.y2 = y2;
+ this.radius = radius;
+ }
+ var _proto4 = ArcTo.prototype;
+ _proto4.exec = function exec(ctx) {
+ ctx.arcTo(this.x1, this.y1, this.x2, this.y2, this.radius);
+ };
+ return ArcTo;
+}();
+var Arc =
+function () {
+ function Arc(x, y, radius, startAngle, endAngle, anticlockwise) {
+ if (anticlockwise === void 0) {
+ anticlockwise = false;
+ }
+ this.x = x;
+ this.y = y;
+ this.radius = radius;
+ this.startAngle = startAngle;
+ this.endAngle = endAngle;
+ this.anticlockwise = anticlockwise;
+ }
+ var _proto5 = Arc.prototype;
+ _proto5.exec = function exec(ctx) {
+ ctx.arc(this.x, this.y, this.radius, this.startAngle, this.endAngle, this.anticlockwise);
+ };
+ return Arc;
+}();
+var QuadraticCurveTo =
+function () {
+ function QuadraticCurveTo(cpx, cpy, x, y) {
+ this.cpx = cpx;
+ this.cpy = cpy;
+ this.x = x;
+ this.y = y;
+ }
+ var _proto6 = QuadraticCurveTo.prototype;
+ _proto6.exec = function exec(ctx) {
+ ctx.quadraticCurveTo(this.cpx, this.cpy, this.x, this.y);
+ };
+ return QuadraticCurveTo;
+}();
+var BezierCurveTo =
+function () {
+ function BezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
+ this.cp1x = cp1x;
+ this.cp1y = cp1y;
+ this.cp2x = cp2x;
+ this.cp2y = cp2y;
+ this.x = x;
+ this.y = y;
+ }
+ var _proto7 = BezierCurveTo.prototype;
+ _proto7.exec = function exec(ctx) {
+ ctx.bezierCurveTo(this.cp1x, this.cp1y, this.cp2x, this.cp2y, this.x, this.y);
+ };
+ return BezierCurveTo;
+}();
+var Rect =
+function () {
+ function Rect(x, y, w, h) {
+ this.x = x;
+ this.y = y;
+ this.w = w;
+ this.h = h;
+ }
+ var _proto8 = Rect.prototype;
+ _proto8.exec = function exec(ctx) {
+ ctx.rect(this.x, this.y, this.w, this.h);
+ };
+ return Rect;
+}();
+var ClosePath =
+function () {
+ function ClosePath() {}
+ var _proto9 = ClosePath.prototype;
+ _proto9.exec = function exec(ctx) {
+ ctx.closePath();
+ };
+ return ClosePath;
+}();
+var BeginPath =
+function () {
+ function BeginPath() {}
+ var _proto10 = BeginPath.prototype;
+ _proto10.exec = function exec(ctx) {
+ ctx.beginPath();
+ };
+ return BeginPath;
+}();
+var Fill =
+function () {
+ function Fill(style, matrix) {
+ this.style = style;
+ this.matrix = matrix;
+ this.path = false;
+ }
+ var _proto11 = Fill.prototype;
+ _proto11.exec = function exec(ctx) {
+ if (!this.style) {
+ return;
+ }
+ ctx.fillStyle = this.style;
+ var mtx = this.matrix;
+ if (mtx) {
+ ctx.save();
+ ctx.transform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx, mtx.ty);
+ }
+ ctx.fill();
+ if (mtx) {
+ ctx.restore();
+ }
+ };
+ _proto11.linearGradient = function linearGradient(colors, ratios, x0, y0, x1, y1) {
+ var o = this.style = Graphics._ctx.createLinearGradient(x0, y0, x1, y1);
+ var l = colors.length;
+ for (var i = 0; i < l; i++) {
+ o.addColorStop(ratios[i], colors[i]);
+ }
+ o.props = {
+ colors: colors,
+ ratios: ratios,
+ x0: x0,
+ y0: y0,
+ x1: x1,
+ y1: y1,
+ type: "linear"
+ };
+ return this;
+ };
+ _proto11.radialGradient = function radialGradient(colors, ratios, x0, y0, r0, x1, y1, r1) {
+ var o = this.style = Graphics._ctx.createRadialGradient(x0, y0, r0, x1, y1, r1);
+ var l = colors.length;
+ for (var i = 0; i < l; i++) {
+ o.addColorStop(ratios[i], colors[i]);
+ }
+ o.props = {
+ colors: colors,
+ ratios: ratios,
+ x0: x0,
+ y0: y0,
+ r0: r0,
+ x1: x1,
+ y1: y1,
+ r1: r1,
+ type: "radial"
+ };
+ return this;
+ };
+ _proto11.bitmap = function bitmap(image, repetition) {
+ if (repetition === void 0) {
+ repetition = "";
+ }
+ if (image.naturalWidth || image.getContext || image.readyState >= 2) {
+ var o = this.style = Graphics._ctx.createPattern(image, repetition);
+ o.props = {
+ image: image,
+ repetition: repetition,
+ type: "bitmap"
+ };
+ }
+ return this;
+ };
+ return Fill;
+}();
+var Stroke =
+function (_Fill) {
+ _inheritsLoose(Stroke, _Fill);
+ function Stroke(style, ignoreScale) {
+ var _this;
+ _this = _Fill.call(this) || this;
+ _this.style = style;
+ _this.ignoreScale = ignoreScale;
+ _this.path = false;
+ return _this;
+ }
+ var _proto12 = Stroke.prototype;
+ _proto12.exec = function exec(ctx) {
+ if (!this.style) {
+ return;
+ }
+ ctx.strokeStyle = this.style;
+ if (this.ignoreScale) {
+ ctx.save();
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
+ }
+ ctx.stroke();
+ if (this.ignoreScale) {
+ ctx.restore();
+ }
+ };
+ return Stroke;
+}(Fill);
+var StrokeStyle =
+function () {
+ function StrokeStyle(width, caps, joints, miterLimit, ignoreScale) {
+ if (width === void 0) {
+ width = 1;
+ }
+ if (caps === void 0) {
+ caps = "butt";
+ }
+ if (joints === void 0) {
+ joints = "miter";
+ }
+ if (miterLimit === void 0) {
+ miterLimit = 10;
+ }
+ if (ignoreScale === void 0) {
+ ignoreScale = false;
+ }
+ this.width = width;
+ this.caps = caps;
+ this.joints = joints;
+ this.miterLimit = miterLimit;
+ this.ignoreScale = ignoreScale;
+ this.path = false;
+ }
+ var _proto13 = StrokeStyle.prototype;
+ _proto13.exec = function exec(ctx) {
+ ctx.lineWidth = this.width;
+ ctx.lineCap = isNaN(this.caps) ? this.caps : Graphics._STROKE_CAPS_MAP[this.caps];
+ ctx.lineJoin = isNaN(this.joints) ? this.joints : Graphics._STROKE_JOINTS_MAP[this.joints];
+ ctx.miterLimit = this.miterLimit;
+ ctx.ignoreScale = this.ignoreScale;
+ };
+ return StrokeStyle;
+}();
+var StrokeDash =
+function () {
+ function StrokeDash(segments, offset) {
+ if (segments === void 0) {
+ segments = [];
+ }
+ if (offset === void 0) {
+ offset = 0;
+ }
+ this.segments = segments;
+ this.offset = offset;
+ }
+ var _proto14 = StrokeDash.prototype;
+ _proto14.exec = function exec(ctx) {
+ if (ctx.setLineDash) {
+ ctx.setLineDash(this.segments);
+ ctx.lineDashOffset = this.offset;
+ }
+ };
+ return StrokeDash;
+}();
+var RoundRect =
+function () {
+ function RoundRect(x, y, w, h, radiusTL, radiusTR, radiusBR, radiusBL) {
+ this.x = x;
+ this.y = y;
+ this.w = w;
+ this.h = h;
+ this.radiusTL = radiusTL;
+ this.radiusTR = radiusTR;
+ this.radiusBR = radiusBR;
+ this.radiusBL = radiusBL;
+ }
+ var _proto15 = RoundRect.prototype;
+ _proto15.exec = function exec(ctx) {
+ var max = (this.w < this.h ? this.w : this.h) / 2;
+ var mTL = 0,
+ mTR = 0,
+ mBR = 0,
+ mBL = 0;
+ var x = this.x,
+ y = this.y,
+ w = this.w,
+ h = this.h;
+ var rTL = this.radiusTL,
+ rTR = this.radiusTR,
+ rBR = this.radiusBR,
+ rBL = this.radiusBL;
+ if (rTL < 0) {
+ rTL *= mTL = -1;
+ }
+ if (rTL > max) {
+ rTL = max;
+ }
+ if (rTR < 0) {
+ rTR *= mTR = -1;
+ }
+ if (rTR > max) {
+ rTR = max;
+ }
+ if (rBR < 0) {
+ rBR *= mBR = -1;
+ }
+ if (rBR > max) {
+ rBR = max;
+ }
+ if (rBL < 0) {
+ rBL *= mBL = -1;
+ }
+ if (rBL > max) {
+ rBL = max;
+ }
+ ctx.moveTo(x + w - rTR, y);
+ ctx.arcTo(x + w + rTR * mTR, y - rTR * mTR, x + w, y + rTR, rTR);
+ ctx.lineTo(x + w, y + h - rBR);
+ ctx.arcTo(x + w + rBR * mBR, y + h + rBR * mBR, x + w - rBR, y + h, rBR);
+ ctx.lineTo(x + rBL, y + h);
+ ctx.arcTo(x - rBL * mBL, y + h + rBL * mBL, x, y + h - rBL, rBL);
+ ctx.lineTo(x, y + rTL);
+ ctx.arcTo(x - rTL * mTL, y - rTL * mTL, x + rTL, y, rTL);
+ ctx.closePath();
+ };
+ return RoundRect;
+}();
+var Circle =
+function () {
+ function Circle(x, y, radius) {
+ this.x = x;
+ this.y = y;
+ this.radius = radius;
+ }
+ var _proto16 = Circle.prototype;
+ _proto16.exec = function exec(ctx) {
+ ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2);
+ };
+ return Circle;
+}();
+var Ellipse =
+function () {
+ function Ellipse(x, y, w, h) {
+ this.x = x;
+ this.y = y;
+ this.w = w;
+ this.h = h;
+ }
+ var _proto17 = Ellipse.prototype;
+ _proto17.exec = function exec(ctx) {
+ var x = this.x,
+ y = this.y;
+ var w = this.w,
+ h = this.h;
+ var k = 0.5522848;
+ var ox = w / 2 * k;
+ var oy = h / 2 * k;
+ var xe = x + w;
+ var ye = y + h;
+ var xm = x + w / 2;
+ var ym = y + h / 2;
+ ctx.moveTo(x, ym);
+ ctx.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y);
+ ctx.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym);
+ ctx.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye);
+ ctx.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym);
+ };
+ return Ellipse;
+}();
+var PolyStar =
+function () {
+ function PolyStar(x, y, radius, sides, pointSize, angle) {
+ if (pointSize === void 0) {
+ pointSize = 0;
+ }
+ if (angle === void 0) {
+ angle = 0;
+ }
+ this.x = x;
+ this.y = y;
+ this.radius = radius;
+ this.sides = sides;
+ this.pointSize = pointSize;
+ this.angle = angle;
+ }
+ var _proto18 = PolyStar.prototype;
+ _proto18.exec = function exec(ctx) {
+ var x = this.x,
+ y = this.y;
+ var radius = this.radius;
+ var angle = this.angle / 180 * Math.PI;
+ var sides = this.sides;
+ var ps = 1 - this.pointSize;
+ var a = Math.PI / sides;
+ ctx.moveTo(x + Math.cos(angle) * radius, y + Math.sin(angle) * radius);
+ for (var i = 0; i < sides; i++) {
+ angle += a;
+ if (ps != 1) {
+ ctx.lineTo(x + Math.cos(angle) * radius * ps, y + Math.sin(angle) * radius * ps);
+ }
+ angle += a;
+ ctx.lineTo(x + Math.cos(angle) * radius, y + Math.sin(angle) * radius);
+ }
+ ctx.closePath();
+ };
+ return PolyStar;
+}();
+Graphics.beginCmd = new BeginPath();
+Graphics._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
+};
+Graphics._STROKE_CAPS_MAP = ["butt", "round", "square"];
+Graphics._STROKE_JOINTS_MAP = ["miter", "round", "bevel"];
+Graphics._ctx = createCanvas().getContext("2d");
+
+var MovieClip =
+function (_Container) {
+ _inheritsLoose(MovieClip, _Container);
+ function MovieClip(props) {
+ var _this;
+ _this = _Container.call(this) || this;
+ !MovieClip.inited && MovieClip.init();
+ _this.mode = props.mode != null ? props.mode : MovieClip.INDEPENDENT;
+ _this.startPosition = props.startPosition != null ? props.startPosition : 0;
+ if (typeof props.loop === "number") {
+ _this.loop = props.loop;
+ } else if (props.loop === false) {
+ _this.loop = 0;
+ } else {
+ _this.loop = -1;
+ }
+ _this.currentFrame = 0;
+ _this.timeline = new tweenjs.Timeline(Object.assign({
+ useTicks: true,
+ paused: true
+ }, props));
+ _this.paused = props.paused != null ? props.paused : false;
+ _this.actionsEnabled = true;
+ _this.autoReset = true;
+ _this.frameBounds = _this.frameBounds || props.frameBounds;
+ _this.framerate = null;
+ _this._synchOffset = 0;
+ _this._rawPosition = -1;
+ _this._t = 0;
+ _this._managed = {};
+ _this._bound_resolveState = _this._resolveState.bind(_assertThisInitialized(_assertThisInitialized(_this)));
+ return _this;
+ }
+ MovieClip.init = function init() {
+ if (MovieClip.inited) {
+ return;
+ }
+ MovieClipPlugin.install();
+ MovieClip.inited = true;
+ };
+ var _proto = MovieClip.prototype;
+ _proto.isVisible = function isVisible() {
+ return !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0);
+ };
+ _proto.draw = function draw(ctx, ignoreCache) {
+ if (this.drawCache(ctx, ignoreCache)) {
+ return true;
+ }
+ this._updateState();
+ _Container.prototype.draw.call(this, ctx, ignoreCache);
+ return true;
+ };
+ _proto.play = function play() {
+ this.paused = false;
+ };
+ _proto.stop = function stop() {
+ this.paused = true;
+ };
+ _proto.gotoAndPlay = function gotoAndPlay(positionOrLabel) {
+ this.play();
+ this._goto(positionOrLabel);
+ };
+ _proto.gotoAndStop = function gotoAndStop(positionOrLabel) {
+ this.stop();
+ this._goto(positionOrLabel);
+ };
+ _proto.advance = function advance(time) {
+ if (this.mode !== MovieClip.INDEPENDENT) {
+ return;
+ }
+ var o = this,
+ fps = o.framerate;
+ while ((o = o.parent) && fps === null) {
+ if (o.mode === MovieClip.INDEPENDENT) {
+ fps = o._framerate;
+ }
+ }
+ this._framerate = fps;
+ if (this.paused) {
+ return;
+ }
+ var t = fps !== null && fps !== -1 && time !== null ? time / (1000 / fps) + this._t : 1;
+ var frames = t | 0;
+ this._t = t - frames;
+ while (frames--) {
+ this._updateTimeline(this._rawPosition + 1, false);
+ }
+ };
+ _proto.clone = function clone() {
+ throw "MovieClip cannot be cloned.";
+ };
+ _proto._updateState = function _updateState() {
+ if (this._rawPosition === -1 || this.mode !== MovieClip.INDEPENDENT) {
+ this._updateTimeline(-1);
+ }
+ };
+ _proto._tick = function _tick(evtObj) {
+ this.advance(evtObj && evtObj.delta);
+ _Container.prototype._tick.call(this, evtObj);
+ };
+ _proto._goto = function _goto(positionOrLabel) {
+ var pos = this.timeline.resolve(positionOrLabel);
+ if (pos == null) {
+ return;
+ }
+ this._t = 0;
+ this._updateTimeline(pos, true);
+ };
+ _proto._reset = function _reset() {
+ this._rawPosition = -1;
+ this._t = this.currentFrame = 0;
+ this.paused = false;
+ };
+ _proto._updateTimeline = function _updateTimeline(rawPosition, jump) {
+ var synced = this.mode !== MovieClip.INDEPENDENT,
+ tl = this.timeline;
+ if (synced) {
+ rawPosition = this.startPosition + (this.mode === MovieClip.SINGLE_FRAME ? 0 : this._synchOffset);
+ }
+ if (rawPosition < 1) {
+ rawPosition = 0;
+ }
+ if (this._rawPosition === rawPosition && !synced) {
+ return;
+ }
+ this._rawPosition = rawPosition;
+ tl.loop = this.loop;
+ tl.setPosition(rawPosition, synced || !this.actionsEnabled, jump, this._bound_resolveState);
+ };
+ _proto._renderFirstFrame = function _renderFirstFrame() {
+ var tl = this.timeline,
+ pos = tl.rawPosition;
+ tl.setPosition(0, true, true, this._bound_resolveState);
+ tl.rawPosition = pos;
+ };
+ _proto._resolveState = function _resolveState() {
+ var tl = this.timeline;
+ this.currentFrame = tl.position;
+ for (var n in this._managed) {
+ this._managed[n] = 1;
+ }
+ var tweens = tl.tweens;
+ for (var _iterator = tweens, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
+ var _ref;
+ if (_isArray) {
+ if (_i >= _iterator.length) break;
+ _ref = _iterator[_i++];
+ } else {
+ _i = _iterator.next();
+ if (_i.done) break;
+ _ref = _i.value;
+ }
+ var tween = _ref;
+ var target = tween.target;
+ if (target === this || tween.passive) {
+ continue;
+ }
+ var offset = tween._stepPosition;
+ if (target instanceof DisplayObject) {
+ this._addManagedChild(target, offset);
+ } else {
+ this._setState(target.state, offset);
+ }
+ }
+ var kids = this.children;
+ for (var i = kids.length - 1; i >= 0; i--) {
+ var id = kids[i].id;
+ if (this._managed[id] === 1) {
+ this.removeChildAt(i);
+ delete this._managed[id];
+ }
+ }
+ };
+ _proto._setState = function _setState(state, offset) {
+ if (!state) {
+ return;
+ }
+ for (var i = state.length - 1; i >= 0; i--) {
+ var o = state[i];
+ var target = o.t;
+ var props = o.p;
+ for (var n in props) {
+ target[n] = props[n];
+ }
+ this._addManagedChild(target, offset);
+ }
+ };
+ _proto._addManagedChild = function _addManagedChild(child, offset) {
+ if (child._off) {
+ return;
+ }
+ this.addChildAt(child, 0);
+ if (child instanceof MovieClip) {
+ child._synchOffset = offset;
+ if (child.mode === MovieClip.INDEPENDENT && child.autoReset && !this._managed[child.id]) {
+ child._reset();
+ }
+ }
+ this._managed[child.id] = 2;
+ };
+ _proto._getBounds = function _getBounds(matrix, ignoreTransform) {
+ var bounds = this.getBounds();
+ if (!bounds && this.frameBounds) {
+ bounds = this._rectangle.copy(this.frameBounds[this.currentFrame]);
+ }
+ if (bounds) {
+ return this._transformBounds(bounds, matrix, ignoreTransform);
+ }
+ return _Container.prototype._getBounds.call(this, matrix, ignoreTransform);
+ };
+ _createClass(MovieClip, [{
+ key: "labels",
+ get: function get() {
+ return this.timeline.labels;
+ }
+ }, {
+ key: "currentLabel",
+ get: function get() {
+ return this.timeline.currentLabel;
+ }
+ }, {
+ key: "duration",
+ get: function get() {
+ return this.timeline.duration;
+ }
+ }, {
+ key: "totalFrames",
+ get: function get() {
+ return this.duration;
+ }
+ }]);
+ return MovieClip;
+}(Container);
+MovieClip.INDEPENDENT = "independent";
+MovieClip.SINGLE_FRAME = "single";
+MovieClip.SYNCHED = "synched";
+MovieClip.inited = false;
+var MovieClipPlugin =
+function () {
+ function MovieClipPlugin() {
+ throw "MovieClipPlugin cannot be instantiated.";
+ }
+ MovieClipPlugin.install = function install() {
+ tweenjs.Tween.installPlugin(MovieClipPlugin);
+ };
+ MovieClipPlugin.init = function init(tween, prop, value) {
+ return value;
+ };
+ MovieClipPlugin.tween = function tween(_tween, prop, value, startValues, endValues, ratio, wait, end) {
+ if (!(_tween.target instanceof MovieClip)) {
+ return value;
+ }
+ return ratio === 1 ? endValues[prop] : startValues[prop];
+ };
+ return MovieClipPlugin;
+}();
+MovieClipPlugin.priority = 100;
+
+var Shape =
+function (_DisplayObject) {
+ _inheritsLoose(Shape, _DisplayObject);
+ function Shape(graphics) {
+ var _this;
+ if (graphics === void 0) {
+ graphics = new Graphics();
+ }
+ _this = _DisplayObject.call(this) || this;
+ _this.graphics = graphics;
+ return _this;
+ }
+ var _proto = Shape.prototype;
+ _proto.isVisible = function isVisible() {
+ var hasContent = this.cacheCanvas || this.graphics && !this.graphics.isEmpty();
+ return !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && hasContent);
+ };
+ _proto.draw = function draw(ctx, ignoreCache) {
+ if (ignoreCache === void 0) {
+ ignoreCache = false;
+ }
+ if (_DisplayObject.prototype.draw.call(this, ctx, ignoreCache)) {
+ return true;
+ }
+ this.graphics.draw(ctx, this);
+ return true;
+ };
+ _proto.clone = function clone(recursive) {
+ if (recursive === void 0) {
+ recursive = false;
+ }
+ var g = recursive && this.graphics ? this.graphics.clone() : this.graphics;
+ return this._cloneProps(new Shape(g));
+ };
+ return Shape;
+}(DisplayObject);
+
+var SpriteSheet =
+function (_EventDispatcher) {
+ _inheritsLoose(SpriteSheet, _EventDispatcher);
+ function SpriteSheet(data) {
+ var _this;
+ _this = _EventDispatcher.call(this) || this;
+ _this.complete = true;
+ _this.framerate = 0;
+ _this._animations = null;
+ _this._frames = null;
+ _this._images = null;
+ _this._data = null;
+ _this._loadCount = 0;
+ _this._frameHeight = 0;
+ _this._frameWidth = 0;
+ _this._numFrames = 0;
+ _this._regX = 0;
+ _this._regY = 0;
+ _this._spacing = 0;
+ _this._margin = 0;
+ _this._parseData(data);
+ return _this;
+ }
+ var _proto = SpriteSheet.prototype;
+ _proto.getNumFrames = function getNumFrames(animation) {
+ if (animation == null) {
+ return this._frames ? this._frames.length : this._numFrames || 0;
+ } else {
+ var data = this._data[animation];
+ if (data == null) {
+ return 0;
+ } else {
+ return data.frames.length;
+ }
+ }
+ };
+ _proto.getAnimation = function getAnimation(name) {
+ return this._data[name];
+ };
+ _proto.getFrame = function getFrame(frameIndex) {
+ var frame;
+ if (this._frames && (frame = this._frames[frameIndex])) {
+ return frame;
+ }
+ return null;
+ };
+ _proto.getFrameBounds = function getFrameBounds(frameIndex, rectangle) {
+ if (rectangle === void 0) {
+ rectangle = new Rectangle();
+ }
+ var frame = this.getFrame(frameIndex);
+ return frame ? rectangle.setValues(-frame.regX, -frame.regY, frame.rect.width, frame.rect.height) : null;
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + "]";
+ };
+ _proto.clone = function clone() {
+ throw "SpriteSheet cannot be cloned.";
+ };
+ _proto._parseData = function _parseData(data) {
+ var _this2 = this;
+ if (data == null) {
+ return;
+ }
+ this.framerate = data.framerate || 0;
+ if (data.images) {
+ var _loop = function _loop() {
+ if (_isArray) {
+ if (_i >= _iterator.length) return "break";
+ _ref = _iterator[_i++];
+ } else {
+ _i = _iterator.next();
+ if (_i.done) return "break";
+ _ref = _i.value;
+ }
+ var img = _ref;
+ var a = _this2._images = [];
+ var src = void 0;
+ if (typeof img === "string") {
+ src = img;
+ img = document.createElement("img");
+ img.src = src;
+ }
+ a.push(img);
+ if (!img.getContext && !img.naturalWidth) {
+ _this2._loadCount++;
+ _this2.complete = false;
+ img.onload = function () {
+ return _this2._handleImageLoad(src);
+ };
+ img.onerror = function () {
+ return _this2._handleImageError(src);
+ };
+ }
+ };
+ for (var _iterator = data.images, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
+ var _ref;
+ var _ret = _loop();
+ if (_ret === "break") break;
+ }
+ }
+ if (data.frames != null) {
+ if (Array.isArray(data.frames)) {
+ this._frames = [];
+ for (var _iterator2 = data.frames, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
+ var _ref2;
+ if (_isArray2) {
+ if (_i2 >= _iterator2.length) break;
+ _ref2 = _iterator2[_i2++];
+ } else {
+ _i2 = _iterator2.next();
+ if (_i2.done) break;
+ _ref2 = _i2.value;
+ }
+ var arr = _ref2;
+ this._frames.push({
+ image: this._images[arr[4] ? arr[4] : 0],
+ rect: new Rectangle(arr[0], arr[1], arr[2], arr[3]),
+ regX: arr[5] || 0,
+ regY: arr[6] || 0
+ });
+ }
+ } else {
+ var o = data.frames;
+ this._frameWidth = o.width;
+ this._frameHeight = o.height;
+ this._regX = o.regX || 0;
+ this._regY = o.regY || 0;
+ this._spacing = o.spacing || 0;
+ this._margin = o.margin || 0;
+ this._numFrames = o.count;
+ if (this._loadCount === 0) {
+ this._calculateFrames();
+ }
+ }
+ }
+ this._animations = [];
+ if (data.animations != null) {
+ this._data = {};
+ var _o = data.animations;
+ for (var name in _o) {
+ var anim = {
+ name: name
+ };
+ var obj = _o[name];
+ var a = void 0;
+ if (typeof obj === "number") {
+ a = anim.frames = [obj];
+ } else if (Array.isArray(obj)) {
+ if (obj.length === 1) {
+ anim.frames = [obj[0]];
+ } else {
+ anim.speed = obj[3];
+ anim.next = obj[2];
+ a = anim.frames = [];
+ for (var i = obj[0]; i <= obj[1]; i++) {
+ a.push(i);
+ }
+ }
+ } else {
+ anim.speed = obj.speed;
+ anim.next = obj.next;
+ var frames = obj.frames;
+ a = anim.frames = typeof frames === "number" ? [frames] : frames.slice(0);
+ }
+ if (anim.next === true || anim.next === undefined) {
+ anim.next = name;
+ }
+ if (anim.next === false || a.length < 2 && anim.next === name) {
+ anim.next = null;
+ }
+ if (!anim.speed) {
+ anim.speed = 1;
+ }
+ this._animations.push(name);
+ this._data[name] = anim;
+ }
+ }
+ };
+ _proto._handleImageLoad = function _handleImageLoad(src) {
+ if (--this._loadCount === 0) {
+ this._calculateFrames();
+ this.complete = true;
+ this.dispatchEvent("complete");
+ }
+ };
+ _proto._handleImageError = function _handleImageError(src) {
+ var errorEvent = new Event("error");
+ errorEvent.src = src;
+ this.dispatchEvent(errorEvent);
+ if (--this._loadCount === 0) {
+ this.dispatchEvent("complete");
+ }
+ };
+ _proto._calculateFrames = function _calculateFrames() {
+ if (this._frames || this._frameWidth === 0) {
+ return;
+ }
+ this._frames = [];
+ var maxFrames = this._numFrames || 100000;
+ var frameCount = 0,
+ frameWidth = this._frameWidth,
+ frameHeight = this._frameHeight;
+ var spacing = this._spacing,
+ margin = this._margin;
+ imgLoop: for (var i = 0, imgs = this._images, l = imgs.length; i < l; i++) {
+ var img = imgs[i],
+ imgW = img.width || img.naturalWidth,
+ imgH = img.height || img.naturalHeight;
+ var y = margin;
+ while (y <= imgH - margin - frameHeight) {
+ var x = margin;
+ while (x <= imgW - margin - frameWidth) {
+ if (frameCount >= maxFrames) {
+ break imgLoop;
+ }
+ frameCount++;
+ this._frames.push({
+ image: img,
+ rect: new Rectangle(x, y, frameWidth, frameHeight),
+ regX: this._regX,
+ regY: this._regY
+ });
+ x += frameWidth + spacing;
+ }
+ y += frameHeight + spacing;
+ }
+ }
+ this._numFrames = frameCount;
+ };
+ _createClass(SpriteSheet, [{
+ key: "animations",
+ get: function get() {
+ return this._animations.slice();
+ }
+ }]);
+ return SpriteSheet;
+}(EventDispatcher);
+
+var Text =
+function (_DisplayObject) {
+ _inheritsLoose(Text, _DisplayObject);
+ function Text(text, font, color) {
+ var _this;
+ _this = _DisplayObject.call(this) || this;
+ _this.text = text;
+ _this.font = font;
+ _this.color = color;
+ _this.textAlign = "left";
+ _this.textBaseline = "top";
+ _this.maxWidth = null;
+ _this.outline = 0;
+ _this.lineHeight = 0;
+ _this.lineWidth = null;
+ return _this;
+ }
+ var _proto = Text.prototype;
+ _proto.isVisible = function isVisible() {
+ var hasContent = this.cacheCanvas || this.text != null && this.text !== "";
+ return !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && hasContent);
+ };
+ _proto.draw = function draw(ctx, ignoreCache) {
+ if (_DisplayObject.prototype.draw.call(this, ctx, ignoreCache)) {
+ return true;
+ }
+ var col = this.color || "#000";
+ if (this.outline) {
+ ctx.strokeStyle = col;
+ ctx.lineWidth = this.outline * 1;
+ } else {
+ ctx.fillStyle = col;
+ }
+ this._drawText(this._prepContext(ctx));
+ return true;
+ };
+ _proto.getMeasuredWidth = function getMeasuredWidth() {
+ return this._getMeasuredWidth(this.text);
+ };
+ _proto.getMeasuredLineHeight = function getMeasuredLineHeight() {
+ return this._getMeasuredWidth("M") * 1.2;
+ };
+ _proto.getMeasuredHeight = function getMeasuredHeight() {
+ return this._drawText(null, {}).height;
+ };
+ _proto.getBounds = function getBounds() {
+ var rect = _DisplayObject.prototype.getBounds.call(this);
+ 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);
+ };
+ _proto.getMetrics = function getMetrics() {
+ 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);
+ };
+ _proto.clone = function clone() {
+ return this._cloneProps(new Text(this.text, this.font, this.color));
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + " (text=" + (this.text.length > 20 ? this.text.substr(0, 17) + "..." : this.text) + ")]";
+ };
+ _proto._cloneProps = function _cloneProps(o) {
+ _DisplayObject.prototype._cloneProps.call(this, 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;
+ };
+ _proto._prepContext = function _prepContext(ctx) {
+ ctx.font = this.font || "10px sans-serif";
+ ctx.textAlign = this.textAlign || "left";
+ ctx.textBaseline = this.textBaseline || "top";
+ ctx.lineJoin = "miter";
+ ctx.miterLimit = 2.5;
+ return ctx;
+ };
+ _proto._drawText = function _drawText(ctx, o, lines) {
+ var paint = !!ctx;
+ if (!paint) {
+ ctx = Text._ctx;
+ 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 _iterator = hardLines, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
+ var _ref;
+ if (_isArray) {
+ if (_i >= _iterator.length) break;
+ _ref = _iterator[_i++];
+ } else {
+ _i = _iterator.next();
+ if (_i.done) break;
+ _ref = _i.value;
+ }
+ var str = _ref;
+ var w = null;
+ if (this.lineWidth != null && (w = ctx.measureText(str).width) > this.lineWidth) {
+ var words = str.split(/(\s)/);
+ str = words[0];
+ w = ctx.measureText(str).width;
+ var l = words.length;
+ for (var i = 1; i < l; i += 2) {
+ var wordW = ctx.measureText(words[i] + words[i + 1]).width;
+ if (w + wordW > this.lineWidth) {
+ if (paint) {
+ this._drawTextLine(ctx, str, count * lineHeight);
+ }
+ if (lines) {
+ lines.push(str);
+ }
+ if (w > maxW) {
+ maxW = w;
+ }
+ str = words[i + 1];
+ w = ctx.measureText(str).width;
+ count++;
+ } else {
+ str += words[i] + words[i + 1];
+ w += wordW;
+ }
+ }
+ }
+ if (paint) {
+ this._drawTextLine(ctx, str, count * lineHeight);
+ }
+ if (lines) {
+ lines.push(str);
+ }
+ if (o && w == null) {
+ w = ctx.measureText(str).width;
+ }
+ if (w > maxW) {
+ maxW = w;
+ }
+ count++;
+ }
+ if (o) {
+ o.width = maxW;
+ o.height = count * lineHeight;
+ }
+ if (!paint) {
+ ctx.restore();
+ }
+ return o;
+ };
+ _proto._drawTextLine = function _drawTextLine(ctx, text, y) {
+ if (this.outline) {
+ ctx.strokeText(text, 0, y, this.maxWidth || 0xFFFF);
+ } else {
+ ctx.fillText(text, 0, y, this.maxWidth || 0xFFFF);
+ }
+ };
+ _proto._getMeasuredWidth = function _getMeasuredWidth(text) {
+ var ctx = Text._ctx;
+ ctx.save();
+ var w = this._prepContext(ctx).measureText(text).width;
+ ctx.restore();
+ return w;
+ };
+ return Text;
+}(DisplayObject);
+Text.H_OFFSETS = {
+ start: 0,
+ left: 0,
+ center: -0.5,
+ end: -1,
+ right: -1
+};
+Text.V_OFFSETS = {
+ top: 0,
+ hanging: -0.01,
+ middle: -0.4,
+ alphabetic: -0.8,
+ ideographic: -0.85,
+ bottom: -1
+};
+Text._ctx = createCanvas().getContext("2d");
+
+var AlphaMapFilter =
+function (_Filter) {
+ _inheritsLoose(AlphaMapFilter, _Filter);
+ function AlphaMapFilter(alphaMap) {
+ var _this;
+ _this = _Filter.call(this) || this;
+ _this.alphaMap = alphaMap;
+ _this._alphaMap = null;
+ _this._mapData = null;
+ _this._mapTexture = null;
+ _this.FRAG_SHADER_BODY = "\n\t\t\tuniform sampler2D uAlphaSampler;\n\n\t\t\tvoid main (void) {\n\t\t\t\tvec4 color = texture2D(uSampler, vRenderCoord);\n\t\t\t\tvec4 alphaMap = texture2D(uAlphaSampler, vTextureCoord);\n\n\t\t\t\t// some image formats can have transparent white rgba(1,1,1, 0) when put on the GPU, this means we need a slight tweak\n\t\t\t\t// using ceil ensure that the colour will be used so long as it exists but pure transparency will be treated black\n\t\t\t\tgl_FragColor = vec4(color.rgb, color.a * (alphaMap.r * ceil(alphaMap.a)));\n\t\t\t}\n\t\t";
+ return _this;
+ }
+ var _proto = AlphaMapFilter.prototype;
+ _proto.shaderParamSetup = function shaderParamSetup(gl, stage, shaderProgram) {
+ if (!this._mapTexture) {
+ this._mapTexture = gl.createTexture();
+ }
+ gl.activeTexture(gl.TEXTURE1);
+ gl.bindTexture(gl.TEXTURE_2D, this._mapTexture);
+ stage.setTextureParams(gl);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this.alphaMap);
+ gl.uniform1i(gl.getUniformLocation(shaderProgram, "uAlphaSampler"), 1);
+ };
+ _proto.clone = function clone() {
+ var o = new AlphaMapFilter(this.alphaMap);
+ o._alphaMap = this._alphaMap;
+ o._mapData = this._mapData;
+ return o;
+ };
+ _proto._applyFilter = function _applyFilter(imageData) {
+ if (!this.alphaMap) {
+ return true;
+ }
+ if (!this._prepAlphaMap()) {
+ return false;
+ }
+ var data = imageData.data;
+ var map = this._mapData;
+ var l = data.length;
+ for (var i = 0; i < l; i += 4) {
+ data[i + 3] = map[i] || 0;
+ }
+ return true;
+ };
+ _proto._prepAlphaMap = function _prepAlphaMap() {
+ if (!this.alphaMap) {
+ return false;
+ }
+ if (this.alphaMap === this._alphaMap && this._mapData) {
+ return true;
+ }
+ this._mapData = null;
+ var map = this._alphaMap = this.alphaMap;
+ var canvas = map;
+ var ctx;
+ if (map instanceof HTMLCanvasElement) {
+ ctx = canvas.getContext("2d");
+ } else {
+ canvas = window.createjs && createjs.createCanvas ? createjs.createCanvas() : document.createElement("canvas");
+ canvas.width = map.width;
+ canvas.height = map.height;
+ ctx = canvas.getContext("2d");
+ ctx.drawImage(map, 0, 0);
+ }
+ try {
+ this._mapData = ctx.getImageData(0, 0, map.width, map.height).data;
+ return true;
+ } catch (e) {
+ return false;
+ }
+ };
+ return AlphaMapFilter;
+}(Filter);
+
+var AlphaMaskFilter =
+function (_Filter) {
+ _inheritsLoose(AlphaMaskFilter, _Filter);
+ function AlphaMaskFilter(mask) {
+ var _this;
+ _this = _Filter.call(this) || this;
+ _this.mask = mask;
+ _this.usesContext = true;
+ _this.FRAG_SHADER_BODY = "\n\t\t\tuniform sampler2D uAlphaSampler;\n\n\t\t\tvoid main (void) {\n\t\t\t\tvec4 color = texture2D(uSampler, vRenderCoord);\n\t\t\t\tvec4 alphaMap = texture2D(uAlphaSampler, vTextureCoord);\n\n\t\t\t\tgl_FragColor = vec4(color.rgb, color.a * alphaMap.a);\n\t\t\t}\n\t\t";
+ return _this;
+ }
+ var _proto = AlphaMaskFilter.prototype;
+ _proto.applyFilter = function applyFilter(ctx, x, y, width, height, targetCtx, targetX, targetY) {
+ if (!this.mask) {
+ return true;
+ }
+ targetCtx = targetCtx || ctx;
+ if (targetX == null) {
+ targetX = x;
+ }
+ if (targetY == null) {
+ targetY = y;
+ }
+ targetCtx.save();
+ if (ctx != targetCtx) {
+ return false;
+ }
+ targetCtx.globalCompositeOperation = "destination-in";
+ targetCtx.drawImage(this.mask, targetX, targetY);
+ targetCtx.restore();
+ return true;
+ };
+ _proto.clone = function clone() {
+ return new AlphaMaskFilter(this.mask);
+ };
+ _proto.shaderParamSetup = function shaderParamSetup(gl, stage, shaderProgram) {
+ if (!this._mapTexture) {
+ this._mapTexture = gl.createTexture();
+ }
+ gl.activeTexture(gl.TEXTURE1);
+ gl.bindTexture(gl.TEXTURE_2D, this._mapTexture);
+ stage.setTextureParams(gl);
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this.mask);
+ gl.uniform1i(gl.getUniformLocation(shaderProgram, "uAlphaSampler"), 1);
+ };
+ return AlphaMaskFilter;
+}(Filter);
+
+var BlurFilter =
+function (_Filter) {
+ _inheritsLoose(BlurFilter, _Filter);
+ function BlurFilter(blurX, blurY, quality) {
+ var _this;
+ if (blurX === void 0) {
+ blurX = 0;
+ }
+ if (blurY === void 0) {
+ blurY = 0;
+ }
+ if (quality === void 0) {
+ quality = 1;
+ }
+ _this = _Filter.call(this) || this;
+ _this._blurX = blurX;
+ _this._blurXTable = [];
+ _this._lastBlurX = null;
+ _this._blurY = blurY;
+ _this._blurYTable = [];
+ _this._lastBlurY = null;
+ _this._quality = isNaN(quality) || quality < 1 ? 1 : quality;
+ _this._lastQuality = null;
+ _this.FRAG_SHADER_TEMPLATE = "\n\t\t\tuniform float xWeight[{{blurX}}];\n\t\t\tuniform float yWeight[{{blurY}}];\n\t\t\tuniform vec2 textureOffset;\n\t\t\tvoid main (void) {\n\t\t\t\tvec4 color = vec4(0.0);\n\n\t\t\t\tfloat xAdj = ({{blurX}}.0-1.0)/2.0;\n\t\t\t\tfloat yAdj = ({{blurY}}.0-1.0)/2.0;\n\t\t\t\tvec2 sampleOffset;\n\n\t\t\t\tfor(int i=0; i<{{blurX}}; i++) {\n\t\t\t\t\tfor(int j=0; j<{{blurY}}; j++) {\n\t\t\t\t\t\tsampleOffset = vRenderCoord + (textureOffset * vec2(float(i)-xAdj, float(j)-yAdj));\n\t\t\t\t\t\tcolor += texture2D(uSampler, sampleOffset) * (xWeight[i] * yWeight[j]);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = color.rgba;\n\t\t\t}\n\t\t";
+ return _this;
+ }
+ var _proto = BlurFilter.prototype;
+ _proto.shaderParamSetup = function shaderParamSetup(gl, stage, shaderProgram) {
+ gl.uniform1fv(gl.getUniformLocation(shaderProgram, "xWeight"), this._blurXTable);
+ gl.uniform1fv(gl.getUniformLocation(shaderProgram, "yWeight"), this._blurYTable);
+ gl.uniform2f(gl.getUniformLocation(shaderProgram, "textureOffset"), 2 / (stage._viewportWidth * this._quality), 2 / (stage._viewportHeight * this._quality));
+ };
+ _proto.getBounds = function getBounds(rect) {
+ var x = this.blurX | 0,
+ y = this.blurY | 0;
+ if (x <= 0 && y <= 0) {
+ return rect;
+ }
+ var q = Math.pow(this.quality, 0.2);
+ return (rect || new Rectangle()).pad(y * q + 1, x * q + 1, y * q + 1, x * q + 1);
+ };
+ _proto.clone = function clone() {
+ return new BlurFilter(this.blurX, this.blurY, this.quality);
+ };
+ _proto._updateShader = function _updateShader() {
+ var result = this.FRAG_SHADER_TEMPLATE;
+ result = result.replace(/{{blurX}}/g, this._blurXTable.length.toFixed(0));
+ result = result.replace(/{{blurY}}/g, this._blurYTable.length.toFixed(0));
+ this.FRAG_SHADER_BODY = result;
+ };
+ _proto._getTable = function _getTable(spread) {
+ var EDGE = 4.2;
+ if (spread <= 1) {
+ return [1];
+ }
+ var result = [];
+ var count = Math.ceil(spread * 2);
+ count += count % 2 ? 0 : 1;
+ var adjust = count / 2 | 0;
+ for (var i = -adjust; i <= adjust; i++) {
+ var x = i / adjust * EDGE;
+ result.push(1 / Math.sqrt(2 * Math.PI) * Math.pow(Math.E, -(Math.pow(x, 2) / 4)));
+ }
+ var factor = result.reduce(function (a, b) {
+ return a + b;
+ }, 0);
+ return result.map(function (currentValue) {
+ return currentValue / factor;
+ });
+ };
+ _proto._applyFilter = function _applyFilter(imageData) {
+ var radiusX = this._blurX >> 1;
+ if (isNaN(radiusX) || radiusX < 0) return false;
+ var radiusY = this._blurY >> 1;
+ if (isNaN(radiusY) || radiusY < 0) return false;
+ if (radiusX === 0 && radiusY === 0) return false;
+ var iterations = this.quality;
+ if (isNaN(iterations) || iterations < 1) iterations = 1;
+ iterations |= 0;
+ if (iterations > 3) iterations = 3;
+ if (iterations < 1) iterations = 1;
+ var px = imageData.data;
+ var x = 0,
+ y = 0,
+ i = 0,
+ p = 0,
+ yp = 0,
+ yi = 0,
+ yw = 0,
+ r = 0,
+ g = 0,
+ b = 0,
+ a = 0,
+ pr = 0,
+ pg = 0,
+ pb = 0,
+ pa = 0;
+ var divx = radiusX + radiusX + 1 | 0;
+ var divy = radiusY + radiusY + 1 | 0;
+ var w = imageData.width | 0;
+ var h = imageData.height | 0;
+ var w1 = w - 1 | 0;
+ var h1 = h - 1 | 0;
+ var rxp1 = radiusX + 1 | 0;
+ var ryp1 = radiusY + 1 | 0;
+ var ssx = {
+ r: 0,
+ b: 0,
+ g: 0,
+ a: 0
+ };
+ var sx = ssx;
+ for (i = 1; i < divx; i++) {
+ sx = sx.n = {
+ r: 0,
+ b: 0,
+ g: 0,
+ a: 0
+ };
+ }
+ sx.n = ssx;
+ var ssy = {
+ r: 0,
+ b: 0,
+ g: 0,
+ a: 0
+ };
+ var sy = ssy;
+ for (i = 1; i < divy; i++) {
+ sy = sy.n = {
+ r: 0,
+ b: 0,
+ g: 0,
+ a: 0
+ };
+ }
+ sy.n = ssy;
+ var si = null;
+ var mtx = BlurFilter.MUL_TABLE[radiusX] | 0;
+ var stx = BlurFilter.SHG_TABLE[radiusX] | 0;
+ var mty = BlurFilter.MUL_TABLE[radiusY] | 0;
+ var sty = BlurFilter.SHG_TABLE[radiusY] | 0;
+ while (iterations-- > 0) {
+ yw = yi = 0;
+ var ms = mtx;
+ var ss = stx;
+ for (y = h; --y > -1;) {
+ r = rxp1 * (pr = px[yi | 0]);
+ g = rxp1 * (pg = px[yi + 1 | 0]);
+ b = rxp1 * (pb = px[yi + 2 | 0]);
+ a = rxp1 * (pa = px[yi + 3 | 0]);
+ sx = ssx;
+ for (i = rxp1; --i > -1;) {
+ sx.r = pr;
+ sx.g = pg;
+ sx.b = pb;
+ sx.a = pa;
+ sx = sx.n;
+ }
+ for (i = 1; i < rxp1; i++) {
+ p = yi + ((w1 < i ? w1 : i) << 2) | 0;
+ r += sx.r = px[p];
+ g += sx.g = px[p + 1];
+ b += sx.b = px[p + 2];
+ a += sx.a = px[p + 3];
+ sx = sx.n;
+ }
+ si = ssx;
+ for (x = 0; x < w; x++) {
+ px[yi++] = r * ms >>> ss;
+ px[yi++] = g * ms >>> ss;
+ px[yi++] = b * ms >>> ss;
+ px[yi++] = a * ms >>> ss;
+ p = yw + ((p = x + radiusX + 1) < w1 ? p : w1) << 2;
+ r -= si.r - (si.r = px[p]);
+ g -= si.g - (si.g = px[p + 1]);
+ b -= si.b - (si.b = px[p + 2]);
+ a -= si.a - (si.a = px[p + 3]);
+ si = si.n;
+ }
+ yw += w;
+ }
+ ms = mty;
+ ss = sty;
+ for (x = 0; x < w; x++) {
+ yi = x << 2 | 0;
+ r = ryp1 * (pr = px[yi]) | 0;
+ g = ryp1 * (pg = px[yi + 1 | 0]) | 0;
+ b = ryp1 * (pb = px[yi + 2 | 0]) | 0;
+ a = ryp1 * (pa = px[yi + 3 | 0]) | 0;
+ sy = ssy;
+ for (i = 0; i < ryp1; i++) {
+ sy.r = pr;
+ sy.g = pg;
+ sy.b = pb;
+ sy.a = pa;
+ sy = sy.n;
+ }
+ yp = w;
+ for (i = 1; i <= radiusY; i++) {
+ yi = yp + x << 2;
+ r += sy.r = px[yi];
+ g += sy.g = px[yi + 1];
+ b += sy.b = px[yi + 2];
+ a += sy.a = px[yi + 3];
+ sy = sy.n;
+ if (i < h1) {
+ yp += w;
+ }
+ }
+ yi = x;
+ si = ssy;
+ if (iterations > 0) {
+ for (y = 0; y < h; y++) {
+ p = yi << 2;
+ px[p + 3] = pa = a * ms >>> ss;
+ if (pa > 0) {
+ px[p] = r * ms >>> ss;
+ px[p + 1] = g * ms >>> ss;
+ px[p + 2] = b * ms >>> ss;
+ } else {
+ px[p] = px[p + 1] = px[p + 2] = 0;
+ }
+ p = x + ((p = y + ryp1) < h1 ? p : h1) * w << 2;
+ r -= si.r - (si.r = px[p]);
+ g -= si.g - (si.g = px[p + 1]);
+ b -= si.b - (si.b = px[p + 2]);
+ a -= si.a - (si.a = px[p + 3]);
+ si = si.n;
+ yi += w;
+ }
+ } else {
+ for (y = 0; y < h; y++) {
+ p = yi << 2;
+ px[p + 3] = pa = a * ms >>> ss;
+ if (pa > 0) {
+ pa = 255 / pa;
+ px[p] = (r * ms >>> ss) * pa;
+ px[p + 1] = (g * ms >>> ss) * pa;
+ px[p + 2] = (b * ms >>> ss) * pa;
+ } else {
+ px[p] = px[p + 1] = px[p + 2] = 0;
+ }
+ p = x + ((p = y + ryp1) < h1 ? p : h1) * w << 2;
+ r -= si.r - (si.r = px[p]);
+ g -= si.g - (si.g = px[p + 1]);
+ b -= si.b - (si.b = px[p + 2]);
+ a -= si.a - (si.a = px[p + 3]);
+ si = si.n;
+ yi += w;
+ }
+ }
+ }
+ }
+ return true;
+ };
+ _createClass(BlurFilter, [{
+ key: "blurX",
+ get: function get() {
+ return this._blurX;
+ },
+ set: function set(blurX) {
+ if (isNaN(blurX) || blurX < 0) {
+ blurX = 0;
+ }
+ this._blurX = blurX;
+ }
+ }, {
+ key: "blurY",
+ get: function get() {
+ return this._blurY;
+ },
+ set: function set(blurY) {
+ if (isNaN(blurY) || blurY < 0) {
+ blurY = 0;
+ }
+ this._blurY = blurY;
+ }
+ }, {
+ key: "quality",
+ get: function get() {
+ return this._quality | 0;
+ },
+ set: function set(quality) {
+ if (isNaN(quality) || quality < 0) {
+ quality = 0;
+ }
+ this._quality = quality;
+ }
+ }, {
+ key: "_buildShader",
+ get: function get() {
+ var xChange = this._lastBlurX !== this._blurX;
+ var yChange = this._lastBlurY !== this._blurY;
+ var qChange = this._lastQuality !== this._quality;
+ if (xChange || yChange || qChange) {
+ if (xChange || qChange) {
+ this._blurXTable = this._getTable(this._blurX * this._quality);
+ }
+ if (yChange || qChange) {
+ this._blurYTable = this._getTable(this._blurY * this._quality);
+ }
+ this._updateShader();
+ this._lastBlurX = this._blurX;
+ this._lastBlurY = this._blurY;
+ this._lastQuality = this._quality;
+ return undefined;
+ }
+ return this._compiledShader;
+ }
+ }, {
+ key: "_builtShader",
+ set: function set(value) {
+ this._compiledShader = value;
+ }
+ }]);
+ return BlurFilter;
+}(Filter);
+BlurFilter.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];
+BlurFilter.SHG_TABLE = [0, 9, 10, 11, 9, 12, 10, 11, 12, 9, 13, 13, 10, 9, 13, 13, 14, 14, 14, 14, 10, 13, 14, 14, 14, 13, 13, 13, 9, 14, 14, 14, 15, 14, 15, 14, 15, 15, 14, 15, 15, 15, 14, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 12, 14, 15, 15, 13, 15, 15, 15, 15, 16, 16, 16, 15, 16, 14, 16, 16, 14, 16, 13, 16, 16, 16, 15, 16, 13, 16, 15, 16, 14, 9, 16, 16, 16, 16, 16, 16, 16, 16, 16, 13, 14, 16, 16, 15, 16, 16, 10, 16, 15, 16, 14, 16, 16, 14, 16, 16, 14, 16, 16, 14, 15, 16, 16, 16, 14, 15, 14, 15, 13, 16, 16, 15, 17, 17, 17, 17, 17, 17, 14, 15, 17, 17, 16, 16, 17, 16, 15, 17, 16, 17, 11, 17, 16, 17, 16, 17, 16, 17, 17, 16, 17, 17, 16, 17, 17, 16, 16, 17, 17, 17, 16, 14, 17, 17, 17, 17, 15, 16, 14, 16, 15, 16, 13, 16, 15, 16, 14, 16, 15, 16, 12, 16, 15, 16, 17, 17, 17, 17, 17, 13, 16, 15, 17, 17, 17, 16, 15, 17, 17, 17, 16, 15, 17, 17, 14, 16, 17, 17, 16, 17, 17, 16, 15, 17, 16, 14, 17, 16, 15, 17, 16, 17, 17, 16, 17, 15, 16, 17, 14, 17, 16, 15, 17, 16, 17, 13, 17, 16, 17, 17, 16, 17, 14, 17, 16, 17, 16, 17, 16, 17, 9];
+
+var ColorFilter =
+function (_Filter) {
+ _inheritsLoose(ColorFilter, _Filter);
+ function ColorFilter(redMultiplier, greenMultiplier, blueMultiplier, alphaMultiplier, redOffset, greenOffset, blueOffset, alphaOffset) {
+ var _this;
+ if (redMultiplier === void 0) {
+ redMultiplier = 1;
+ }
+ if (greenMultiplier === void 0) {
+ greenMultiplier = 1;
+ }
+ if (blueMultiplier === void 0) {
+ blueMultiplier = 1;
+ }
+ if (alphaMultiplier === void 0) {
+ alphaMultiplier = 1;
+ }
+ if (redOffset === void 0) {
+ redOffset = 0;
+ }
+ if (greenOffset === void 0) {
+ greenOffset = 0;
+ }
+ if (blueOffset === void 0) {
+ blueOffset = 0;
+ }
+ if (alphaOffset === void 0) {
+ alphaOffset = 0;
+ }
+ _this = _Filter.call(this) || this;
+ _this.redMultiplier = redMultiplier;
+ _this.greenMultiplier = greenMultiplier;
+ _this.blueMultiplier = blueMultiplier;
+ _this.alphaMultiplier = alphaMultiplier;
+ _this.redOffset = redOffset;
+ _this.greenOffset = greenOffset;
+ _this.blueOffset = blueOffset;
+ _this.alphaOffset = alphaOffset;
+ _this.FRAG_SHADER_BODY = "\n\t\t\tuniform vec4 uColorMultiplier;\n\t\t\tuniform vec4 uColorOffset;\n\n\t\t\tvoid main (void) {\n\t\t\t\tvec4 color = texture2D(uSampler, vRenderCoord);\n\n\t\t\t\tgl_FragColor = (color * uColorMultiplier) + uColorOffset;\n\t\t\t}\n\t\t";
+ return _this;
+ }
+ var _proto = ColorFilter.prototype;
+ _proto.shaderParamSetup = function shaderParamSetup(gl, stage, shaderProgram) {
+ gl.uniform4f(gl.getUniformLocation(shaderProgram, "uColorMultiplier"), this.redMultiplier, this.greenMultiplier, this.blueMultiplier, this.alphaMultiplier);
+ gl.uniform4f(gl.getUniformLocation(shaderProgram, "uColorOffset"), this.redOffset / 255, this.greenOffset / 255, this.blueOffset / 255, this.alphaOffset / 255);
+ };
+ _proto.clone = function clone() {
+ return new ColorFilter(this.redMultiplier, this.greenMultiplier, this.blueMultiplier, this.alphaMultiplier, this.redOffset, this.greenOffset, this.blueOffset, this.alphaOffset);
+ };
+ _proto._applyFilter = function _applyFilter(imageData) {
+ var data = imageData.data;
+ var l = data.length;
+ for (var i = 0; i < l; i += 4) {
+ data[i] = data[i] * this.redMultiplier + this.redOffset;
+ data[i + 1] = data[i + 1] * this.greenMultiplier + this.greenOffset;
+ data[i + 2] = data[i + 2] * this.blueMultiplier + this.blueOffset;
+ data[i + 3] = data[i + 3] * this.alphaMultiplier + this.alphaOffset;
+ }
+ return true;
+ };
+ return ColorFilter;
+}(Filter);
+
+var ColorMatrix =
+function () {
+ function ColorMatrix(brightness, contrast, saturation, hue) {
+ this.setColor(brightness, contrast, saturation, hue);
+ }
+ var _proto = ColorMatrix.prototype;
+ _proto.setColor = function setColor(brightness, contrast, saturation, hue) {
+ return this.reset().adjustColor(brightness, contrast, saturation, hue);
+ };
+ _proto.reset = function reset() {
+ return this.copy(ColorMatrix.IDENTITY_MATRIX);
+ };
+ _proto.adjustColor = function adjustColor(brightness, contrast, saturation, hue) {
+ return this.adjustBrightness(brightness).adjustContrast(contrast).adjustSaturation(saturation).adjustHue(hue);
+ };
+ _proto.adjustBrightness = function adjustBrightness(value) {
+ if (value === 0 || isNaN(value)) {
+ return this;
+ }
+ value = this._cleanValue(value, 255);
+ this._multiplyMatrix([1, 0, 0, 0, value, 0, 1, 0, 0, value, 0, 0, 1, 0, value, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
+ return this;
+ };
+ _proto.adjustContrast = function adjustContrast(value) {
+ if (value === 0 || isNaN(value)) {
+ return this;
+ }
+ value = this._cleanValue(value, 100);
+ var x;
+ if (value < 0) {
+ x = 127 + value / 100 * 127;
+ } else {
+ x = value % 1;
+ if (x === 0) {
+ x = ColorMatrix.DELTA_INDEX[value];
+ } else {
+ x = ColorMatrix.DELTA_INDEX[value << 0] * (1 - x) + ColorMatrix.DELTA_INDEX[(value << 0) + 1] * x;
+ }
+ x = x * 127 + 127;
+ }
+ this._multiplyMatrix([x / 127, 0, 0, 0, 0.5 * (127 - x), 0, x / 127, 0, 0, 0.5 * (127 - x), 0, 0, x / 127, 0, 0.5 * (127 - x), 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
+ return this;
+ };
+ _proto.adjustSaturation = function adjustSaturation(value) {
+ if (value === 0 || isNaN(value)) {
+ return this;
+ }
+ value = this._cleanValue(value, 100);
+ var x = 1 + (value > 0 ? 3 * value / 100 : value / 100);
+ var lumR = 0.3086;
+ var lumG = 0.6094;
+ var lumB = 0.0820;
+ this._multiplyMatrix([lumR * (1 - x) + x, lumG * (1 - x), lumB * (1 - x), 0, 0, lumR * (1 - x), lumG * (1 - x) + x, lumB * (1 - x), 0, 0, lumR * (1 - x), lumG * (1 - x), lumB * (1 - x) + x, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
+ return this;
+ };
+ _proto.adjustHue = function adjustHue(value) {
+ if (value === 0 || isNaN(value)) {
+ return this;
+ }
+ value = this._cleanValue(value, 180) / 180 * Math.PI;
+ var cosVal = Math.cos(value);
+ var sinVal = Math.sin(value);
+ var lumR = 0.213;
+ var lumG = 0.715;
+ var lumB = 0.072;
+ this._multiplyMatrix([lumR + cosVal * (1 - lumR) + sinVal * -lumR, lumG + cosVal * -lumG + sinVal * -lumG, lumB + cosVal * -lumB + sinVal * (1 - lumB), 0, 0, lumR + cosVal * -lumR + sinVal * 0.143, lumG + cosVal * (1 - lumG) + sinVal * 0.140, lumB + cosVal * -lumB + sinVal * -0.283, 0, 0, lumR + cosVal * -lumR + sinVal * -(1 - lumR), lumG + cosVal * -lumG + sinVal * lumG, lumB + cosVal * (1 - lumB) + sinVal * lumB, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
+ return this;
+ };
+ _proto.concat = function concat(matrix) {
+ matrix = this._fixMatrix(matrix);
+ if (matrix.length != ColorMatrix.LENGTH) {
+ return this;
+ }
+ this._multiplyMatrix(matrix);
+ return this;
+ };
+ _proto.clone = function clone() {
+ return new ColorMatrix().copy(this);
+ };
+ _proto.toArray = function toArray() {
+ var arr = [];
+ var l = ColorMatrix.LENGTH;
+ for (var i = 0; i < l; i++) {
+ arr[i] = this[i];
+ }
+ return arr;
+ };
+ _proto.copy = function copy(matrix) {
+ var l = ColorMatrix.LENGTH;
+ for (var i = 0; i < l; i++) {
+ this[i] = matrix[i];
+ }
+ return this;
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + "]";
+ };
+ _proto._multiplyMatrix = function _multiplyMatrix(matrix) {
+ var col = [];
+ for (var i = 0; i < 5; i++) {
+ for (var j = 0; j < 5; j++) {
+ col[j] = this[j + i * 5];
+ }
+ for (var _j = 0; _j < 5; _j++) {
+ var val = 0;
+ for (var k = 0; k < 5; k++) {
+ val += matrix[_j + k * 5] * col[k];
+ }
+ this[_j + i * 5] = val;
+ }
+ }
+ };
+ _proto._cleanValue = function _cleanValue(value, limit) {
+ return Math.min(limit, Math.max(-limit, value));
+ };
+ _proto._fixMatrix = function _fixMatrix(matrix) {
+ if (matrix instanceof ColorMatrix) {
+ matrix = matrix.toArray();
+ }
+ if (matrix.length < ColorMatrix.LENGTH) {
+ matrix = matrix.slice(0, matrix.length).concat(ColorMatrix.IDENTITY_MATRIX.slice(matrix.length, ColorMatrix.LENGTH));
+ } else if (matrix.length > ColorMatrix.LENGTH) {
+ matrix = matrix.slice(0, ColorMatrix.LENGTH);
+ }
+ return matrix;
+ };
+ return ColorMatrix;
+}();
+ColorMatrix.DELTA_INDEX = Object.freeze([0, 0.01, 0.02, 0.04, 0.05, 0.06, 0.07, 0.08, 0.1, 0.11, 0.12, 0.14, 0.15, 0.16, 0.17, 0.18, 0.20, 0.21, 0.22, 0.24, 0.25, 0.27, 0.28, 0.30, 0.32, 0.34, 0.36, 0.38, 0.40, 0.42, 0.44, 0.46, 0.48, 0.5, 0.53, 0.56, 0.59, 0.62, 0.65, 0.68, 0.71, 0.74, 0.77, 0.80, 0.83, 0.86, 0.89, 0.92, 0.95, 0.98, 1.0, 1.06, 1.12, 1.18, 1.24, 1.30, 1.36, 1.42, 1.48, 1.54, 1.60, 1.66, 1.72, 1.78, 1.84, 1.90, 1.96, 2.0, 2.12, 2.25, 2.37, 2.50, 2.62, 2.75, 2.87, 3.0, 3.2, 3.4, 3.6, 3.8, 4.0, 4.3, 4.7, 4.9, 5.0, 5.5, 6.0, 6.5, 6.8, 7.0, 7.3, 7.5, 7.8, 8.0, 8.4, 8.7, 9.0, 9.4, 9.6, 9.8, 10.0]);
+ColorMatrix.IDENTITY_MATRIX = Object.freeze([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]);
+ColorMatrix.LENGTH = 25;
+
+var ColorMatrixFilter =
+function (_Filter) {
+ _inheritsLoose(ColorMatrixFilter, _Filter);
+ function ColorMatrixFilter(matrix) {
+ var _this;
+ _this = _Filter.call(this) || this;
+ _this.matrix = matrix;
+ _this.FRAG_SHADER_BODY = "\n\t\t\tuniform mat4 uColorMatrix;\n\t\t\tuniform vec4 uColorMatrixOffset;\n\n\t\t\tvoid main (void) {\n\t\t\t\tvec4 color = texture2D(uSampler, vRenderCoord);\n\n\t\t\t\tmat4 m = uColorMatrix;\n\t\t\t\tvec4 newColor = vec4(0,0,0,0);\n\t\t\t\tnewColor.r = color.r*m[0][0] + color.g*m[0][1] + color.b*m[0][2] + color.a*m[0][3];\n\t\t\t\tnewColor.g = color.r*m[1][0] + color.g*m[1][1] + color.b*m[1][2] + color.a*m[1][3];\n\t\t\t\tnewColor.b = color.r*m[2][0] + color.g*m[2][1] + color.b*m[2][2] + color.a*m[2][3];\n\t\t\t\tnewColor.a = color.r*m[3][0] + color.g*m[3][1] + color.b*m[3][2] + color.a*m[3][3];\n\n\t\t\t\tgl_FragColor = newColor + uColorMatrixOffset;\n\t\t\t}\n\t\t";
+ return _this;
+ }
+ var _proto = ColorMatrixFilter.prototype;
+ _proto.shaderParamSetup = function shaderParamSetup(gl, stage, shaderProgram) {
+ var mat = this.matrix;
+ var colorMatrix = new Float32Array([mat[0], mat[1], mat[2], mat[3], mat[5], mat[6], mat[7], mat[8], mat[10], mat[11], mat[12], mat[13], mat[15], mat[16], mat[17], mat[18]]);
+ gl.uniformMatrix4fv(gl.getUniformLocation(shaderProgram, "uColorMatrix"), false, colorMatrix);
+ gl.uniform4f(gl.getUniformLocation(shaderProgram, "uColorMatrixOffset"), mat[4] / 255, mat[9] / 255, mat[14] / 255, mat[19] / 255);
+ };
+ _proto.clone = function clone() {
+ return new ColorMatrixFilter(this.matrix);
+ };
+ _proto._applyFilter = function _applyFilter(imageData) {
+ var data = imageData.data;
+ var l = data.length;
+ var r, g, b, a;
+ var mtx = this.matrix;
+ var m0 = mtx[0],
+ m1 = mtx[1],
+ m2 = mtx[2],
+ m3 = mtx[3],
+ m4 = mtx[4];
+ var m5 = mtx[5],
+ m6 = mtx[6],
+ m7 = mtx[7],
+ m8 = mtx[8],
+ m9 = mtx[9];
+ var m10 = mtx[10],
+ m11 = mtx[11],
+ m12 = mtx[12],
+ m13 = mtx[13],
+ m14 = mtx[14];
+ var m15 = mtx[15],
+ m16 = mtx[16],
+ m17 = mtx[17],
+ m18 = mtx[18],
+ m19 = mtx[19];
+ for (var i = 0; i < l; i += 4) {
+ r = data[i];
+ g = data[i + 1];
+ b = data[i + 2];
+ a = data[i + 3];
+ data[i] = r * m0 + g * m1 + b * m2 + a * m3 + m4;
+ data[i + 1] = r * m5 + g * m6 + b * m7 + a * m8 + m9;
+ data[i + 2] = r * m10 + g * m11 + b * m12 + a * m13 + m14;
+ data[i + 3] = r * m15 + g * m16 + b * m17 + a * m18 + m19;
+ }
+ return true;
+ };
+ return ColorMatrixFilter;
+}(Filter);
+
+var ButtonHelper =
+function () {
+ function ButtonHelper(target, outLabel, overLabel, downLabel, play, hitArea, hitLabel) {
+ if (outLabel === void 0) {
+ outLabel = "out";
+ }
+ if (overLabel === void 0) {
+ overLabel = "over";
+ }
+ if (downLabel === void 0) {
+ downLabel = "down";
+ }
+ if (play === void 0) {
+ play = false;
+ }
+ if (!target.addEventListener) {
+ return;
+ }
+ this.target = target;
+ this.overLabel = overLabel;
+ this.outLabel = outLabel;
+ this.downLabel = downLabel == null;
+ this.play = play;
+ this._isPressed = false;
+ this._isOver = false;
+ this._enabled = false;
+ target.mouseChildren = false;
+ this.enabled = true;
+ this.handleEvent({});
+ if (hitArea) {
+ if (hitLabel) {
+ hitArea.actionsEnabled = false;
+ hitArea.gotoAndStop && hitArea.gotoAndStop(hitLabel);
+ }
+ target.hitArea = hitArea;
+ }
+ }
+ var _proto = ButtonHelper.prototype;
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + "]";
+ };
+ _proto.handleEvent = function handleEvent(evt) {
+ var label,
+ t = this.target,
+ type = evt.type;
+ if (type === "mousedown") {
+ this._isPressed = true;
+ label = this.downLabel;
+ } else if (type === "pressup") {
+ this._isPressed = false;
+ label = this._isOver ? this.overLabel : this.outLabel;
+ } else if (type === "rollover") {
+ this._isOver = true;
+ label = this._isPressed ? this.downLabel : this.overLabel;
+ } else {
+ this._isOver = false;
+ label = this._isPressed ? this.overLabel : this.outLabel;
+ }
+ if (this.play) {
+ t.gotoAndPlay && t.gotoAndPlay(label);
+ } else {
+ t.gotoAndStop && t.gotoAndStop(label);
+ }
+ };
+ _proto._reset = function _reset() {
+ var p = this.paused;
+ this.__reset();
+ this.paused = p;
+ };
+ _createClass(ButtonHelper, [{
+ key: "enabled",
+ get: function get() {
+ return this._enabled;
+ },
+ set: function set(enabled) {
+ if (enabled === this._enabled) {
+ return;
+ }
+ var o = this.target;
+ this._enabled = enabled;
+ if (enabled) {
+ o.cursor = "pointer";
+ o.addEventListener("rollover", this);
+ o.addEventListener("rollout", this);
+ o.addEventListener("mousedown", this);
+ o.addEventListener("pressup", this);
+ if (o._reset) {
+ o.__reset = o._reset;
+ o._reset = this._reset;
+ }
+ } else {
+ o.cursor = null;
+ o.removeEventListener("rollover", this);
+ o.removeEventListener("rollout", this);
+ o.removeEventListener("mousedown", this);
+ o.removeEventListener("pressup", this);
+ if (o.__reset) {
+ o._reset = o.__reset;
+ delete o.__reset;
+ }
+ }
+ }
+ }]);
+ return ButtonHelper;
+}();
+
+var Touch = {
+ isSupported: function isSupported() {
+ return !!('ontouchstart' in window ||
+ window.MSPointerEvent && window.navigator.msMaxTouchPoints > 0
+ || window.PointerEvent && window.navigator.maxTouchPoints > 0);
+ },
+ enable: function enable(stage, singleTouch, allowDefault) {
+ if (singleTouch === void 0) {
+ singleTouch = false;
+ }
+ if (allowDefault === void 0) {
+ allowDefault = false;
+ }
+ if (!stage || !stage.canvas || !this.isSupported()) {
+ return false;
+ }
+ if (stage.__touch) {
+ return true;
+ }
+ stage.__touch = {
+ pointers: {},
+ multitouch: !singleTouch,
+ preventDefault: !allowDefault,
+ count: 0
+ };
+ if ('ontouchstart' in window) {
+ this._IOS_enable(stage);
+ } else if (window.PointerEvent || window.MSPointerEvent) {
+ this._IE_enable(stage);
+ }
+ return true;
+ },
+ disable: function disable(stage) {
+ if (!stage) {
+ return;
+ }
+ if ('ontouchstart' in window) {
+ this._IOS_disable(stage);
+ } else if (window.PointerEvent || window.MSPointerEvent) {
+ this._IE_disable(stage);
+ }
+ delete stage.__touch;
+ },
+ _IOS_enable: function _IOS_enable(stage) {
+ var _this = this;
+ var canvas = stage.canvas;
+ var f = stage.__touch.f = function (e) {
+ return _this._IOS_handleEvent(stage, e);
+ };
+ canvas.addEventListener("touchstart", f, false);
+ canvas.addEventListener("touchmove", f, false);
+ canvas.addEventListener("touchend", f, false);
+ canvas.addEventListener("touchcancel", f, false);
+ },
+ _IOS_disable: function _IOS_disable(stage) {
+ var canvas = stage.canvas;
+ if (!canvas) {
+ return;
+ }
+ var f = stage.__touch.f;
+ canvas.removeEventListener("touchstart", f, false);
+ canvas.removeEventListener("touchmove", f, false);
+ canvas.removeEventListener("touchend", f, false);
+ canvas.removeEventListener("touchcancel", f, false);
+ },
+ _IOS_handleEvent: function _IOS_handleEvent(stage, e) {
+ if (!stage) {
+ return;
+ }
+ if (stage.__touch.preventDefault) {
+ e.preventDefault && e.preventDefault();
+ }
+ var touches = e.changedTouches;
+ var type = e.type;
+ var l = touches.length;
+ for (var _iterator = touches, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
+ var _ref;
+ if (_isArray) {
+ if (_i >= _iterator.length) break;
+ _ref = _iterator[_i++];
+ } else {
+ _i = _iterator.next();
+ if (_i.done) break;
+ _ref = _i.value;
+ }
+ var touch = _ref;
+ var id = touch.identifier;
+ if (touch.target != stage.canvas) {
+ continue;
+ }
+ if (type === "touchstart") {
+ this._handleStart(stage, id, e, touch.pageX, touch.pageY);
+ } else if (type === "touchmove") {
+ this._handleMove(stage, id, e, touch.pageX, touch.pageY);
+ } else if (type === "touchend" || type === "touchcancel") {
+ this._handleEnd(stage, id, e);
+ }
+ }
+ },
+ _IE_enable: function _IE_enable(stage) {
+ var _this2 = this;
+ var canvas = stage.canvas;
+ var f = stage.__touch.f = function (e) {
+ return _this2._IE_handleEvent(stage, e);
+ };
+ if (window.PointerEvent === undefined) {
+ canvas.addEventListener("MSPointerDown", f, false);
+ window.addEventListener("MSPointerMove", f, false);
+ window.addEventListener("MSPointerUp", f, false);
+ window.addEventListener("MSPointerCancel", f, false);
+ if (stage.__touch.preventDefault) {
+ canvas.style.msTouchAction = "none";
+ }
+ } else {
+ canvas.addEventListener("pointerdown", f, false);
+ window.addEventListener("pointermove", f, false);
+ window.addEventListener("pointerup", f, false);
+ window.addEventListener("pointercancel", f, false);
+ if (stage.__touch.preventDefault) {
+ canvas.style.touchAction = "none";
+ }
+ }
+ stage.__touch.activeIDs = {};
+ },
+ _IE_disable: function _IE_disable(stage) {
+ var f = stage.__touch.f;
+ if (window.PointerEvent === undefined) {
+ window.removeEventListener("MSPointerMove", f, false);
+ window.removeEventListener("MSPointerUp", f, false);
+ window.removeEventListener("MSPointerCancel", f, false);
+ if (stage.canvas) {
+ stage.canvas.removeEventListener("MSPointerDown", f, false);
+ }
+ } else {
+ window.removeEventListener("pointermove", f, false);
+ window.removeEventListener("pointerup", f, false);
+ window.removeEventListener("pointercancel", f, false);
+ if (stage.canvas) {
+ stage.canvas.removeEventListener("pointerdown", f, false);
+ }
+ }
+ },
+ _IE_handleEvent: function _IE_handleEvent(stage, e) {
+ if (!stage) {
+ return;
+ }
+ if (stage.__touch.preventDefault) {
+ e.preventDefault && e.preventDefault();
+ }
+ var type = e.type;
+ var id = e.pointerId;
+ var ids = stage.__touch.activeIDs;
+ if (type === "MSPointerDown" || type === "pointerdown") {
+ if (e.srcElement != stage.canvas) {
+ return;
+ }
+ ids[id] = true;
+ this._handleStart(stage, id, e, e.pageX, e.pageY);
+ } else if (ids[id]) {
+ if (type === "MSPointerMove" || type === "pointermove") {
+ this._handleMove(stage, id, e, e.pageX, e.pageY);
+ } else if (type === "MSPointerUp" || type === "MSPointerCancel" || type === "pointerup" || type === "pointercancel") {
+ delete ids[id];
+ this._handleEnd(stage, id, e);
+ }
+ }
+ },
+ _handleStart: function _handleStart(stage, id, e, x, y) {
+ var props = stage.__touch;
+ if (!props.multitouch && props.count) {
+ return;
+ }
+ var ids = props.pointers;
+ if (ids[id]) {
+ return;
+ }
+ ids[id] = true;
+ props.count++;
+ stage._handlePointerDown(id, e, x, y);
+ },
+ _handleMove: function _handleMove(stage, id, e, x, y) {
+ if (!stage.__touch.pointers[id]) {
+ return;
+ }
+ stage._handlePointerMove(id, e, x, y);
+ },
+ _handleEnd: function _handleEnd(stage, id, e) {
+ var props = stage.__touch;
+ var ids = props.pointers;
+ if (!ids[id]) {
+ return;
+ }
+ props.count--;
+ stage._handlePointerUp(id, e, true);
+ delete ids[id];
+ }
+};
+
+var SpriteSheetBuilder =
+function (_EventDispatcher) {
+ _inheritsLoose(SpriteSheetBuilder, _EventDispatcher);
+ function SpriteSheetBuilder(framerate) {
+ var _this;
+ if (framerate === void 0) {
+ framerate = 0;
+ }
+ _this = _EventDispatcher.call(this) || this;
+ _this.maxWidth = 2048;
+ _this.maxHeight = 2048;
+ _this.spriteSheet = null;
+ _this.scale = 1;
+ _this.padding = 1;
+ _this.timeSlice = 0.3;
+ _this.progress = -1;
+ _this.framerate = framerate;
+ _this._frames = [];
+ _this._animations = {};
+ _this._data = null;
+ _this._nextFrameIndex = 0;
+ _this._index = 0;
+ _this._timerID = null;
+ _this._scale = 1;
+ return _this;
+ }
+ var _proto = SpriteSheetBuilder.prototype;
+ _proto.addFrame = function addFrame(source, sourceRect, scale, setupFunction, setupData) {
+ if (scale === void 0) {
+ scale = 1;
+ }
+ if (this._data) {
+ throw SpriteSheetBuilder.ERR_RUNNING;
+ }
+ var rect = sourceRect || source.bounds || source.nominalBounds || source.getBounds && source.getBounds();
+ if (!rect) {
+ return null;
+ }
+ return this._frames.push({
+ source: source,
+ sourceRect: rect,
+ scale: scale,
+ funct: setupFunction,
+ data: setupData,
+ index: this._frames.length,
+ height: rect.height * scale
+ }) - 1;
+ };
+ _proto.addAnimation = function addAnimation(name, frames, next, speed) {
+ if (this._data) {
+ throw SpriteSheetBuilder.ERR_RUNNING;
+ }
+ this._animations[name] = {
+ frames: frames,
+ next: next,
+ speed: speed
+ };
+ };
+ _proto.addMovieClip = function addMovieClip(source, sourceRect, scale, setupFunction, setupData, labelFunction) {
+ if (scale === void 0) {
+ scale = 1;
+ }
+ if (this._data) {
+ throw SpriteSheetBuilder.ERR_RUNNING;
+ }
+ var rects = source.frameBounds;
+ var rect = sourceRect || source.bounds || source.nominalBounds || source.getBounds && source.getBounds();
+ if (!rect && !rects) {
+ return;
+ }
+ var baseFrameIndex = this._frames.length;
+ var duration = source.timeline.duration;
+ for (var i = 0; i < duration; i++) {
+ var r = rects && rects[i] ? rects[i] : rect;
+ this.addFrame(source, r, scale, this._setupMovieClipFrame, {
+ i: i,
+ f: setupFunction,
+ d: setupData
+ });
+ }
+ var labels = source.timeline._labels;
+ var lbls = [];
+ for (var n in labels) {
+ lbls.push({
+ index: labels[n],
+ label: n
+ });
+ }
+ if (lbls.length) {
+ lbls.sort(function (a, b) {
+ return a.index - b.index;
+ });
+ for (var _i = 0, l = lbls.length; _i < l; _i++) {
+ var label = lbls[_i].label;
+ var start = baseFrameIndex + lbls[_i].index;
+ var end = baseFrameIndex + (_i === l - 1 ? duration : lbls[_i + 1].index);
+ var frames = [];
+ for (var _i2 = start; _i2 < end; _i2++) {
+ frames.push(_i2);
+ }
+ if (labelFunction) {
+ label = labelFunction(label, source, start, end);
+ if (!label) {
+ continue;
+ }
+ }
+ this.addAnimation(label, frames, true);
+ }
+ }
+ };
+ _proto.build = function build() {
+ if (this._data) {
+ throw SpriteSheetBuilder.ERR_RUNNING;
+ }
+ this._startBuild();
+ while (this._drawNext()) {}
+ this._endBuild();
+ return this.spriteSheet;
+ };
+ _proto.buildAsync = function buildAsync(timeSlice) {
+ var _this2 = this;
+ if (this._data) {
+ throw SpriteSheetBuilder.ERR_RUNNING;
+ }
+ this.timeSlice = timeSlice;
+ this._startBuild();
+ this._timerID = setTimeout(function () {
+ return _this2._run();
+ }, 50 - Math.max(0.01, Math.min(0.99, this.timeSlice || 0.3)) * 50);
+ };
+ _proto.stopAsync = function stopAsync() {
+ clearTimeout(this._timerID);
+ this._data = null;
+ };
+ _proto.toString = function toString() {
+ return "[" + this.constructor.name + "]";
+ };
+ _proto._startBuild = function _startBuild() {
+ var pad = this.padding || 0;
+ this.progress = 0;
+ this.spriteSheet = null;
+ this._index = 0;
+ this._scale = this.scale;
+ var dataFrames = [];
+ this._data = {
+ images: [],
+ frames: dataFrames,
+ framerate: this.framerate,
+ animations: this._animations
+ };
+ var frames = this._frames.slice();
+ frames.sort(function (a, b) {
+ return a.height <= b.height ? -1 : 1;
+ });
+ if (frames[frames.length - 1].height + pad * 2 > this.maxHeight) {
+ throw SpriteSheetBuilder.ERR_DIMENSIONS;
+ }
+ var y = 0,
+ x = 0;
+ var img = 0;
+ while (frames.length) {
+ var o = this._fillRow(frames, y, img, dataFrames, pad);
+ if (o.w > x) {
+ x = o.w;
+ }
+ y += o.h;
+ if (!o.h || !frames.length) {
+ var canvas = window.createjs && createjs.createCanvas ? createjs.createCanvas() : document.createElement("canvas");
+ canvas.width = this._getSize(x, this.maxWidth);
+ canvas.height = this._getSize(y, this.maxHeight);
+ this._data.images[img] = canvas;
+ if (!o.h) {
+ x = y = 0;
+ img++;
+ }
+ }
+ }
+ };
+ _proto._setupMovieClipFrame = function _setupMovieClipFrame(source, data) {
+ var ae = source.actionsEnabled;
+ source.actionsEnabled = false;
+ source.gotoAndStop(data.i);
+ source.actionsEnabled = ae;
+ data.f && data.f(source, data.d, data.i);
+ };
+ _proto._getSize = function _getSize(size, max) {
+ var pow = 4;
+ while (Math.pow(2, ++pow) < size) {}
+ return Math.min(max, Math.pow(2, pow));
+ };
+ _proto._fillRow = function _fillRow(frames, y, img, dataFrames, pad) {
+ var w = this.maxWidth;
+ var maxH = this.maxHeight;
+ y += pad;
+ var h = maxH - y;
+ var x = pad;
+ var height = 0;
+ for (var i = frames.length - 1; i >= 0; i--) {
+ var frame = frames[i];
+ var sc = this._scale * frame.scale;
+ var rect = frame.sourceRect;
+ var source = frame.source;
+ var rx = Math.floor(sc * rect.x - pad);
+ var ry = Math.floor(sc * rect.y - pad);
+ var rh = Math.ceil(sc * rect.height + pad * 2);
+ var rw = Math.ceil(sc * rect.width + pad * 2);
+ if (rw > w) {
+ throw SpriteSheetBuilder.ERR_DIMENSIONS;
+ }
+ if (rh > h || x + rw > w) {
+ continue;
+ }
+ frame.img = img;
+ frame.rect = new Rectangle(x, y, rw, rh);
+ height = height || rh;
+ frames.splice(i, 1);
+ dataFrames[frame.index] = [x, y, rw, rh, img, Math.round(-rx + sc * source.regX - pad), Math.round(-ry + sc * source.regY - pad)];
+ x += rw;
+ }
+ return {
+ w: x,
+ h: height
+ };
+ };
+ _proto._endBuild = function _endBuild() {
+ this.spriteSheet = new SpriteSheet(this._data);
+ this._data = null;
+ this.progress = 1;
+ this.dispatchEvent("complete");
+ };
+ _proto._run = function _run() {
+ var _this3 = this;
+ var ts = Math.max(0.01, Math.min(0.99, this.timeSlice || 0.3)) * 50;
+ var t = new Date().getTime() + ts;
+ var complete = false;
+ while (t > new Date().getTime()) {
+ if (!this._drawNext()) {
+ complete = true;
+ break;
+ }
+ }
+ if (complete) {
+ this._endBuild();
+ } else {
+ this._timerID = setTimeout(function () {
+ return _this3._run();
+ }, 50 - ts);
+ }
+ var p = this.progress = this._index / this._frames.length;
+ if (this.hasEventListener("progress")) {
+ var evt = new Event("progress");
+ evt.progress = p;
+ this.dispatchEvent(evt);
+ }
+ };
+ _proto._drawNext = function _drawNext() {
+ var frame = this._frames[this._index];
+ var sc = frame.scale * this._scale;
+ var rect = frame.rect;
+ var sourceRect = frame.sourceRect;
+ var canvas = this._data.images[frame.img];
+ var ctx = canvas.getContext("2d");
+ frame.funct && frame.funct(frame.source, frame.data);
+ ctx.save();
+ ctx.beginPath();
+ ctx.rect(rect.x, rect.y, rect.width, rect.height);
+ ctx.clip();
+ ctx.translate(Math.ceil(rect.x - sourceRect.x * sc), Math.ceil(rect.y - sourceRect.y * sc));
+ ctx.scale(sc, sc);
+ frame.source.draw(ctx);
+ ctx.restore();
+ return ++this._index < this._frames.length;
+ };
+ return SpriteSheetBuilder;
+}(EventDispatcher);
+SpriteSheetBuilder.ERR_DIMENSIONS = "frame dimensions exceed max spritesheet dimensions";
+SpriteSheetBuilder.ERR_RUNNING = "a build is already running";
+
+var SpriteSheetUtils = {
+ _workingCanvas: createCanvas(),
+ get _workingContext() {
+ return this._workingCanvas.getContext("2d");
+ },
+ extractFrame: function extractFrame(spriteSheet, frameOrAnimation) {
+ if (isNaN(frameOrAnimation)) {
+ frameOrAnimation = spriteSheet.getAnimation(frameOrAnimation).frames[0];
+ }
+ var data = spriteSheet.getFrame(frameOrAnimation);
+ if (!data) {
+ return null;
+ }
+ var r = data.rect;
+ var canvas = this._workingCanvas;
+ canvas.width = r.width;
+ canvas.height = r.height;
+ this._workingContext.drawImage(data.image, r.x, r.y, r.width, r.height, 0, 0, r.width, r.height);
+ var img = document.createElement("img");
+ img.src = canvas.toDataURL("image/png");
+ return img;
+ },
+ _flip: function _flip(spriteSheet, count, h, v) {
+ var imgs = spriteSheet._images;
+ var canvas = this._workingCanvas;
+ var ctx = this._workingContext;
+ var il = imgs.length / count;
+ for (var i = 0; i < il; i++) {
+ var src = imgs[i];
+ src.__tmp = i;
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
+ ctx.clearRect(0, 0, canvas.width + 1, canvas.height + 1);
+ canvas.width = src.width;
+ canvas.height = src.height;
+ ctx.setTransform(h ? -1 : 1, 0, 0, v ? -1 : 1, h ? src.width : 0, v ? src.height : 0);
+ ctx.drawImage(src, 0, 0);
+ var img = document.createElement("img");
+ img.src = canvas.toDataURL("image/png");
+ img.width = src.width || src.naturalWidth;
+ img.height = src.height || src.naturalHeight;
+ imgs.push(img);
+ }
+ var frames = spriteSheet._frames;
+ var fl = frames.length / count;
+ for (var _i = 0; _i < fl; _i++) {
+ var _src = frames[_i];
+ var rect = _src.rect.clone();
+ var _img = imgs[_src.image.__tmp + il * count];
+ var frame = {
+ image: _img,
+ rect: rect,
+ regX: _src.regX,
+ regY: _src.regY
+ };
+ if (h) {
+ rect.x = (_img.width || _img.naturalWidth) - rect.x - rect.width;
+ frame.regX = rect.width - _src.regX;
+ }
+ if (v) {
+ rect.y = (_img.height || _img.naturalHeight) - rect.y - rect.height;
+ frame.regY = rect.height - _src.regY;
+ }
+ frames.push(frame);
+ }
+ var sfx = "_" + (h ? "h" : "") + (v ? "v" : "");
+ var names = spriteSheet._animations;
+ var data = spriteSheet._data;
+ var al = names.length / count;
+ for (var _i2 = 0; _i2 < al; _i2++) {
+ var name = names[_i2];
+ var _src2 = data[name];
+ var anim = {
+ name: name + sfx,
+ speed: _src2.speed,
+ next: _src2.next,
+ frames: []
+ };
+ if (_src2.next) {
+ anim.next += sfx;
+ }
+ var _frames = _src2.frames;
+ for (var _i3 = 0, l = _frames.length; _i3 < l; _i3++) {
+ anim.frames.push(_frames[_i3] + fl * count);
+ }
+ data[anim.name] = anim;
+ names.push(anim.name);
+ }
+ }
+};
+
+var WebGLInspector =
+function (_EventDispatcher) {
+ _inheritsLoose(WebGLInspector, _EventDispatcher);
+ function WebGLInspector(stage) {
+ var _this;
+ _this = _EventDispatcher.call(this) || this;
+ _this._stage = stage;
+ return _this;
+ }
+ WebGLInspector.dispProps = function dispProps(item, prepend) {
+ if (prepend === void 0) {
+ prepend = "";
+ }
+ var p = "\tP: " + item.x.toFixed(2) + "x" + item.y.toFixed(2) + "\t";
+ var r = "\tR: " + item.regX.toFixed(2) + "x" + item.regY.toFixed(2) + "\t";
+ WebGLInspector._log(prepend, item.toString() + "\t", p, r);
+ };
+ WebGLInspector._log = function _log() {
+ if (WebGLInspector.alternateOutput) {
+ var _WebGLInspector$alter;
+ (_WebGLInspector$alter = WebGLInspector.alternateOutput).log.apply(_WebGLInspector$alter, arguments);
+ } else {
+ var _console;
+ (_console = console).log.apply(_console, arguments);
+ }
+ };
+ var _proto = WebGLInspector.prototype;
+ _proto.log = function log(stage) {
+ if (!stage) {
+ stage = this._stage;
+ }
+ WebGLInspector._log("Batches Per Draw: " + (stage._batchID / stage._drawID).toFixed(4));
+ this.logContextInfo(stage._webGLContext);
+ this.logDepth(stage.children, "");
+ this.logTextureFill(stage);
+ };
+ _proto.toggleGPUDraw = function toggleGPUDraw(stage, enabled) {
+ if (!stage) {
+ stage = this._stage;
+ }
+ if (enabled === undefined) {
+ enabled = !!stage._drawBuffers_;
+ }
+ if (enabled && stage._drawBuffers_) {
+ stage._drawBuffers = stage._drawBuffers_;
+ stage._drawBuffers_ = undefined;
+ } else {
+ stage._drawBuffers_ = stage._drawBuffers;
+ stage._drawBuffers = function _inspectorDrawBuffers(gl) {
+ if (this.vocalDebug) {
+ WebGLInspector._log("BlankDraw[" + this._drawID + ":" + this._batchID + "] : " + this.batchReason);
+ }
+ };
+ }
+ };
+ _proto.logDepth = function logDepth(children, prepend, logFunc) {
+ if (prepend === void 0) {
+ prepend = "";
+ }
+ if (logFunc === void 0) {
+ logFunc = WebGLInspector._log;
+ }
+ if (!children) {
+ children = this._stage.children;
+ }
+ var l = children.length;
+ for (var i = 0; i < l; i++) {
+ var child = children[i];
+ logFunc(prepend + "-", child);
+ if (child.children && child.children.length) {
+ this.logDepth(child.children, "|" + prepend, logFunc);
+ }
+ }
+ };
+ _proto.logContextInfo = function logContextInfo(gl) {
+ if (!gl) {
+ gl = this._stage._webGLContext;
+ }
+ var data = "\n\t\t\t== LOG:\n\n\t\t\tMax textures per draw: " + gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS) + "\n\n\t\t\tMax textures active: " + gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS) + "\n\n\t\t\t\n\n\t\t\tMax texture size: " + gl.getParameter(gl.MAX_TEXTURE_SIZE) / 2 + "\n\n\t\t\tMax cache size: " + gl.getParameter(gl.MAX_RENDERBUFFER_SIZE) / 2 + "\n\n\t\t\t\n\n\t\t\tMax attributes per vertex: " + gl.getParameter(gl.MAX_VERTEX_ATTRIBS) + "\n\n\t\t\tWebGL Version string: " + gl.getParameter(gl.VERSION) + "\n\n\t\t\t======\n\t\t";
+ WebGLInspector._log(data);
+ };
+ _proto.logTextureFill = function logTextureFill(stage) {
+ if (!stage) {
+ stage = this._stage;
+ }
+ var dict = stage._textureDictionary;
+ var count = stage._batchTextureCount;
+ WebGLInspector._log(textureMax + ": " + count);
+ var output = [];
+ for (var n in dict) {
+ var str = n.replace(window.location.origin, "");
+ var tex = dict[n];
+ var shifted = tex._lastActiveIndex ? tex._lastActiveIndex === tex._activeIndex : false;
+ output.push({
+ src: src,
+ element: tex,
+ shifted: shifted
+ });
+ tex._lastActiveIndex = tex._activeIndex;
+ }
+ output.sort(function (a, b) {
+ if (a.element._drawID === stage._drawID) {
+ return 1;
+ }
+ if (a.element._drawID < b.element._drawID) {
+ return -1;
+ }
+ return 0;
+ });
+ var l = output.length;
+ for (var i = 0; i < l; i++) {
+ var out = output[i];
+ var active = out.element._drawID === stage._drawID;
+ WebGLInspector._log("[" + out.src + "] " + (active ? "ACTIVE" : "stale") + " " + (out.shifted ? "steady" : "DRIFT"), out.element);
+ }
+ };
+ return WebGLInspector;
+}(EventDispatcher);
+WebGLInspector.alternateOutput = null;
+
+exports.Event = Event;
+exports.EventDispatcher = EventDispatcher;
+exports.Ticker = Ticker;
+exports.StageGL = StageGL;
+exports.Stage = Stage;
+exports.Container = Container;
+exports.DisplayObject = DisplayObject;
+exports.Bitmap = Bitmap;
+exports.BitmapText = BitmapText;
+exports.DOMElement = DOMElement;
+exports.Graphics = Graphics;
+exports.MovieClip = MovieClip;
+exports.Shadow = Shadow;
+exports.Shape = Shape;
+exports.Sprite = Sprite;
+exports.SpriteSheet = SpriteSheet;
+exports.Text = Text;
+exports.MouseEvent = MouseEvent;
+exports.AlphaMapFilter = AlphaMapFilter;
+exports.AlphaMaskFilter = AlphaMaskFilter;
+exports.BitmapCache = BitmapCache;
+exports.BlurFilter = BlurFilter;
+exports.ColorFilter = ColorFilter;
+exports.ColorMatrix = ColorMatrix;
+exports.ColorMatrixFilter = ColorMatrixFilter;
+exports.Filter = Filter;
+exports.DisplayProps = DisplayProps;
+exports.Matrix2D = Matrix2D;
+exports.Point = Point;
+exports.Rectangle = Rectangle;
+exports.ButtonHelper = ButtonHelper;
+exports.Touch = Touch;
+exports.SpriteSheetBuilder = SpriteSheetBuilder;
+exports.SpriteSheetUtils = SpriteSheetUtils;
+exports.uid = uid;
+exports.createCanvas = createCanvas;
+exports.WebGLInspector = WebGLInspector;
+
+
+ var cjs = window.createjs = window.createjs || {};
+ var v = cjs.v = cjs.v || {};
+
+v.easeljs = "NEXT";
+//# sourceMappingURL=easeljs.cjs.js.map
diff --git a/dist/easeljs.cjs.js.map b/dist/easeljs.cjs.js.map
new file mode 100644
index 000000000..66ee8ae11
--- /dev/null
+++ b/dist/easeljs.cjs.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"easeljs.cjs.js","sources":["../../core/src/events/Event.js","../../core/src/events/EventDispatcher.js","../../core/src/utils/Ticker.js","../src/display/StageGL.js","../src/display/Shadow.js","../src/utils/uid.js","../src/geom/Point.js","../src/geom/Matrix2D.js","../src/geom/DisplayProps.js","../src/geom/Rectangle.js","../src/filters/Filter.js","../src/filters/BitmapCache.js","../src/display/DisplayObject.js","../src/display/Container.js","../src/events/MouseEvent.js","../src/display/Stage.js","../src/utils/Canvas.js","../src/utils/VideoBuffer.js","../src/display/Bitmap.js","../src/display/Sprite.js","../src/display/BitmapText.js","../src/display/DOMElement.js","../src/display/Graphics.js","../src/display/MovieClip.js","../src/display/Shape.js","../src/display/SpriteSheet.js","../src/display/Text.js","../src/filters/AlphaMapFilter.js","../src/filters/AlphaMaskFilter.js","../src/filters/BlurFilter.js","../src/filters/ColorFilter.js","../src/filters/ColorMatrix.js","../src/filters/ColorMatrixFilter.js","../src/ui/ButtonHelper.js","../src/ui/Touch.js","../src/utils/SpriteSheetBuilder.js","../src/utils/SpriteSheetUtils.js","../src/utils/WebGLInspector.js"],"sourcesContent":["/**\n * @license Event\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * Contains properties and methods shared by all events for use with {@link core.EventDispatcher}.\n * Note that Event objects are often reused, so you should never\n * rely on an event object's state outside of the call stack it was received in.\n *\n * @memberof core\n * @example\n * const evt = new Event(\"myEvent\");\n * const dispatcher = new EventDispatcher();\n * dispatcher.on(\"myEvent\", event => console.log(event.type));\n * dispatcher.dispatchEvent(evt); // logs \"myEvent\"\n *\n * @param {string} type The event type.\n * @param {boolean} [bubbles=false] Indicates whether the event will bubble through the display list.\n * @param {boolean} [cancelable=false] Indicates whether the default behaviour of this event can be cancelled.\n */\nclass Event {\n\n\tconstructor (type, bubbles = false, cancelable = false) {\n\t\t/**\n\t\t * The type of event.\n\t\t * @type string\n\t\t */\n\t\tthis.type = type;\n\n\t\t/**\n\t\t * The object that generated an event.\n\t\t *\n\t\t * @type Object\n\t\t * @default null\n\t\t * @readonly\n\t\t */\n\t\tthis.target = null;\n\n\t\t/**\n\t\t * The current target that a bubbling event is being dispatched from. For non-bubbling events, this will\n\t\t * always be the same as target. For example, if childObj.parent = parentObj, and a bubbling event\n\t\t * is generated from childObj, then a listener on parentObj would receive the event with\n\t\t * target=childObj (the original target) and currentTarget=parentObj (where the listener was added).\n\t\t *\n\t\t * @type Object\n\t\t * @default null\n\t\t * @readonly\n\t\t */\n\t\tthis.currentTarget = null;\n\n\t\t/**\n\t\t * For bubbling events, this indicates the current event phase:\n\t\t * \n\t\t * \t
capture phase: starting from the top parent to the target
\n\t\t * \t
at target phase: currently being dispatched from the target
\n\t\t * \t
bubbling phase: from the target to the top parent
\n\t\t * \n\t\t *\n\t\t * @type number\n\t\t * @default 0\n\t\t * @readonly\n\t\t */\n\t\tthis.eventPhase = 0;\n\n\t\t/**\n\t\t * Indicates whether the event will bubble through the display list.\n\t\t *\n\t\t * @type boolean\n\t\t * @readonly\n\t\t */\n\t\tthis.bubbles = bubbles;\n\n\t\t/**\n\t\t * Indicates whether the default behaviour of this event can be cancelled via {@link core.Event#preventDefault}.\n\t\t *\n\t\t * @type boolean\n\t\t * @readonly\n\t\t */\n\t\tthis.cancelable = cancelable;\n\n\t\t/**\n\t\t * The epoch time at which this event was created.\n\t\t *\n\t\t * @type number\n\t\t * @readonly\n\t\t */\n\t\tthis.timeStamp = new Date().getTime();\n\n\t\t/**\n\t\t * Indicates if {@link core.Event#preventDefault} has been called on this event.\n\t\t *\n\t\t * @type boolean\n\t\t * @default false\n\t\t * @readonly\n\t\t */\n\t\tthis.defaultPrevented = false;\n\n\t\t/**\n\t\t * Indicates if {@link core.Event#stopPropagation} or {@link core.Event#stopImmediatePropagation} has been called on this event.\n\t\t *\n\t\t * @type boolean\n\t\t * @default false\n\t\t * @readonly\n\t\t */\n\t\tthis.propagationStopped = false;\n\n\t\t/**\n\t\t * Indicates if {@link core.Event#stopImmediatePropagation} has been called on this event.\n\t\t *\n\t\t * @type boolean\n\t\t * @default false\n\t\t * @readonly\n\t\t */\n\t\tthis.immediatePropagationStopped = false;\n\n\t\t/**\n\t\t * Indicates if {@link core.Event#remove} has been called on this event.\n\t\t *\n\t\t * @type boolean\n\t\t * @default false\n\t\t * @readonly\n\t\t */\n\t\tthis.removed = false;\n\t}\n\n\t/**\n\t * Sets {@link core.Event#defaultPrevented} to true if the event is cancelable.\n\t * Mirrors the DOM level 2 event standard. In general, cancelable events that have `preventDefault()` called will\n\t * cancel the default behaviour associated with the event.\n\t * @return {core.Event} this, chainable\n\t */\n\tpreventDefault () {\n\t\tthis.defaultPrevented = this.cancelable;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets {@link core.Event#propagationStopped} to true.\n\t * Mirrors the DOM event standard.\n\t * @return {core.Event} this, chainable\n\t */\n\tstopPropagation () {\n\t\tthis.propagationStopped = true;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets {@link core.Event#propagationStopped} and {@link core.Event#immediatePropagationStopped} to true.\n\t * Mirrors the DOM event standard.\n\t * @return {core.Event} this, chainable\n\t */\n\tstopImmediatePropagation () {\n\t\tthis.immediatePropagationStopped = this.propagationStopped = true;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Causes the active listener to be removed via removeEventListener();\n\t *\n\t * @example\n\t * myBtn.addEventListener(\"click\", event => {\n\t * event.remove(); // removes this listener.\n\t * });\n\t *\n\t * @return {core.Event} this, chainable\n\t */\n\tremove () {\n\t\tthis.removed = true;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns a clone of the Event instance.\n\t *\n\t * @return {core.Event} a clone of the Event instance.\n\t */\n\tclone () {\n\t\tconst event = new Event(this.type, this.bubbles, this.cancelable);\n\t\tfor (let n in this) {\n\t\t\tif (this.hasOwnProperty(n)) {\n\t\t\t\tevent[n] = this[n];\n\t\t\t}\n\t\t}\n\t\treturn event;\n\t}\n\n\t/**\n\t * Provides a return {core.Event} this, chainable shortcut method for setting a number of properties on the instance.\n\t *\n\t * @param {Object} props A generic object containing properties to copy to the instance.\n\t * @return {core.Event} this, chainable\n\t */\n\tset (props) {\n\t\tfor (let n in props) { this[n] = props[n]; }\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t *\n\t * @return {string} A string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name} (type=${this.type})]`;\n\t}\n\n}\n\nexport default Event;\n","/**\n * @license EventDispatcher\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Event from \"./Event\";\n\n/**\n * EventDispatcher provides methods for managing queues of event listeners and dispatching events.\n *\n * You can either extend EventDispatcher or mix its methods into an existing prototype or instance by using the\n * EventDispatcher {@link core.EventDispatcher.initialize} method.\n *\n * Together with the CreateJS Event class, EventDispatcher provides an extended event model that is based on the\n * DOM Level 2 event model, including addEventListener, removeEventListener, and dispatchEvent. It supports\n * bubbling / capture, preventDefault, stopPropagation, stopImmediatePropagation, and handleEvent.\n *\n * EventDispatcher also exposes a {@link core.EventDispatcher#on} method, which makes it easier\n * to create scoped listeners, listeners that only run once, and listeners with associated arbitrary data. The\n * {@link core.EventDispatcher#off} method is merely an alias to {@link core.EventDispatcher#removeEventListener}.\n *\n * Another addition to the DOM Level 2 model is the {@link core.EventDispatcher#removeAllEventListeners}\n * method, which can be used to listeners for all events, or listeners for a specific event. The Event object also\n * includes a {@link core.Event#remove} method which removes the active listener.\n *\n * @memberof core\n * @example\n * // add EventDispatcher capabilities to the \"MyClass\" class.\n * EventDispatcher.initialize(MyClass.prototype);\n *\n * // Add an event.\n * instance.addEventListener(\"eventName\", event => console.log(event.target + \" was clicked.\"));\n *\n * // scope (\"this\") can be be a challenge with events.\n * // using the {@link core.EventDispatcher#on} method to subscribe to events simplifies this.\n * instance.addEventListener(\"click\", event => console.log(instance === this)); // false, scope is ambiguous.\n * instance.on(\"click\", event => console.log(instance === this)); // true, `on` uses dispatcher scope by default.\n */\nclass EventDispatcher {\n\n\t/**\n\t * Static initializer to mix EventDispatcher methods into a target object or prototype.\n\t *\n\t * @static\n\t * @example\n\t * EventDispatcher.initialize(MyClass.prototype); // add to the prototype of the class\n\t * EventDispatcher.initialize(myInstance); // add to a specific instance\n\t *\n\t * @param {Object} target The target object to inject EventDispatcher methods into.\n\t */\n\tstatic initialize (target) {\n\t\tconst p = EventDispatcher.prototype;\n\t\ttarget.addEventListener = p.addEventListener;\n\t\ttarget.on = p.on;\n\t\ttarget.removeEventListener = target.off = p.removeEventListener;\n\t\ttarget.removeAllEventListeners = p.removeAllEventListeners;\n\t\ttarget.hasEventListener = p.hasEventListener;\n\t\ttarget.dispatchEvent = p.dispatchEvent;\n\t\ttarget._dispatchEvent = p._dispatchEvent;\n\t\ttarget.willTrigger = p.willTrigger;\n\t}\n\n\tconstructor () {\n\t\t/**\n\t\t * @private\n\t\t * @default null\n\t\t * @type Object\n\t\t */\n\t\tthis._listeners = null;\n\n\t\t/**\n\t\t * @private\n\t\t * @default null\n\t\t * @type Object\n\t\t */\n\t\tthis._captureListeners = null;\n\t}\n\n\t/**\n\t * Adds the specified event listener. Note that adding multiple listeners to the same function will result in\n\t * multiple callbacks getting fired.\n\t *\n\t * @example\n\t * displayObject.addEventListener(\"click\", event => console.log('clicked', event));\n\t *\n\t * @param {string} type The string type of the event.\n\t * @param {Function|Object} listener An object with a handleEvent method, or a function that will be called when the event is dispatched.\n\t * @param {boolean} [useCapture=false] For events that bubble, indicates whether to listen for the event in the capture or bubbling/target phase.\n\t * @return {Function|Object} Returns the listener for chaining or assignment.\n\t */\n\taddEventListener (type, listener, useCapture = false) {\n\t\tlet listeners;\n\t\tif (useCapture) {\n\t\t\tlisteners = this._captureListeners = this._captureListeners || {};\n\t\t} else {\n\t\t\tlisteners = this._listeners = this._listeners || {};\n\t\t}\n\t\tlet arr = listeners[type];\n\t\tif (arr) {\n\t\t\tthis.removeEventListener(type, listener, useCapture);\n\t\t\tarr = listeners[type]; // remove may have deleted the array\n\t\t}\n\t\tif (arr) { arr.push(listener); }\n\t\telse { listeners[type] = [listener]; }\n\t\treturn listener;\n\t}\n\n\t/**\n\t * A shortcut method for using addEventListener that makes it easier to specify an execution scope, have a listener\n\t * only run once, associate arbitrary data with the listener, and remove the listener.\n\t *\n\t * This method works by creating an anonymous wrapper function and subscribing it with `addEventListener`.\n\t * The wrapper function is returned for use with `removeEventListener` (or `off`).\n\t *\n\t * To remove a listener added with `on`, you must pass in the returned wrapper function as the listener, or use\n\t * {@link core.Event#remove}. Likewise, each time you call `on` a NEW wrapper function is subscribed, so multiple calls\n\t * to `on` with the same params will create multiple listeners.\n\t *\n\t * @example\n\t * const listener = myBtn.on(\"click\", handleClick, null, false, { count: 3 });\n\t * function handleClick (evt, data) {\n\t * data.count -= 1;\n\t * console.log(this == myBtn); // true - scope defaults to the dispatcher\n\t * if (data.count == 0) {\n\t * alert(\"clicked 3 times!\");\n\t * myBtn.off(\"click\", listener);\n\t * // alternately: evt.remove();\n\t * }\n\t * }\n\t *\n\t * @param {string} type The string type of the event.\n\t * @param {Function|Object} listener An object with a handleEvent method, or a function that will be called when the event is dispatched.\n\t * @param {Object} [scope=null] The scope to execute the listener in. Defaults to the dispatcher/currentTarget for function listeners, and to the listener itself for object listeners (ie. using handleEvent).\n\t * @param {boolean} [once=false] If true, the listener will remove itself after the first time it is triggered.\n\t * @param {*} [data={}] Arbitrary data that will be included as the second parameter when the listener is called.\n\t * @param {boolean} [useCapture=false] For events that bubble, indicates whether to listen for the event in the capture or bubbling/target phase.\n\t * @return {Function} Returns the anonymous function that was created and assigned as the listener. This is needed to remove the listener later using .removeEventListener.\n\t */\n\ton (type, listener, scope = null, once = false, data = {}, useCapture = false) {\n\t\tif (listener.handleEvent) {\n\t\t\tscope = scope || listener;\n\t\t\tlistener = listener.handleEvent;\n\t\t}\n\t\tscope = scope || this;\n\t\treturn this.addEventListener(type, evt => {\n\t\t\tlistener.call(scope, evt, data);\n\t\t\tonce && evt.remove();\n\t\t}, useCapture);\n\t}\n\n\t/**\n\t * Removes the specified event listener.\n\t *\n\t * You must pass the exact function reference used when the event was added. If a proxy\n\t * function, or function closure is used as the callback, the proxy/closure reference must be used - a new proxy or\n\t * closure will not work.\n\t *\n\t * @example\n\t * displayObject.removeEventListener(\"click\", handleClick);\n\t *\n\t * @param {string} type The string type of the event.\n\t * @param {Function|Object} listener The listener function or object.\n\t * @param {boolean} [useCapture=false] For events that bubble, indicates whether to listen for the event in the capture or bubbling/target phase.\n\t */\n\tremoveEventListener (type, listener, useCapture = false) {\n\t\tconst listeners = useCapture ? this._captureListeners : this._listeners;\n\t\tif (!listeners) { return; }\n\t\tconst arr = listeners[type];\n\t\tif (!arr) { return; }\n\t\tconst l = arr.length;\n\t\tfor (let i = 0; i < l; i++) {\n\t\t\tif (arr[i] === listener) {\n\t\t\t\tif (l === 1) { delete(listeners[type]); } // allows for faster checks.\n\t\t\t\telse { arr.splice(i, 1); }\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * A shortcut to the removeEventListener method, with the same parameters and return value. This is a companion to the\n\t * `on` method.\n\t *\n\t * To remove a listener added with `on`, you must pass in the returned wrapper function as the listener. See\n\t * {@link core.EventDispatcher#on} for an example.\n\t *\n\t * @param {string} type The string type of the event.\n\t * @param {Function|Object} listener The listener function or object.\n\t * @param {boolean} [useCapture=false] For events that bubble, indicates whether to listen for the event in the capture or bubbling/target phase.\n\t */\n\toff (type, listener, useCapture = false) {\n\t\tthis.removeEventListener(type, listener, useCapture);\n\t}\n\n\t/**\n\t * Removes all listeners for the specified type, or all listeners of all types.\n\t *\n\t * @example\n\t * // remove all listeners\n\t * displayObject.removeAllEventListeners();\n\t *\n\t * // remove all click listeners\n\t * displayObject.removeAllEventListeners(\"click\");\n\t *\n\t * @param {string} [type=null] The string type of the event. If omitted, all listeners for all types will be removed.\n\t */\n\tremoveAllEventListeners (type = null) {\n\t\tif (type) {\n\t\t\tif (this._listeners) { delete(this._listeners[type]); }\n\t\t\tif (this._captureListeners) { delete(this._captureListeners[type]); }\n\t\t} else {\n\t\t\tthis._listeners = this._captureListeners = null;\n\t\t}\n\t}\n\n\t/**\n\t * Dispatches the specified event to all listeners.\n\t *\n\t * @example\n\t * // use a string event\n\t * this.dispatchEvent(\"complete\")\n\t *\n\t * // use an Event instance\n\t * const event = new createjs.Event(\"progress\");\n\t * this.dispatchEvent(event);\n\t *\n\t * @param {Object|Event|string} eventObj An object with a \"type\" property, or a string type.\n\t * While a generic object will work, it is recommended to use a CreateJS Event instance. If a string is used,\n\t * dispatchEvent will construct an Event instance if necessary with the specified type. This latter approach can\n\t * be used to avoid event object instantiation for non-bubbling events that may not have any listeners.\n\t * @param {boolean} [bubbles=false] Specifies the `bubbles` value when a string was passed to eventObj.\n\t * @param {boolean} [cancelable=false] Specifies the `cancelable` value when a string was passed to eventObj.\n\t * @return {boolean} Returns false if `preventDefault()` was called on a cancelable event, true otherwise.\n\t */\n\tdispatchEvent (eventObj, bubbles = false, cancelable = false) {\n\t\tif (typeof eventObj === \"string\") {\n\t\t\t// skip everything if there's no listeners and it doesn't bubble:\n\t\t\tconst listeners = this._listeners;\n\t\t\tif (!bubbles && (!listeners || !listeners[eventObj])) { return true; }\n\t\t\teventObj = new Event(eventObj, bubbles, cancelable);\n\t\t} else if (eventObj.target && eventObj.clone) {\n\t\t\t// redispatching an active event object, so clone it:\n\t\t\teventObj = eventObj.clone();\n\t\t}\n\n\t\t// TODO: it would be nice to eliminate this. Maybe in favour of evtObj instanceof Event? Or !!evtObj.createEvent\n\t\ttry { eventObj.target = this; } catch (e) {} // try/catch allows redispatching of native events\n\n\t\tif (!eventObj.bubbles || !this.parent) {\n\t\t\tthis._dispatchEvent(eventObj, 2);\n\t\t} else {\n\t\t\tlet top = this;\n\t\t\tconst list = [top];\n\t\t\twhile (top.parent) { list.push(top = top.parent); }\n\t\t\tconst l = list.length;\n\t\t\tlet i;\n\n\t\t\t// capture & atTarget\n\t\t\tfor (i = l - 1; i >= 0 && !eventObj.propagationStopped; i--) {\n\t\t\t\tlist[i]._dispatchEvent(eventObj, 1+(i==0));\n\t\t\t}\n\t\t\t// bubbling\n\t\t\tfor (i = 1; i < l && !eventObj.propagationStopped; i++) {\n\t\t\t\tlist[i]._dispatchEvent(eventObj, 3);\n\t\t\t}\n\t\t}\n\t\treturn !eventObj.defaultPrevented;\n\t}\n\n\t/**\n\t * Indicates whether there is at least one listener for the specified event type.\n\t *\n\t * @param {string} type The string type of the event.\n\t * @return {boolean} Returns true if there is at least one listener for the specified event.\n\t */\n\thasEventListener (type) {\n\t\tconst listeners = this._listeners, captureListeners = this._captureListeners;\n\t\treturn !!((listeners && listeners[type]) || (captureListeners && captureListeners[type]));\n\t}\n\n\t/**\n\t * Indicates whether there is at least one listener for the specified event type on this object or any of its\n\t * ancestors (parent, parent's parent, etc). A return value of true indicates that if a bubbling event of the\n\t * specified type is dispatched from this object, it will trigger at least one listener.\n\t *\n\t * This is similar to {@link core.EventDispatcher#hasEventListener}, but it searches the entire\n\t * event flow for a listener, not just this object.\n\t *\n\t * @param {string} type The string type of the event.\n\t * @return {boolean} Returns `true` if there is at least one listener for the specified event.\n\t */\n\twillTrigger (type) {\n\t\tlet o = this;\n\t\twhile (o) {\n\t\t\tif (o.hasEventListener(type)) { return true; }\n\t\t\to = o.parent;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name + this.name ? ` ${this.name}` : \"\"}]`;\n\t}\n\n\t/**\n\t * @private\n\t * @param {Object|Event|string} eventObj\n\t * @param {Object} eventPhase\n\t */\n\t_dispatchEvent (eventObj, eventPhase) {\n\t\tconst listeners = eventPhase === 1 ? this._captureListeners : this._listeners;\n\t\tif (eventObj && listeners) {\n\t\t\tlet arr = listeners[eventObj.type];\n\t\t\tlet l;\n\t\t\tif (!arr || (l = arr.length) === 0) { return; }\n\t\t\ttry { eventObj.currentTarget = this; } catch (e) {}\n\t\t\ttry { eventObj.eventPhase = eventPhase; } catch (e) {}\n\t\t\teventObj.removed = false;\n\n\t\t\tarr = arr.slice(); // to avoid issues with items being removed or added during the dispatch\n\t\t\tfor (let i = 0; i < l && !eventObj.immediatePropagationStopped; i++) {\n\t\t\t\tlet o = arr[i];\n\t\t\t\tif (o.handleEvent) { o.handleEvent(eventObj); }\n\t\t\t\telse { o(eventObj); }\n\t\t\t\tif (eventObj.removed) {\n\t\t\t\t\tthis.off(eventObj.type, o, eventPhase === 1);\n\t\t\t\t\teventObj.removed = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n}\n\nexport default EventDispatcher;\n","/**\n * @license Ticker\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport EventDispatcher from \"../events/EventDispatcher\";\nimport Event from \"../events/Event\";\n\n/**\n * The Ticker provides a centralized tick or heartbeat broadcast at a set interval. Listeners can subscribe to the tick\n * event to be notified when a set time interval has elapsed.\n *\n * Note that the interval that the tick event is called is a target interval, and may be broadcast at a slower interval\n * when under high CPU load. The Ticker class uses a static interface (ex. `Ticker.framerate = 30;`) and\n * can not be instantiated.\n *\n * @todo Pass timingMode, maxDelta, paused values as instantiation arguments?\n *\n * @memberof core\n * @example\n * Ticker.addEventListener(\"tick\", event => {\n * // Actions carried out each tick (aka frame)\n * if (!event.paused) {\n * // Actions carried out when the Ticker is not paused.\n * }\n * });\n * @example\n * // Ticker export explanation\n * import Ticker, { Ticker as TickerClass, getTicker } from \"@createjs/core\";\n * Ticker.name, Ticker.RAF // -> createjs.global, undefined\n * TickerClass.RAF // -> raf\n * Ticker === getTicker(\"createjs.global\") // -> true\n *\n * @extends core.EventDispatcher\n * @param {string} name The name assigned to this instance.\n */\nclass Ticker extends EventDispatcher {\n\n\t/**\n\t * In this mode, Ticker uses the requestAnimationFrame API, but attempts to synch the ticks to target framerate. It\n\t * uses a simple heuristic that compares the time of the RAF return to the target time for the current frame and\n\t * dispatches the tick when the time is within a certain threshold.\n\t *\n\t * This mode has a higher variance for time between frames than {{#crossLink \"Ticker/TIMEOUT:property\"}}{{/crossLink}},\n\t * but does not require that content be time based as with {{#crossLink \"Ticker/RAF:property\"}}{{/crossLink}} while\n\t * gaining the benefits of that API (screen synch, background throttling).\n\t *\n\t * Variance is usually lowest for framerates that are a divisor of the RAF frequency. This is usually 60, so\n\t * framerates of 10, 12, 15, 20, and 30 work well.\n\t *\n\t * Falls back to {{#crossLink \"Ticker/TIMEOUT:property\"}}{{/crossLink}} if the requestAnimationFrame API is not\n\t * supported.\n\t *\n\t * @static\n\t * @type {string}\n\t * @default \"synched\"\n\t * @readonly\n\t */\n\tstatic get RAF_SYNCHED () { return \"synched\"; }\n\n\t/**\n\t * In this mode, Ticker passes through the requestAnimationFrame heartbeat, ignoring the target framerate completely.\n\t * Because requestAnimationFrame frequency is not deterministic, any content using this mode should be time based.\n\t * You can leverage {@link core.Ticker#getTime} and the {@link core.Ticker#event:tick}\n\t * event object's \"delta\" properties to make this easier.\n\t *\n\t * Falls back on {@link core.Ticker.TIMEOUT} if the requestAnimationFrame API is not supported.\n\t *\n\t * @static\n\t * @type {string}\n\t * @default \"raf\"\n\t * @readonly\n\t */\n\tstatic get RAF () { return \"raf\"; }\n\n\t/**\n\t * In this mode, Ticker uses the setTimeout API. This provides predictable, adaptive frame timing, but does not\n\t * provide the benefits of requestAnimationFrame (screen synch, background throttling).\n\t *\n\t * @static\n\t * @type {string}\n\t * @default \"timeout\"\n\t * @readonly\n\t */\n\tstatic get TIMEOUT () { return \"timeout\"; }\n\n\tconstructor (name) {\n\t\tsuper();\n\n\t\t/**\n\t\t * The name of this instance.\n\t\t * @type {string}\n\t\t */\n\t\tthis.name = name;\n\n\t\t/**\n\t\t * Specifies the timing api (setTimeout or requestAnimationFrame) and mode to use.\n\t\t *\n\t\t * @see {@link core.Ticker.TIMEOUT}\n\t\t * @see {@link core.Ticker.RAF}\n\t\t * @see {@link core.Ticker.RAF_SYNCHED}\n\t\t *\n\t\t * @type {string}\n\t\t * @default Ticker.TIMEOUT\n\t\t */\n\t\tthis.timingMode = Ticker.TIMEOUT;\n\n\t\t/**\n\t\t * Specifies a maximum value for the delta property in the tick event object. This is useful when building time\n\t\t * based animations and systems to prevent issues caused by large time gaps caused by background tabs, system sleep,\n\t\t * alert dialogs, or other blocking routines. Double the expected frame duration is often an effective value\n\t\t * (ex. maxDelta=50 when running at 40fps).\n\t\t *\n\t\t * This does not impact any other values (ex. time, runTime, etc), so you may experience issues if you enable maxDelta\n\t\t * when using both delta and other values.\n\t\t *\n\t\t * If 0, there is no maximum.\n\t\t *\n\t\t * @type {number}\n\t\t * @default 0\n\t\t */\n\t\tthis.maxDelta = 0;\n\n\t\t/**\n\t\t * When the ticker is paused, all listeners will still receive a tick event, but the `paused` property\n\t\t * of the event will be `true`. Also, while paused the `runTime` will not increase.\n\t\t *\n\t\t * @example\n\t\t * Ticker.addEventListener(\"tick\", event => console.log(event.paused, Ticker.getTime(false), Ticker.getTime(true)));\n\t\t * Ticker.paused = true;\n\t\t *\n\t\t * @see {@link core.Ticker#event:tick}\n\t\t * @see {@link core.Ticker#getTime}\n\t\t * @see {@link core.Ticker#getEventTime}\n\t\t *\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.paused = false;\n\n\t\t/**\n\t\t * @private\n\t\t * @type {boolean}\n\t\t * @default false\n\t\t */\n\t\tthis._inited = false;\n\n\t\t/**\n\t\t * @private\n\t\t * @type {number}\n\t\t * @default 0\n\t\t */\n\t\tthis._startTime = 0;\n\n\t\t/**\n\t\t * @private\n\t\t * @type {number}\n\t\t * @default 0\n\t\t */\n\t\tthis._pausedTime = 0;\n\n\t\t/**\n\t\t * The number of ticks that have passed.\n\t\t *\n\t\t * @private\n\t\t * @type {number}\n\t\t * @default 0\n\t\t */\n\t\tthis._ticks = 0;\n\n\t\t/**\n\t\t * The number of ticks that have passed while Ticker has been paused.\n\t\t *\n\t\t * @private\n\t\t * @type {number}\n\t\t * @default\n\t\t */\n\t\tthis._pausedTicks = 0;\n\n\t\t/**\n\t\t * @private\n\t\t * @type {number}\n\t\t * @default\n\t\t */\n\t\tthis._interval = 50;\n\n\t\t/**\n\t\t * @private\n\t\t * @type {number}\n\t\t * @default\n\t\t */\n\t\tthis._lastTime = 0;\n\n\t\t/**\n\t\t * @private\n\t\t * @type {Array}\n\t\t * @default null\n\t\t */\n\t\tthis._times = null;\n\n\t\t/**\n\t\t * @private\n\t\t * @type {Array}\n\t\t * @default null\n\t\t */\n\t\tthis._tickTimes = null;\n\n\t\t/**\n\t\t * Stores the timeout or requestAnimationFrame id.\n\t\t *\n\t\t * @private\n\t\t * @type {number}\n\t\t * @default null\n\t\t */\n\t\tthis._timerId = null;\n\n\t\t/**\n\t\t * True if currently using requestAnimationFrame, false if using setTimeout. This may be different than timingMode\n\t\t * if that property changed and a tick hasn't fired.\n\t\t *\n\t\t * @private\n\t\t * @type {boolean}\n\t\t * @default true\n\t\t */\n\t\tthis._raf = true;\n\t}\n\n\t/**\n\t * Indicates the target time (in milliseconds) between ticks. Default is 50 (20 FPS).\n\t * Note that actual time between ticks may be more than specified depending on CPU load.\n\t * This property is ignored if the ticker is using the `RAF` timing mode.\n\t *\n\t * @type {number}\n\t */\n\tget interval () { return this._interval; }\n\tset interval (interval) {\n\t\tthis._interval = interval;\n\t\tif (!this._inited) { return; }\n\t\tthis._setupTick();\n\t}\n\n\t/**\n\t * Indicates the target frame rate in frames per second (FPS). Effectively just a shortcut to `interval`, where\n\t * `framerate == 1000/interval`.\n\t *\n\t * @type {number}\n\t */\n\tget framerate () { return 1000 / this._interval; }\n\tset framerate (framerate) { this.interval = 1000 / framerate; }\n\n\t/**\n\t * Starts the tick. This is called automatically when the first listener is added.\n\t */\n\tinit () {\n\t\tif (this._inited) { return; }\n\t\tthis._inited = true;\n\t\tthis._times = [];\n\t\tthis._tickTimes = [];\n\t\tthis._startTime = this._getTime();\n\t\tthis._times.push(this._lastTime = 0);\n\t\tthis._setupTick();\n\t}\n\n\t/**\n\t * Stops the Ticker and removes all listeners. Use init() to restart the Ticker.\n\t */\n\treset () {\n\t\tif (this._raf) {\n\t\t\tlet f = window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.oCancelAnimationFrame || window.msCancelAnimationFrame;\n\t\t\tf && f(this._timerId);\n\t\t} else {\n\t\t\tclearTimeout(this._timerId);\n\t\t}\n\t\tthis.removeAllEventListeners(\"tick\");\n\t\tthis._timerId = this._times = this._tickTimes = null;\n\t\tthis._startTime = this._lastTime = this._ticks = 0;\n\t\tthis._inited = false;\n\t}\n\n\t/**\n\t * Init the Ticker instance if it hasn't been already.\n\t */\n\taddEventListener (type, listener, useCapture) {\n\t\t!this._inited && this.init();\n\t\treturn super.addEventListener(type, listener, useCapture);\n\t}\n\n\t/**\n\t * Returns the average time spent within a tick. This can vary significantly from the value provided by getMeasuredFPS\n\t * because it only measures the time spent within the tick execution stack.\n\t *\n\t * Example 1: With a target FPS of 20, getMeasuredFPS() returns 20fps, which indicates an average of 50ms between\n\t * the end of one tick and the end of the next. However, getMeasuredTickTime() returns 15ms. This indicates that\n\t * there may be up to 35ms of \"idle\" time between the end of one tick and the start of the next.\n\t *\n\t * Example 2: With a target FPS of 30, getFPS() returns 10fps, which indicates an average of 100ms between the end of\n\t * one tick and the end of the next. However, getMeasuredTickTime() returns 20ms. This would indicate that something\n\t * other than the tick is using ~80ms (another script, DOM rendering, etc).\n\t *\n\t * @param {number} [ticks=null] The number of previous ticks over which to measure the average time spent in a tick.\n\t * Defaults to the number of ticks per second. To get only the last tick's time, pass in 1.\n\t * @return {number} The average time spent in a tick in milliseconds.\n\t */\n\tgetMeasuredTickTime (ticks = null) {\n\t\tconst times = this._tickTimes;\n\t\tif (!times || times.length < 1) { return -1; }\n\t\t// by default, calculate average for the past ~1 second:\n\t\tticks = Math.min(times.length, ticks || (this.framerate | 0));\n\t\treturn times.reduce((a, b) => a + b, 0) / ticks;\n\t}\n\n\t/**\n\t * Returns the actual frames / ticks per second.\n\t *\n\t * @param {number} [ticks=null] The number of previous ticks over which to measure the actual frames / ticks per second.\n\t * Defaults to the number of ticks per second.\n\t * @return {number} The actual frames / ticks per second. Depending on performance, this may differ\n\t * from the target frames per second.\n\t */\n\tgetMeasuredFPS (ticks = null) {\n\t\tconst times = this._times;\n\t\tif (!times || times.length < 2) { return -1; }\n\t\t// by default, calculate fps for the past ~1 second:\n\t\tticks = Math.min(times.length - 1, ticks || (this.framerate | 0));\n\t\treturn 1000 / ((times[0] - times[ticks]) / ticks);\n\t}\n\n\t/**\n\t * Returns the number of milliseconds that have elapsed since Ticker was initialized via {@link core.Ticker#init}.\n\t * Returns -1 if Ticker has not been initialized. For example, you could use\n\t * this in a time synchronized animation to determine the exact amount of time that has elapsed.\n\t *\n\t * @param {boolean} [runTime=false] If true only time elapsed while Ticker was not paused will be returned.\n\t * If false, the value returned will be total time elapsed since the first tick event listener was added.\n\t * @return {number} Number of milliseconds that have elapsed since Ticker was initialized or -1.\n\t */\n\tgetTime (runTime = false) {\n\t\treturn this._startTime ? this._getTime() - (runTime ? this._pausedTime : 0) : -1;\n\t}\n\n\t/**\n\t * Similar to {@link core.Ticker#getTime}, but returns the time on the most recent {@link core.Ticker#event:tick}\n\t * event object.\n\t *\n\t * @param {boolean} [runTime=false] If true, the runTime property will be returned instead of time.\n\t * @returns {number} The time or runTime property from the most recent tick event or -1.\n\t */\n\tgetEventTime (runTime = false) {\n\t\treturn this._startTime ? (this._lastTime || this._startTime) - (runTime ? this._pausedTime : 0) : -1;\n\t}\n\n\t/**\n\t * Returns the number of ticks that have been broadcast by Ticker.\n\t *\n\t * @param {boolean} [pauseable=false] Indicates whether to include ticks that would have been broadcast\n\t * while Ticker was paused. If true only tick events broadcast while Ticker is not paused will be returned.\n\t * If false, tick events that would have been broadcast while Ticker was paused will be included in the return\n\t * value.\n\t * @return {number} of ticks that have been broadcast.\n\t */\n\tgetTicks (pauseable = false) {\n\t\treturn this._ticks - (pauseable ? this._pausedTicks : 0);\n\t}\n\n\t/**\n\t * @private\n\t */\n\t_handleSynch () {\n\t\tthis._timerId = null;\n\t\tthis._setupTick();\n\n\t\t// run if enough time has elapsed, with a little bit of flexibility to be early:\n\t\tif (this._getTime() - this._lastTime >= (this._interval - 1) * 0.97) {\n\t\t\tthis._tick();\n\t\t}\n\t}\n\n\t/**\n\t * @private\n\t */\n\t_handleRAF () {\n\t\tthis._timerId = null;\n\t\tthis._setupTick();\n\t\tthis._tick();\n\t}\n\n\t/**\n\t * @private\n\t */\n\t_handleTimeout () {\n\t\tthis._timerId = null;\n\t\tthis._setupTick();\n\t\tthis._tick();\n\t}\n\n\t/**\n\t * @private\n\t */\n\t_setupTick () {\n\t\tif (this._timerId != null) { return; } // avoid duplicates\n\t\tconst mode = this.timingMode || (this._raf && Ticker.RAF);\n\t\tif (mode === Ticker.RAF_SYNCHED || mode === Ticker.RAF) {\n\t\t\tconst f = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame;\n\t\t\tif (f) {\n\t\t\t\tthis._timerId = f(mode === Ticker.RAF ? this._handleRAF.bind(this) : this._handleSynch.bind(this));\n\t\t\t\tthis._raf = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tthis._raf = false;\n\t\tthis._timerId = setTimeout(this._handleTimeout.bind(this), this._interval);\n\t}\n\n\t/**\n\t * @private\n\t * @emits core.Ticker#event:tick\n\t */\n\t_tick () {\n\t\tconst paused = this.paused, time = this._getTime(), elapsedTime = time - this._lastTime;\n\t\tthis._lastTime = time;\n\t\tthis._ticks++;\n\n\t\tif (paused) {\n\t\t\tthis._pausedTicks++;\n\t\t\tthis._pausedTime += elapsedTime;\n\t\t}\n\n\t\tif (this.hasEventListener(\"tick\")) {\n\t\t\tconst event = new Event(\"tick\");\n\t\t\tconst maxDelta = this.maxDelta;\n\t\t\tevent.delta = (maxDelta && elapsedTime > maxDelta) ? maxDelta : elapsedTime;\n\t\t\tevent.paused = paused;\n\t\t\tevent.time = time;\n\t\t\tevent.runTime = time - this._pausedTime;\n\t\t\tthis.dispatchEvent(event);\n\t\t}\n\n\t\tthis._tickTimes.unshift(this._getTime() - time);\n\t\twhile (this._tickTimes.length > 100) { this._tickTimes.pop(); }\n\n\t\tthis._times.unshift(time);\n\t\twhile (this._times.length > 100) { this._times.pop(); }\n\t}\n\n\t/**\n\t * @private\n\t */\n\t_getTime () {\n\t\tconst now = window.performance && window.performance.now;\n\t\treturn ((now && now.call(performance)) || (new Date().getTime())) - this._startTime;\n\t}\n\n\tstatic on (type, listener, scope, once, data, useCapture) { return _instance.on(type, listener, scope, once, data, useCapture); }\n\tstatic removeEventListener (type, listener, useCapture) { _instance.removeEventListener(type, listener, useCapture); }\n\tstatic off (type, listener, useCapture) { _instance.off(type, listener, useCapture); }\n\tstatic removeAllEventListeners (type) { _instance.removeAllEventListeners(type); }\n\tstatic dispatchEvent (eventObj, bubbles, cancelable) { return _instance.dispatchEvent(eventObj, bubbles, cancelable); }\n\tstatic hasEventListener (type) { return _instance.hasEventListener(type); }\n\tstatic willTrigger (type) { return _instance.willTrigger(type); }\n\tstatic toString () { return _instance.toString(); }\n\tstatic init () { _instance.init(); }\n\tstatic reset () { _instance.reset(); }\n\tstatic addEventListener (type, listener, useCapture) { _instance.addEventListener(type, listener, useCapture); }\n\tstatic getMeasuredTickTime (ticks) { return _instance.getMeasuredTickTime(ticks); }\n\tstatic getMeasuredFPS (ticks) { return _instance.getMeasuredFPS(ticks); }\n\tstatic getTime (runTime) { return _instance.getTime(runTime); }\n\tstatic getEventTime (runTime) { return _instance.getEventTime(runTime); }\n\tstatic getTicks (pauseable) { return _instance.getTicks(pauseable); }\n\n\tstatic get interval () { return _instance.interval; }\n\tstatic set interval (interval) { _instance.interval = interval; }\n\tstatic get framerate () { return _instance.framerate; }\n\tstatic set framerate (framerate) { _instance.framerate = framerate; }\n\tstatic get name () { return _instance.name; }\n\tstatic set name (name) { _instance.name = name; }\n\tstatic get timingMode () { return _instance.timingMode; }\n\tstatic set timingMode (timingMode) { _instance.timingMode = timingMode; }\n\tstatic get maxDelta () { return _instance.maxDelta; }\n\tstatic set maxDelta (maxDelta) { _instance.maxDelta = maxDelta; }\n\tstatic get paused () { return _instance.paused; }\n\tstatic set paused (paused) { _instance.paused = paused; }\n\n}\n\n/**\n * Dispatched each tick. The event will be dispatched to each listener even when the Ticker has been paused.\n *\n * @example\n * Ticker.addEventListener(\"tick\", event => console.log(\"Paused:\", event.paused, event.delta));\n *\n * @event core.Ticker#tick\n * @type {Object}\n * @property {Object} target The object that dispatched the event.\n * @property {string} type The event type.\n * @property {boolean} paused Indicates whether the ticker is currently paused.\n * @property {number} delta The time elapsed in ms since the last tick.\n * @property {number} time The total time in ms since Ticker was initialized.\n * @property {number} runTime The total time in ms that Ticker was not paused since it was initialized. For example,\n * you could determine the amount of time that the Ticker has been paused since initialization with `time-runTime`.\n * @since 0.6.0\n */\n\nexport default Ticker;\n\n// the default Ticker instance\nconst _instance = new Ticker(\"createjs.global\");\n","/**\n * @license\n *\n * StageGL\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nclass StageGL {\n\tconstructor () {\n\t\tthrow new Error(`\n\t\t\tStageGL is not currently supported on the EaselJS 2.0 branch.\n\t\t\tEnd of Q1 2018 is targetted for StageGL support.\n\t\t\tFollow @CreateJS on Twitter for updates.\n\t\t`);\n\t}\n}\n\nexport default StageGL;\n","/**\n * @license Shadow\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * This class encapsulates the properties required to define a shadow to apply to a {@link easeljs.DisplayObject}\n * via its `shadow` property.\n *\n * @memberof easeljs\n * @example\n * img.shadow = new Shadow(\"#000000\", 5, 5, 10);\n *\n * @param {String} [color=black] The color of the shadow. This can be any valid CSS color value.\n * @param {Number} [offsetX=0] The x offset of the shadow in pixels.\n * @param {Number} [offsetY=0] The y offset of the shadow in pixels.\n * @param {Number} [blur=0] The size of the blurring effect.\n */\nexport default class Shadow {\n\n\tconstructor (color = \"black\", offsetX = 0, offsetY = 0, blur = 0) {\n\t\t/**\n\t\t * The color of the shadow. This can be any valid CSS color value.\n\t\t * @type {String}\n\t\t * @default black\n\t\t */\n\t\tthis.color = color;\n\n\t\t/**\n\t\t * The x offset of the shadow.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.offsetX = offsetX;\n\n\t\t/**\n\t\t * The y offset of the shadow.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.offsetY = offsetY;\n\n\t\t/**\n\t\t * The blur of the shadow.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.blur = blur;\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @return {String}\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name}]`;\n\t}\n\n\t/**\n\t * Returns a clone of this Shadow instance.\n\t * @return {Shadow} A clone of the current Shadow instance.\n\t */\n\tclone () {\n\t\treturn new Shadow(this.color, this.offsetX, this.offsetY, this.blur);\n\t}\n\n}\n\n/**\n * An identity shadow object (all properties are set to 0).\n * @type {easeljs.Shadow}\n * @static\n * @readonly\n */\nShadow.identity = new Shadow(\"transparent\");\n","/**\n * @license uid\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/** @ignore */\nlet _nextId = 0;\n\n/**\n * Global utility for generating sequential unique ID numbers.\n *\n * @memberof easeljs\n * @name easeljs.uid\n * @example\n * import { uid } from \"@createjs/easeljs\";\n * var ids = [];\n * while (ids.length <= 3) {\n * ids.push(uid());\n * }\n * // ids == [0, 1, 2, 3]\n */\nexport default function uid () {\n\treturn _nextId++;\n}\n","/**\n * @license Point\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * Represents a point on a 2 dimensional x / y coordinate system.\n *\n * @memberof easeljs\n * @example\n * let point = new Point(0, 100);\n *\n * @param {Number} [x] X position.\n * @param {Number} [y] Y position.\n */\nexport default class Point {\n\n\tconstructor (x, y) {\n\t\tthis.setValues(x, y);\n\n\t\t// assigned in the setValues method.\n\t\t/**\n\t\t * X position.\n\t\t * @property x\n\t\t * @type {Number}\n\t\t */\n\n\t\t/**\n\t\t * Y position.\n\t\t * @property y\n\t\t * @type {Number}\n\t\t */\n\t}\n\n\t/**\n\t * Sets the specified values on this instance.\n\t * @param {Number} [x=0] X position.\n\t * @param {Number} [y=0] Y position.\n\t * @return {easeljs.Point} This instance. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tsetValues (x = 0, y = 0) {\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Copies all properties from the specified point to this point.\n\t * @param {easeljs.Point} point The point to copy properties from.\n\t * @return {easeljs.Point} This point. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tcopy (point) {\n\t\tthis.x = point.x;\n\t\tthis.y = point.y;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns a clone of the Point instance.\n\t * @return {easeljs.Point} a clone of the Point instance.\n\t */\n\tclone () {\n\t\treturn new Point(this.x, this.y);\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name} (x=${this.x} y=${this.y})]`;\n\t}\n\n}\n","/**\n * @license Matrix2D\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Point from \"./Point\";\n\n/**\n * Represents an affine transformation matrix, and provides tools for constructing and concatenating matrices.\n *\n *
\n * This matrix can be visualized as:\n *\n * \t[ a c tx\n * \t b d ty\n * \t 0 0 1 ]\n *\n * Note the locations of b and c.\n *
\n *\n * @param {Number} [a] Specifies the a property for the new matrix.\n * @param {Number} [b] Specifies the b property for the new matrix.\n * @param {Number} [c] Specifies the c property for the new matrix.\n * @param {Number} [d] Specifies the d property for the new matrix.\n * @param {Number} [tx] Specifies the tx property for the new matrix.\n * @param {Number} [ty] Specifies the ty property for the new matrix.\n */\nexport default class Matrix2D {\n\n\tconstructor (a, b, c, d, tx, ty) {\n\t\tthis.setValues(a, b, c, d, tx, ty);\n\n\t\t// assigned in the setValues method.\n\t\t/**\n\t\t * Position (0, 0) in a 3x3 affine transformation matrix.\n\t\t * @property a\n\t\t * @type {Number}\n\t\t */\n\n\t\t/**\n\t\t * Position (0, 1) in a 3x3 affine transformation matrix.\n\t\t * @property b\n\t\t * @type {Number}\n\t\t */\n\n\t\t/**\n\t\t * Position (1, 0) in a 3x3 affine transformation matrix.\n\t\t * @property c\n\t\t * @type {Number}\n\t\t */\n\n\t\t/**\n\t\t * Position (1, 1) in a 3x3 affine transformation matrix.\n\t\t * @property d\n\t\t * @type {Number}\n\t\t */\n\n\t\t/**\n\t\t * Position (2, 0) in a 3x3 affine transformation matrix.\n\t\t * @property tx\n\t\t * @type {Number}\n\t\t */\n\n\t\t/**\n\t\t * Position (2, 1) in a 3x3 affine transformation matrix.\n\t\t * @property ty\n\t\t * @type {Number}\n\t\t */\n\t}\n\n\t/**\n\t * Sets the specified values on this instance.\n\t * @param {Number} [a=1] Specifies the a property for the new matrix.\n\t * @param {Number} [b=0] Specifies the b property for the new matrix.\n\t * @param {Number} [c=0] Specifies the c property for the new matrix.\n\t * @param {Number} [d=1] Specifies the d property for the new matrix.\n\t * @param {Number} [tx=0] Specifies the tx property for the new matrix.\n\t * @param {Number} [ty=0] Specifies the ty property for the new matrix.\n\t * @return {Matrix2D} This instance. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tsetValues (a = 1, b = 0, c = 0, d = 1, tx = 0, ty = 0) {\n\t\t// don't forget to update docs in the constructor if these change:\n\t\tthis.a = a;\n\t\tthis.b = b;\n\t\tthis.c = c;\n\t\tthis.d = d;\n\t\tthis.tx = tx;\n\t\tthis.ty = ty;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Appends the specified matrix properties to this matrix. All parameters are required.\n\t * This is the equivalent of multiplying `(this matrix) * (specified matrix)`.\n\t * @param {Number} a\n\t * @param {Number} b\n\t * @param {Number} c\n\t * @param {Number} d\n\t * @param {Number} tx\n\t * @param {Number} ty\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t */\n\tappend (a, b, c, d, tx, ty) {\n\t\tlet a1 = this.a;\n\t\tlet b1 = this.b;\n\t\tlet c1 = this.c;\n\t\tlet d1 = this.d;\n\t\tif (a != 1 || b != 0 || c != 0 || d != 1) {\n\t\t\tthis.a = a1*a+c1*b;\n\t\t\tthis.b = b1*a+d1*b;\n\t\t\tthis.c = a1*c+c1*d;\n\t\t\tthis.d = b1*c+d1*d;\n\t\t}\n\t\tthis.tx = a1*tx+c1*ty+this.tx;\n\t\tthis.ty = b1*tx+d1*ty+this.ty;\n\t\treturn this;\n\t};\n\n\t/**\n\t * Prepends the specified matrix properties to this matrix.\n\t * This is the equivalent of multiplying `(specified matrix) * (this matrix)`.\n\t * @param {Number} a\n\t * @param {Number} b\n\t * @param {Number} c\n\t * @param {Number} d\n\t * @param {Number} tx\n\t * @param {Number} ty\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t */\n\tprepend (a, b, c, d, tx, ty) {\n\t\tlet a1 = this.a;\n\t\tlet c1 = this.c;\n\t\tlet tx1 = this.tx;\n\n\t\tthis.a = a*a1+c*this.b;\n\t\tthis.b = b*a1+d*this.b;\n\t\tthis.c = a*c1+c*this.d;\n\t\tthis.d = b*c1+d*this.d;\n\t\tthis.tx = a*tx1+c*this.ty+tx;\n\t\tthis.ty = b*tx1+d*this.ty+ty;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Appends the specified matrix to this matrix.\n\t * This is the equivalent of multiplying `(this matrix) * (specified matrix)`.\n\t * @param {easeljs.Matrix2D} matrix\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t */\n\tappendMatrix (matrix) {\n\t\treturn this.append(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);\n\t}\n\n\t/**\n\t * Prepends the specified matrix to this matrix.\n\t * This is the equivalent of multiplying `(specified matrix) * (this matrix)`.\n\t *\n\t * @example
Calculate the combined transformation for a child object
\n\t * let o = displayObject;\n\t * let mtx = o.getMatrix();\n\t * while (o = o.parent) {\n\t * \t // prepend each parent's transformation in turn:\n\t * \t o.prependMatrix(o.getMatrix());\n\t * }\n\t *\n\t * @param {easeljs.Matrix2D} matrix\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t */\n\tprependMatrix (matrix) {\n\t\treturn this.prepend(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);\n\t}\n\n\t/**\n\t * Generates matrix properties from the specified display object transform properties, and appends them to this matrix.\n\t *\n\t * @example
Generate a matrix representing the transformations of a display object
\n\t * let mtx = new Matrix2D();\n\t * mtx.appendTransform(o.x, o.y, o.scaleX, o.scaleY, o.rotation);\n\t *\n\t * @param {Number} x\n\t * @param {Number} y\n\t * @param {Number} scaleX\n\t * @param {Number} scaleY\n\t * @param {Number} rotation\n\t * @param {Number} skewX\n\t * @param {Number} skewY\n\t * @param {Number} [regX]\n\t * @param {Number} [regY]\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t */\n\tappendTransform (x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) {\n\t\tlet r, cos, sin;\n\t\tif (rotation%360) {\n\t\t\tr = rotation*Matrix2D.DEG_TO_RAD;\n\t\t\tcos = Math.cos(r);\n\t\t\tsin = Math.sin(r);\n\t\t} else {\n\t\t\tcos = 1;\n\t\t\tsin = 0;\n\t\t}\n\n\t\tif (skewX || skewY) {\n\t\t\t// TODO: can this be combined into a single append operation?\n\t\t\tskewX *= Matrix2D.DEG_TO_RAD;\n\t\t\tskewY *= Matrix2D.DEG_TO_RAD;\n\t\t\tthis.append(Math.cos(skewY), Math.sin(skewY), -Math.sin(skewX), Math.cos(skewX), x, y);\n\t\t\tthis.append(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, 0, 0);\n\t\t} else {\n\t\t\tthis.append(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, x, y);\n\t\t}\n\n\t\tif (regX || regY) {\n\t\t\t// append the registration offset:\n\t\t\tthis.tx -= regX*this.a+regY*this.c;\n\t\t\tthis.ty -= regX*this.b+regY*this.d;\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Generates matrix properties from the specified display object transform properties, and prepends them to this matrix.\n\t *\n\t * Note that the above example would not account for {@link easeljs.DisplayObject#transformMatrix} values.\n\t * See {@link easeljs.Matrix2D#prependMatrix} for an example that does.\n\t *\n\t * @example
Calculate the combined transformation for a child object
\n\t * let o = displayObject;\n\t * let mtx = new Matrix2D();\n\t * do {\n\t * \t // prepend each parent's transformation in turn:\n\t * \t mtx.prependTransform(o.x, o.y, o.scaleX, o.scaleY, o.rotation, o.skewX, o.skewY, o.regX, o.regY);\n\t * } while (o = o.parent);\n\t *\n\t * @param {Number} x\n\t * @param {Number} y\n\t * @param {Number} scaleX\n\t * @param {Number} scaleY\n\t * @param {Number} rotation\n\t * @param {Number} skewX\n\t * @param {Number} skewY\n\t * @param {Number} [regX]\n\t * @param {Number} [regY]\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t */\n\tprependTransform (x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) {\n\t\tlet r, cos, sin;\n\t\tif (rotation%360) {\n\t\t\tr = rotation*Matrix2D.DEG_TO_RAD;\n\t\t\tcos = Math.cos(r);\n\t\t\tsin = Math.sin(r);\n\t\t} else {\n\t\t\tcos = 1;\n\t\t\tsin = 0;\n\t\t}\n\n\t\tif (regX || regY) {\n\t\t\t// prepend the registration offset:\n\t\t\tthis.tx -= regX; this.ty -= regY;\n\t\t}\n\t\tif (skewX || skewY) {\n\t\t\t// TODO: can this be combined into a single prepend operation?\n\t\t\tskewX *= Matrix2D.DEG_TO_RAD;\n\t\t\tskewY *= Matrix2D.DEG_TO_RAD;\n\t\t\tthis.prepend(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, 0, 0);\n\t\t\tthis.prepend(Math.cos(skewY), Math.sin(skewY), -Math.sin(skewX), Math.cos(skewX), x, y);\n\t\t} else {\n\t\t\tthis.prepend(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, x, y);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Applies a clockwise rotation transformation to the matrix.\n\t * @param {Number} angle The angle to rotate by, in degrees. To use a value in radians, multiply it by `Math.PI/180`.\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t */\n\trotate (angle) {\n\t\tangle *= Matrix2D.DEG_TO_RAD;\n\t\tlet cos = Math.cos(angle);\n\t\tlet sin = Math.sin(angle);\n\n\t\tlet a1 = this.a;\n\t\tlet b1 = this.b;\n\n\t\tthis.a = a1*cos+this.c*sin;\n\t\tthis.b = b1*cos+this.d*sin;\n\t\tthis.c = -a1*sin+this.c*cos;\n\t\tthis.d = -b1*sin+this.d*cos;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Applies a skew transformation to the matrix.\n\t * @param {Number} skewX The amount to skew horizontally in degrees. To use a value in radians, multiply it by `Math.PI/180`.\n\t * @param {Number} skewY The amount to skew vertically in degrees.\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tskew (skewX, skewY) {\n\t\tskewX *= Matrix2D.DEG_TO_RAD;\n\t\tskewY *= Matrix2D.DEG_TO_RAD;\n\t\tthis.append(Math.cos(skewY), Math.sin(skewY), -Math.sin(skewX), Math.cos(skewX), 0, 0);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Applies a scale transformation to the matrix.\n\t * @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.\n\t * @param {Number} y The amount to scale vertically.\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t */\n\tscale (x, y) {\n\t\tthis.a *= x;\n\t\tthis.b *= x;\n\t\tthis.c *= y;\n\t\tthis.d *= y;\n\t\t//this.tx *= x;\n\t\t//this.ty *= y;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Translates the matrix on the x and y axes.\n\t * @param {Number} x\n\t * @param {Number} y\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t */\n\ttranslate (x, y) {\n\t\tthis.tx += this.a*x + this.c*y;\n\t\tthis.ty += this.b*x + this.d*y;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the properties of the matrix to those of an identity matrix (one that applies a null transformation).\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t */\n\tidentity () {\n\t\tthis.a = this.d = 1;\n\t\tthis.b = this.c = this.tx = this.ty = 0;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Inverts the matrix, causing it to perform the opposite transformation.\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t */\n\tinvert () {\n\t\tlet a1 = this.a;\n\t\tlet b1 = this.b;\n\t\tlet c1 = this.c;\n\t\tlet d1 = this.d;\n\t\tlet tx1 = this.tx;\n\t\tlet n = a1*d1-b1*c1;\n\n\t\tthis.a = d1/n;\n\t\tthis.b = -b1/n;\n\t\tthis.c = -c1/n;\n\t\tthis.d = a1/n;\n\t\tthis.tx = (c1*this.ty-d1*tx1)/n;\n\t\tthis.ty = -(a1*this.ty-b1*tx1)/n;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns true if the matrix is an identity matrix.\n\t * @return {Boolean}\n\t */\n\tisIdentity () {\n\t\treturn this.tx === 0 && this.ty === 0 && this.a === 1 && this.b === 0 && this.c === 0 && this.d === 1;\n\t}\n\n\t/**\n\t * Returns true if this matrix is equal to the specified matrix (all property values are equal).\n\t * @param {easeljs.Matrix2D} matrix The matrix to compare.\n\t * @return {Boolean}\n\t */\n\tequals (matrix) {\n\t\treturn this.tx === matrix.tx && this.ty === matrix.ty && this.a === matrix.a && this.b === matrix.b && this.c === matrix.c && this.d === matrix.d;\n\t}\n\n\t/**\n\t * Transforms a point according to this matrix.\n\t * @param {Number} x The x component of the point to transform.\n\t * @param {Number} y The y component of the point to transform.\n\t * @param {easeljs.Point | Object} [pt] An object to copy the result into. If omitted a generic object with x/y properties will be returned.\n\t * @return {easeljs.Point} This matrix. Useful for chaining method calls.\n\t */\n\ttransformPoint (x, y, pt = new Point()) {\n\t\tpt.x = x*this.a+y*this.c+this.tx;\n\t\tpt.y = x*this.b+y*this.d+this.ty;\n\t\treturn pt;\n\t}\n\n\t/**\n\t * Decomposes the matrix into transform properties (x, y, scaleX, scaleY, and rotation). Note that these values\n\t * may not match the transform properties you used to generate the matrix, though they will produce the same visual\n\t * results.\n\t * @param {Object} [target] The object to apply the transform properties to. If null, then a new object will be returned.\n\t * @return {Object} The target, or a new generic object with the transform properties applied.\n\t*/\n\tdecompose (target = {}) {\n\t\t// 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\n\t\ttarget.x = this.tx;\n\t\ttarget.y = this.ty;\n\t\ttarget.scaleX = Math.sqrt(this.a * this.a + this.b * this.b);\n\t\ttarget.scaleY = Math.sqrt(this.c * this.c + this.d * this.d);\n\n\t\tlet skewX = Math.atan2(-this.c, this.d);\n\t\tlet skewY = Math.atan2(this.b, this.a);\n\n\t\tlet delta = Math.abs(1-skewX/skewY);\n\t\tif (delta < 0.00001) { // effectively identical, can use rotation:\n\t\t\ttarget.rotation = skewY/Matrix2D.DEG_TO_RAD;\n\t\t\tif (this.a < 0 && this.d >= 0) {\n\t\t\t\ttarget.rotation += (target.rotation <= 0) ? 180 : -180;\n\t\t\t}\n\t\t\ttarget.skewX = target.skewY = 0;\n\t\t} else {\n\t\t\ttarget.skewX = skewX/Matrix2D.DEG_TO_RAD;\n\t\t\ttarget.skewY = skewY/Matrix2D.DEG_TO_RAD;\n\t\t}\n\t\treturn target;\n\t}\n\n\t/**\n\t * Copies all properties from the specified matrix to this matrix.\n\t * @param {easeljs.Matrix2D} matrix The matrix to copy properties from.\n\t * @return {easeljs.Matrix2D} This matrix. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tcopy (matrix) {\n\t\treturn this.setValues(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);\n\t}\n\n\t/**\n\t * Returns a clone of the Matrix2D instance.\n\t * @return {easeljs.Matrix2D} a clone of the Matrix2D instance.\n\t */\n\tclone () {\n\t\treturn new Matrix2D(this.a, this.b, this.c, this.d, this.tx, this.ty);\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name} (a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty})]`;\n\t}\n\n}\n\n/**\n * Multiplier for converting degrees to radians. Used internally by Matrix2D.\n * @static\n * @type {Number}\n * @readonly\n */\nMatrix2D.DEG_TO_RAD = Math.PI/180;\n/**\n * An identity matrix, representing a null transformation.\n * @static\n * @type {easeljs.Matrix2D}\n * @readonly\n */\nMatrix2D.identity = new Matrix2D();\n","/**\n * @license DisplayProps\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Matrix2D from \"./Matrix2D\";\n\n/**\n * Used for calculating and encapsulating display related properties.\n * @memberof easeljs\n * @param {Number} [visible] Visible value.\n * @param {Number} [alpha] Alpha value.\n * @param {Number} [shadow] A Shadow instance or null.\n * @param {Number} [compositeOperation] A compositeOperation value or null.\n * @param {Number} [matrix] A transformation matrix. Defaults to a new identity matrix.\n */\nexport default class DisplayProps {\n\n\tconstructor (visible, alpha, shadow, compositeOperation, matrix) {\n\t\tthis.setValues(visible, alpha, shadow, compositeOperation, matrix);\n\n\t\t// assigned in the setValues method.\n\t\t/**\n\t\t * Property representing the alpha that will be applied to a display object.\n\t\t * @property alpha\n\t\t * @type {Number}\n\t\t */\n\n\t\t/**\n\t\t * Property representing the shadow that will be applied to a display object.\n\t\t * @property shadow\n\t\t * @type {easeljs.Shadow}\n\t\t */\n\n\t\t/**\n\t\t * Property representing the compositeOperation that will be applied to a display object.\n\t\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Compositing}\n\t\t * @property compositeOperation\n\t\t * @type {String}\n\t\t */\n\n\t\t/**\n\t\t * Property representing the value for visible that will be applied to a display object.\n\t\t * @property visible\n\t\t * @type {Boolean}\n\t\t */\n\n\t\t/**\n\t\t * The transformation matrix that will be applied to a display object.\n\t\t * @property matrix\n\t\t * @type {easeljs.Matrix2D}\n\t\t */\n\t}\n\n\t/**\n\t * Reinitializes the instance with the specified values.\n\t * @param {Number} [visible=true] Visible value.\n\t * @param {Number} [alpha=1] Alpha value.\n\t * @param {Number} [shadow] A Shadow instance or null.\n\t * @param {Number} [compositeOperation] A compositeOperation value or null.\n\t * @param {Number} [matrix] A transformation matrix. Defaults to an identity matrix.\n\t * @return {easeljs.DisplayProps} This instance. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tsetValues (visible = true, alpha = 1, shadow, compositeOperation, matrix) {\n\t\tthis.visible = visible;\n\t\tthis.alpha = alpha;\n\t\tthis.shadow = shadow;\n\t\tthis.compositeOperation = compositeOperation;\n\t\tthis.matrix = matrix || (this.matrix&&this.matrix.identity()) || new Matrix2D();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Appends the specified display properties. This is generally used to apply a child's properties its parent's.\n\t * @param {Boolean} visible desired visible value\n\t * @param {Number} alpha desired alpha value\n\t * @param {easeljs.Shadow} shadow desired shadow value\n\t * @param {String} compositeOperation desired composite operation value\n\t * @param {easeljs.Matrix2D} [matrix] a Matrix2D instance\n\t * @return {easeljs.DisplayProps} This instance. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tappend (visible, alpha, shadow, compositeOperation, matrix) {\n\t\tthis.alpha *= alpha;\n\t\tthis.shadow = shadow || this.shadow;\n\t\tthis.compositeOperation = compositeOperation || this.compositeOperation;\n\t\tthis.visible = this.visible && visible;\n\t\tmatrix&&this.matrix.appendMatrix(matrix);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Prepends the specified display properties. This is generally used to apply a parent's properties to a child's.\n\t * For example, to get the combined display properties that would be applied to a child, you could use:\n\t *\n\t * @example\n\t * let o = displayObject;\n\t * let props = new DisplayProps();\n\t * do {\n\t * \t // prepend each parent's props in turn:\n\t * \t props.prepend(o.visible, o.alpha, o.shadow, o.compositeOperation, o.getMatrix());\n\t * } while (o = o.parent);\n\t *\n\t * @param {Boolean} visible desired visible value\n\t * @param {Number} alpha desired alpha value\n\t * @param {easeljs.Shadow} shadow desired shadow value\n\t * @param {String} compositeOperation desired composite operation value\n\t * @param {easeljs.Matrix2D} [matrix] a Matrix2D instance\n\t * @return {easeljs.DisplayProps} This instance. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tprepend (visible, alpha, shadow, compositeOperation, matrix) {\n\t\tthis.alpha *= alpha;\n\t\tthis.shadow = this.shadow || shadow;\n\t\tthis.compositeOperation = this.compositeOperation || compositeOperation;\n\t\tthis.visible = this.visible && visible;\n\t\tmatrix&&this.matrix.prependMatrix(matrix);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Resets this instance and its matrix to default values.\n\t * @return {easeljs.DisplayProps} This instance. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tidentity () {\n\t\tthis.visible = true;\n\t\tthis.alpha = 1;\n\t\tthis.shadow = this.compositeOperation = null;\n\t\tthis.matrix.identity();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns a clone of the DisplayProps instance. Clones the associated matrix.\n\t * @return {easeljs.DisplayProps} a clone of the DisplayProps instance.\n\t */\n\tclone () {\n\t\treturn new DisplayProps(this.alpha, this.shadow, this.compositeOperation, this.visible, this.matrix.clone());\n\t}\n\n}\n","/**\n * @license Rectangle\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * Represents a rectangle as defined by the points (x, y) and (x+width, y+height).\n * Used by {@link easeljs.DisplayObjects#getBounds}.\n *\n * @memberof easeljs\n * @example\n * let rect = new Rectangle(0, 0, 100, 100);\n *\n * @param {Number} [x] X position.\n * @param {Number} [y] Y position.\n * @param {Number} [width] The width of the Rectangle.\n * @param {Number} [height] The height of the Rectangle.\n */\nexport default class Rectangle {\n\n\tconstructor (x, y, width, height) {\n\t\tthis.setValues(x, y, width, height);\n\n\t\t// assigned in the setValues method.\n\t\t/**\n\t\t * X position.\n\t\t * @property x\n\t\t * @type {Number}\n\t\t */\n\n\t\t/**\n\t\t * Y position.\n\t\t * @property y\n\t\t * @type {Number}\n\t\t */\n\n\t\t/**\n\t\t * Width.\n\t\t * @property width\n\t\t * @type {Number}\n\t\t */\n\n\t\t/**\n\t\t * Height.\n\t\t * @property height\n\t\t * @type {Number}\n\t\t */\n\t}\n\n\t/**\n\t * Sets the specified values on this instance.\n\t * @param {Number} [x=0] X position.\n\t * @param {Number} [y=0] Y position.\n\t * @param {Number} [width=0] The width of the Rectangle.\n\t * @param {Number} [height=0] The height of the Rectangle.\n\t * @return {easeljs.Rectangle} This instance. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tsetValues (x = 0, y = 0, width = 0, height = 0) {\n\t\t// don't forget to update docs in the constructor if these change:\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.width = width;\n\t\tthis.height = height;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Extends the rectangle's bounds to include the described point or rectangle.\n\t * @param {Number} x X position of the point or rectangle.\n\t * @param {Number} y Y position of the point or rectangle.\n\t * @param {Number} [width=0] The width of the rectangle.\n\t * @param {Number} [height=0] The height of the rectangle.\n\t * @return {easeljs.Rectangle} This instance. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\textend (x, y, width = 0, height = 0) {\n\t\tif (x+width > this.x+this.width) { this.width = x+width-this.x; }\n\t\tif (y+height > this.y+this.height) { this.height = y+height-this.y; }\n\t\tif (x < this.x) { this.width += this.x-x; this.x = x; }\n\t\tif (y < this.y) { this.height += this.y-y; this.y = y; }\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds the specified padding to the rectangle's bounds.\n\t * @param {Number} top\n\t * @param {Number} left\n\t * @param {Number} bottom\n\t * @param {Number} right\n\t * @return {easeljs.Rectangle} This instance. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tpad (top, left, bottom, right) {\n\t\tthis.x -= left;\n\t\tthis.y -= top;\n\t\tthis.width += left+right;\n\t\tthis.height += top+bottom;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Copies all properties from the specified rectangle to this rectangle.\n\t * @param {easeljs.Rectangle} rectangle The rectangle to copy properties from.\n\t * @return {easeljs.Rectangle} This rectangle. Useful for chaining method calls.\n\t * @chainable\n\t*/\n\tcopy (rect) {\n\t\treturn this.setValues(rect.x, rect.y, rect.width, rect.height);\n\t}\n\n\t/**\n\t * Returns true if this rectangle fully encloses the described point or rectangle.\n\t * @param {Number} x X position of the point or rectangle.\n\t * @param {Number} y Y position of the point or rectangle.\n\t * @param {Number} [width=0] The width of the rectangle.\n\t * @param {Number} [height=0] The height of the rectangle.\n\t * @return {Boolean} True if the described point or rectangle is contained within this rectangle.\n\t*/\n\tcontains (x, y, width = 0, height = 0) {\n\t\treturn (x >= this.x && x+width <= this.x+this.width && y >= this.y && y+height <= this.y+this.height);\n\t}\n\n\t/**\n\t * Returns a new rectangle which contains this rectangle and the specified rectangle.\n\t * @param {easeljs.Rectangle} rect The rectangle to calculate a union with.\n\t * @return {easeljs.Rectangle} A new rectangle describing the union.\n\t*/\n\tunion (rect) {\n\t\treturn this.clone().extend(rect.x, rect.y, rect.width, rect.height);\n\t}\n\n\t/**\n\t * Returns a new rectangle which describes the intersection (overlap) of this rectangle and the specified rectangle,\n\t * or null if they do not intersect.\n\t * @param {easeljs.Rectangle} rect The rectangle to calculate an intersection with.\n\t * @return {easeljs.Rectangle} A new rectangle describing the intersection or null.\n\t*/\n\tintersection (rect) {\n\t\tlet x1 = rect.x, y1 = rect.y, x2 = x1+rect.width, y2 = y1+rect.height;\n\t\tif (this.x > x1) { x1 = this.x; }\n\t\tif (this.y > y1) { y1 = this.y; }\n\t\tif (this.x + this.width < x2) { x2 = this.x + this.width; }\n\t\tif (this.y + this.height < y2) { y2 = this.y + this.height; }\n\t\treturn (x2 <= x1 || y2 <= y1) ? null : new Rectangle(x1, y1, x2-x1, y2-y1);\n\t}\n\n\t/**\n\t * Returns true if the specified rectangle intersects (has any overlap) with this rectangle.\n\t * @param {easeljs.Rectangle} rect The rectangle to compare.\n\t * @return {Boolean} True if the rectangles intersect.\n\t*/\n\tintersects (rect) {\n\t\treturn (rect.x <= this.x+this.width && this.x <= rect.x+rect.width && rect.y <= this.y+this.height && this.y <= rect.y + rect.height);\n\t}\n\n\t/**\n\t * Returns true if the width or height are equal or less than 0.\n\t * @return {Boolean} True if the rectangle is empty.\n\t*/\n\tisEmpty () {\n\t\treturn this.width <= 0 || this.height <= 0;\n\t}\n\n\t/**\n\t * Returns a clone of the Rectangle instance.\n\t * @return {easeljs.Rectangle} a clone of the Rectangle instance.\n\t */\n\tclone () {\n\t\treturn new Rectangle(this.x, this.y, this.width, this.height);\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name} (x=${this.x} y=${this.y} width=${this.width} height=${this.height})]`;\n\t}\n\n}\n","/**\n * @license Filter\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * Base class that all filters should inherit from. Filters need to be applied to objects that have been cached using\n * the {@link easeljs.DisplayObject#cache} method. If an object changes, please cache it again, or use\n * {@link easeljs.DisplayObject#updateCache}. Note that the filters must be applied before caching.\n *\n * Note that each filter can implement a {@link easeljs.Filter#getBounds} method, which returns the\n * margins that need to be applied in order to fully display the filter. For example, the {@link easeljs.BlurFilter}\n * will cause an object to feather outwards, resulting in a margin around the shape.\n *\n *
EaselJS Filters
\n * EaselJS comes with a number of pre-built filters:\n *
\n *
{@link easeljs.AlphaMapFilter}: Map a greyscale image to the alpha channel of a display object
\n *
{@link easeljs.AlphaMaskFilter}: Map an image's alpha channel to the alpha channel of a display object
\n *
{@link easeljs.BlurFilter}: Apply vertical and horizontal blur to a display object
\n *
{@link easeljs.ColorFilter}: Color transform a display object
\n *
{@link easeljs.ColorMatrixFilter}: Transform an image using a {{#crossLink \"ColorMatrix\"}}{{/crossLink}}
\n *
\n *\n * @memberof easeljs\n * @example\n * shape.filters = [\n * new createjs.ColorFilter(0, 0, 0, 1, 255, 0, 0),\n * new createjs.BlurFilter(5, 5, 10)\n * ];\n * shape.cache(0, 0, 100, 100);\n */\nexport default class Filter {\n\n\tconstructor () {\n\t\t/**\n\t\t * A flag stating that this filter uses a context draw mode and cannot be batched into imageData processing.\n\t\t * @type {Boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.usesContext = false;\n\n\t\t/**\n\t\t * Another filter that is required to act as part of this filter and created and managed under the hood.\n\t\t * @private\n\t\t * @type {easeljs.Filter}\n\t\t * @default null\n\t\t */\n\t\tthis._multiPass = null;\n\n\t\t/**\n\t\t * Pre-processing shader code, will be parsed before being fed in.\n\t\t * This should be based upon StageGL.SHADER_VERTEX_BODY_REGULAR\n\t\t * @virtual\n\t\t * @type {String}\n\t\t * @readonly\n\t\t */\n\t\tthis.VTX_SHADER_BODY = null;\n\n\t\t/**\n\t\t * Pre-processing shader code, will be parsed before being fed in.\n\t\t * This should be based upon StageGL.SHADER_FRAGMENT_BODY_REGULAR\n\t\t * @virtual\n\t\t * @type {String}\n\t\t * @readonly\n\t\t */\n\t\tthis.FRAG_SHADER_BODY = null;\n\t}\n\n\t/**\n\t * Provides padding values for this filter. That is, how much the filter will extend the visual bounds of an object it is applied to.\n\t * @abstract\n\t * @param {easeljs.Rectangle} [rect] If specified, the provided Rectangle instance will be expanded by the padding amounts and returned.\n\t * @return {easeljs.Rectangle} If a `rect` param was provided, it is returned. If not, either a new rectangle with the padding values, or null if no padding is required for this filter.\n\t */\n\tgetBounds (rect) { }\n\n\t/**\n\t * @virtual\n\t * @abstract\n\t * @param {WebGLContext} gl The context associated with the stage performing the render.\n\t * @param {easeljs.StageGL} stage The stage instance that will be rendering.\n\t * @param {ShaderProgram} shaderProgram The compiled shader that is going to be sued to perform the render.\n\t */\n\tshaderParamSetup (gl, stage, shaderProgram) { }\n\n\t/**\n\t * Applies the filter to the specified context.\n\t * @param {CanvasRenderingContext2D} ctx The 2D context to use as the source.\n\t * @param {Number} x The x position to use for the source rect.\n\t * @param {Number} y The y position to use for the source rect.\n\t * @param {Number} width The width to use for the source rect.\n\t * @param {Number} height The height to use for the source rect.\n\t * @param {CanvasRenderingContext2D} [targetCtx] The 2D context to draw the result to. Defaults to the context passed to ctx.\n\t * @param {Number} [targetX] The x position to draw the result to. Defaults to the value passed to x.\n\t * @param {Number} [targetY] The y position to draw the result to. Defaults to the value passed to y.\n\t * @return {Boolean} If the filter was applied successfully.\n\t */\n\tapplyFilter (ctx, x, y, width, height, targetCtx, targetX, targetY) {\n\t\t// this is the default behaviour because most filters access pixel data. It is overridden when not needed.\n\t\ttargetCtx = targetCtx || ctx;\n\t\tif (targetX == null) { targetX = x; }\n\t\tif (targetY == null) { targetY = y; }\n\t\ttry {\n\t\t\tlet imageData = ctx.getImageData(x, y, width, height);\n\t\t\tif (this._applyFilter(imageData)) {\n\t\t\t\ttargetCtx.putImageData(imageData, targetX, targetY);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} catch (e) {}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name}]`;\n\t}\n\n\t/**\n\t * Returns a clone of this Filter instance.\n\t * @return {easeljs.Filter} A clone of the current Filter instance.\n\t */\n\tclone () {\n\t\treturn new Filter();\n\t}\n\n\t/**\n\t * @abstract\n\t * @param {ImageData} imageData Target ImageData instance.\n\t * @return {Boolean}\n\t */\n\t_applyFilter (imageData) { }\n\n}\n","/**\n * @license BitmapCache\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Filter from \"./Filter\";\nimport Rectangle from \"../geom/Rectangle\";\nimport StageGL from \"../display/StageGL\";\n\n/**\n * The BitmapCache is an internal representation of all the cache properties and logic required in order to \"cache\"\n * an object. This information and functionality used to be located on a {@link easeljs.DisplayObject#cache}\n * method in {@link easeljs.DisplayObject}, but was moved to its own class.\n *\n * Caching in this context is purely visual, and will render the DisplayObject out into an image to be used instead\n * of the object. The actual cache itself is still stored on the target with the {@link easeljs.DisplayObject#cacheCanvas}.\n *\n * Working with a singular image like a {@link easeljs.Bitmap}, there is little benefit to performing\n * a cache operation, as it is already a single image. Caching is best done on containers that have multiple complex\n * parts that do not change often, so that rendering the image will improve overall rendering speed. A cached object\n * will not visually update until explicitly told to do so with a call to {@link easeljs.Stage#update},\n * much like a Stage. If a cache is being updated every frame, it is likely not improving rendering performance.\n * Caches are best used when updates will be sparse.\n *\n * Caching is also a co-requisite for applying filters to prevent expensive filters running constantly without need.\n * The BitmapCache is also responsible for applying filters to objects, and reads each {@link easeljs.Filter}.\n * Real-time Filters are not recommended when dealing with a Context2D canvas if performance is a concern. For best\n * performance and to still allow for some visual effects, use a {{#crossLink \"DisplayObject/compositeOperation:property\"}}{{/crossLink}}\n * when possible.\n *\n * @memberof easeljs\n * @extends easeljs.Filter\n */\nexport default class BitmapCache extends Filter {\n\n\tconstructor () {\n\t\tsuper();\n\n\t\t/**\n\t\t * Width of the cache relative to the target object.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default undefined\n\t\t */\n\t\tthis.width = undefined;\n\n\t\t/**\n\t\t * Height of the cache relative to the target object.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default undefined\n\t\t */\n\t\tthis.height = undefined;\n\n\t\t/**\n\t\t * Horizontal position of the cache relative to the target's origin.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default undefined\n\t\t */\n\t\tthis.x = undefined;\n\n\t\t/**\n\t\t * Vertical position of the cache relative to target's origin.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default undefined\n\t\t */\n\t\tthis.y = undefined;\n\n\t\t/**\n\t\t * The internal scale of the cache image, does not affects display size. This is useful to both increase and\n\t\t * decrease render quality. Objects with increased scales are more likely to look good when scaled up. Objects\n\t\t * with decreased scales can save on rendering performance.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 1\n\t\t */\n\t\tthis.scale = 1;\n\n\t\t/**\n\t\t * The relative offset of the {@link easeljs.BitmapCache#x} position, used for drawing\n\t\t * into the cache with the correct offsets. Re-calculated every update call before drawing.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.offX = 0;\n\n\t\t/**\n\t\t * The relative offset of the {@link easeljs.BitmapCache#y} position, used for drawing\n\t\t * into the cache with the correct offsets. Re-calculated every update call before drawing.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.offY = 0;\n\n\t\t/**\n\t\t * Track how many times the cache has been updated, mostly used for preventing duplicate cacheURLs. This can be\n\t\t * useful to see if a cache has been updated.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.cacheID = 0;\n\n\t\t/**\n\t\t * Relative offset of the x position, used for drawing the cache into other scenes.\n\t\t * Re-calculated every update call before drawing.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t * @todo Is this description right? Its the same as offX.\n\t\t */\n\t\tthis._filterOffX = 0;\n\n\t\t/**\n\t\t * Relative offset of the y position, used for drawing into the cache into other scenes.\n\t\t * Re-calculated every update call before drawing.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t * @todo Is this description right? Its the same as offY.\n\t\t */\n\t\tthis._filterOffY = 0;\n\n\t\t/**\n\t\t * The cacheID when a DataURL was requested.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis._cacheDataURLID = 0;\n\n\t\t/**\n\t\t * The cache's DataURL, generated on-demand using the getter.\n\t\t * @protected\n\t\t * @type {String}\n\t\t * @default null\n\t\t */\n\t\tthis._cacheDataURL = null;\n\n\t\t/**\n\t\t * Internal tracking of final bounding width, approximately `width*scale;` however, filters can complicate the actual value.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis._drawWidth = 0;\n\n\t\t/**\n\t\t * Internal tracking of final bounding height, approximately `height*scale;` however, filters can complicate the actual value.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis._drawHeight = 0;\n\n\t\t/**\n\t\t * Internal tracking of the last requested bounds, may happen repeadtedly so stored to avoid object creation.\n\t\t * @protected\n\t\t * @type {easeljs.Rectangle}\n\t\t * @default easeljs.Rectangle\n\t\t */\n\t\tthis._boundRect = new Rectangle();\n\n\t}\n\n\t/**\n\t * Returns the bounds that surround all applied filters. This relies on each filter to describe how it changes bounds.\n\t * @param {easeljs.DisplayObject} target The object to check the filter bounds for.\n\t * @param {easeljs.Rectangle} [output] Calculated bounds will be applied to this rect.\n\t * @return {easeljs.Rectangle}\n\t * @static\n\t */\n\tstatic getFilterBounds (target, output = new Rectangle()) {\n\t\tlet filters = target.filters;\n\t\tlet filterCount = filters && filters.length;\n\t\tif (!!filterCount <= 0) { return output; }\n\n\t\tfor (let i=0; i= 1 ? width : 1;\n\t\tthis.height = height >= 1 ? height : 1;\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.scale = scale;\n\n\t\tthis.update();\n\t}\n\n\t/**\n\t * Directly called via {@link easeljs.DisplayObject#updateCache}, but also internally. This\n\t * has the dual responsibility of making sure the surface is ready to be drawn to, and performing the draw. For\n\t * full details of each behaviour, check the protected functions {@link easeljs.BitmapCache#_updateSurface}\n\t * and {@link easeljs.BitmapCache#_drawToCache} respectively.\n\t * @param {String} [compositeOperation] The DisplayObject this cache is linked to.\n\t */\n\tupdate (compositeOperation) {\n\t\tif (!this.target) { throw \"define() must be called before update()\"; }\n\n\t\tlet filterBounds = BitmapCache.getFilterBounds(this.target);\n\t\tlet surface = this.target.cacheCanvas;\n\n\t\tthis._drawWidth = Math.ceil(this.width*this.scale) + filterBounds.width;\n\t\tthis._drawHeight = Math.ceil(this.height*this.scale) + filterBounds.height;\n\n\t\tif (!surface || this._drawWidth != surface.width || this._drawHeight != surface.height) {\n\t\t\tthis._updateSurface();\n\t\t}\n\n\t\tthis._filterOffX = filterBounds.x;\n\t\tthis._filterOffY = filterBounds.y;\n\t\tthis.offX = this.x*this.scale + this._filterOffX;\n\t\tthis.offY = this.y*this.scale + this._filterOffY;\n\n\t\tthis._drawToCache(compositeOperation);\n\n\t\tthis.cacheID = this.cacheID?this.cacheID+1:1;\n\t}\n\n\t/**\n\t * Reset and release all the properties and memory associated with this cache.\n\t */\n\trelease () {\n\t\tlet stage = this.target.stage;\n\t\tif (this._useWebGL && this._webGLCache) {\n\t\t\t// if it isn't cache controlled clean up after yourself\n\t\t\tif (!this._webGLCache.isCacheControlled) {\n\t\t\t\tif (this.__lastRT) { this.__lastRT = undefined; }\n\t\t\t\tif (this.__rtA) { this._webGLCache._killTextureObject(this.__rtA); }\n\t\t\t\tif (this.__rtB) { this._webGLCache._killTextureObject(this.__rtB); }\n\t\t\t\tif (this.target && this.target.cacheCanvas) { this._webGLCache._killTextureObject(this.target.cacheCanvas); }\n\t\t\t}\n\t\t\t// set the context to none and let the garbage collector get the rest when the canvas itself gets removed\n\t\t\tthis._webGLCache = false;\n\t\t} else if (stage instanceof StageGL) {\n\t\t\tstage.releaseTexture(this.target.cacheCanvas);\n\t\t}\n\t\tthis.target = this.target.cacheCanvas = null;\n\t\tthis.cacheID = this._cacheDataURLID = this._cacheDataURL = undefined;\n\t\tthis.width = this.height = this.x = this.y = this.offX = this.offY = 0;\n\t\tthis.scale = 1;\n\t}\n\n\t/**\n\t * Returns a data URL for the cache, or `null` if this display object is not cached.\n\t * Uses {@link easeljs.BitmapCache#cacheID} to ensure a new data URL is not generated if the\n\t * cache has not changed.\n\t * @return {String} The image data url for the cache.\n\t */\n\tgetCacheDataURL () {\n\t\tlet cacheCanvas = this.target && this.target.cacheCanvas;\n\t\tif (!cacheCanvas) { return null; }\n\t\tif (this.cacheID != this._cacheDataURLID) {\n\t\t\tthis._cacheDataURLID = this.cacheID;\n\t\t\tthis._cacheDataURL = cacheCanvas.toDataURL?cacheCanvas.toDataURL():null;\t// incase function is\n\t\t}\n\t\treturn this._cacheDataURL;\n\t}\n\n\t/**\n\t * Use context2D drawing commands to display the cache canvas being used.\n\t * @param {CanvasRenderingContext2D} ctx The context to draw into.\n\t * @return {Boolean} Whether the draw was handled successfully.\n\t */\n\tdraw (ctx) {\n\t\tif (!this.target) { return false; }\n\t\tctx.drawImage(\n\t\t\tthis.target.cacheCanvas,\n\t\t\tthis.x + (this._filterOffX/this.scale),\n\t\t\tthis.y + (this._filterOffY/this.scale),\n\t\t\tthis._drawWidth/this.scale,\n\t\t\tthis._drawHeight/this.scale\n\t\t);\n\t\treturn true;\n\t}\n\n\t/**\n\t * Determine the bounds of the shape in local space.\n\t * @returns {easeljs.Rectangle}\n\t */\n\tgetBounds () {\n\t\tconst scale = this.scale;\n\t\treturn this._boundRect.setValue(\n\t\t\tthis._filterOffX/scale,\n\t\t\tthis._filterOffY/scale,\n\t\t\tthis.width/scale,\n\t\t\tthis.height/scale\n\t\t);\n\t}\n\n\t/**\n\t * Basic context2D caching works by creating a new canvas element and setting its physical size. This function will\n\t * create and or size the canvas as needed.\n\t * @protected\n\t */\n\t_updateSurface () {\n\t\tlet surface;\n\t\tif (!this._useWebGL) {\n\t\t\tsurface = this.target.cacheCanvas;\n\t\t\t// create it if it's missing\n\t\t\tif (!surface) {\n\t\t\t\tsurface = this.target.cacheCanvas = window.createjs&&createjs.createCanvas?createjs.createCanvas():document.createElement(\"canvas\");\n\t\t\t}\n\t\t\t// now size it\n\t\t\tsurface.width = this._drawWidth;\n\t\t\tsurface.height = this._drawHeight;\n\t\t\t// skip the webgl-only updates\n\t\t\treturn;\n\t\t}\n\n\t\t// create it if it's missing\n\t\tif (!this._webGLCache) {\n\t\t\tif (this._options.useGL === \"stage\") {\n\t\t\t\tif(!(this.target.stage != null && this.target.stage.isWebGL)) {\n\t\t\t\t\tthrow `Cannot use 'stage' for cache because the object's parent stage is ${this.target.stage != null ? \"non WebGL.\" : \"not set, please addChild to the correct stage.\"}`;\n\t\t\t\t}\n\t\t\t\tthis.target.cacheCanvas = true; // will be replaced with RenderTexture, temporary positive value for old \"isCached\" checks\n\t\t\t\tthis._webGLCache = this.target.stage;\n\t\t\t} else if (this._options.useGL === \"new\") {\n\t\t\t\tthis.target.cacheCanvas = document.createElement(\"canvas\"); // we can turn off autopurge because we wont be making textures here\n\t\t\t\tthis._webGLCache = new StageGL(this.target.cacheCanvas, {antialias: true, transparent: true, autoPurge: -1});\n\t\t\t\tthis._webGLCache.isCacheControlled = true; // use this flag to control stage sizing and final output\n\t\t\t} else {\n\t\t\t\tthrow \"Invalid option provided to useGL, expected ['stage', 'new', StageGL, undefined], got \"+ this._options.useGL;\n\t\t\t}\n\t\t}\n\n\t\t// now size render surfaces\n\t\tlet stageGL = this._webGLCache;\n\t\tsurface = this.target.cacheCanvas;\n\n\t\t// if we have a dedicated stage we've gotta size it\n\t\tif (stageGL.isCacheControlled) {\n\t\t\tsurface.width = this._drawWidth;\n\t\t\tsurface.height = this._drawHeight;\n\t\t\tstageGL.updateViewport(this._drawWidth, this._drawHeight);\n\t\t}\n\t\tif (this.target.filters) {\n\t\t\t// with filters we can't tell how many we'll need but the most we'll ever need is two, so make them now\n\t\t\tstageGL.getTargetRenderTexture(this.target, this._drawWidth,this._drawHeight);\n\t\t\tstageGL.getTargetRenderTexture(this.target, this._drawWidth,this._drawHeight);\n\t\t} else if (!stageGL.isCacheControlled) {\n\t\t\t// without filters then we only need one RenderTexture, and that's only if its not a dedicated stage\n\t\t\tstageGL.getTargetRenderTexture(this.target, this._drawWidth,this._drawHeight);\n\t\t}\n\t}\n\n\t/**\n\t * Perform the cache draw out for context 2D now that the setup properties have been performed.\n\t * @protected\n\t */\n\t_drawToCache (compositeOperation) {\n\t\tlet target = this.target;\n\t\tlet surface = target.cacheCanvas;\n\t\tlet webGL = this._webGLCache;\n\n\t\tif (!this._useWebGL || !webGL) {\n\t\t\tlet ctx = surface.getContext(\"2d\");\n\n\t\t\tif (!compositeOperation) {\n\t\t\t\tctx.clearRect(0, 0, this._drawWidth+1, this._drawHeight+1);\n\t\t\t}\n\n\t\t\tctx.save();\n\t\t\tctx.globalCompositeOperation = compositeOperation;\n\t\t\tctx.setTransform(this.scale,0,0,this.scale, -this._filterOffX,-this._filterOffY);\n\t\t\tctx.translate(-this.x, -this.y);\n\t\t\ttarget.draw(ctx, true);\n\t\t\tctx.restore();\n\n\t\t\tif (target.filters && target.filters.length) {\n\t\t\t\tthis._applyFilters(target);\n\t\t\t}\n\t\t\tsurface._invalid = true;\n\t\t\treturn;\n\t\t}\n\n\t\tthis._webGLCache.cacheDraw(target, target.filters, this);\n\t\t// NOTE: we may of swapped around which element the surface is, so we re-fetch it\n\t\tsurface = this.target.cacheCanvas;\n\t\tsurface.width = this._drawWidth;\n\t\tsurface.height = this._drawHeight;\n\t\tsurface._invalid = true;\n\t}\n\n\t/**\n\t * Work through every filter and apply its individual transformation to it.\n\t * @protected\n\t */\n\t_applyFilters () {\n\t\tlet surface = this.target.cacheCanvas;\n\t\tlet filters = this.target.filters;\n\n\t\tlet w = this._drawWidth;\n\t\tlet h = this._drawHeight;\n\n\t\t// setup\n\t\tlet data = surface.getContext(\"2d\").getImageData(0,0, w,h);\n\n\t\t// apply\n\t\tlet l = filters.length;\n\t\tfor (let i=0; iWebGL cache with 2d context\n * let stage = new Stage();\n * let bmp = new Bitmap(src);\n * bmp.cache(0, 0, bmp.width, bmp.height, 1, true); // no StageGL to use, so make one\n * let shape = new Shape();\n * shape.graphics.clear().fill(\"red\").drawRect(0,0,20,20);\n * shape.cache(0, 0, 20, 20, 1); // cannot use WebGL cache\n *\n * @example
WebGL cache with WebGL context
\n * let stageGL = new StageGL();\n * let bmp = new Bitmap(src);\n * bmp.cache(0, 0, bmp.width, bmp.height, 1, stageGL); // use our StageGL to cache\n * let shape = new Shape();\n * shape.graphics.clear().fill(\"red\").drawRect(0,0,20,20);\n * shape.cache(0, 0, 20, 20, 1); // cannot use WebGL cache\n *\n * @param {Number} x The x coordinate origin for the cache region.\n * @param {Number} y The y coordinate origin for the cache region.\n * @param {Number} width The width of the cache region.\n * @param {Number} height The height of the cache region.\n * @param {Number} [scale=1] The scale at which the cache will be created. For example, if you cache a vector shape using\n * \tmyShape.cache(0,0,100,100,2) then the resulting cacheCanvas will be 200x200 px. This lets you scale and rotate\n * \tcached elements with greater fidelity.\n * @param {Boolean | easeljs.StageGL} [options] Select whether to use context 2D, or WebGL rendering, and whether to make a new stage instance or use an existing one.\n */\n","/**\n * @license DisplayObject\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport { EventDispatcher } from \"@createjs/core\";\nimport Shadow from \"./Shadow\";\nimport uid from \"../utils/uid\";\nimport DisplayProps from \"../geom/DisplayProps\";\nimport Rectangle from \"../geom/Rectangle\";\nimport Point from \"../geom/Point\";\nimport Matrix2D from \"../geom/Matrix2D\";\nimport BitmapCache from \"../filters/BitmapCache\";\n\n/**\n * DisplayObject is an abstract class that should not be constructed directly. Instead construct subclasses such as\n * {@link easeljs.Container}, {@link easeljs.Bitmap}, and {@link easeljs.Shape}.\n * DisplayObject is the base class for all display classes in the EaselJS library. It defines the core properties and\n * methods that are shared between all display objects, such as transformation properties (x, y, scaleX, scaleY, etc),\n * caching, and mouse handlers.\n *\n * @memberof easeljs\n * @extends EventDispatcher\n */\nexport default class DisplayObject extends EventDispatcher {\n\n\tconstructor () {\n\t\tsuper();\n\n\t\t/**\n\t\t * The alpha (transparency) for this display object. 0 is fully transparent, 1 is fully opaque.\n\t\t * @type {Number}\n\t\t * @default 1\n\t\t */\n\t\tthis.alpha = 1;\n\n\t\t/**\n\t\t * If a cache is active, this returns the canvas that holds the image of this display object.\n\t\t * Use this to display the result of a cache. This will be a HTMLCanvasElement unless special cache rules have been deliberately enabled for this cache.\n\t\t * @see {@link easeljs.DisplayObject#cache}\n\t\t * @type {HTMLCanvasElement | Object}\n\t\t * @default null\n\t\t * @readonly\n\t\t */\n\t\tthis.cacheCanvas = null;\n\n\t\t/**\n\t\t * If a cache has been made, this returns the class that is managing the cacheCanvas and its properties.\n\t\t * @see {@link easeljs.BitmapCache}\n\t\t * @type {easeljs.BitmapCache}\n\t\t * @default null\n\t\t * @readonly\n\t\t */\n\t\tthis.bitmapCache = null;\n\n\t\t/**\n\t\t * Unique ID for this display object. Makes display objects easier for some uses.\n\t\t * @type {Number}\n\t\t */\n\t\tthis.id = uid();\n\n\t\t/**\n\t\t * Indicates whether to include this object when running mouse interactions. Setting this to `false` for children\n\t\t * of a {@link easeljs.Container} will cause events on the Container to not fire when that child is\n\t\t * clicked. Setting this property to `false` does not prevent the {@link easeljs.Container#getObjectsUnderPoint}\n\t\t * method from returning the child.\n\t\t *\n\t\t * Note: In EaselJS 0.7.0, the `mouseEnabled` property will not work properly with nested Containers.\n\t\t *\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.mouseEnabled = true;\n\n\t\t/**\n\t\t * If false, the tick will not run on this display object (or its children). This can provide some performance benefits.\n\t\t * In addition to preventing the {@link core.Ticker#event:tick} event from being dispatched, it will also prevent tick related updates\n\t\t * on some display objects (ex. Sprite & MovieClip frame advancing, DOMElement visibility handling).\n\t\t * @type Boolean\n\t\t * @default true\n\t\t */\n\t\tthis.tickEnabled = true;\n\n\t\t/**\n\t\t * An optional name for this display object. Included in {@link easeljs.DisplayObject#toString}. Useful for debugging.\n\t\t * @type {String}\n\t\t * @default null\n\t\t */\n\t\tthis.name = null;\n\n\t\t/**\n\t\t * A reference to the {@link easeljs.Container} or {@link easeljs.Stage} object that\n\t\t * contains this display object, or null if it has not been added to one.\n\t\t * @type {easeljs.Container}\n\t\t * @default null\n\t\t * @readonly\n\t\t */\n\t\tthis.parent = null;\n\n\t\t/**\n\t\t * The left offset for this display object's registration point. For example, to make a 100x100px Bitmap rotate\n\t\t * around its center, you would set regX and {@link easeljs.DisplayObject#regY} to 50.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.regX = 0;\n\n\t\t/**\n\t\t * The y offset for this display object's registration point. For example, to make a 100x100px Bitmap rotate around\n\t\t * its center, you would set {@link easeljs.DisplayObject#regX} and regY to 50.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.regY = 0;\n\n\t\t/**\n\t\t * The rotation in degrees for this display object.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.rotation = 0;\n\n\t\t/**\n\t\t * The factor to stretch this display object horizontally. For example, setting scaleX to 2 will stretch the display\n\t\t * object to twice its nominal width. To horizontally flip an object, set the scale to a negative number.\n\t\t * @type {Number}\n\t\t * @default 1\n\t\t */\n\t\tthis.scaleX = 1;\n\n\t\t/**\n\t\t * The factor to stretch this display object vertically. For example, setting scaleY to 0.5 will stretch the display\n\t\t * object to half its nominal height. To vertically flip an object, set the scale to a negative number.\n\t\t * @type {Number}\n\t\t * @default 1\n\t\t */\n\t\tthis.scaleY = 1;\n\n\t\t/**\n\t\t * The factor to skew this display object horizontally.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.skewX = 0;\n\n\t\t/**\n\t\t * The factor to skew this display object vertically.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.skewY = 0;\n\n\t\t/**\n\t\t * A shadow object that defines the shadow to render on this display object. Set to `null` to remove a shadow. If\n\t\t * null, this property is inherited from the parent container.\n\t\t * @type {easeljs.Shadow}\n\t\t * @default null\n\t\t */\n\t\tthis.shadow = null;\n\n\t\t/**\n\t\t * Indicates whether this display object should be rendered to the canvas and included when running the Stage\n\t\t * {@link easeljs.Stage#getObjectsUnderPoint} method.\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.visible = true;\n\n\t\t/**\n\t\t * The x (horizontal) position of the display object, relative to its parent.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.x = 0;\n\n\t\t/**\n\t\t * The y (vertical) position of the display object, relative to its parent.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.y = 0;\n\n\t\t/**\n\t\t * If set, defines the transformation for this display object, overriding all other transformation properties\n\t\t * (x, y, rotation, scale, skew).\n\t\t * @type {easeljs.Matrix2D}\n\t\t * @default null\n\t\t */\n\t\tthis.transformMatrix = null;\n\n\t\t/**\n\t\t * The composite operation indicates how the pixels of this display object will be composited with the elements\n\t\t * behind it. If `null`, this property is inherited from the parent container.\n\t\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#compositing \"WHATWG spec on compositing\"}\n\t\t * @type {String}\n\t\t * @default null\n\t\t */\n\t\tthis.compositeOperation = null;\n\n\t\t/**\n\t\t * Indicates whether the display object should be drawn to a whole pixel when {@link easeljs.Stage#snapToPixelEnabled} is true.\n\t\t * To enable/disable snapping on whole categories of display objects, set this value on the prototype (Ex. Text.prototype.snapToPixel = true).\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.snapToPixel = true;\n\n\t\t/**\n\t\t * An array of Filter objects to apply to this display object. Filters are only applied / updated when {@link easeljs.DisplayObject#cache}\n\t\t * or {@link easeljs.DisplayObject#updateCache} is called on the display object, and only apply to the area that is cached.\n\t\t * @type {Array}\n\t\t * @default null\n\t\t */\n\t\tthis.filters = null;\n\n\t\t/**\n\t\t * A Shape instance that defines a vector mask (clipping path) for this display object. The shape's transformation\n\t\t * will be applied relative to the display object's parent coordinates (as if it were a child of the parent).\n\t\t * @type {easeljs.Shape}\n\t\t * @default null\n\t\t */\n\t\tthis.mask = null;\n\n\t\t/**\n\t\t * A display object that will be tested when checking mouse interactions or testing {@link easeljs.Container#getObjectsUnderPoint}.\n\t\t * The hit area will have its transformation applied relative to this display object's coordinate space (as though\n\t\t * the hit test object were a child of this display object and relative to its regX/Y). The hitArea will be tested\n\t\t * using only its own `alpha` value regardless of the alpha value on the target display object, or the target's\n\t\t * ancestors (parents).\n\t\t *\n\t\t * If set on a {@link easeljs.Container}, children of the Container will not receive mouse events.\n\t\t * This is similar to setting {@link easeljs.DisplayObject#mouseChildren} to false.\n\t\t *\n\t\t * Note that hitArea is NOT currently used by the `hitTest()` method, nor is it supported for {@link easeljs.Stage}.\n\t\t *\n\t\t * @type {easeljs.DisplayObject}\n\t\t * @default null\n\t\t */\n\t\tthis.hitArea = null;\n\n\t\t/**\n\t\t * A CSS cursor (ex. \"pointer\", \"help\", \"text\", etc) that will be displayed when the user hovers over this display\n\t\t * object. You must enable mouseover events using the {@link easeljs.Stage#enableMouseOver} method to\n\t\t * use this property. Setting a non-null cursor on a Container will override the cursor set on its descendants.\n\t\t *\n\t\t * @type {String}\n\t\t * @default null\n\t\t */\n\t\tthis.cursor = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.DisplayProps}\n\t\t */\n\t\tthis._props = new DisplayProps();\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.Rectangle}\n\t\t */\n\t\tthis._rectangle = new Rectangle();\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.Rectangle}\n\t\t * @default null\n\t\t */\n\t\tthis._bounds = null;\n\n\t\t/**\n\t\t * Where StageGL should look for required display properties, matters only for leaf display objects. Containers\n\t\t * or cached objects won't use this property, it's for native display of terminal elements.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis._webGLRenderStyle = DisplayObject._StageGL_NONE;\n\t}\n\n\t/**\n\t * Returns the {@link easeljs.Stage} instance that this display object will be rendered on, or null if it has not been added to one.\n\t * @type {Stage}\n\t * @readonly\n\t */\n\tget stage () {\n\t\t// uses dynamic access to avoid circular dependencies;\n\t\tlet o = this;\n\t\twhile (o.parent) { o = o.parent; }\n\t\tif (/^\\[Stage(GL)?(\\s\\(name=\\w+\\))?\\]$/.test(o.toString())) { return o; }\n\t\treturn null;\n\t}\n\n\t/**\n\t * Set both the {@link easeljs.DisplayObject#scaleX} and the {@link easeljs.DisplayObject#scaleY} property to the same value.\n\t * Note that when you get the value, if the `scaleX` and `scaleY` are different values, it will return only the `scaleX`.\n\t * @type {Number}\n\t * @default 1\n\t */\n\tset scale (value) { this.scaleX = this.scaleY = value; }\n\tget scale () { return this.scaleX; }\n\n\t/**\n\t * Returns true or false indicating whether the display object would be visible if drawn to a canvas.\n\t * This does not account for whether it would be visible within the boundaries of the stage.\n\t * NOTE: This method is mainly for internal use, though it may be useful for advanced uses.\n\t * @return {Boolean} Boolean indicating whether the display object would be visible if drawn to a canvas\n\t */\n\tisVisible () {\n\t\treturn !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0);\n\t}\n\n\t/**\n\t * Alias for drawCache(). Used by grandchildren (or deeper) in their draw method to directly\n\t * call {@link easeljs.DisplayObject#drawCache}, bypassing their parent(s).\n\t *\n\t * @param {CanvasRenderingContext2D} ctx The canvas 2D context object to draw into.\n\t * @param {Boolean} [ignoreCache=false] Indicates whether the draw operation should ignore any current cache. For example,\n\t * used for drawing the cache (to prevent it from simply drawing an existing cache back into itself).\n\t * @return {Boolean}\n\t */\n\tdraw (ctx, ignoreCache = false) {\n\t\treturn this.drawCache(ctx, ignoreCache);\n\t}\n\n\t/**\n\t * Draws the display object into the specified context ignoring its visible, alpha, shadow, and transform.\n\t * Returns `true` if the draw was handled (useful for overriding functionality).\n\t *\n\t * NOTE: This method is mainly for internal use, though it may be useful for advanced uses.\n\t * @param {CanvasRenderingContext2D} ctx The canvas 2D context object to draw into.\n\t * @param {Boolean} [ignoreCache=false] Indicates whether the draw operation should ignore any current cache. For example,\n\t * used for drawing the cache (to prevent it from simply drawing an existing cache back into itself).\n\t * @return {Boolean}\n\t */\n\tdrawCache (ctx, ignoreCache = false) {\n\t\tlet cache = this.bitmapCache;\n\t\tif (cache && !ignoreCache) {\n\t\t\treturn cache.draw(ctx);\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Applies this display object's transformation, alpha, globalCompositeOperation, clipping path (mask), and shadow\n\t * to the specified context. This is typically called prior to {@link easeljs.DisplayObject#draw}.\n\t * @param {CanvasRenderingContext2D} ctx The canvas 2D to update.\n\t */\n\tupdateContext (ctx) {\n\t\tlet o=this, mask=o.mask, mtx=o._props.matrix;\n\n\t\tif (mask && mask.graphics && !mask.graphics.isEmpty()) {\n\t\t\tmask.getMatrix(mtx);\n\t\t\tctx.transform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx, mtx.ty);\n\n\t\t\tmask.graphics.drawAsPath(ctx);\n\t\t\tctx.clip();\n\n\t\t\tmtx.invert();\n\t\t\tctx.transform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx, mtx.ty);\n\t\t}\n\n\t\tthis.getMatrix(mtx);\n\t\tlet tx = mtx.tx, ty = mtx.ty;\n\t\tif (DisplayObject._snapToPixelEnabled && o.snapToPixel) {\n\t\t\ttx = tx + (tx < 0 ? -0.5 : 0.5) | 0;\n\t\t\tty = ty + (ty < 0 ? -0.5 : 0.5) | 0;\n\t\t}\n\t\tctx.transform(mtx.a, mtx.b, mtx.c, mtx.d, tx, ty);\n\t\tctx.globalAlpha *= o.alpha;\n\t\tif (o.compositeOperation) { ctx.globalCompositeOperation = o.compositeOperation; }\n\t\tif (o.shadow) { this._applyShadow(ctx, o.shadow); }\n\t}\n\n\t/**\n\t * Draws the display object into a new element, which is then used for subsequent draws. Intended for complex content\n\t * that does not change frequently (ex. a Container with many children that do not move, or a complex vector Shape),\n\t * this can provide for much faster rendering because the content does not need to be re-rendered each tick. The\n\t * cached display object can be moved, rotated, faded, etc freely, however if its content changes, you must manually\n\t * update the cache by calling `updateCache()` again. You must specify the cached area via the x, y, w,\n\t * and h parameters. This defines the rectangle that will be rendered and cached using this display object's coordinates.\n\t *\n\t * Note that filters need to be defined before the cache is applied or you will have to call updateCache after\n\t * application. Check out the {@link easeljs.Filter} class for more information. Some filters\n\t * (ex. {@link easeljs.BlurFilter}) may not work as expected in conjunction with the scale param.\n\t *\n\t * Usually, the resulting cacheCanvas will have the dimensions width*scale by height*scale, however some filters (ex. BlurFilter)\n\t * will add padding to the canvas dimensions.\n\t *\n\t * Actual implementation of the caching mechanism can change with a {@link easeljs.StageGL} and so\n\t * all caching and filter behaviour has been moved to the {@link easeljs.BitmapCache}\n\t *\n\t * @example\n\t * // If you defined a Shape that drew a circle at 0, 0 with a radius of 25:\n\t * var shape = new createjs.Shape();\n\t * shape.graphics.beginFill(\"#ff0000\").drawCircle(0, 0, 25);\n\t * shape.cache(-25, -25, 50, 50);\n\t *\n\t * @param {Number} x The x coordinate origin for the cache region.\n\t * @param {Number} y The y coordinate origin for the cache region.\n\t * @param {Number} width The width of the cache region.\n\t * @param {Number} height The height of the cache region.\n\t * @param {Number} [scale=1] The scale at which the cache will be created. For example, if you cache a vector shape using\n\t * \tmyShape.cache(0,0,100,100,2) then the resulting cacheCanvas will be 200x200 px. This lets you scale and rotate\n\t * \tcached elements with greater fidelity. Default is 1.\n\t * @param {Object} [options] When using alternate displays there may be extra caching opportunities or needs.\n\t */\n\tcache (x, y, width, height, scale = 1, options) {\n\t\tif (!this.bitmapCache) {\n\t\t\tthis.bitmapCache = new BitmapCache();\n\t\t}\n\t\tthis.bitmapCache.define(this, x, y, width, height, scale, options);\n\t}\n\n\t/**\n\t * Redraws the display object to its cache. Calling updateCache without an active cache will throw an error.\n\t * If compositeOperation is null the current cache will be cleared prior to drawing. Otherwise the display object\n\t * will be drawn over the existing cache using the specified compositeOperation.\n\t *\n\t * Actual implementation of the caching mechanism can change with a {@link easeljs.StageGL} and so\n\t * all caching and filter behaviour has been moved to the {@link easeljs.BitmapCache}\n\t *\n\t * @example\n\t * // clear current graphics\n\t * shapeInstance.clear();\n\t * // draw new instructions\n\t * shapeInstance.setStrokeStyle(3).beginStroke(\"#FF0000\").moveTo(100, 100).lineTo(200,200);\n\t * // update cache, drawing new line on top of old one\n\t * shapeInstance.updateCache();\n\t *\n\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#compositing \"WHATWG spec on compositing\"}\n\t * @param {String} compositeOperation The compositeOperation to use, or null to clear the cache and redraw it.\n\t */\n\tupdateCache (compositeOperation) {\n\t\tif (!this.bitmapCache) {\n\t\t\tthrow \"No cache found. cache() must be called before updateCache()\";\n\t\t}\n\t\tthis.bitmapCache.update(compositeOperation);\n\t}\n\n\t/**\n\t * Clears the current cache.\n\t * @see {@link easeljs.DisplayObject.#cache}\n\t */\n\tuncache () {\n\t\tif (this.bitmapCache) {\n\t\t\tthis.bitmapCache.release();\n\t\t\tthis.bitmapCache = undefined;\n\t\t}\n\t}\n\n\t/**\n\t * Returns a data URL for the cache, or null if this display object is not cached.\n\t * Only generated if the cache has changed, otherwise returns last result.\n\t * @return {String} The image data url for the cache.\n\t */\n\tgetCacheDataURL () {\n\t\treturn this.bitmapCache ? this.bitmapCache.getDataURL() : null;\n\t}\n\n\t/**\n\t * Transforms the specified x and y position from the coordinate space of the display object\n\t * to the global (stage) coordinate space. For example, this could be used to position an HTML label\n\t * over a specific point on a nested display object. Returns a Point instance with x and y properties\n\t * correlating to the transformed coordinates on the stage.\n\t *\n\t * @example\n\t * displayObject.x = 300;\n\t * displayObject.y = 200;\n\t * stage.addChild(displayObject);\n\t * let point = displayObject.localToGlobal(100, 100);\n\t * // Results in x=400, y=300\n\t *\n\t * @param {Number} x The x position in the source display object to transform.\n\t * @param {Number} y The y position in the source display object to transform.\n\t * @param {easeljs.Point | Object} [pt=Point] An object to copy the result into. If omitted a new Point object with x/y properties will be returned.\n\t * @return {easeljs.Point} A Point instance with x and y properties correlating to the transformed coordinates\n\t * on the stage.\n\t */\n\tlocalToGlobal (x, y, pt = new Point()) {\n\t\treturn this.getConcatenatedMatrix(this._props.matrix).transformPoint(x, y, pt);\n\t}\n\n\t/**\n\t * Transforms the specified x and y position from the global (stage) coordinate space to the\n\t * coordinate space of the display object. For example, this could be used to determine\n\t * the current mouse position within the display object. Returns a Point instance with x and y properties\n\t * correlating to the transformed position in the display object's coordinate space.\n\t *\n\t * @example\n\t * displayObject.x = 300;\n\t * displayObject.y = 200;\n\t * stage.addChild(displayObject);\n\t * let point = displayObject.globalToLocal(100, 100);\n\t * // Results in x=-200, y=-100\n\t *\n\t * @param {Number} x The x position on the stage to transform.\n\t * @param {Number} y The y position on the stage to transform.\n\t * @param {easeljs.Point | Object} [pt=Point] An object to copy the result into. If omitted a new Point object with x/y properties will be returned.\n\t * @return {easeljs.Point} A Point instance with x and y properties correlating to the transformed position in the\n\t * display object's coordinate space.\n\t */\n\tglobalToLocal (x, y, pt = new Point()) {\n\t\treturn this.getConcatenatedMatrix(this._props.matrix).invert().transformPoint(x, y, pt);\n\t}\n\n\t/**\n\t * Transforms the specified x and y position from the coordinate space of this display object to the coordinate\n\t * space of the target display object. Returns a Point instance with x and y properties correlating to the\n\t * transformed position in the target's coordinate space. Effectively the same as using the following code with\n\t * {@link easeljs.DisplayObject#localToGlobal} and {@link easeljs.DisplayObject#globalToLocal}.\n\t *\n\t * @example\n\t * // long way\n\t * let pt = this.localToGlobal(x, y);\n\t * pt = target.globalToLocal(pt.x, pt.y);\n\t * // shorthand\n\t * let pt = this.localToLocal(x, y, target);\n\t *\n\t * @param {Number} x The x position in the source display object to transform.\n\t * @param {Number} y The y position on the source display object to transform.\n\t * @param {easeljs.DisplayObject} target The target display object to which the coordinates will be transformed.\n\t * @param {easeljs.Point | Object} [pt] An object to copy the result into. If omitted a new Point object with x/y properties will be returned.\n\t * @return {easeljs.Point} Returns a Point instance with x and y properties correlating to the transformed position\n\t * in the target's coordinate space.\n\t */\n\tlocalToLocal (x, y, target, pt) {\n\t\tpt = this.localToGlobal(x, y, pt);\n\t\treturn target.globalToLocal(pt.x, pt.y, pt);\n\t}\n\n\t/**\n\t * Shortcut method to quickly set the transform properties on the display object. All parameters are optional.\n\t * Omitted parameters will have the default value set.\n\t *\n\t * @example\n\t * displayObject.setTransform(100, 100, 2, 2);\n\t *\n\t * @param {Number} [x=0] The horizontal translation (x position) in pixels\n\t * @param {Number} [y=0] The vertical translation (y position) in pixels\n\t * @param {Number} [scaleX=1] The horizontal scale, as a percentage of 1\n\t * @param {Number} [scaleY=1] the vertical scale, as a percentage of 1\n\t * @param {Number} [rotation=0] The rotation, in degrees\n\t * @param {Number} [skewX=0] The horizontal skew factor\n\t * @param {Number} [skewY=0] The vertical skew factor\n\t * @param {Number} [regX=0] The horizontal registration point in pixels\n\t * @param {Number} [regY=0] The vertical registration point in pixels\n\t * @return {easeljs.DisplayObject} Returns this instance. Useful for chaining commands.\n\t*/\n\tsetTransform (x=0, y=0, scaleX=1, scaleY=1, rotation=0, skewX=0, skewY=0, regX=0, regY=0) {\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.scaleX = scaleX;\n\t\tthis.scaleY = scaleY;\n\t\tthis.rotation = rotation;\n\t\tthis.skewX = skewX;\n\t\tthis.skewY = skewY;\n\t\tthis.regX = regX;\n\t\tthis.regY = regY;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns a matrix based on this object's current transform.\n\t * @param {easeljs.Matrix2D} [matrix] A Matrix2D object to populate with the calculated values. If null, a new Matrix object is returned.\n\t * @return {easeljs.Matrix2D} A matrix representing this display object's transform.\n\t */\n\tgetMatrix (matrix) {\n\t\tlet o = this, mtx = matrix&&matrix.identity() || new Matrix2D();\n\t\treturn o.transformMatrix ? mtx.copy(o.transformMatrix) : mtx.appendTransform(o.x, o.y, o.scaleX, o.scaleY, o.rotation, o.skewX, o.skewY, o.regX, o.regY);\n\t}\n\n\t/**\n\t * Generates a Matrix2D object representing the combined transform of the display object and all of its\n\t * parent Containers up to the highest level ancestor (usually the {@link easeljs.Stage}). This can\n\t * be used to transform positions between coordinate spaces, such as with {@link easeljs.DisplayObject#localToGlobal}\n\t * and {@link easeljs.DisplayObject#globalToLocal}.\n\t *\n\t * @param {easeljs.Matrix2D} [matrix] A Matrix2D object to populate with the calculated values. If null, a new Matrix2D object is returned.\n\t * @return {easeljs.Matrix2D} The combined matrix.\n\t */\n\tgetConcatenatedMatrix (matrix) {\n\t\tlet o = this, mtx = this.getMatrix(matrix);\n\t\twhile (o = o.parent) {\n\t\t\tmtx.prependMatrix(o.getMatrix(o._props.matrix));\n\t\t}\n\t\treturn mtx;\n\t}\n\n\t/**\n\t * Generates a DisplayProps object representing the combined display properties of the object and all of its\n\t * parent Containers up to the highest level ancestor (usually the {@link easeljs.Stage}).\n\t * @param {easeljs.DisplayProps} [props] A DisplayProps object to populate with the calculated values. If null, a new DisplayProps object is returned.\n\t * @return {easeljs.DisplayProps} The combined display properties.\n\t */\n\tgetConcatenatedDisplayProps (props) {\n\t\tprops = props ? props.identity() : new DisplayProps();\n\t\tlet o = this, mtx = o.getMatrix(props.matrix);\n\t\tdo {\n\t\t\tprops.prepend(o.visible, o.alpha, o.shadow, o.compositeOperation);\n\n\t\t\t// we do this to avoid problems with the matrix being used for both operations when o._props.matrix is passed in as the props param.\n\t\t\t// this could be simplified (ie. just done as part of the prepend above) if we switched to using a pool.\n\t\t\tif (o != this) { mtx.prependMatrix(o.getMatrix(o._props.matrix)); }\n\t\t} while (o = o.parent);\n\t\treturn props;\n\t}\n\n\t/**\n\t * Tests whether the display object intersects the specified point in local coordinates (ie. draws a pixel with alpha > 0 at\n\t * the specified position). This ignores the alpha, shadow, hitArea, mask, and compositeOperation of the display object.\n\t *\n\t * Please note that shape-to-shape collision is not currently supported by EaselJS.\n\t *\n\t * @example\n\t * stage.addEventListener(\"stagemousedown\", event => {\n\t * let hit = shape.hitTest(event.stageX, event.stageY);\n\t * // hit == true when shape is clicked\n\t * });\n\t *\n\t * @param {Number} x The x position to check in the display object's local coordinates.\n\t * @param {Number} y The y position to check in the display object's local coordinates.\n\t * @return {Boolean} A Boolean indicating whether a visible portion of the DisplayObject intersect the specified\n\t * local Point.\n\t*/\n\thitTest (x, y) {\n\t\tlet ctx = DisplayObject._hitTestContext;\n\t\tctx.setTransform(1, 0, 0, 1, -x, -y);\n\t\tthis.draw(ctx);\n\n\t\tlet hit = this._testHit(ctx);\n\t\tctx.setTransform(1, 0, 0, 1, 0, 0);\n\t\tctx.clearRect(0, 0, 2, 2);\n\t\treturn hit;\n\t}\n\n\t/**\n\t * Provides a chainable shortcut method for setting a number of properties on the instance.\n\t *\n\t * @example\n\t * let graphics = new Graphics().beginFill(\"#ff0000\").drawCircle(0, 0, 25);\n\t * let shape = stage.addChild(new Shape()).set({ graphics, x: 100, y: 100, alpha: 0.5 });\n\t *\n\t * @param {Object} props A generic object containing properties to copy to the DisplayObject instance.\n\t * @return {easeljs.DisplayObject} Returns the instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t*/\n\tset (props) {\n\t\tfor (let n in props) { this[n] = props[n]; }\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns a rectangle representing this object's bounds in its local coordinate system (ie. with no transformation).\n\t * Objects that have been cached will return the bounds of the cache.\n\t *\n\t * Not all display objects can calculate their own bounds (ex. Shape). For these objects, you can use\n\t * {@link easeljs.DisplayObject#setBounds} so that they are included when calculating Container bounds.\n\t *\n\t *
\n\t * \t
All
\n\t * \t\tAll display objects support setting bounds manually using setBounds(). Likewise, display objects that\n\t * \t\thave been cached using cache() will return the bounds of their cache. Manual and cache bounds will override\n\t * \t\tthe automatic calculations listed below.\n\t * \t
\n\t * \t
Bitmap
\n\t * \t\tReturns the width and height of the sourceRect (if specified) or image, extending from (x=0,y=0).\n\t * \t
\n\t * \t
Sprite
\n\t * \t\tReturns the bounds of the current frame. May have non-zero x/y if a frame registration point was specified\n\t * \t\tin the spritesheet data. See also {@link easeljs.SpriteSheet#getFrameBounds}\n\t * \t
\n\t * \t
Container
\n\t * \t\tReturns the aggregate (combined) bounds of all children that return a non-null value from getBounds().\n\t * \t
\n\t * \t
Shape
\n\t * \t\tDoes not currently support automatic bounds calculations. Use setBounds() to manually define bounds.\n\t * \t
\n\t * \t
Text
\n\t * \t\tReturns approximate bounds. Horizontal values (x/width) are quite accurate, but vertical values (y/height) are\n\t * \t\tnot, especially when using textBaseline values other than \"top\".\n\t * \t
\n\t * \t
BitmapText
\n\t * \t\tReturns approximate bounds. Values will be more accurate if spritesheet frame registration points are close\n\t * \t\tto (x=0,y=0).\n\t * \t
\n\t*
\n\t *\n\t * @example\n\t * /* Bounds can be expensive to calculate for some objects (ex. text, or containers with many children), and\n\t * are recalculated each time you call getBounds(). You can prevent recalculation on static objects by setting the\n\t * bounds explicitly. *\\/\n\t * let bounds = obj.getBounds();\n\t * obj.setBounds(bounds.x, bounds.y, bounds.width, bounds.height);\n\t * // getBounds will now use the set values, instead of recalculating\n\t *\n\t * @example\n\t * // To reduce memory impact, the returned Rectangle instance may be reused internally\n\t * let bounds = obj.getBounds().clone();\n\t * // OR:\n\t * rect.copy(obj.getBounds());\n\t *\n\t * @return {easeljs.Rectangle} A Rectangle instance representing the bounds, or null if bounds are not available for this object.\n\t */\n\tgetBounds () {\n\t\tif (this._bounds) { return this._rectangle.copy(this._bounds); }\n\t\tlet cacheCanvas = this.cacheCanvas;\n\t\tif (cacheCanvas) {\n\t\t\tlet scale = this._cacheScale;\n\t\t\treturn this._rectangle.setValues(this._cacheOffsetX, this._cacheOffsetY, cacheCanvas.width/scale, cacheCanvas.height/scale);\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**\n\t * Returns a rectangle representing this object's bounds in its parent's coordinate system (ie. with transformations applied).\n\t * Objects that have been cached will return the transformed bounds of the cache.\n\t *\n\t * Not all display objects can calculate their own bounds (ex. Shape). For these objects, you can use\n\t * {@link easeljs.DisplayObject#setBounds} so that they are included when calculating Container bounds.\n\t *\n\t * To reduce memory impact, the returned Rectangle instance may be reused internally; clone the instance or copy its\n\t * values if you need to retain it.\n\t *\n\t * Container instances calculate aggregate bounds for all children that return bounds via getBounds.\n\t * @return {easeljs.Rectangle} A Rectangle instance representing the bounds, or null if bounds are not available for this object.\n\t */\n\tgetTransformedBounds () {\n\t\treturn this._getBounds();\n\t}\n\n\t/**\n\t * Allows you to manually specify the bounds of an object that either cannot calculate their own bounds (ex. Shape &\n\t * Text) for future reference, or so the object can be included in Container bounds. Manually set bounds will always\n\t * override calculated bounds.\n\t *\n\t * The bounds should be specified in the object's local (untransformed) coordinates. For example, a Shape instance\n\t * with a 25px radius circle centered at 0,0 would have bounds of (-25, -25, 50, 50).\n\t *\n\t * @param {Number} x The x origin of the bounds. Pass null to remove the manual bounds.\n\t * @param {Number} y The y origin of the bounds.\n\t * @param {Number} width The width of the bounds.\n\t * @param {Number} height The height of the bounds.\n\t */\n\tsetBounds (x, y, width, height) {\n\t\tif (x == null) { this._bounds = null; }\n\t\tthis._bounds = (this._bounds || new Rectangle()).setValues(x, y, width, height);\n\t}\n\n\t/**\n\t * Returns a clone of this DisplayObject. Some properties that are specific to this instance's current context are\n\t * reverted to their defaults (for example .parent). Caches are not maintained across clones, and some elements\n\t * are copied by reference (masks, individual filter instances, hit area)\n\t *\n\t * @return {easeljs.DisplayObject} A clone of the current DisplayObject instance.\n\t */\n\tclone () {\n\t\treturn this._cloneProps(new DisplayObject());\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name}${this.name ? ` (name=${this.name})` : \"\"}]`;\n\t}\n\n\t/**\n\t * @protected\n\t * @param {easeljs.DisplayObject} o The DisplayObject instance which will have properties from the current DisplayObject\n\t * instance copied into.\n\t * @return {easeljs.DisplayObject} o\n\t */\n\t_cloneProps (o) {\n\t\to.alpha = this.alpha;\n\t\to.mouseEnabled = this.mouseEnabled;\n\t\to.tickEnabled = this.tickEnabled;\n\t\to.name = this.name;\n\t\to.regX = this.regX;\n\t\to.regY = this.regY;\n\t\to.rotation = this.rotation;\n\t\to.scaleX = this.scaleX;\n\t\to.scaleY = this.scaleY;\n\t\to.shadow = this.shadow;\n\t\to.skewX = this.skewX;\n\t\to.skewY = this.skewY;\n\t\to.visible = this.visible;\n\t\to.x = this.x;\n\t\to.y = this.y;\n\t\to.compositeOperation = this.compositeOperation;\n\t\to.snapToPixel = this.snapToPixel;\n\t\to.filters = this.filters==null?null:this.filters.slice(0);\n\t\to.mask = this.mask;\n\t\to.hitArea = this.hitArea;\n\t\to.cursor = this.cursor;\n\t\to._bounds = this._bounds;\n\t\treturn o;\n\t}\n\n\t/**\n\t * @protected\n\t * @param {CanvasRenderingContext2D} ctx\n\t * @param {easeljs.Shadow} [shadow=Shadow]\n\t */\n\t_applyShadow (ctx, shadow = Shadow.identity) {\n\t\tshadow = shadow;\n\t\tctx.shadowColor = shadow.color;\n\t\tctx.shadowOffsetX = shadow.offsetX;\n\t\tctx.shadowOffsetY = shadow.offsetY;\n\t\tctx.shadowBlur = shadow.blur;\n\t}\n\n\t/**\n\t * @protected\n\t * @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.\n\t */\n\t_tick (evtObj) {\n\t\t// because tick can be really performance sensitive, check for listeners before calling dispatchEvent.\n\t\tlet ls = this._listeners;\n\t\tif (ls && ls[\"tick\"]) {\n\t\t\t// reset & reuse the event object to avoid construction / GC costs:\n\t\t\tevtObj.target = null;\n\t\t\tevtObj.propagationStopped = evtObj.immediatePropagationStopped = false;\n\t\t\tthis.dispatchEvent(evtObj);\n\t\t}\n\t}\n\n\t/**\n\t * @protected\n\t * @param {CanvasRenderingContext2D} ctx\n\t * @return {Boolean}\n\t */\n\t_testHit (ctx) {\n\t\ttry {\n\t\t\treturn ctx.getImageData(0, 0, 1, 1).data[3] > 1;\n\t\t} catch (e) {\n\t\t\tif (!DisplayObject.suppressCrossDomainErrors) {\n\t\t\t\tthrow \"An error has occurred. This is most likely due to security restrictions on reading canvas pixel data with local or cross-domain images.\";\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * @protected\n\t * @param {easeljs.Matrix2D} matrix\n\t * @param {Boolean} ignoreTransform If true, does not apply this object's transform.\n\t * @return {easeljs.Rectangle}\n\t */\n\t_getBounds (matrix, ignoreTransform) {\n\t\treturn this._transformBounds(this.getBounds(), matrix, ignoreTransform);\n\t}\n\n\t/**\n\t * @protected\n\t * @param {easeljs.Rectangle} bounds\n\t * @param {easeljs.Matrix2D} matrix\n\t * @param {Boolean} ignoreTransform\n\t * @return {easeljs.Rectangle}\n\t */\n\t_transformBounds (bounds, matrix, ignoreTransform) {\n\t\tif (!bounds) { return bounds; }\n\t\tlet { x, y, width, height } = bounds;\n\t\tlet mtx = this._props.matrix;\n\t\tmtx = ignoreTransform ? mtx.identity() : this.getMatrix(mtx);\n\n\t\tif (x || y) { mtx.appendTransform(0,0,1,1,0,0,0,-x,-y); } // TODO: simplify this.\n\t\tif (matrix) { mtx.prependMatrix(matrix); }\n\n\t\tlet x_a = width*mtx.a, x_b = width*mtx.b;\n\t\tlet y_c = height*mtx.c, y_d = height*mtx.d;\n\t\tlet tx = mtx.tx, ty = mtx.ty;\n\n\t\tlet minX = tx, maxX = tx, minY = ty, maxY = ty;\n\n\t\tif ((x = x_a + tx) < minX) { minX = x; } else if (x > maxX) { maxX = x; }\n\t\tif ((x = x_a + y_c + tx) < minX) { minX = x; } else if (x > maxX) { maxX = x; }\n\t\tif ((x = y_c + tx) < minX) { minX = x; } else if (x > maxX) { maxX = x; }\n\n\t\tif ((y = x_b + ty) < minY) { minY = y; } else if (y > maxY) { maxY = y; }\n\t\tif ((y = x_b + y_d + ty) < minY) { minY = y; } else if (y > maxY) { maxY = y; }\n\t\tif ((y = y_d + ty) < minY) { minY = y; } else if (y > maxY) { maxY = y; }\n\n\t\treturn bounds.setValues(minX, minY, maxX-minX, maxY-minY);\n\t}\n\n\t/**\n\t * Indicates whether the display object has any mouse event listeners or a cursor.\n\t * @protected\n\t * @return {Boolean}\n\t */\n\t_hasMouseEventListener () {\n\t\tlet evts = DisplayObject._MOUSE_EVENTS;\n\t\tfor (let i=0, l=evts.length; i}\n * @readonly\n */\nDisplayObject._MOUSE_EVENTS = [\"click\",\"dblclick\",\"mousedown\",\"mouseout\",\"mouseover\",\"pressmove\",\"pressup\",\"rollout\",\"rollover\"];\n\n/**\n * Suppresses errors generated when using features like hitTest, mouse events, and {{#crossLink \"getObjectsUnderPoint\"}}{{/crossLink}}\n * with cross domain content.\n * @static\n * @type {Boolean}\n * @default false\n */\nDisplayObject.suppressCrossDomainErrors = false;\n\n/**\n * @static\n * @type {Boolean}\n * @default false\n */\nDisplayObject.snapToPixelEnabled = false;\n\n/**\n * Enum like property for determining StageGL render lookup, i.e. where to expect properties.\n * @static\n * @type {Number}\n */\nDisplayObject._StageGL_NONE = 0;\n\n/**\n * Enum like property for determining StageGL render lookup, i.e. where to expect properties.\n * @static\n * @type {Number}\n */\nDisplayObject._StageGL_SPRITE = 1;\n\n/**\n * Enum like property for determining StageGL render lookup, i.e. where to expect properties.\n * @static\n * @type {Number}\n */\nDisplayObject._StageGL_BITMAP = 2;\n\n/**\n * Dispatched when the user presses their left mouse button over the display object.\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.DisplayObject#mousedown\n * @since 0.6.0\n */\n\n/**\n * Dispatched when the user presses their left mouse button and then releases it while over the display object.\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.DisplayObject#click\n * @since 0.6.0\n */\n\n/**\n * Dispatched when the user double clicks their left mouse button over this display object.\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.DisplayObject#dblclick\n * @since 0.6.0\n */\n\n/**\n * Dispatched when the user's mouse enters this display object. This event must be enabled using\n * {@link easeljs.Stage#enableMouseOver}.\n * @see {@link easeljs.DisplayObject#event:rollover}\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.DisplayObject#mouseover\n * @since 0.6.0\n */\n\n/**\n * Dispatched when the user's mouse leaves this display object. This event must be enabled using\n * {@link easeljs.Stage#enableMouseOver}.\n * @see {@link easeljs.DisplayObject#event:rollout}\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.DisplayObject#mouseout\n * @since 0.6.0\n */\n\n/**\n * This event is similar to {@link easeljs.DisplayObject#event:mouseover}, with the following\n * differences: it does not bubble, and it considers {@link easeljs.Container} instances as an\n * aggregate of their content.\n *\n * For example, myContainer contains two overlapping children: shapeA and shapeB. The user moves their mouse over\n * shapeA and then directly on to shapeB. With a listener for {@link easeljs.DisplayObject#event:mouseover} on\n * myContainer, two events would be received, each targeting a child element:\n * \n *
when the mouse enters shapeA (target=shapeA)
\n *
when the mouse enters shapeB (target=shapeB)
\n * \n * However, with a listener for \"rollover\" instead, only a single event is received when the mouse first enters\n * the aggregate myContainer content (target=myContainer).\n *\n * This event must be enabled using {@link easeljs.Stage#enableMouseOver}.\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.DisplayObject#rollover\n * @since 0.7.0\n */\n\n/**\n * This event is similar to {@link easeljs.DisplayObject#event:mouseout}, with the following\n * differences: it does not bubble, and it considers {@link easeljs.Container} instances as an\n * aggregate of their content.\n *\n * For example, myContainer contains two overlapping children: shapeA and shapeB. The user moves their mouse over\n * shapeA, then directly on to shapeB, then off both. With a listener for {@link easeljs.DisplayObject#event:mouseout}\n * on myContainer, two events would be received, each targeting a child element:\n *
when the mouse leaves shapeA (target=shapeA)
\n *
when the mouse leaves shapeB (target=shapeB)
\n * \n * However, with a listener for \"rollout\" instead, only a single event is received when the mouse leaves\n * the aggregate myContainer content (target=myContainer).\n *\n * This event must be enabled using {@link easeljs.Stage#enableMouseOver}.\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.DisplayObject#rollout\n * @since 0.7.0\n */\n\n/**\n * After a {@link easeljs.DisplayObject#event:mousedown} occurs on a display object, a pressmove\n * event will be generated on that object whenever the mouse moves until the mouse press is released. This can be\n * useful for dragging and similar operations.\n * @event easeljs.DisplayObject#pressmove\n * @since 0.7.0\n */\n\n/**\n * After a {@link easeljs.DisplayObject#event:mousedown} occurs on a display object, a pressup event\n * will be generated on that object when that mouse press is released. This can be useful for dragging and similar\n * operations.\n * @event easeljs.DisplayObject#pressup\n * @since 0.7.0\n */\n\n/**\n * Dispatched when the display object is added to a parent container.\n * @event easeljs.DisplayObject#added\n */\n\n/**\n * Dispatched when the display object is removed from its parent container.\n * @event easeljs.DisplayObject#removed\n */\n\n/**\n * Dispatched on each display object on a stage whenever the stage updates. This occurs immediately before the\n * rendering (draw) pass. When {@link easeljs.Stage#update} is called, first all display objects on\n * the stage dispatch the tick event, then all of the display objects are drawn to stage. Children will have their\n * tick event dispatched in order of their depth prior to the event being dispatched on their parent.\n * @event easeljs.DisplayObject#tick\n * @param {Object} target The object that dispatched the event.\n * @param {String} type The event type.\n * @param {Array} params An array containing any arguments that were passed to the Stage.update() method.\n * @since 0.6.0\n */\n","/**\n * @license Container\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport DisplayObject from \"./DisplayObject\";\n\n/**\n * A Container is a nestable display list that allows you to work with compound display elements. For example you could\n * group arm, leg, torso and head {{#crossLink \"Bitmap\"}}{{/crossLink}} instances together into a Person Container, and\n * transform them as a group, while still being able to move the individual parts relative to each other. Children of\n * containers have their `transform` and `alpha` properties concatenated with their parent\n * Container.\n *\n * For example, a {{#crossLink \"Shape\"}}{{/crossLink}} with x=100 and alpha=0.5, placed in a Container with `x=50`\n * and `alpha=0.7` will be rendered to the canvas at `x=150` and `alpha=0.35`.\n * Containers have some overhead, so you generally shouldn't create a Container to hold a single child.\n *\n * @memberof easeljs\n * @extends easeljs.DisplayObject\n * @example\n * import { Container } from \"@createjs/easeljs\";\n * const container = new Container();\n * container.addChild(bitmapInstance, shapeInstance);\n * container.x = 100;\n */\nexport default class Container extends DisplayObject {\n\n\tconstructor () {\n\t\tsuper();\n\n\t\t/**\n\t\t * The array of children in the display list. You should usually use the child management methods such as\n\t\t * {@link easeljs.Container#addChild}, {@link easeljs.Container#removeChild}, {@link easeljs.Container#swapChildren},\n\t\t * etc, rather than accessing this directly, but it is included for advanced uses.\n\t\t * @type {Array}\n\t\t * @default []\n\t\t */\n\t\tthis.children = [];\n\n\t\t/**\n\t\t * Indicates whether the children of this container are independently enabled for mouse/pointer interaction.\n\t\t * If false, the children will be aggregated under the container - for example, a click on a child shape would\n\t\t * trigger a click event on the container.\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.mouseChildren = true;\n\n\t\t/**\n\t\t * If false, the tick will not be propagated to children of this Container. This can provide some performance benefits.\n\t\t * In addition to preventing the {@link core.Ticker#event:tick} event from being dispatched, it will also prevent tick related updates\n\t\t * on some display objects (ex. Sprite & MovieClip frame advancing, DOMElement visibility handling).\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.tickChildren = true;\n\t}\n\n\t/**\n\t * Returns the number of children in the container.\n\t * @type {Number}\n\t * @readonly\n\t */\n\tget numChildren () {\n\t\treturn this.children.length;\n\t}\n\n\tisVisible () {\n\t\tlet hasContent = this.cacheCanvas || this.children.length;\n\t\treturn !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && hasContent);\n\t}\n\n\tdraw (ctx, ignoreCache = false) {\n\t\tif (super.draw(ctx, ignoreCache)) { return true; }\n\n\t\t// this ensures we don't have issues with display list changes that occur during a draw:\n\t\tlet list = this.children.slice();\n\t\tfor (let i=0,l=list.length; i 1) {\n\t\t\tfor (let i = 0; i < l; i++) { child = this.addChild(children[i]); }\n\t\t\treturn child;\n\t\t}\n // Note: a lot of duplication with addChildAt, but push is WAY faster than splice.\n let parent = child.parent, silent = parent === this;\n parent && parent._removeChildAt(parent.children.indexOf(child), silent);\n\t\tchild.parent = this;\n\t\tthis.children.push(child);\n if (!silent) { child.dispatchEvent(\"added\"); }\n\t\treturn child;\n\t}\n\n\t/**\n\t * Adds a child to the display list at the specified index, bumping children at equal or greater indexes up one, and\n\t * setting its parent to this container.\n\t *\n\t * @example\n\t * container.addChildAt(child1, index);\n\t * // You can also add multiple children, such as:\n\t * container.addChildAt(child1, child2, ..., index);\n\t * // The index must be between 0 and numChildren. For example, to add myShape under otherShape in the display list, you could use:\n\t * container.addChildAt(myShape, container.getChildIndex(otherShape));\n\t * // This would also bump otherShape's index up by one. Fails silently if the index is out of range.\n\t *\n\t * @param {...easeljs.DisplayObject} children The display object(s) to add.\n\t * @param {Number} index The index to add the child at.\n\t * @return {easeljs.DisplayObject} Returns the last child that was added, or the last child if multiple children were added.\n\t */\n\taddChildAt (...children) {\n\t\tconst l = children.length;\n if (l === 0) { return null; }\n let index = children.pop();\n\t\tif (index < 0 || index > this.children.length) { return children[l - 2]; }\n\t\tif (l > 2) {\n\t\t\tfor (let i = 0; i < l - 1; i++) { this.addChildAt(children[i], index++); }\n\t\t\treturn children[l - 2];\n\t\t}\n\t\tlet child = children[0];\n let parent = child.parent, silent = parent === this;\n parent && parent._removeChildAt(parent.children.indexOf(child), silent);\n\t\tchild.parent = this;\n\t\tthis.children.splice(index++, 0, child);\n if (!silent) { child.dispatchEvent(\"added\"); }\n\t\treturn child;\n\t}\n\n\t/**\n\t * Removes the specified child from the display list. Note that it is faster to use removeChildAt() if the index is\n\t * already known.\n\t *\n\t * @example\n\t * container.removeChild(child);\n\t * // You can also remove multiple children:\n\t * container.removeChild(child1, child2, ...);\n\t *\n\t * @param {...easeljs.DisplayObject} children The display object(s) to remove.\n\t * @return {Boolean} true if the child (or children) was removed, or false if it was not in the display list.\n\t */\n\tremoveChild (...children) {\n\t\tconst l = children.length;\n if (l === 0) { return true; }\n\t\tif (l > 1) {\n\t\t\tlet good = true;\n\t\t\tfor (let i = 0; i < l; i++) { good = good && this.removeChild(children[i]); }\n\t\t\treturn good;\n\t\t}\n\t\treturn this._removeChildAt(this.children.indexOf(children[0]));\n\t}\n\n\t/**\n\t * Removes the child at the specified index from the display list, and sets its parent to null.\n\t *\n\t * @example\n\t * container.removeChildAt(2);\n\t * // You can also remove multiple children:\n\t * container.removeChildAt(2, 7, ...)\n\t *\n\t * @param {...Number} indexes The indexes of children to remove.\n\t * @return {Boolean} true if the child (or children) was removed, or false if any index was out of range.\n\t */\n\tremoveChildAt (...indexes) {\n\t\tconst l = indexes.length;\n if (l === 0) { return true; }\n\t\tif (l > 1) {\n\t\t\tindexes.sort((a, b) => b - a);\n\t\t\tlet good = true;\n\t\t\tfor (let i = 0; i < l; i++) { good = good && this._removeChildAt(indexes[i]); }\n\t\t\treturn good;\n\t\t}\n\t\treturn this._removeChildAt(indexes[0]);\n\t}\n\n\t/**\n\t * Removes all children from the display list.\n\t */\n\tremoveAllChildren () {\n\t\tlet kids = this.children;\n\t\twhile (kids.length) { this._removeChildAt(0); }\n\t}\n\n\t/**\n\t * Returns the child at the specified index.\n\t * @param {Number} index The index of the child to return.\n\t * @return {easeljs.DisplayObject} The child at the specified index. Returns null if there is no child at the index.\n\t */\n\tgetChildAt (index) {\n\t\treturn this.children[index];\n\t}\n\n\t/**\n\t * Returns the child with the specified name.\n\t * @param {String} name The name of the child to return.\n\t * @return {easeljs.DisplayObject} The child with the specified name.\n\t */\n\tgetChildByName (name) {\n\t\tlet kids = this.children;\n\t\tconst l = kids.length;\n\t\tfor (let i = 0; i < l; i++) {\n\t\t\tif (kids[i].name === name) { return kids[i]; }\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**\n\t * Performs an array sort operation on the child list.\n\t *\n\t * @example\n\t * // Display children with a higher y in front.\n\t * container.sortChildren((obj1, obj2, options) => {\n\t * \t if (obj1.y > obj2.y) { return 1; }\n\t * if (obj1.y < obj2.y) { return -1; }\n\t * return 0;\n\t * });\n\t *\n\t * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort}\n\t * @param {Function} sortFunction the function to use to sort the child list.\n\t */\n\tsortChildren (sortFunction) {\n\t\tthis.children.sort(sortFunction);\n\t}\n\n\t/**\n\t * Returns the index of the specified child in the display list, or -1 if it is not in the display list.\n\t * @param {easeljs.DisplayObject} child The child to return the index of.\n\t * @return {Number} The index of the specified child. -1 if the child is not found.\n\t */\n\tgetChildIndex (child) {\n\t\treturn this.children.indexOf(child);\n\t}\n\n\t/**\n\t * Swaps the children at the specified indexes. Fails silently if either index is out of range.\n\t * @param {Number} index1\n\t * @param {Number} index2\n\t */\n\tswapChildrenAt (index1, index2) {\n\t\tlet kids = this.children;\n\t\tlet o1 = kids[index1];\n\t\tlet o2 = kids[index2];\n\t\tif (!o1 || !o2) { return; }\n\t\tkids[index1] = o2;\n\t\tkids[index2] = o1;\n\t};\n\n\t/**\n\t * Swaps the specified children's depth in the display list. Fails silently if either child is not a child of this\n\t * Container.\n\t * @param {easeljs.DisplayObject} child1\n\t * @param {easeljs.DisplayObject} child2\n\t */\n\tswapChildren (child1, child2) {\n\t\tlet kids = this.children;\n\t\tconst l = kids.length;\n\t\tlet index1,index2;\n\t\tfor (var i = 0; i < l; i++) {\n\t\t\tif (kids[i] === child1) { index1 = i; }\n\t\t\tif (kids[i] === child2) { index2 = i; }\n\t\t\tif (index1 != null && index2 != null) { break; }\n\t\t}\n\t\tif (i === l) { return; } // TODO: throw error?\n\t\tkids[index1] = child2;\n\t\tkids[index2] = child1;\n\t}\n\n\t/**\n\t * Changes the depth of the specified child. Fails silently if the child is not a child of this container, or the index is out of range.\n\t * @param {easeljs.DisplayObject} child\n\t * @param {Number} index\n\t */\n\tsetChildIndex (child, index) {\n\t\tlet kids = this.children;\n\t\tconst l = kids.length;\n\t\tif (child.parent != this || index < 0 || index >= l) { return; }\n\t\tfor (var i = 0; i < l; i++) {\n\t\t\tif (kids[i] === child) { break; }\n\t\t}\n\t\tif (i === l || i === index) { return; }\n\t\tkids.splice(i, 1);\n\t\tkids.splice(index, 0, child);\n\t}\n\n\t/**\n\t * Returns true if the specified display object either is this container or is a descendent (child, grandchild, etc)\n\t * of this container.\n\t * @param {easeljs.DisplayObject} child The DisplayObject to be checked.\n\t * @return {Boolean} true if the specified display object either is this container or is a descendent.\n\t */\n\tcontains (child) {\n\t\twhile (child) {\n\t\t\tif (child === this) { return true; }\n\t\t\tchild = child.parent;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Tests whether the display object intersects the specified local point (ie. draws a pixel with alpha > 0 at the\n\t * specified position). This ignores the alpha, shadow and compositeOperation of the display object, and all\n\t * transform properties including regX/Y.\n\t * @param {Number} x The x position to check in the display object's local coordinates.\n\t * @param {Number} y The y position to check in the display object's local coordinates.\n\t * @return {Boolean} A Boolean indicating whether there is a visible section of a DisplayObject that overlaps the specified\n\t * coordinates.\n\t */\n\thitTest (x, y) {\n\t\t// TODO: optimize to use the fast cache check where possible.\n\t\treturn this.getObjectUnderPoint(x, y) != null;\n\t}\n\n\t/**\n\t * Returns an array of all display objects under the specified coordinates that are in this container's display\n\t * list. This routine ignores any display objects with {@link easeljs.DisplayObject#mouseEnabled} set to `false`.\n\t * The array will be sorted in order of visual depth, with the top-most display object at index 0.\n\t * This uses shape based hit detection, and can be an expensive operation to run, so it is best to use it carefully.\n\t * For example, if testing for objects under the mouse, test on tick (instead of on {@link easeljs.DisplayObject#event:mousemove}),\n\t * and only if the mouse's position has changed.\n\t *\n\t *
\n\t *
By default (mode=0) this method evaluates all display objects.
\n\t *
By setting the `mode` parameter to `1`, the {@link easeljs.DisplayObject#mouseEnabled}\n\t * and {@link easeljs.DisplayObject#mouseChildren} properties will be respected.
\n\t *
Setting the `mode` to `2` additionally excludes display objects that do not have active mouse event\n\t * listeners or a {@link easeljs.DisplayObject#cursor} property. That is, only objects\n\t * that would normally intercept mouse interaction will be included. This can significantly improve performance\n\t * in some cases by reducing the number of display objects that need to be tested.
\n\t *
\n\t *\n\t * This method accounts for both {@link easeljs.DisplayObject#hitArea} and {@link easeljs.DisplayObject#mask}.\n\t *\n\t * @param {Number} x The x position in the container to test.\n\t * @param {Number} y The y position in the container to test.\n\t * @param {Number} [mode=0] The mode to use to determine which display objects to include. 0-all, 1-respect mouseEnabled/mouseChildren, 2-only mouse opaque objects.\n\t * @return {Array} An array of DisplayObjects under the specified coordinates.\n\t */\n\tgetObjectsUnderPoint (x, y, mode = 0) {\n\t\tlet arr = [];\n\t\tlet pt = this.localToGlobal(x, y);\n\t\tthis._getObjectsUnderPoint(pt.x, pt.y, arr, mode > 0, mode === 1);\n\t\treturn arr;\n\t}\n\n\t/**\n\t * Similar to {@link easeljs.Container#getObjectsUnderPoint}, but returns only the top-most display\n\t * object. This runs significantly faster than `getObjectsUnderPoint()`, but is still potentially an expensive\n\t * operation.\n\t *\n\t * @param {Number} x The x position in the container to test.\n\t * @param {Number} y The y position in the container to test.\n\t * @param {Number} [mode=0] The mode to use to determine which display objects to include. 0-all, 1-respect mouseEnabled/mouseChildren, 2-only mouse opaque objects.\n\t * @return {easeljs.DisplayObject} The top-most display object under the specified coordinates.\n\t */\n\tgetObjectUnderPoint (x, y, mode = 0) {\n\t\tlet pt = this.localToGlobal(x, y);\n\t\treturn this._getObjectsUnderPoint(pt.x, pt.y, null, mode > 0, mode === 1);\n\t}\n\n\tgetBounds () {\n\t\treturn this._getBounds(null, true);\n\t}\n\n\tgetTransformedBounds () {\n\t\treturn this._getBounds();\n\t}\n\n\t/**\n\t * Returns a clone of this Container. Some properties that are specific to this instance's current context are\n\t * reverted to their defaults (for example `.parent`).\n\t * @param {Boolean} [recursive=false] If true, all of the descendants of this container will be cloned recursively. If false, the\n\t * properties of the container will be cloned, but the new instance will not have any children.\n\t * @return {easeljs.Container} A clone of the current Container instance.\n\t */\n\tclone (recursive = false) {\n\t\tlet o = this._cloneProps(new Container());\n\t\tif (recursive) { this._cloneChildren(o); }\n\t\treturn o;\n\t}\n\n\t_tick (evtObj) {\n\t\tif (this.tickChildren) {\n\t\t\tfor (let i = this.children.length - 1; i >= 0; i--) {\n\t\t\t\tlet child = this.children[i];\n\t\t\t\tif (child.tickEnabled && child._tick) { child._tick(evtObj); }\n\t\t\t}\n\t\t}\n\t\tsuper._tick(evtObj);\n\t}\n\n\t/**\n\t * Recursively clones all children of this container, and adds them to the target container.\n\t * @protected\n\t * @param {easeljs.Container} o The target container.\n\t */\n\t_cloneChildren (o) {\n\t\tif (o.children.length) { o.removeAllChildren(); }\n\t\tlet arr = o.children;\n\t\tconst l = this.children.length;\n\t\tfor (let i = 0; i < l; i++) {\n\t\t\tlet clone = this.children[i].clone(true);\n\t\t\tclone.parent = o;\n\t\t\tarr.push(clone);\n\t\t}\n\t}\n\n /**\n * Removes the child at the specified index from the display list, and sets its parent to null.\n * Used by `removeChildAt`, `addChild`, and `addChildAt`.\n *\n * @protected\n * @param {Number} index The index of the child to remove.\n * @param {Boolean} [silent=false] Prevents dispatch of `removed` event if true.\n * @return {Boolean} true if the child (or children) was removed, or false if any index was out of range.\n */\n _removeChildAt (index, silent = false) {\n\t\tif (index < 0 || index > this.children.length - 1) { return false; }\n\t\tlet child = this.children[index];\n\t\tif (child) { child.parent = null; }\n\t\tthis.children.splice(index, 1);\n\t\tif (!silent) { child.dispatchEvent(\"removed\"); }\n\t\treturn true;\n }\n\n\t/**\n\t * @protected\n\t * @param {Number} x\n\t * @param {Number} y\n\t * @param {Array} arr\n\t * @param {Boolean} mouse If true, it will respect mouse interaction properties like mouseEnabled, mouseChildren, and active listeners.\n\t * @param {Boolean} activeListener If true, there is an active mouse event listener on a parent object.\n\t * @param {Number} [currentDepth=0] Indicates the current depth of the search.\n\t * @return {easeljs.DisplayObject}\n\t */\n\t_getObjectsUnderPoint (x, y, arr, mouse, activeListener, currentDepth = 0) {\n\t\tif (!currentDepth && !this._testMask(this, x, y)) { return null; }\n\t\tlet mtx, ctx = DisplayObject._hitTestContext;\n\t\tactiveListener = activeListener || (mouse && this._hasMouseEventListener());\n\n\t\t// draw children one at a time, and check if we get a hit:\n\t\tlet children = this.children;\n\t\tconst l = children.length;\n\t\tfor (let i = l - 1; i >= 0; i--) {\n\t\t\tlet child = children[i];\n\t\t\tlet hitArea = child.hitArea;\n\t\t\tif (!child.visible || (!hitArea && !child.isVisible()) || (mouse && !child.mouseEnabled)) { continue; }\n\t\t\tif (!hitArea && !this._testMask(child, x, y)) { continue; }\n\n\t\t\t// if a child container has a hitArea then we only need to check its hitArea, so we can treat it as a normal DO:\n\t\t\tif (!hitArea && child instanceof Container) {\n\t\t\t\tlet result = child._getObjectsUnderPoint(x, y, arr, mouse, activeListener, currentDepth + 1);\n\t\t\t\tif (!arr && result) { return (mouse && !this.mouseChildren) ? this : result; }\n\t\t\t} else {\n\t\t\t\tif (mouse && !activeListener && !child._hasMouseEventListener()) { continue; }\n\n\t\t\t\t// TODO: can we pass displayProps forward, to avoid having to calculate this backwards every time? It's kind of a mixed bag. When we're only hunting for DOs with event listeners, it may not make sense.\n\t\t\t\tlet props = child.getConcatenatedDisplayProps(child._props);\n\t\t\t\tmtx = props.matrix;\n\n\t\t\t\tif (hitArea) {\n\t\t\t\t\tmtx.appendMatrix(hitArea.getMatrix(hitArea._props.matrix));\n\t\t\t\t\tprops.alpha = hitArea.alpha;\n\t\t\t\t}\n\n\t\t\t\tctx.globalAlpha = props.alpha;\n\t\t\t\tctx.setTransform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx-x, mtx.ty-y);\n\t\t\t\t(hitArea || child).draw(ctx);\n\t\t\t\tif (!this._testHit(ctx)) { continue; }\n\t\t\t\tctx.setTransform(1, 0, 0, 1, 0, 0);\n\t\t\t\tctx.clearRect(0, 0, 2, 2);\n\t\t\t\tif (arr) { arr.push(child); }\n\t\t\t\telse { return (mouse && !this.mouseChildren) ? this : child; }\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\t/**\n\t * @protected\n\t * @param {easeljs.DisplayObject} target\n\t * @param {Number} x\n\t * @param {Number} y\n\t * @return {Boolean} Indicates whether the x/y is within the masked region.\n\t */\n\t_testMask (target, x, y) {\n\t\tlet mask = target.mask;\n\t\tif (!mask || !mask.graphics || mask.graphics.isEmpty()) { return true; }\n\n\t\tlet mtx = this._props.matrix, parent = target.parent;\n\t\tmtx = parent ? parent.getConcatenatedMatrix(mtx) : mtx.identity();\n\t\tmtx = mask.getMatrix(mask._props.matrix).prependMatrix(mtx);\n\n\t\tlet ctx = DisplayObject._hitTestContext;\n\t\tctx.setTransform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx-x, mtx.ty-y);\n\n\t\t// draw the mask as a solid fill:\n\t\tmask.graphics.drawAsPath(ctx);\n\t\tctx.fillStyle = \"#000\";\n\t\tctx.fill();\n\n\t\tif (!this._testHit(ctx)) { return false; }\n\t\tctx.setTransform(1, 0, 0, 1, 0, 0);\n\t\tctx.clearRect(0, 0, 2, 2);\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * @protected\n\t * @param {easeljs.Matrix2D} matrix\n\t * @param {Boolean} ignoreTransform If true, does not apply this object's transform.\n\t * @return {easeljs.Rectangle}\n\t */\n\t_getBounds (matrix, ignoreTransform) {\n\t\tlet bounds = super.getBounds();\n\t\tif (bounds) { return this._transformBounds(bounds, matrix, ignoreTransform); }\n\n\t\tlet mtx = this._props.matrix;\n\t\tmtx = ignoreTransform ? mtx.identity() : this.getMatrix(mtx);\n\t\tif (matrix) { mtx.prependMatrix(matrix); }\n\n\t\tconst l = this.children.length;\n\t\tlet rect = null;\n\t\tfor (let i = 0; i < l; i++) {\n\t\t\tlet child = this.children[i];\n\t\t\tif (!child.visible || !(bounds = child._getBounds(mtx))) { continue; }\n\t\t\tif (rect) { rect.extend(bounds.x, bounds.y, bounds.width, bounds.height); }\n\t\t\telse { rect = bounds.clone(); }\n\t\t}\n\t\treturn rect;\n\t}\n\n}\n","/**\n * @license MouseEvent\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport { Event } from \"@createjs/core\";\n\n/**\n * Passed as the parameter to all mouse/pointer/touch related events. For a listing of mouse events and their properties,\n * see the {@link easeljs.DisplayObject} and {@link easeljs.Stage} event listings.\n * @memberof easeljs\n * @extends core.Event\n * @param {String} type The event type.\n * @param {Boolean} bubbles Indicates whether the event will bubble through the display list.\n * @param {Boolean} cancelable Indicates whether the default behaviour of this event can be cancelled.\n * @param {Number} stageX The normalized x position relative to the stage.\n * @param {Number} stageY The normalized y position relative to the stage.\n * @param {easeljs.MouseEvent} nativeEvent The native DOM event related to this mouse event.\n * @param {Number} pointerID The unique id for the pointer.\n * @param {Boolean} primary Indicates whether this is the primary pointer in a multitouch environment.\n * @param {Number} rawX The raw x position relative to the stage.\n * @param {Number} rawY The raw y position relative to the stage.\n * @param {easeljs.DisplayObject} relatedTarget The secondary target for the event.\n */\nexport default class MouseEvent extends Event {\n\n\tconstructor (type, bubbles, cancelable, stageX, stageY, nativeEvent, pointerID, primary, rawX, rawY, relatedTarget) {\n\t\tsuper(type, bubbles, cancelable);\n\n// public properties:\n\t\t/**\n\t\t * The normalized x position on the stage. This will always be within the range 0 to stage width.\n\t\t * @type {Number}\n\t\t*/\n\t\tthis.stageX = stageX;\n\n\t\t/**\n\t\t * The normalized y position on the stage. This will always be within the range 0 to stage height.\n\t\t * @type {Number}\n\t\t */\n\t\tthis.stageY = stageY;\n\n\t\t/**\n\t\t * The raw x position relative to the stage. Normally this will be the same as the stageX value, unless\n\t\t * stage.mouseMoveOutside is true and the pointer is outside of the stage bounds.\n\t\t * @type {Number}\n\t\t*/\n\t\tthis.rawX = (rawX==null)?stageX:rawX;\n\n\t\t/**\n\t\t * The raw y position relative to the stage. Normally this will be the same as the stageY value, unless\n\t\t * stage.mouseMoveOutside is true and the pointer is outside of the stage bounds.\n\t\t * @type {Number}\n\t\t*/\n\t\tthis.rawY = (rawY==null)?stageY:rawY;\n\n\t\t/**\n\t\t * The native MouseEvent generated by the browser. The properties and API for this\n\t\t * event may differ between browsers. This property will be null if the\n\t\t * EaselJS property was not directly generated from a native MouseEvent.\n\t\t * @type {HTMLMouseEvent}\n\t\t */\n\t\tthis.nativeEvent = nativeEvent;\n\n\t\t/**\n\t\t * The unique id for the pointer (touch point or cursor). This will be either -1 for the mouse, or the system\n\t\t * supplied id value.\n\t\t * @type {Number}\n\t\t */\n\t\tthis.pointerID = pointerID;\n\n\t\t/**\n\t\t * Indicates whether this is the primary pointer in a multitouch environment. This will always be true for the mouse.\n\t\t * For touch pointers, the first pointer in the current stack will be considered the primary pointer.\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis.primary = !!primary;\n\n\t\t/**\n\t\t * The secondary target for the event, if applicable. This is used for mouseout/rollout\n\t\t * events to indicate the object that the mouse entered from, mouseover/rollover for the object the mouse exited,\n\t\t * and stagemousedown/stagemouseup events for the object that was the under the cursor, if any.\n\t\t *\n\t\t * Only valid interaction targets will be returned (ie. objects with mouse listeners or a cursor set).\n\t\t * @type {easeljs.DisplayObject}\n\t\t */\n\t\tthis.relatedTarget = relatedTarget;\n\t}\n\n\t/**\n\t * Returns the x position of the mouse in the local coordinate system of the current target (ie. the dispatcher).\n\t * @type {Number}\n\t * @readonly\n\t */\n\tget localX () {\n\t\treturn this.currentTarget.globalToLocal(this.rawX, this.rawY).x;\n\t}\n\n\t/**\n\t * Returns the y position of the mouse in the local coordinate system of the current target (ie. the dispatcher).\n\t * @type {Number}\n\t * @readonly\n\t */\n\tget localY () {\n\t\treturn this.currentTarget.globalToLocal(this.rawX, this.rawY).y;\n\t}\n\n\t/**\n\t * Indicates whether the event was generated by a touch input (versus a mouse input).\n\t * @type {Boolean}\n\t * @readonly\n\t */\n\tget isTouch () {\n\t\treturn this.pointerID !== -1;\n\t}\n\n\t/**\n\t * Returns a clone of the MouseEvent instance.\n\t * @return {easeljs.MouseEvent} a clone of the MouseEvent instance.\n\t */\n\tclone () {\n\t\treturn new MouseEvent(this.type, this.bubbles, this.cancelable, this.stageX, this.stageY, this.nativeEvent, this.pointerID, this.primary, this.rawX, this.rawY);\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name} (type=${this.type} stageX=${this.stageX} stageY=${this.stageY})]`;\n\t}\n\n}\n","/**\n * @license Stage\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Container from \"./Container\";\nimport DisplayObject from \"./DisplayObject\";\nimport { Event } from \"@createjs/core\";\nimport MouseEvent from \"../events/MouseEvent\";\n\n/**\n * A stage is the root level {@link easeljs.Container} for a display list. Each time its {@link easeljs.Stage#tick}\n * method is called, it will render its display list to its target canvas.\n *\n * @memberof easeljs\n * @extends easeljs.Container\n * @example\n * let stage = new Stage(\"canvasElementId\");\n * let image = new Bitmap(\"imagePath.png\");\n * stage.addChild(image);\n * Ticker.addEventListener(\"tick\", event => {\n * image.x += 10;\n * \t stage.update();\n * });\n *\n * @param {HTMLCanvasElement | String | Object} canvas A canvas object that the Stage will render to, or the string id\n * of a canvas object in the current document.\n */\nexport default class Stage extends Container {\n\n\tconstructor (canvas) {\n\t\tsuper();\n\n\t\t/**\n\t\t * Indicates whether the stage should automatically clear the canvas before each render. You can set this to `false`\n\t\t * to manually control clearing (for generative art, or when pointing multiple stages at the same canvas for\n\t\t * example).\n\t\t *\n\t\t * @example\n\t\t * let stage = new Stage(\"canvasId\");\n\t\t * stage.autoClear = false;\n\t\t *\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.autoClear = true;\n\n\t\t/**\n\t\t * The canvas the stage will render to. Multiple stages can share a single canvas, but you must disable autoClear for all but the\n\t\t * first stage that will be ticked (or they will clear each other's render).\n\t\t *\n\t\t * When changing the canvas property you must disable the events on the old canvas, and enable events on the\n\t\t * new canvas or mouse events will not work as expected.\n\t\t *\n\t\t * @example\n\t\t * stage.enableDOMEvents(false);\n\t\t * stage.canvas = anotherCanvas;\n\t\t * stage.enableDOMEvents(true);\n\t\t *\n\t\t * @type {HTMLCanvasElement | Object}\n\t\t */\n\t\tthis.canvas = (typeof canvas === \"string\") ? document.getElementById(canvas) : canvas;\n\n\t\t/**\n\t\t * The current mouse X position on the canvas. If the mouse leaves the canvas, this will indicate the most recent\n\t\t * position over the canvas, and mouseInBounds will be set to false.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t * @readonly\n\t\t */\n\t\tthis.mouseX = 0;\n\n\t\t/**\n\t\t * The current mouse Y position on the canvas. If the mouse leaves the canvas, this will indicate the most recent\n\t\t * position over the canvas, and mouseInBounds will be set to false.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t * @readonly\n\t\t */\n\t\tthis.mouseY = 0;\n\n\t\t/**\n\t\t * Specifies the area of the stage to affect when calling update. This can be use to selectively\n\t\t * re-draw specific regions of the canvas. If null, the whole canvas area is drawn.\n\t\t * @type {easeljs.Rectangle}\n\t\t */\n\t\tthis.drawRect = null;\n\n\t\t/**\n\t\t * Indicates whether display objects should be rendered on whole pixels. You can set the {@link easeljs.DisplayObject.snapToPixelEnabled}\n\t\t * property of display objects to false to enable/disable this behaviour on a per instance basis.\n\t\t * @type {Boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.snapToPixelEnabled = false;\n\n\t\t/**\n\t\t * Indicates whether the mouse is currently within the bounds of the canvas.\n\t\t * @type {Boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.mouseInBounds = false;\n\n\t\t/**\n\t\t * If true, tick callbacks will be called on all display objects on the stage prior to rendering to the canvas.\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.tickOnUpdate = true;\n\n\t\t/**\n\t\t * If true, mouse move events will continue to be called when the mouse leaves the target canvas.\n\t\t * See {@link easeljs.Stage#mouseInBounds}, and {@link easeljs.MouseEvent} x/y/rawX/rawY.\n\t\t * @type {Boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.mouseMoveOutside = false;\n\n\n\t\t/**\n\t\t * Prevents selection of other elements in the html page if the user clicks and drags, or double clicks on the canvas.\n\t\t * This works by calling `preventDefault()` on any mousedown events (or touch equivalent) originating on the canvas.\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.preventSelection = true;\n\n\t\t/**\n\t\t * The hitArea property is not supported for Stage.\n\t\t * @property hitArea\n\t\t * @override\n\t\t * @default null\n\t\t * @private\n\t\t */\n\n\t\t/**\n\t\t * Holds objects with data for each active pointer id. Each object has the following properties:\n\t\t * x, y, event, target, overTarget, overX, overY, inBounds, posEvtObj (native event that last updated position)\n\t\t * @type {Object}\n\t\t * @private\n\t\t */\n\t\tthis._pointerData = {};\n\n\t\t/**\n\t\t * Number of active pointers.\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._pointerCount = 0;\n\n\t\t/**\n\t\t * The ID of the primary pointer.\n\t\t * @type {String}\n\t\t * @private\n\t\t */\n\t\tthis._primaryPointerID = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._mouseOverIntervalID = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.Stage}\n\t\t */\n\t\tthis._nextStage = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.Stage}\n\t\t */\n\t\tthis._prevStage = null;\n\n\t\tthis.enableDOMEvents(true);\n\t}\n\n\t/**\n\t * Specifies a target stage that will have mouse/touch interactions relayed to it after this stage handles them.\n\t * This can be useful in cases where you have multiple layered canvases and want user interactions\n\t * events to pass through.\n\t *\n\t * MouseOver, MouseOut, RollOver, and RollOut interactions are also passed through using the mouse over settings\n\t * of the top-most stage, but are only processed if the target stage has mouse over interactions enabled.\n\t * Considerations when using roll over in relay targets:\n\t * \n\t *
The top-most (first) stage must have mouse over interactions enabled (via enableMouseOver)
\n\t *
All stages that wish to participate in mouse over interaction must enable them via enableMouseOver
\n\t *
All relay targets will share the frequency value of the top-most stage
\n\t * stage.enableDOMEvents(false);\n\t *\n\t * @type {easeljs.Stage}\n\t */\n\tget nextStage () { return this._nextStage; }\n\tset nextStage (stage) {\n\t\tif (this._nextStage) { this._nextStage._prevStage = null; }\n\t\tif (stage) { stage._prevStage = this; }\n\t\tthis._nextStage = stage;\n\t}\n\n// public methods:\n\t/**\n\t * Each time the update method is called, the stage will call {@link easeljs.Stage#tick}\n\t * unless {@link easeljs.Stage#tickOnupdate} is set to false,\n\t * and then render the display list to the canvas.\n\t *\n\t * @param {Object} [props] Props object to pass to `tick()`. Should usually be a {@link core.Ticker} event object, or similar object with a delta property.\n\t */\n\tupdate (props) {\n\t\tif (!this.canvas) { return; }\n\t\tif (this.tickOnUpdate) { this.tick(props); }\n\t\tif (this.dispatchEvent(\"drawstart\", false, true) === false) { return; }\n\t\tDisplayObject._snapToPixelEnabled = this.snapToPixelEnabled;\n\t\tlet r = this.drawRect, ctx = this.canvas.getContext(\"2d\");\n\t\tctx.setTransform(1, 0, 0, 1, 0, 0);\n\t\tif (this.autoClear) {\n\t\t\tif (r) { ctx.clearRect(r.x, r.y, r.width, r.height); }\n\t\t\telse { ctx.clearRect(0, 0, this.canvas.width+1, this.canvas.height+1); }\n\t\t}\n\t\tctx.save();\n\t\tif (this.drawRect) {\n\t\t\tctx.beginPath();\n\t\t\tctx.rect(r.x, r.y, r.width, r.height);\n\t\t\tctx.clip();\n\t\t}\n\t\tthis.updateContext(ctx);\n\t\tthis.draw(ctx, false);\n\t\tctx.restore();\n\t\tthis.dispatchEvent(\"drawend\");\n\t}\n\n\t/**\n\t * Propagates a tick event through the display list. This is automatically called by {@link easeljs.Stage#update}\n\t * unless {@link easeljs.Stage#tickOnUpdate} is set to false.\n\t *\n\t * If a props object is passed to `tick()`, then all of its properties will be copied to the event object that is\n\t * propagated to listeners.\n\t *\n\t * Some time-based features in EaselJS (for example {@link easeljs.Sprite#framerate} require that\n\t * a {@link core.Ticker#event:tick} event object (or equivalent object with a delta property) be\n\t * passed as the `props` parameter to `tick()`.\n\t *\n\t * @example\n\t * Ticker.on(\"tick\", (evt) => {\n\t * // clone the event object from Ticker, and add some custom data to it:\n\t * \t let data = evt.clone().set({ greeting: \"hello\", name: \"world\" });\n\t * \t // pass it to stage.update():\n\t * \t stage.update(data); // subsequently calls tick() with the same param\n\t * });\n\t *\n\t * shape.on(\"tick\", (evt) => {\n\t * console.log(evt.delta); // the delta property from the Ticker tick event object\n\t * \t console.log(evt.greeting, evt.name); // custom data: \"hello world\"\n\t * });\n\t *\n\t * @emits easeljs.Stage#event:tickstart\n\t * @emits easeljs.Stage#event:tickend\n\t * @param {Object} [props] An object with properties that should be copied to the event object. Should usually be a Ticker event object, or similar object with a delta property.\n\t */\n\ttick (props) {\n\t\tif (!this.tickEnabled || this.dispatchEvent(\"tickstart\", false, true) === false) { return; }\n\t\tlet evtObj = new Event(\"tick\");\n\t\tif (props) {\n\t\t\tfor (let n in props) {\n\t\t\t\tif (props.hasOwnProperty(n)) { evtObj[n] = props[n]; }\n\t\t\t}\n\t\t}\n\t\tthis._tick(evtObj);\n\t\tthis.dispatchEvent(\"tickend\");\n\t}\n\n\t/**\n\t * Default event handler that calls the Stage {@link easeljs.Stage#update} method when a {@link easeljs.DisplayObject#event:tick}\n\t * event is received. This allows you to register a Stage instance as a event listener on {@link core.Ticker} directly.\n\t * Note that if you subscribe to ticks using this pattern, then the tick event object will be passed through to\n\t * display object tick handlers, instead of `delta` and `paused` parameters.\n\t */\n\thandleEvent (evt) {\n\t\tif (evt.type === \"tick\") { this.update(evt); }\n\t}\n\n\t/**\n\t * Clears the target canvas. Useful if {@link easeljs.State#autoClear} is set to `false`.\n\t */\n\tclear () {\n\t\tif (!this.canvas) { return; }\n\t\tlet ctx = this.canvas.getContext(\"2d\");\n\t\tctx.setTransform(1, 0, 0, 1, 0, 0);\n\t\tctx.clearRect(0, 0, this.canvas.width+1, this.canvas.height+1);\n\t}\n\n\t/**\n\t * Returns a data url that contains a Base64-encoded image of the contents of the stage. The returned data url can\n\t * be specified as the src value of an image element.\n\t *\n\t * @param {String} [backgroundColor] The background color to be used for the generated image. Any valid CSS color\n\t * value is allowed. The default value is a transparent background.\n\t * @param {String} [mimeType=\"image/png\"] The MIME type of the image format to be create. If an unknown MIME type\n\t * is passed in, or if the browser does not support the specified MIME type, the default value will be used.\n\t * @return {String} a Base64 encoded image.\n\t */\n\ttoDataURL (backgroundColor, mimeType = \"image/png\") {\n\t\tlet data, ctx = this.canvas.getContext('2d'), w = this.canvas.width, h = this.canvas.height;\n\n\t\tif (backgroundColor) {\n\t\t\tdata = ctx.getImageData(0, 0, w, h);\n\t\t\tvar compositeOperation = ctx.globalCompositeOperation;\n\t\t\tctx.globalCompositeOperation = \"destination-over\";\n\n\t\t\tctx.fillStyle = backgroundColor;\n\t\t\tctx.fillRect(0, 0, w, h);\n\t\t}\n\n\t\tlet dataURL = this.canvas.toDataURL(mimeType);\n\n\t\tif (backgroundColor) {\n\t\t\tctx.putImageData(data, 0, 0);\n\t\t\tctx.globalCompositeOperation = compositeOperation;\n\t\t}\n\n\t\treturn dataURL;\n\t}\n\n\t/**\n\t * Enables or disables (by passing a frequency of 0) mouse over {@link easeljs.DisplayObject#event:mouseover}\n\t * and {@link easeljs.DisplayObject#event:mouseout} and roll over events {@link easeljs.DisplayObject#event:rollover}\n\t * and {@link easeljs.DisplayObject#event:rollout} for this stage's display list. These events can\n\t * be expensive to generate, so they are disabled by default. The frequency of the events can be controlled\n\t * independently of mouse move events via the optional `frequency` parameter.\n\t *\n\t * @example\n\t * const stage = new Stage(\"canvasId\");\n\t * stage.enableMouseOver(10); // 10 updates per second\n\t *\n\t * @param {Number} [frequency=20] Optional param specifying the maximum number of times per second to broadcast\n\t * mouse over/out events. Set to 0 to disable mouse over events completely. Maximum is 50. A lower frequency is less\n\t * responsive, but uses less CPU.\n\t */\n\tenableMouseOver (frequency = 20) {\n\t\tif (this._mouseOverIntervalID) {\n\t\t\tclearInterval(this._mouseOverIntervalID);\n\t\t\tthis._mouseOverIntervalID = null;\n\t\t\tif (frequency === 0) {\n\t\t\t\tthis._testMouseOver(true);\n\t\t\t}\n\t\t}\n\t\tif (frequency <= 0) { return; }\n\t\tthis._mouseOverIntervalID = setInterval(() => this._testMouseOver(), 1000/Math.min(50,frequency));\n\t}\n\n\t/**\n\t * Enables or disables the event listeners that stage adds to DOM elements (window, document and canvas). It is good\n\t * practice to disable events when disposing of a Stage instance, otherwise the stage will continue to receive\n\t * events from the page.\n\t * When changing the canvas property you must disable the events on the old canvas, and enable events on the\n\t * new canvas or mouse events will not work as expected.\n\t *\n\t * @example\n\t * stage.enableDOMEvents(false);\n\t * stage.canvas = anotherCanvas;\n\t * stage.enableDOMEvents(true);\n\t *\n\t * @param {Boolean} [enable=true] Indicates whether to enable or disable the events.\n\t */\n\tenableDOMEvents (enable = true) {\n\t\tlet ls = this._eventListeners;\n\t\tif (!enable && ls) {\n\t\t\tfor (let n in ls) {\n\t\t\t\tlet o = ls[n];\n\t\t\t\to.t.removeEventListener(n, o.f, false);\n\t\t\t}\n\t\t\tthis._eventListeners = null;\n\t\t} else if (enable && !ls && this.canvas) {\n\t\t\tlet t = window.addEventListener ? window : document;\n\t\t\tls = this._eventListeners = {\n\t\t\t\tmouseup: {t, f:e => this._handleMouseUp(e) },\n\t\t\t\tmousemove: {t, f:e => this._handleMouseMove(e) },\n\t\t\t\tdblclick: {t:this.canvas, f:e => this._handleDoubleClick(e) },\n\t\t\t\tmousedown: {t:this.canvas, f:e => this._handleMouseDown(e) }\n\t\t\t};\n\t\t\tfor (let n in ls) {\n\t\t\t\tlet o = ls[n];\n\t\t\t\to.t.addEventListener && o.t.addEventListener(n, o.f, false);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Stage instances cannot be cloned.\n\t * @throws Stage cannot be cloned\n\t * @override\n\t */\n\tclone () {\n\t\tthrow \"Stage cannot be cloned.\";\n\t}\n\n\t/**\n\t * @protected\n\t * @param {HTMLElement} e\n\t * @returns {Object}\n\t */\n\t_getElementRect (e) {\n\t\tlet bounds;\n\t\ttry { bounds = e.getBoundingClientRect(); } // this can fail on disconnected DOM elements in IE9\n\t\tcatch (err) { bounds = {top:e.offsetTop, left:e.offsetLeft, width:e.offsetWidth, height:e.offsetHeight}; }\n\n\t\tlet offX = (window.pageXOffset || document.scrollLeft || 0) - (document.clientLeft || document.body.clientLeft || 0);\n\t\tlet offY = (window.pageYOffset || document.scrollTop || 0) - (document.clientTop || document.body.clientTop || 0);\n\n\t\tlet styles = window.getComputedStyle ? getComputedStyle(e, null) : e.currentStyle; // IE <9 compatibility.\n\t\tlet padL = parseInt(styles.paddingLeft)+parseInt(styles.borderLeftWidth);\n\t\tlet padT = parseInt(styles.paddingTop)+parseInt(styles.borderTopWidth);\n\t\tlet padR = parseInt(styles.paddingRight)+parseInt(styles.borderRightWidth);\n\t\tlet padB = parseInt(styles.paddingBottom)+parseInt(styles.borderBottomWidth);\n\n\t\t// note: in some browsers bounds properties are read only.\n\t\treturn {\n\t\t\tleft: bounds.left+offX+padL,\n\t\t\tright: bounds.right+offX-padR,\n\t\t\ttop: bounds.top+offY+padT,\n\t\t\tbottom: bounds.bottom+offY-padB\n\t\t};\n\t}\n\n\t/**\n\t * @protected\n\t * @param {Number} id\n\t * @returns {Object}\n\t */\n\t_getPointerData (id) {\n\t\tlet data = this._pointerData[id];\n\t\tif (!data) { data = this._pointerData[id] = {x:0, y:0}; }\n\t\treturn data;\n\t}\n\n\t/**\n\t * @protected\n\t * @param {easeljs.MouseEvent} [e=window.event]\n\t */\n\t_handleMouseMove (e = window.event) {\n\t\tthis._handlePointerMove(-1, e, e.pageX, e.pageY);\n\t}\n\n\t/**\n\t * @emits {@link easeljs.DisplayObject#event:mouseleave}\n\t * @emits {@link easeljs.DisplayObject#event:mouseenter}\n\t * @emits {@link easeljs.DisplayObject#event:pressmove}\n\t * @emits {@link easeljs.Stage#event:stagemousemove}\n\t * @protected\n\t * @param {Number} id\n\t * @param {easeljs.MouseEvent | Event} e\n\t * @param {Number} pageX\n\t * @param {Number} pageY\n\t * @param {easeljs.Stage} owner Indicates that the event has already been captured & handled by the indicated stage.\n\t */\n\t_handlePointerMove (id, e, pageX, pageY, owner) {\n\t\tif (this._prevStage && owner === undefined) { return; } // redundant listener.\n\t\tif (!this.canvas) { return; }\n\t\tlet nextStage=this._nextStage, o=this._getPointerData(id);\n\n\t\tlet inBounds = o.inBounds;\n\t\tthis._updatePointerPosition(id, e, pageX, pageY);\n\t\tif (inBounds || o.inBounds || this.mouseMoveOutside) {\n\t\t\tif (id === -1 && o.inBounds === !inBounds) {\n\t\t\t\tthis._dispatchMouseEvent(this, (inBounds ? \"mouseleave\" : \"mouseenter\"), false, id, o, e);\n\t\t\t}\n\n\t\t\tthis._dispatchMouseEvent(this, \"stagemousemove\", false, id, o, e);\n\t\t\tthis._dispatchMouseEvent(o.target, \"pressmove\", true, id, o, e);\n\t\t}\n\n\t\tnextStage&&nextStage._handlePointerMove(id, e, pageX, pageY, null);\n\t}\n\n\t/**\n\t * @protected\n\t * @param {Number} id\n\t * @param {easeljs.MouseEvent | Event} e\n\t * @param {Number} pageX\n\t * @param {Number} pageY\n\t */\n\t_updatePointerPosition (id, e, pageX, pageY) {\n\t\tlet rect = this._getElementRect(this.canvas);\n\t\tpageX -= rect.left;\n\t\tpageY -= rect.top;\n\n\t\tlet w = this.canvas.width;\n\t\tlet h = this.canvas.height;\n\t\tpageX /= (rect.right-rect.left)/w;\n\t\tpageY /= (rect.bottom-rect.top)/h;\n\t\tlet o = this._getPointerData(id);\n\t\tif (o.inBounds = (pageX >= 0 && pageY >= 0 && pageX <= w-1 && pageY <= h-1)) {\n\t\t\to.x = pageX;\n\t\t\to.y = pageY;\n\t\t} else if (this.mouseMoveOutside) {\n\t\t\to.x = pageX < 0 ? 0 : (pageX > w-1 ? w-1 : pageX);\n\t\t\to.y = pageY < 0 ? 0 : (pageY > h-1 ? h-1 : pageY);\n\t\t}\n\n\t\to.posEvtObj = e;\n\t\to.rawX = pageX;\n\t\to.rawY = pageY;\n\n\t\tif (id === this._primaryPointerID || id === -1) {\n\t\t\tthis.mouseX = o.x;\n\t\t\tthis.mouseY = o.y;\n\t\t\tthis.mouseInBounds = o.inBounds;\n\t\t}\n\t}\n\n\t/**\n\t * @protected\n\t * @param {easeljs.MouseEvent} e\n\t */\n\t_handleMouseUp (e) {\n\t\tthis._handlePointerUp(-1, e, false);\n\t}\n\n\t/**\n\t * @emits {@link easeljs.Stage#event:stagemouseup}\n\t * @emits {@link easeljs.DisplayObject#event:click}\n\t * @emits {@link easeljs.DisplayObject#event:pressup}\n\t * @protected\n\t * @param {Number} id\n\t * @param {easeljs.MouseEvent | Event} e\n\t * @param {Boolean} clear\n\t * @param {easeljs.Stage} owner Indicates that the event has already been captured & handled by the indicated stage.\n\t */\n\t_handlePointerUp (id, e, clear, owner) {\n\t\tlet nextStage = this._nextStage, o = this._getPointerData(id);\n\t\tif (this._prevStage && owner === undefined) { return; } // redundant listener.\n\n\t\tlet target=null, oTarget = o.target;\n\t\tif (!owner && (oTarget || nextStage)) { target = this._getObjectsUnderPoint(o.x, o.y, null, true); }\n\n\t\tif (o.down) { this._dispatchMouseEvent(this, \"stagemouseup\", false, id, o, e, target); o.down = false; }\n\n\t\tif (target === oTarget) { this._dispatchMouseEvent(oTarget, \"click\", true, id, o, e); }\n\t\tthis._dispatchMouseEvent(oTarget, \"pressup\", true, id, o, e);\n\n\t\tif (clear) {\n\t\t\tif (id==this._primaryPointerID) { this._primaryPointerID = null; }\n\t\t\tdelete(this._pointerData[id]);\n\t\t} else { o.target = null; }\n\n\t\tnextStage&&nextStage._handlePointerUp(id, e, clear, owner || target && this);\n\t}\n\n\t/**\n\t * @protected\n\t * @param {easeljs.MouseEvent} e\n\t */\n\t_handleMouseDown (e) {\n\t\tthis._handlePointerDown(-1, e, e.pageX, e.pageY);\n\t}\n\n\t/**\n\t * @emits {@link easeljs.Stage#event:stagemousedown}\n\t * @emits {@link easeljs.DisplayObject#event:mousedown}\n\t * @protected\n\t * @param {Number} id\n\t * @param {easeljs.MouseEvent | Event} e\n\t * @param {Number} pageX\n\t * @param {Number} pageY\n\t * @param {easeljs.Stage} owner Indicates that the event has already been captured & handled by the indicated stage.\n\t */\n\t_handlePointerDown (id, e, pageX, pageY, owner) {\n\t\tif (this.preventSelection) { e.preventDefault(); }\n\t\tif (this._primaryPointerID == null || id === -1) { this._primaryPointerID = id; } // mouse always takes over.\n\n\t\tif (pageY != null) { this._updatePointerPosition(id, e, pageX, pageY); }\n\t\tlet target = null, nextStage = this._nextStage, o = this._getPointerData(id);\n\t\tif (!owner) { target = o.target = this._getObjectsUnderPoint(o.x, o.y, null, true); }\n\n\t\tif (o.inBounds) { this._dispatchMouseEvent(this, \"stagemousedown\", false, id, o, e, target); o.down = true; }\n\t\tthis._dispatchMouseEvent(target, \"mousedown\", true, id, o, e);\n\n\t\tnextStage&&nextStage._handlePointerDown(id, e, pageX, pageY, owner || target && this);\n\t}\n\n\t/**\n\t * @emits {@link easeljs.DisplayObject#event:mouseout}\n\t * @emits {@link easeljs.DisplayObject#event:rollout}\n\t * @emits {@link easeljs.DisplayObject#event:rollover}\n\t * @emits {@link easeljs.DisplayObject#event:mouseover}\n\t * @param {Boolean} clear If true, clears the mouseover / rollover (ie. no target)\n\t * @param {easeljs.Stage} owner Indicates that the event has already been captured & handled by the indicated stage.\n\t * @param {easeljs.Stage} eventTarget The stage that the cursor is actively over.\n\t * @protected\n\t */\n\t_testMouseOver (clear, owner, eventTarget) {\n\t\tif (this._prevStage && owner === undefined) { return; } // redundant listener.\n\n\t\tlet nextStage = this._nextStage;\n\t\tif (!this._mouseOverIntervalID) {\n\t\t\t// not enabled for mouseover, but should still relay the event.\n\t\t\tnextStage&&nextStage._testMouseOver(clear, owner, eventTarget);\n\t\t\treturn;\n\t\t}\n\t\tlet o = this._getPointerData(-1);\n\t\t// only update if the mouse position has changed. This provides a lot of optimization, but has some trade-offs.\n\t\tif (!o || (!clear && this.mouseX === this._mouseOverX && this.mouseY === this._mouseOverY && this.mouseInBounds)) { return; }\n\n\t\tlet e = o.posEvtObj;\n\t\tlet isEventTarget = eventTarget || e&&(e.target === this.canvas);\n\t\tlet target=null, common = -1, cursor=\"\";\n\n\t\tif (!owner && (clear || this.mouseInBounds && isEventTarget)) {\n\t\t\ttarget = this._getObjectsUnderPoint(this.mouseX, this.mouseY, null, true);\n\t\t\tthis._mouseOverX = this.mouseX;\n\t\t\tthis._mouseOverY = this.mouseY;\n\t\t}\n\n\t\tlet oldList = this._mouseOverTarget||[];\n\t\tlet oldTarget = oldList[oldList.length-1];\n\t\tlet list = this._mouseOverTarget = [];\n\n\t\t// generate ancestor list and check for cursor:\n\t\tlet t = target;\n\t\twhile (t) {\n\t\t\tlist.unshift(t);\n\t\t\tif (!cursor) { cursor = t.cursor; }\n\t\t\tt = t.parent;\n\t\t}\n\t\tthis.canvas.style.cursor = cursor;\n\t\tif (!owner && eventTarget) { eventTarget.canvas.style.cursor = cursor; }\n\n\t\t// find common ancestor:\n\t\tfor (let i=0,l=list.length; icommon; i--) {\n\t\t\tthis._dispatchMouseEvent(oldList[i], \"rollout\", false, -1, o, e, target);\n\t\t}\n\n\t\tfor (let i=list.length-1; i>common; i--) {\n\t\t\tthis._dispatchMouseEvent(list[i], \"rollover\", false, -1, o, e, oldTarget);\n\t\t}\n\n\t\tif (oldTarget != target) {\n\t\t\tthis._dispatchMouseEvent(target, \"mouseover\", true, -1, o, e, oldTarget);\n\t\t}\n\n\t\tnextStage&&nextStage._testMouseOver(clear, owner || target && this, eventTarget || isEventTarget && this);\n\t}\n\n\t/**\n\t * @emits {@link easeljs.DisplayObject#event:dblclick}\n\t * @protected\n\t * @param {easeljs.MouseEvent} e\n\t * @param {easeljs.Stage} owner Indicates that the event has already been captured & handled by the indicated stage.\n\t */\n\t_handleDoubleClick (e, owner) {\n\t\tlet target=null, nextStage=this._nextStage, o=this._getPointerData(-1);\n\t\tif (!owner) {\n\t\t\ttarget = this._getObjectsUnderPoint(o.x, o.y, null, true);\n\t\t\tthis._dispatchMouseEvent(target, \"dblclick\", true, -1, o, e);\n\t\t}\n\t\tnextStage&&nextStage._handleDoubleClick(e, owner || target && this);\n\t}\n\n\t/**\n\t * @protected\n\t * @param {easeljs.DisplayObject} target\n\t * @param {String} type\n\t * @param {Boolean} bubbles\n\t * @param {Number} pointerId\n\t * @param {Object} o\n\t * @param {easeljs.MouseEvent} [nativeEvent]\n\t * @param {easeljs.DisplayObject} [relatedTarget]\n\t */\n\t_dispatchMouseEvent (target, type, bubbles, pointerId, o, nativeEvent, relatedTarget) {\n\t\t// TODO: might be worth either reusing MouseEvent instances, or adding a willTrigger method to avoid GC.\n\t\tif (!target || (!bubbles && !target.hasEventListener(type))) { return; }\n\t\t/*\n\t\t// TODO: account for stage transformations?\n\t\tthis._mtx = this.getConcatenatedMatrix(this._mtx).invert();\n\t\tlet pt = this._mtx.transformPoint(o.x, o.y);\n\t\tlet evt = new MouseEvent(type, bubbles, false, pt.x, pt.y, nativeEvent, pointerId, pointerId==this._primaryPointerID || pointerId==-1, o.rawX, o.rawY);\n\t\t*/\n\t\tlet evt = new MouseEvent(type, bubbles, false, o.x, o.y, nativeEvent, pointerId, pointerId === this._primaryPointerID || pointerId === -1, o.rawX, o.rawY, relatedTarget);\n\t\ttarget.dispatchEvent(evt);\n\t}\n\n}\n\n/**\n * Dispatched when the user moves the mouse over the canvas.\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.Stage#stagemousemove\n * @since 0.6.0\n */\n/**\n * Dispatched when the user presses their left mouse button on the canvas.\n * You can use {@link easeljs.Stage#mouseInBounds} to check whether the mouse is currently within the stage bounds.\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.Stage#stagemousedown\n * @since 0.6.0\n */\n/**\n * Dispatched when the user the user presses somewhere on the stage, then releases the mouse button anywhere that the page can detect it (this varies slightly between browsers).\n * You can use {@link easeljs.Stage#mouseInBounds} to check whether the mouse is currently within the stage bounds.\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.Stage#stagemouseup\n * @since 0.6.0\n */\n/**\n * Dispatched when the mouse moves from within the canvas area (mouseInBounds === true) to outside it (mouseInBounds === false).\n * This is currently only dispatched for mouse input (not touch).\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.Stage#mouseleave\n * @since 0.7.0\n */\n/**\n * Dispatched when the mouse moves into the canvas area (mouseInBounds === false) from outside it (mouseInBounds === true).\n * This is currently only dispatched for mouse input (not touch).\n * @see {@link easeljs.MouseEvent}\n * @event easeljs.Stage#mouseenter\n * @since 0.7.0\n */\n/**\n * Dispatched each update immediately before the tick event is propagated through the display list.\n * You can call preventDefault on the event object to cancel propagating the tick event.\n * @event easeljs.Stage#tickstart\n * @since 0.7.0\n */\n/**\n * Dispatched each update immediately after the tick event is propagated through the display list. Does not fire if\n * tickOnUpdate is false. Precedes the \"drawstart\" event.\n * @event easeljs.Stage#tickend\n * @since 0.7.0\n */\n/**\n * Dispatched each update immediately before the canvas is cleared and the display list is drawn to it.\n * You can call preventDefault on the event object to cancel the draw.\n * @event easeljs.Stage#drawstart\n * @since 0.7.0\n */\n/**\n * Dispatched each update immediately after the display list is drawn to the canvas and the canvas context is restored.\n * @event easeljs.Stage#drawend\n * @since 0.7.0\n */\n","/**\r\n * @license Canvas\r\n * Visit http://createjs.com/ for documentation, updates and examples.\r\n *\r\n * Copyright (c) 2017 gskinner.com, inc.\r\n *\r\n * Permission is hereby granted, free of charge, to any person\r\n * obtaining a copy of this software and associated documentation\r\n * files (the \"Software\"), to deal in the Software without\r\n * restriction, including without limitation the rights to use,\r\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n * copies of the Software, and to permit persons to whom the\r\n * Software is furnished to do so, subject to the following\r\n * conditions:\r\n *\r\n * The above copyright notice and this permission notice shall be\r\n * included in all copies or substantial portions of the Software.\r\n *\r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\r\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\r\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\r\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\r\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\r\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\r\n * OTHER DEALINGS IN THE SOFTWARE.\r\n */\r\n\r\n/**\r\n * Global utility for creating canvases.\r\n * @memberof easeljs\n * @name easeljs.createCanvas\n * @param {Number} [width=1]\n * @param {Number} [height=1]\r\n */\r\nexport default function createCanvas(width=1, height=1) {\n\tlet c;\n\tif (window.createjs !== undefined && window.createjs.createCanvas !== undefined) {\n\t\tc = window.createjs.createCanvas();\n\t}\n\tif (window.document !== undefined && window.document.createElement !== undefined) {\n\t\tc = document.createElement(\"canvas\");\n\t}\n\tif (c !== undefined) {\n\t\tc.width = width;\n\t\tc.height = height;\n\t\treturn c;\n\t}\n\n\tthrow \"Canvas not supported in this environment.\";\r\n}\r\n","/**\n * @license VideoBuffer\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2010 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport createCanvas from \"./Canvas\";\n\n/**\n * When an HTML video seeks, including when looping, there is an indeterminate period before a new frame is available.\n * This can result in the video blinking or flashing when it is drawn to a canvas. The VideoBuffer class resolves\n * this issue by drawing each frame to an off-screen canvas and preserving the prior frame during a seek.\n *\n * @example\n * let buffer = new VideoBuffer(video);\n * let bitmap = new Bitmap(buffer);\n *\n * @param {HTMLVideoElement} video The HTML video element to buffer.\n */\nexport default class VideoBuffer {\n\n constructor (video) {\n\n \t/**\n \t * Used by Bitmap to determine when the video buffer is ready to be drawn. Not intended for general use.\n \t * @protected\n \t * @type {Number}\n \t */\n \tthis.readyState = video.readyState;\n\n \t/**\n \t * @protected\n \t * @type {HTMLVideoElement}\n \t */\n \tthis._video = video;\n\n \t/**\n \t * @protected\n \t * @type {HTMLCanvasElement}\n \t */\n \tthis._canvas = null;\n\n \t/**\n \t * @protected\n \t * @type {Number}\n \t * @default -1\n \t */\n \tthis._lastTime = -1;\n\n \tif (this.readyState < 2) {\n video.addEventListener(\"canplaythrough\", this._videoReady.bind(this));\n }\n // {once: true} isn't supported everywhere, but its a non-critical optimization here.\n }\n\n /**\n * Gets an HTML canvas element showing the current video frame, or the previous frame if in a seek / loop.\n * Primarily for use by {@link easeljs.Bitmap}.\n */\n getImage () {\n \tif (this.readyState < 2) { return; }\n \tlet canvas = this._canvas, video = this._video;\n \tif (!canvas) {\n\t\t\tcanvas = this._canvas = createCanvas();\n \t\tcanvas.width = video.videoWidth;\n \t\tcanvas.height = video.videoHeight;\n \t}\n \tif (video.readyState >= 2 && video.currentTime !== this._lastTime) {\n \t\tconst ctx = canvas.getContext(\"2d\");\n \t\tctx.clearRect(0, 0, canvas.width, canvas.height);\n \t\tctx.drawImage(video, 0, 0, canvas.width, canvas.height);\n \t\tthis._lastTime = video.currentTime;\n \t}\n \treturn canvas;\n }\n\n /**\n * @protected\n */\n _videoReady () {\n \tthis.readyState = 2;\n }\n\n}\n","/**\n * @license Bitmap\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport DisplayObject from \"./DisplayObject\";\nimport VideoBuffer from \"../utils/VideoBuffer\";\n\n/**\n * A Bitmap represents an Image, Canvas, or Video in the display list. A Bitmap can be instantiated using an existing\n * HTML element, or a string.\n *\n * Notes:\n * \n *
When using a video source that may loop or seek, use a {@link easeljs.VideoBuffer} object to\n * blinking / flashing.\n *
When a string path or image tag that is not yet loaded is used, the stage may need to be redrawn before it\n * will be displayed.
\n *
Bitmaps with an SVG source currently will not respect an alpha value other than 0 or 1. To get around this,\n * the Bitmap can be cached.
\n *
Bitmaps with an SVG source will taint the canvas with cross-origin data, which prevents interactivity. This\n * happens in all browsers except recent Firefox builds.
\n *
Images loaded cross-origin will throw cross-origin security errors when interacted with using a mouse, using\n * methods such as `getObjectUnderPoint`, or using filters, or caching. You can get around this by setting\n * `crossOrigin` flags on your images before passing them to EaselJS, eg: `img.crossOrigin=\"Anonymous\";`
\n * \n *\n * @memberof easeljs\n * @extends easeljs.DisplayObject\n * @example\n * const bitmap = new Bitmap(\"imagePath.jpg\");\n *\n * @param {CanvasImageSource | String | Object} imageOrUri The source image to display. This can be a CanvasImageSource\n * (image, video, canvas), an object with a `getImage` method that returns a CanvasImageSource, or a string URL to an image.\n * If the latter, a new Image instance with the URL as its src will be used.\n */\nexport default class Bitmap extends DisplayObject {\n\n\tconstructor (imageOrUri) {\n\t\tsuper();\n\n\t\t/**\n\t\t * The source image to display. This can be a CanvasImageSource\n\t\t * (image, video, canvas), an object with a `getImage` method that returns a CanvasImageSource, or a string URL to an image.\n\t\t * If the latter, a new Image instance with the URL as its src will be used.\n\t\t * @property image\n\t\t * @type {CanvasImageSource | Object}\n\t\t */\n\t\tif (typeof imageOrUri === \"string\") {\n\t\t\tthis.image = document.createElement(\"img\");\n\t\t\tthis.image.src = imageOrUri;\n\t\t} else {\n\t\t\tthis.image = imageOrUri;\n\t\t}\n\n\t\t/**\n\t\t * Specifies an area of the source image to draw. If omitted, the whole image will be drawn.\n\t\t * Note that video sources must have a width / height set to work correctly with `sourceRect`.\n\t\t * @type {easeljs.Rectangle}\n\t\t * @default null\n\t\t */\n\t\tthis.sourceRect = null;\n\n\t\t/**\n\t\t * Set as compatible with WebGL.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._webGLRenderStyle = DisplayObject._StageGL_BITMAP;\n\t}\n\n\tisVisible () {\n\t\tlet image = this.image;\n\t\tlet hasContent = this.cacheCanvas || (image && (image.naturalWidth || image.getContext || image.readyState >= 2));\n\t\treturn !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && hasContent);\n\t}\n\n\tdraw (ctx, ignoreCache = false) {\n\t\tif (super.draw(ctx, ignoreCache)) { return true; }\n\t\tlet img = this.image, rect = this.sourceRect;\n\t\tif (img instanceof VideoBuffer) { img = img.getImage(); }\n\t\tif (img == null) { return true; }\n\t\tif (rect) {\n\t\t\t// some browsers choke on out of bound values, so we'll fix them:\n\t\t\tlet x1 = rect.x, y1 = rect.y, x2 = x1 + rect.width, y2 = y1 + rect.height, x = 0, y = 0, w = img.width, h = img.height;\n\t\t\tif (x1 < 0) { x -= x1; x1 = 0; }\n\t\t\tif (x2 > w) { x2 = w; }\n\t\t\tif (y1 < 0) { y -= y1; y1 = 0; }\n\t\t\tif (y2 > h) { y2 = h; }\n\t\t\tctx.drawImage(img, x1, y1, x2-x1, y2-y1, x, y, x2-x1, y2-y1);\n\t\t} else {\n\t\t\tctx.drawImage(img, 0, 0);\n\t\t}\n\t\treturn true;\n\t}\n\n\t// Note, the doc sections below document using the specified APIs (from DisplayObject) from\n\t// Bitmap. This is why they have no method implementations.\n\n\t/**\n\t * Because the content of a Bitmap is already in a simple format, cache is unnecessary for Bitmap instances.\n\t * You should not cache Bitmap instances as it can degrade performance.\n\t *\n\t * However: If you want to use a filter on a Bitmap, you MUST cache it, or it will not work.\n\t * To see the API for caching, please visit the {@link easeljs.DisplayObject#cache} method.\n\t *\n\t * @alias easeljs.Bitmap#cache\n\t */\n\n\t/**\n\t * Because the content of a Bitmap is already in a simple format, cache is unnecessary for Bitmap instances.\n\t * You should not cache Bitmap instances as it can degrade performance.\n\t *\n\t * However: If you want to use a filter on a Bitmap, you MUST cache it, or it will not work.\n\t * To see the API for caching, please visit the {@link easeljs.DisplayObject#cache} method.\n\t *\n\t * @alias easeljs.Bitmap#updateCache\n\t */\n\n\t/**\n\t * Because the content of a Bitmap is already in a simple format, cache is unnecessary for Bitmap instances.\n\t * You should not cache Bitmap instances as it can degrade performance.\n\t *\n\t * However: If you want to use a filter on a Bitmap, you MUST cache it, or it will not work.\n\t * To see the API for caching, please visit the {@link easeljs.DisplayObject#cache} method.\n\t *\n\t * @alias easeljs.Bitmap#uncache\n\t */\n\n\tgetBounds () {\n\t\tlet rect = super.getBounds();\n\t\tif (rect) { return rect; }\n\t\tlet image = this.image, o = this.sourceRect || image;\n\t\tlet hasContent = (image && (image.naturalWidth || image.getContext || image.readyState >= 2));\n\t\treturn hasContent ? this._rectangle.setValues(0, 0, o.width, o.height) : null;\n\t}\n\n\t/**\n\t * Returns a clone of the Bitmap instance.\n\t * @param {Boolean} [node] Whether the underlying DOM element should be cloned as well.\n\t * @return {easeljs.Bitmap} A clone of the Bitmap instance.\n\t */\n\tclone (node) {\n\t\tlet img = this.image;\n\t\tif (img != null && node != null) { img = img.cloneNode(); }\n\t\tlet bmp = new Bitmap(img);\n\t\tif (this.sourceRect) { bmp.sourceRect = this.sourceRect.clone(); }\n\t\tthis._cloneProps(bmp);\n\t\treturn bmp;\n\t}\n\n}\n","/**\n * @license Sprite\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport DisplayObject from \"./DisplayObject\";\nimport { Event } from \"@createjs/core\";\n\n/**\n * Displays a frame or sequence of frames (ie. an animation) from a SpriteSheet instance. A sprite sheet is a series of\n * images (usually animation frames) combined into a single image. For example, an animation consisting of 8 100x100\n * images could be combined into a 400x200 sprite sheet (4 frames across by 2 high). You can display individual frames,\n * play frames as an animation, and even sequence animations together.\n *\n * @memberof easeljs\n * @extends easeljs.DisplayObject\n * @example\n * let sprite = new Sprite(spriteSheet);\n * sprite.gotoAndStop(\"frameName\");\n *\n * Until {@link easeljs.Sprite#gotoAndStop} or {@link easeljs.Sprite#gotoAndPlay} is called,\n * only the first defined frame defined in the sprite sheet will be displayed.\n *\n * @see {@link easeljs.SpriteSheet \"More information on setting up frames and animations.\"}\n * @param {SpriteSheet} spriteSheet The SpriteSheet instance to play back. This includes the source image(s), frame\n * dimensions, and frame data.\n * @param {String | Number} [frameOrAnimation] The frame number or animation to play initially.\n */\nexport default class Sprite extends DisplayObject {\n\n\tconstructor (spriteSheet, frameOrAnimation) {\n\t\tsuper();\n\n\t\t/**\n\t\t * The frame index that will be drawn when draw is called. Note that with some {@link easeljs.SpriteSheet}\n\t\t * definitions, this will advance non-sequentially. This will always be an integer value.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t * @readonly\n\t\t */\n\t\tthis.currentFrame = 0;\n\n\t\t/**\n\t\t * Returns the name of the currently playing animation.\n\t\t * @type {String}\n\t\t * @readonly\n\t\t */\n\t\tthis.currentAnimation = null;\n\n\t\t/**\n\t\t * Prevents the animation from advancing each tick automatically. For example, you could create a sprite\n\t\t * sheet of icons, set paused to true, and display the appropriate icon by setting `currentFrame`.\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.paused = true;\n\n\t\t/**\n\t\t * The SpriteSheet instance to play back. This includes the source image, frame dimensions, and frame data.\n\t\t * @type {easeljs.SpriteSheet}\n\t\t * @readonly\n\t\t */\n\t\tthis.spriteSheet = spriteSheet;\n\n\t\t/**\n\t\t * Specifies the current frame index within the currently playing animation. When playing normally, this will increase\n\t\t * from 0 to n-1, where n is the number of frames in the current animation.\n\t\t * This could be a non-integer value if using time-based playback, or if the animation's speed is not an integer.\n\t\t * @see {@link easeljs.Sprite#framerate}\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.currentAnimationFrame = 0;\n\n\t\t/**\n\t\t * By default Sprite instances advance one frame per tick. Specifying a framerate for the Sprite (or its related\n\t\t * SpriteSheet) will cause it to advance based on elapsed time between ticks as appropriate to maintain the target\n\t\t * framerate.\n\t\t *\n\t\t * For example, if a Sprite with a framerate of 10 is placed on a Stage being updated at 40fps, then the Sprite will\n\t\t * advance roughly one frame every 4 ticks. This will not be exact, because the time between each tick will\n\t\t * vary slightly between frames.\n\t\t *\n\t\t * This feature is dependent on the tick event object (or an object with an appropriate \"delta\" property) being\n\t\t * passed into {@link easeljs.Stage#update}.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.framerate = 0;\n\n\t\t/**\n\t\t * Current animation object.\n\t\t * @protected\n\t\t * @type {Object}\n\t\t * @default null\n\t\t */\n\t\tthis._animation = null;\n\n\t\t/**\n\t\t * Current frame index.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default null\n\t\t */\n\t\tthis._currentFrame = null;\n\n\t\t/**\n\t\t * Skips the next auto advance. Used by gotoAndPlay to avoid immediately jumping to the next frame\n\t\t * @protected\n\t\t * @type {Boolean}\n\t\t * @default false\n\t\t */\n\t\tthis._skipAdvance = false;\n\n\t\t/**\n\t\t * Set as compatible with WebGL.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 1\n\t\t */\n\t\tthis._webGLRenderStyle = DisplayObject._StageGL_SPRITE;\n\n\t\tif (frameOrAnimation != null) {\n\t\t\tthis.gotoAndPlay(frameOrAnimation);\n\t\t}\n\t}\n\n\tisVisible () {\n\t\tlet hasContent = this.cacheCanvas || this.spriteSheet.complete;\n\t\treturn !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && hasContent);\n\t}\n\n\tdraw (ctx, ignoreCache) {\n\t\tif (super.draw(ctx, ignoreCache)) { return true; }\n\t\tthis._normalizeFrame();\n\t\tlet o = this.spriteSheet.getFrame(this._currentFrame|0);\n\t\tif (!o) { return false; }\n\t\tlet rect = o.rect;\n\t\tif (rect.width && rect.height) { ctx.drawImage(o.image, rect.x, rect.y, rect.width, rect.height, -o.regX, -o.regY, rect.width, rect.height); }\n\t\treturn true;\n\t}\n\n\t// Note, the doc sections below document using the specified APIs (from DisplayObject) from\n\t// Bitmap. This is why they have no method implementations.\n\n\t/**\n\t * Because the content of a Sprite is already in a raster format, cache is unnecessary for Sprite instances.\n\t * You should not cache Sprite instances as it can degrade performance.\n\t * @name easeljs.Sprite#cache\n\t */\n\n\t/**\n\t * Because the content of a Sprite is already in a raster format, cache is unnecessary for Sprite instances.\n\t * You should not cache Sprite instances as it can degrade performance.\n\t * @name easeljs.Sprite#updateCache\n\t */\n\n\t/**\n\t * Because the content of a Sprite is already in a raster format, cache is unnecessary for Sprite instances.\n\t * You should not cache Sprite instances as it can degrade performance.\n\t * @name easeljs.Sprite#uncache\n\t */\n\n\t/**\n\t * Play (unpause) the current animation. The Sprite will be paused if either {@link easeljs.Sprite#stop}\n\t * or {@link easeljs.Sprite#gotoAndStop} is called. Single frame animations will remain unchanged.\n\t */\n\tplay () {\n\t\tthis.paused = false;\n\t}\n\n\t/**\n\t * Stop playing a running animation. The Sprite will be playing if {@link easeljs.Sprite#gotoAndPlay} is called.\n\t * Note that calling `gotoAndPlay()` or {@link easeljs.Sprite#play} will resume playback.\n\t */\n\tstop () {\n\t\tthis.paused = true;\n\t}\n\n\t/**\n\t * Sets paused to false and plays the specified animation name, named frame, or frame number.\n\t * @param {String | Number} frameOrAnimation The frame number or animation name that the playhead should move to\n\t * and begin playing.\n\t */\n\tgotoAndPlay (frameOrAnimation) {\n\t\tthis.paused = false;\n\t\tthis._skipAdvance = true;\n\t\tthis._goto(frameOrAnimation);\n\t}\n\n\t/**\n\t * Sets paused to true and seeks to the specified animation name, named frame, or frame number.\n\t * @param {String | Number} frameOrAnimation The frame number or animation name that the playhead should move to\n\t * and stop.\n\t */\n\tgotoAndStop (frameOrAnimation) {\n\t\tthis.paused = true;\n\t\tthis._goto(frameOrAnimation);\n\t}\n\n\t/**\n\t * Advances the playhead. This occurs automatically each tick by default.\n\t * @param {Number} [time] The amount of time in ms to advance by. Only applicable if framerate is set on the Sprite\n\t * or its SpriteSheet.\n\t*/\n\tadvance (time) {\n\t\tlet fps = this.framerate || this.spriteSheet.framerate;\n\t\tlet t = (fps && time != null) ? time/(1000/fps) : 1;\n\t\tthis._normalizeFrame(t);\n\t}\n\n\t/**\n\t * Returns a {@link easeljs.Rectangle} instance defining the bounds of the current frame relative to\n\t * the origin. For example, a 90 x 70 frame with `regX=50` and `regY=40` would return a\n\t * rectangle with [x=-50, y=-40, width=90, height=70]. This ignores transformations on the display object.\n\t *\n\t * @see {@link easeljs.SpriteSheet#frameBounds}\n\t * @return {easeljs.Rectangle} A Rectangle instance. Returns null if the frame does not exist, or the image is not fully loaded.\n\t */\n\tgetBounds () {\n\t\t// TODO: should this normalizeFrame?\n\t\treturn super.getBounds() || this.spriteSheet.getFrameBounds(this.currentFrame, this._rectangle);\n\t}\n\n\t/**\n\t * Returns a clone of the Sprite instance. Note that the same SpriteSheet is shared between cloned instances.\n\t * @return {easeljs.Sprite} a clone of the Sprite instance.\n\t */\n\tclone () {\n\t\treturn this._cloneProps(new Sprite(this.spriteSheet));\n\t}\n\n\t/**\n\t * @param {easeljs.Sprite} o\n\t * @return {easeljs.Sprite} o\n\t * @protected\n\t */\n\t_cloneProps (o) {\n\t\tsuper._cloneProps(o);\n\t\to.currentFrame = this.currentFrame;\n\t\to.currentAnimation = this.currentAnimation;\n\t\to.paused = this.paused;\n\t\to.currentAnimationFrame = this.currentAnimationFrame;\n\t\to.framerate = this.framerate;\n\n\t\to._animation = this._animation;\n\t\to._currentFrame = this._currentFrame;\n\t\to._skipAdvance = this._skipAdvance;\n\t\treturn o;\n\t}\n\n\t_tick (evtObj) {\n\t\tif (!this.paused) {\n\t\t\tif (!this._skipAdvance) { this.advance(evtObj&&evtObj.delta); }\n\t\t\tthis._skipAdvance = false;\n\t\t}\n\t\tsuper._tick(evtObj);\n\t}\n\n\t/**\n\t * Normalizes the current frame, advancing animations and dispatching callbacks as appropriate.\n\t * @protected\n\t * @param {Number} [frameDelta=0]\n\t */\n\t_normalizeFrame (frameDelta = 0) {\n\t\tlet animation = this._animation;\n\t\tlet paused = this.paused;\n\t\tlet frame = this._currentFrame;\n\n\t\tif (animation) {\n\t\t\tlet speed = animation.speed || 1;\n\t\t\tlet animFrame = this.currentAnimationFrame;\n\t\t\tlet l = animation.frames.length;\n\t\t\tif (animFrame + frameDelta * speed >= l) {\n\t\t\t\tlet next = animation.next;\n\t\t\t\tif (this._dispatchAnimationEnd(animation, frame, paused, next, l - 1)) {\n\t\t\t\t\t// something changed in the event stack, so we shouldn't make any more changes here.\n\t\t\t\t\treturn;\n\t\t\t\t} else if (next) {\n\t\t\t\t\t// sequence. Automatically calls _normalizeFrame again with the remaining frames.\n\t\t\t\t\treturn this._goto(next, frameDelta - (l - animFrame) / speed);\n\t\t\t\t} else {\n\t\t\t\t\t// end.\n\t\t\t\t\tthis.paused = true;\n\t\t\t\t\tanimFrame = animation.frames.length - 1;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tanimFrame += frameDelta * speed;\n\t\t\t}\n\t\t\tthis.currentAnimationFrame = animFrame;\n\t\t\tthis._currentFrame = animation.frames[animFrame | 0]\n\t\t} else {\n\t\t\tframe = (this._currentFrame += frameDelta);\n\t\t\tlet l = this.spriteSheet.getNumFrames();\n\t\t\tif (frame >= l && l > 0) {\n\t\t\t\tif (!this._dispatchAnimationEnd(animation, frame, paused, l - 1)) {\n\t\t\t\t\t// looped.\n\t\t\t\t\tif ((this._currentFrame -= l) >= l) { return this._normalizeFrame(); }\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tframe = this._currentFrame | 0;\n\t\tif (this.currentFrame != frame) {\n\t\t\tthis.currentFrame = frame;\n\t\t\tthis.dispatchEvent(\"change\");\n\t\t}\n\t};\n\n\t/**\n\t * Dispatches the \"animationend\" event. Returns true if a handler changed the animation (ex. calling {@link easlejs.Sprite#stop},\n\t * {@link easeljs.Sprite#gotoAndPlay}, etc.)\n\t * @param animation\n\t * @param frame\n\t * @param paused\n\t * @param next\n\t * @param end\n\t * @private\n\t */\n\t_dispatchAnimationEnd (animation, frame, paused, next, end) {\n\t\tlet name = animation ? animation.name : null;\n\t\tif (this.hasEventListener(\"animationend\")) {\n\t\t\tlet evt = new Event(\"animationend\");\n\t\t\tevt.name = name;\n\t\t\tevt.next = next;\n\t\t\tthis.dispatchEvent(evt);\n\t\t}\n\t\t// did the animation get changed in the event stack?:\n\t\tlet changed = (this._animation != animation || this._currentFrame != frame);\n\t\t// if the animation hasn't changed, but the sprite was paused, then we want to stick to the last frame:\n\t\tif (!changed && !paused && this.paused) { this.currentAnimationFrame = end; changed = true; }\n\t\treturn changed;\n\t}\n\n\t/**\n\t * Moves the playhead to the specified frame number or animation.\n\t * @param {String | Number} frameOrAnimation The frame number or animation that the playhead should move to.\n\t * @param {Number} [frame=0] The frame of the animation to go to. Defaults to 0.\n\t * @protected\n\t */\n\t_goto (frameOrAnimation, frame = 0) {\n\t\tthis.currentAnimationFrame = 0;\n\t\tif (isNaN(frameOrAnimation)) {\n\t\t\tlet data = this.spriteSheet.getAnimation(frameOrAnimation);\n\t\t\tif (data) {\n\t\t\t\tthis._animation = data;\n\t\t\t\tthis.currentAnimation = frameOrAnimation;\n\t\t\t\tthis._normalizeFrame(frame);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.currentAnimation = this._animation = null;\n\t\t\tthis._currentFrame = frameOrAnimation;\n\t\t\tthis._normalizeFrame();\n\t\t}\n\t}\n\n}\n\n/**\n * Dispatched when an animation reaches its ends.\n * @event easeljs.Sprite#animationend\n * @property {Object} target The object that dispatched the event.\n * @property {String} type The event type.\n * @property {String} name The name of the animation that just ended.\n * @property {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.\n * @since 0.6.0\n */\n\n/**\n * Dispatched any time the current frame changes. For example, this could be due to automatic advancement on a tick,\n * or calling gotoAndPlay() or gotoAndStop().\n * @event easeljs.Sprite#change\n * @property {Object} target The object that dispatched the event.\n * @property {String} type The event type.\n */\n","/**\n * @license BitmapText\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Container from \"./Container\";\nimport Sprite from \"./Sprite\";\n\n/**\n * Displays text using bitmap glyphs defined in a sprite sheet. Multi-line text is supported using new line characters,\n * but automatic wrapping is not supported. See the {@link easeljs.BitmapText#spriteSheet} property for more information on defining glyphs.\n *\n * Important: While BitmapText extends Container, it is not designed to be used as one.\n * As such, methods like addChild and removeChild are disabled.\n *\n * @memberof easeljs\n * @extends easeljs.Container\n *\n * @param {String} [text=\"\"] The text to display.\n * @param {SpriteSheet} [spriteSheet=null] The spritesheet that defines the character glyphs.\n */\nexport default class BitmapText extends Container {\n\n\tconstructor (text = \"\", spriteSheet = null) {\n\t\tsuper();\n\n\t\t/**\n\t\t * The text to display.\n\t\t * @type {String}\n\t\t * @default \"\"\n\t\t */\n\t\tthis.text = text;\n\n\t\t/**\n\t\t * A SpriteSheet instance that defines the glyphs for this bitmap text. Each glyph/character\n\t\t * should have a single frame animation defined in the sprite sheet named the same as\n\t\t * corresponding character.\n\t\t *\n\t\t * @example\n\t\t * // the following animation definition would indicate that the frame at index 0 of the spritesheet should be drawn for the \"A\" character.\n\t\t * \"A\": {frames: [0]}\n\t\t * // The short form is also acceptable:\n\t\t * \"A\": 0\n\t\t *\n\t\t * Note that if a character in the text is not found in the sprite sheet, it will also\n\t\t * try to use the alternate case (upper or lower).\n\t\t *\n\t\t * @see {@link easeljs.SpriteSheet}\n\t\t * @type {easeljs.SpriteSheet}\n\t\t * @default null\n\t\t */\n\t\tthis.spriteSheet = spriteSheet;\n\n\t\t/**\n\t\t * The height of each line of text. If 0, then it will use a line height calculated\n\t\t * by checking for the height of the \"1\", \"T\", or \"L\" character (in that order). If\n\t\t * those characters are not defined, it will use the height of the first frame of the\n\t\t * sprite sheet.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.lineHeight = 0;\n\n\t\t/**\n\t\t * This spacing (in pixels) will be added after each character in the output.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.letterSpacing = 0;\n\n\t\t/**\n\t\t * If a space character is not defined in the sprite sheet, then empty pixels equal to\n\t\t * spaceWidth will be inserted instead. If 0, then it will use a value calculated\n\t\t * by checking for the width of the \"1\", \"l\", \"E\", or \"A\" character (in that order). If\n\t\t * those characters are not defined, it will use the width of the first frame of the\n\t\t * sprite sheet.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.spaceWidth = 0;\n\n\t \t/**\n\t\t * @type {Object}\n\t\t * @protected\n\t\t */\n\t\tthis._oldProps = {text:0,spriteSheet:0,lineHeight:0,letterSpacing:0,spaceWidth:0};\n\n\t\t/**\n\t\t * Used to track the object which this class attached listeners to, helps optimize listener attachment.\n\t\t * @type {easeljs.Stage}\n\t\t * @protected\n\t\t */\n\t\tthis._oldStage = null;\n\n\t\t/**\n\t\t * The event listener proxy triggered drawing draw for special circumstances.\n\t\t * @type {Function}\n\t\t * @protected\n\t\t */\n\t\tthis._drawAction = null;\n\n\t}\n\n\tdraw (ctx, ignoreCache) {\n\t\tif (this.drawCache(ctx, ignoreCache)) { return; }\n\t\tthis._updateState();\n\t\tsuper.draw(ctx, ignoreCache);\n\t}\n\n\tgetBounds () {\n\t\tthis._updateText();\n\t\treturn super.getBounds();\n\t}\n\n\tisVisible () {\n\t\tlet hasContent = this.cacheCanvas || (this.spriteSheet && this.spriteSheet.complete && this.text);\n\t\treturn !!(this.visible && this.alpha > 0 && this.scaleX !== 0 && this.scaleY !== 0 && hasContent);\n\t}\n\n\tclone () {\n\t\treturn this._cloneProps(new BitmapText(this.text, this.spriteSheet));\n\t}\n\n\t/**\n\t * Disabled in BitmapText.\n\t */\n\taddChild () {}\n\n\t/**\n\t * Disabled in BitmapText.\n\t */\n\taddChildAt () {}\n\n\t/**\n\t * Disabled in BitmapText.\n\t */\n\tremoveChild () {}\n\n\t/**\n\t * Disabled in BitmapText.\n\t */\n\tremoveChildAt () {}\n\n\t/**\n\t * Disabled in BitmapText.\n\t */\n\tremoveAllChildren () {}\n\n\t_updateState () {\n\t\tthis._updateText();\n\t}\n\n \t/**\n\t * @param {easeljs.BitmapText} o\n\t * @return {easeljs.BitmapText}\n\t * @protected\n\t */\n\t_cloneProps (o) {\n\t\tsuper._cloneProps(o);\n\t\to.lineHeight = this.lineHeight;\n\t\to.letterSpacing = this.letterSpacing;\n\t\to.spaceWidth = this.spaceWidth;\n\t\treturn o;\n\t}\n\n\t/**\n\t * @param {String} character\n\t * @param {easeljs.SpriteSheet} spriteSheet\n\t * @return {Number}\n\t * @protected\n\t */\n\t_getFrameIndex (character, spriteSheet) {\n\t\tlet c, o = spriteSheet.getAnimation(character);\n\t\tif (!o) {\n\t\t\t(character != (c = character.toUpperCase())) || (character != (c = character.toLowerCase())) || (c = null);\n\t\t\tif (c) { o = spriteSheet.getAnimation(c); }\n\t\t}\n\t\treturn o && o.frames[0];\n\t}\n\n\t/**\n\t * @param {String} character\n\t * @param {easeljs.SpriteSheet} spriteSheet\n\t * @return {Object}\n\t * @protected\n\t */\n\t_getFrame (character, spriteSheet) {\n\t\tlet index = this._getFrameIndex(character, spriteSheet);\n\t\treturn index == null ? index : spriteSheet.getFrame(index);\n\t}\n\n\t/**\n\t * @param {easeljs.SpriteSheet} ss\n\t * @return {Number}\n\t * @protected\n\t */\n\t_getLineHeight (ss) {\n\t\tlet frame = this._getFrame(\"1\", ss) || this._getFrame(\"T\", ss) || this._getFrame(\"L\", ss) || ss.getFrame(0);\n\t\treturn frame ? frame.rect.height : 1;\n\t}\n\n\t/**\n\t * @param {easeljs.SpriteSheet} ss\n\t * @return {Number}\n\t * @protected\n\t */\n\t_getSpaceWidth (ss) {\n\t\tlet frame = this._getFrame(\"1\", ss) || this._getFrame(\"l\", ss) || this._getFrame(\"e\", ss) || this._getFrame(\"a\", ss) || ss.getFrame(0);\n\t\treturn frame ? frame.rect.width : 1;\n\t}\n\n\t_tick (evtObj) {\n\t\tlet stage = this.stage;\n\t\tstage && stage.on(\"drawstart\", this._updateText, this, true);\n\t\tsuper._tick(evtObj);\n\t}\n\n\t/**\n\t * @protected\n\t */\n\t_updateText () {\n\t\tlet x = 0, y = 0, o = this._oldProps, change = false, spaceW = this.spaceWidth, lineH = this.lineHeight, ss = this.spriteSheet;\n\t\tlet pool = BitmapText._spritePool, kids = this.children, childIndex = 0, numKids = kids.length, sprite;\n\n\t\tfor (let n in o) {\n\t\t\tif (o[n] != this[n]) {\n\t\t\t\to[n] = this[n];\n\t\t\t\tchange = true;\n\t\t\t}\n\t\t}\n\t\tif (!change) { return; }\n\n\t\tlet hasSpace = !!this._getFrame(\" \", ss);\n\t\tif (!hasSpace && !spaceW) { spaceW = this._getSpaceWidth(ss); }\n\t\tif (!lineH) { lineH = this._getLineHeight(ss); }\n\n\t\tfor (let i = 0, l = this.text.length; i < l; i++) {\n\t\t\tlet character = this.text.charAt(i);\n\t\t\tif (character === \" \" && !hasSpace) {\n\t\t\t\tx += spaceW;\n\t\t\t\tcontinue;\n\t\t\t} else if (character === \"\\n\" || character === \"\\r\") {\n\t\t\t\tif (character === \"\\r\" && this.text.charAt(i+1) === \"\\n\") { i++; } // crlf\n\t\t\t\tx = 0;\n\t\t\t\ty += lineH;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlet index = this._getFrameIndex(character, ss);\n\t\t\tif (index == null) { continue; }\n\n\t\t\tif (childIndex < numKids) {\n\t\t\t\tsprite = kids[childIndex];\n\t\t\t} else {\n\t\t\t\tkids.push(sprite = pool.length ? pool.pop() : new Sprite());\n\t\t\t\tsprite.parent = this;\n\t\t\t\tnumKids++;\n\t\t\t}\n\t\t\tsprite.spriteSheet = ss;\n\t\t\tsprite.gotoAndStop(index);\n\t\t\tsprite.x = x;\n\t\t\tsprite.y = y;\n\t\t\tchildIndex++;\n\n\t\t\tx += sprite.getBounds().width + this.letterSpacing;\n\t\t}\n\n\t\twhile (numKids > childIndex) {\n\t\t\t // faster than removeChild.\n\t\t\tpool.push(sprite = kids.pop());\n\t\t\tsprite.parent = null;\n\t\t\tnumKids--;\n\t\t}\n\t\tif (pool.length > BitmapText.maxPoolSize) { pool.length = BitmapText.maxPoolSize; }\n\t}\n\n}\n\n/**\n * BitmapText uses Sprite instances to draw text. To reduce the creation and destruction of instances (and thus garbage collection), it maintains\n * an internal object pool of sprite instances to reuse. Increasing this value can cause more sprites to be\n * retained, slightly increasing memory use, but reducing instantiation.\n * @type {Number}\n * @static\n * @default 100\n */\nBitmapText.maxPoolSize = 100;\n/**\n * Sprite object pool.\n * @type {Array}\n * @static\n * @private\n * @readonly\n */\nBitmapText._spritePool = [];\n","/**\n * @license DOMElement\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport DisplayObject from \"./DisplayObject\";\nimport DisplayProps from \"../geom/DisplayProps\";\n\n/**\n * This class is still experimental, and more advanced use is likely to be buggy. Please report bugs.\n *\n * A DOMElement allows you to associate a HTMLElement with the display list. It will be transformed\n * within the DOM as though it is child of the {{#crossLink \"Container\"}}{{/crossLink}} it is added to. However, it is\n * not rendered to canvas, and as such will retain whatever z-index it has relative to the canvas (ie. it will be\n * drawn in front of or behind the canvas).\n *\n * The position of a DOMElement is relative to their parent node in the DOM. It is recommended that\n * the DOM Object be added to a div that also contains the canvas so that they share the same position\n * on the page.\n *\n * DOMElement is useful for positioning HTML elements over top of canvas content, and for elements\n * that you want to display outside the bounds of the canvas. For example, a tooltip with rich HTML\n * content.\n *\n *
Mouse Interaction
\n *\n * DOMElement instances are not full EaselJS display objects, and do not participate in EaselJS mouse\n * events or support methods like hitTest. To get mouse events from a DOMElement, you must instead add handlers to\n * the htmlElement (note, this does not support EventDispatcher)\n *\n * var domElement = new createjs.DOMElement(htmlElement);\n * domElement.htmlElement.onclick = function() {\n * console.log(\"clicked\");\n * }\n *\n * Important: This class needs to be notified it is about to be drawn, this will happen automatically\n * if you call stage.update, calling stage.draw or disabling tickEnabled will miss important steps and it will render\n * stale information.\n *\n * @memberof easeljs\n * @extends DisplayObject\n * @param {HTMLElement | String} htmlElement A reference or id for the DOM element to manage.\n */\nexport default class DOMElement extends DisplayObject {\n\n\tconstructor (htmlElement) {\n\t\tsuper();\n\n\t\tif (typeof htmlElement === \"string\") { htmlElement = document.getElementById(htmlElement); }\n\t\tthis.mouseEnabled = false;\n\n\t\tlet style = htmlElement.style;\n\t\tstyle.position = \"absolute\";\n\t\tstyle.transformOrigin = style.WebkitTransformOrigin = style.msTransformOrigin = style.MozTransformOrigin = style.OTransformOrigin = \"0% 0%\";\n\n\t\t/**\n\t\t * The DOM object to manage.\n\t\t * @type {HTMLElement}\n\t\t */\n\t\tthis.htmlElement = htmlElement;\n\n\t\t/**\n\t\t * @type {easeljs.Matrix2D}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis._oldProps = null;\n\n\t\t/**\n\t\t * Used to track the object which this class attached listeners to, helps optimize listener attachment.\n\t\t * @type {easeljs.Stage}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis._oldStage = null;\n\t\t/**\n\t\t * The event listener proxy triggered drawing draw for special circumstances.\n\t\t * @type {Function}\n\t\t * @default null\n\t\t * @protected\n\t\t */\n\t\tthis._drawAction = null;\n\t}\n\n\tisVisible () {\n\t\treturn this.htmlElement != null;\n\t}\n\n\tdraw (ctx, ignoreCache) {\n\t\t// this relies on the _tick method because draw isn't called if the parent is not visible.\n\t\t// the actual update happens in _handleDrawEnd\n\t\treturn true;\n\t}\n\n\t/**\n\t * Disabled in DOMElement.\n\t */\n\tcache () {}\n\n\t/**\n\t * Disabled in DOMElement.\n\t */\n\tuncache () {}\n\n\t/**\n\t * Disabled in DOMElement.\n\t */\n\tupdateCache () {}\n\n\t/**\n\t * Disabled in DOMElement.\n\t */\n\thitTest () {}\n\n\t/**\n\t * Disabled in DOMElement.\n\t */\n\tlocalToGlobal () {}\n\n\t/**\n\t * Disabled in DOMElement.\n\t */\n\tglobalToLocal () {}\n\n\t/**\n\t * Disabled in DOMElement.\n\t */\n\tlocalToLocal () {}\n\n\t/**\n\t * DOMElement cannot be cloned.\n\t * @throws DOMElement cannot be cloned\n\t */\n\tclone () {\n\t\tthrow \"DOMElement cannot be cloned.\";\n\t}\n\n\t_tick (evtObj) {\n\t\tlet stage = this.stage;\n\t\tif (stage != null && stage !== this._oldStage) {\n\t\t\tthis._drawAction && stage.off(\"drawend\", this._drawAction);\n\t\t\tthis._drawAction = stage.on(\"drawend\", this._handleDrawEnd, this);\n\t\t\tthis._oldStage = stage;\n\t\t}\n\t\tsuper._tick(evtObj);\n\t}\n\n\t/**\n\t * @param {core.Event} evt\n\t * @protected\n\t */\n\t_handleDrawEnd (evt) {\n\t\tlet o = this.htmlElement;\n\t\tif (!o) { return; }\n\t\tlet style = o.style;\n\n\t\tlet props = this.getConcatenatedDisplayProps(this._props), mtx = props.matrix;\n\n\t\tlet visibility = props.visible ? \"visible\" : \"hidden\";\n\t\tif (visibility != style.visibility) { style.visibility = visibility; }\n\t\tif (!props.visible) { return; }\n\n\t\tlet oldProps = this._oldProps, oldMtx = oldProps&&oldProps.matrix;\n\t\tlet n = 10000; // precision\n\n\t\tif (!oldMtx || !oldMtx.equals(mtx)) {\n\t\t\tlet str = \"matrix(\" + (mtx.a*n|0)/n +\",\"+ (mtx.b*n|0)/n +\",\"+ (mtx.c*n|0)/n +\",\"+ (mtx.d*n|0)/n +\",\"+ (mtx.tx+0.5|0);\n\t\t\tstyle.transform = style.WebkitTransform = style.OTransform = style.msTransform = str +\",\"+ (mtx.ty+0.5|0) +\")\";\n\t\t\tstyle.MozTransform = str +\"px,\"+ (mtx.ty+0.5|0) +\"px)\";\n\t\t\tif (!oldProps) { oldProps = this._oldProps = new DisplayProps(true, null); }\n\t\t\toldProps.matrix.copy(mtx);\n\t\t}\n\n\t\tif (oldProps.alpha != props.alpha) {\n\t\t\tstyle.opacity = \"\"+(props.alpha*n|0)/n;\n\t\t\toldProps.alpha = props.alpha;\n\t\t}\n\t}\n\n}\n\n/**\n * Interaction events should be added to `htmlElement`, and not the DOMElement instance, since DOMElement instances\n * are not full EaselJS display objects and do not participate in EaselJS mouse events.\n * @event easeljs.DOMElement#click\n */\n\n/**\n * Interaction events should be added to `htmlElement`, and not the DOMElement instance, since DOMElement instances\n * are not full EaselJS display objects and do not participate in EaselJS mouse events.\n * @event easeljs.DOMElement#dblClick\n */\n\n/**\n * Interaction events should be added to `htmlElement`, and not the DOMElement instance, since DOMElement instances\n * are not full EaselJS display objects and do not participate in EaselJS mouse events.\n * @event easeljs.DOMElement#mousedown\n */\n\n/**\n * Interaction events should be added to `htmlElement`, and not the DOMElement instance, since DOMElement instances\n * are not full EaselJS display objects and do not participate in EaselJS mouse events.\n * @event easeljs.DOMElement#mouseover\n */\n\n/**\n * Disabled in DOMElement.\n * @event easeljs.DOMElement#tick\n */\n","/**\n * @license Graphics\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport createCanvas from \"../utils/Canvas\";\n\n/**\n * The Graphics class exposes an easy to use API for generating vector drawing instructions and drawing them to a\n * specified context. Note that you can use Graphics without any dependency on the EaselJS framework by calling {@link easeljs.Graphics#draw}\n * directly, or it can be used with the {@link easeljs.Shape} object to draw vector graphics within the\n * context of an EaselJS display list.\n *\n * There are two approaches to working with Graphics object: calling methods on a Graphics instance (the \"Graphics API\"), or\n * instantiating Graphics command objects and adding them to the graphics queue via {@link easeljs.Graphics#append}.\n * The former abstracts the latter, simplifying beginning and ending paths, fills, and strokes.\n *\n *
Tiny API
\n * The Graphics class also includes a \"tiny API\", which is one or two-letter methods that are shortcuts for all of the\n * Graphics methods. These methods are great for creating compact instructions, and is used by the Toolkit for CreateJS\n * to generate readable code. All tiny methods are marked as protected, so you can view them by enabling protected\n * descriptions in the docs.\n *\n *
\n *\n * @example\n * var g = new createjs.Graphics();\n * g.setStrokeStyle(1);\n * g.beginStroke(\"#000000\");\n * g.beginFill(\"red\");\n * g.drawCircle(0,0,30);\n *\n * @example\n * // All drawing methods in Graphics return the Graphics instance, so they can be chained together.\n * graphics.beginStroke(\"red\").beginFill(\"blue\").drawRect(20, 20, 100, 50);\n *\n * @example\n * // Each graphics API call generates a command object (see below). The last command to be created can be accessed via .command\n * let fillCommand = graphics.beginFill(\"red\").command;\n * fillCommand.style = \"blue\";\n * // or change it to a bitmap fill:\n * fillCommand.bitmap(img);\n *\n * @example\n * // For more direct control of rendering, you can instantiate and append command objects to the graphics queue directly.\n * // In this case, you need to manage path creation manually, and ensure that fill/stroke is applied to a defined path:\n *\n * // start a new path. Graphics.beginCmd is a reusable BeginPath instance:\n * graphics.append(Graphics.beginCmd);\n * // we need to define the path before applying the fill:\n * let circle = new Graphics.Circle(0,0,30);\n * graphics.append(circle);\n * // fill the path we just defined:\n * let fill = new Graphics.Fill(\"red\");\n * graphics.append(fill);\n *\n * // These approaches can be used together, for example to insert a custom command:\n * graphics.beginFill(\"red\");\n * let customCommand = new CustomSpiralCommand(etc);\n * graphics.append(customCommand);\n * graphics.beginFill(\"blue\");\n * graphics.drawCircle(0, 0, 30);\n *\n * @example
Using the Tiny API
\n * graphics.s(\"red\").f(\"blue\").r(20, 20, 100, 50);\n *\n * @see {@link easeljs.Graphics#append}\n * @memberof easeljs\n */\nexport default class Graphics {\n\n\tconstructor () {\n\t\t/**\n\t\t * Holds a reference to the last command that was created or appended. For example, you could retain a reference\n\t\t * to a Fill command in order to dynamically update the color later by using:\n\t\t *\n\t\t * @example\n\t\t * let fill = graphics.beginFill(\"red\").command;\n\t\t * // update color later:\n\t\t * fill.style = \"yellow\";\n\t\t *\n\t\t * @type {Object}\n\t\t * @default null\n\t\t */\n\t\tthis.command = null;\n\n\n\t// private properties\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.Graphics.Stroke}\n\t\t */\n\t\tthis._stroke = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.Graphics.StrokeStyle}\n\t\t */\n\t\tthis._strokeStyle = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.Graphics.StrokeStyle}\n\t\t */\n\t\tthis._oldStrokeStyle = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.Graphics.StrokeDash}\n\t\t */\n\t\tthis._strokeDash = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.Graphics.StrokeDash}\n\t\t */\n\t\tthis._oldStrokeDash = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {easeljs.Graphics.Fill}\n\t\t */\n\t\tthis._fill = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis._strokeIgnoreScale = false;\n\n\t\t/**\n\t\t * Indicates the last instruction index that was committed.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis._commitIndex = 0;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Array}\n\t\t */\n\t\tthis._instructions = [];\n\n\t\t/**\n\t\t * Uncommitted instructions.\n\t\t * @protected\n\t\t * @type {Array}\n\t\t */\n\t\tthis._activeInstructions = [];\n\n\t\t/**\n\t\t * This indicates that there have been changes to the activeInstruction list since the last updateInstructions call.\n\t\t * @protected\n\t\t * @type {Boolean}\n\t\t * @default false\n\t\t */\n\t\tthis._dirty = false;\n\n\t\t/**\n\t\t * Index to draw from if a store operation has happened.\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis._storeIndex = 0;\n\n\t\t/**\n\t\t * Maps the familiar ActionScript `curveTo()` method to the functionally similar {@link easeljs.Graphics#quadraticCurveTo} method.\n\t\t * @param {Number} cpx\n\t\t * @param {Number} cpy\n\t\t * @param {Number} x\n\t\t * @param {Number} y\n\t\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t\t * @chainable\n\t\t */\n\t\tthis.curveTo = this.quadraticCurveTo;\n\n\t\t/**\n\t\t * Maps the familiar ActionScript `drawRect()` method to the functionally similar {@link easeljs.Graphics#rect} method.\n\t\t * @param {Number} x\n\t\t * @param {Number} y\n\t\t * @param {Number} w Width of the rectangle\n\t\t * @param {Number} h Height of the rectangle\n\t\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t\t * @chainable\n\t\t */\n\t\tthis.drawRect = this.rect;\n\n\t\t// tiny api\n\t\tthis.mt = this.moveTo;\n\t\tthis.lt = this.lineTo;\n\t\tthis.at = this.arcTo;\n\t\tthis.bt = this.bezierCurveTo;\n\t\tthis.qt = this.quadraticCurveTo;\n\t\tthis.a = this.arc;\n\t\tthis.r = this.rect;\n\t\tthis.cp = this.closePath;\n\t\tthis.c = this.clear;\n\t\tthis.f = this.beginFill;\n\t\tthis.lf = this.beginLinearGradientFill;\n\t\tthis.rf = this.beginRadialGradientFill;\n\t\tthis.bf = this.beginBitmapFill;\n\t\tthis.ef = this.endFill;\n\t\tthis.ss = this.setStrokeStyle;\n\t\tthis.sd = this.setStrokeDash;\n\t\tthis.s = this.beginStroke;\n\t\tthis.ls = this.beginLinearGradientStroke;\n\t\tthis.rs = this.beginRadialGradientStroke;\n\t\tthis.bs = this.beginBitmapStroke;\n\t\tthis.es = this.endStroke;\n\t\tthis.dr = this.drawRect;\n\t\tthis.rr = this.drawRoundRect;\n\t\tthis.rc = this.drawRoundRectComplex;\n\t\tthis.dc = this.drawCircle;\n\t\tthis.de = this.drawEllipse;\n\t\tthis.dp = this.drawPolyStar;\n\t\tthis.p = this.decodePath;\n\n\t\tthis.clear();\n\t}\n\n\t/**\n\t * Returns a CSS compatible color string based on the specified RGB numeric color values in the format\n\t * \"rgba(255,255,255,1.0)\", or if alpha is null then in the format \"rgb(255,255,255)\".\n\t * It also supports passing a single hex color value as the first param, and an optional alpha value as the second\n\t * param.\n\t *\n\t * @example\n\t * Graphics.getRGB(50, 100, 150, 0.5); // rgba(50,100,150,0.5)\n\t * Graphics.getRGB(0xFF00FF, 0.2); // rgba(255,0,255,0.2)\n\t *\n\t * @static\n\t * @param {Number} r The red component for the color, between 0 and 0xFF (255).\n\t * @param {Number} g The green component for the color, between 0 and 0xFF (255).\n\t * @param {Number} b The blue component for the color, between 0 and 0xFF (255).\n\t * @param {Number} [alpha] The alpha component for the color where 0 is fully transparent and 1 is fully opaque.\n\t * @return {String} A CSS compatible color string based on the specified RGB numeric color values in the format\n\t * \"rgba(255,255,255,1.0)\", or if alpha is null then in the format \"rgb(255,255,255)\".\n\t */\n\tstatic getRGB (r, g, b, alpha) {\n\t\tif (r != null && b == null) {\n\t\t\talpha = g;\n\t\t\tb = r&0xFF;\n\t\t\tg = r>>8&0xFF;\n\t\t\tr = r>>16&0xFF;\n\t\t}\n\t\tif (alpha == null) {\n\t\t\treturn `rgb(${r},${g},${b})`;\n\t\t} else {\n\t\t\treturn `rgba(${r},${g},${b},${alpha})`;\n\t\t}\n\t}\n\n\t/**\n\t * Returns a CSS compatible color string based on the specified HSL numeric color values in the format \"hsla(360,100,100,1.0)\",\n\t * or if alpha is null then in the format \"hsl(360,100,100)\".\n\t *\n\t * @example\n\t * Graphics.getHSL(150, 100, 70); // hsl(150,100,70)\n\t *\n\t * @static\n\t * @param {Number} hue The hue component for the color, between 0 and 360.\n\t * @param {Number} saturation The saturation component for the color, between 0 and 100.\n\t * @param {Number} lightness The lightness component for the color, between 0 and 100.\n\t * @param {Number} [alpha] The alpha component for the color where 0 is fully transparent and 1 is fully opaque.\n\t * @return {String} A CSS compatible color string based on the specified HSL numeric color values in the format\n\t * \"hsla(360,100,100,1.0)\", or if alpha is null then in the format \"hsl(360,100,100)\".\n\t */\n\tstatic getHSL (hue, saturation, lightness, alpha) {\n\t\tif (alpha == null) {\n\t\t\treturn `hsl(${hue % 360},${saturation}%,${lightness}%)`;\n\t\t} else {\n\t\t\treturn `hsl(${hue % 360},${saturation}%,${lightness}%,${alpha})`;\n\t\t}\n\t}\n\n\t/**\n\t * Returns the graphics instructions array. Each entry is a graphics command object (ex. Graphics.Fill, Graphics.Rect)\n\t * Modifying the returned array directly is not recommended, and is likely to result in unexpected behaviour.\n\t *\n\t * This property is mainly intended for introspection of the instructions (ex. for graphics export).\n\t * @type {Array}\n\t * @readonly\n\t */\n\tget instructions () {\n\t\tthis._updateInstructions();\n\t\treturn this._instructions;\n\t}\n\n\t/**\n\t * Returns true if this Graphics instance has no drawing commands.\n\t * @return {Boolean} Returns true if this Graphics instance has no drawing commands.\n\t */\n\tisEmpty () {\n\t\treturn !(this._instructions.length || this._activeInstructions.length);\n\t}\n\n\t/**\n\t * Draws the display object into the specified context ignoring its visible, alpha, shadow, and transform.\n\t * Returns true if the draw was handled (useful for overriding functionality).\n\t *\n\t * NOTE: This method is mainly for internal use, though it may be useful for advanced uses.\n\t *\n\t * @param {CanvasRenderingContext2D} ctx The canvas 2D context object to draw into.\n\t * @param {Object} data Optional data that is passed to graphics command exec methods. When called from a Shape instance, the shape passes itself as the data parameter. This can be used by custom graphic commands to insert contextual data.\n\t */\n\tdraw (ctx, data) {\n\t\tthis._updateInstructions();\n\t\tlet instr = this._instructions;\n\t\tconst l = instr.length;\n\t\tfor (let i = this._storeIndex; i < l; i++) {\n\t\t\tinstr[i].exec(ctx, data);\n\t\t}\n\t}\n\n\t/**\n\t * Draws only the path described for this Graphics instance, skipping any non-path instructions, including fill and\n\t * stroke descriptions. Used for `DisplayObject.mask` to draw the clipping path, for example.\n\t *\n\t * NOTE: This method is mainly for internal use, though it may be useful for advanced uses.\n\t *\n\t * @param {CanvasRenderingContext2D} ctx The canvas 2D context object to draw into.\n\t */\n\tdrawAsPath (ctx) {\n\t\tthis._updateInstructions();\n\t\tlet instr, instrs = this._instructions;\n\t\tconst l = instrs.length;\n\t\tfor (let i = this._storeIndex; i < l; i++) {\n\t\t\t// the first command is always a beginPath command.\n\t\t\tif ((instr = instrs[i]).path !== false) { instr.exec(ctx); }\n\t\t}\n\t}\n\n\t/**\n\t * Moves the drawing point to the specified position.\n\t * A tiny API method \"mt\" also exists.\n\t * @param {Number} x The x coordinate the drawing point should move to.\n\t * @param {Number} y The y coordinate the drawing point should move to.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls).\n\t * @chainable\n\t */\n\tmoveTo (x, y) {\n\t\treturn this.append(new MoveTo(x,y), true);\n\t}\n\n\t/**\n\t * Draws a line from the current drawing point to the specified position, which become the new current drawing\n\t * point. Note that you *must* call {@link easeljs.Graphics#moveTo} before the first `lineTo()`.\n\t * A tiny API method \"lt\" also exists.\n\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#complex-shapes-(paths) \"WHATWG spec\"}\n\t * @param {Number} x The x coordinate the drawing point should draw to.\n\t * @param {Number} y The y coordinate the drawing point should draw to.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tlineTo (x, y) {\n\t\treturn this.append(new LineTo(x,y));\n\t}\n\n\t/**\n\t * Draws an arc with the specified control points and radius.\n\t * A tiny API method \"at\" also exists.\n\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-arcto \"WHATWG spec\"}\n\t * @param {Number} x1\n\t * @param {Number} y1\n\t * @param {Number} x2\n\t * @param {Number} y2\n\t * @param {Number} radius\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tarcTo (x1, y1, x2, y2, radius) {\n\t\treturn this.append(new ArcTo(x1, y1, x2, y2, radius));\n\t}\n\n\t/**\n\t * Draws an arc defined by the radius, startAngle and endAngle arguments, centered at the position (x, y).\n\t * A tiny API method \"a\" also exists.\n\t *\n\t * @example\n\t * // draw a full circle with a radius of 20 centered at (100, 100)\n\t * arc(100, 100, 20, 0, Math.PI*2);\n\t *\n\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-arc \"WHATWG spec\"}\n\t * @param {Number} x\n\t * @param {Number} y\n\t * @param {Number} radius\n\t * @param {Number} startAngle Measured in radians.\n\t * @param {Number} endAngle Measured in radians.\n\t * @param {Boolean} anticlockwise\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tarc (x, y, radius, startAngle, endAngle, anticlockwise) {\n\t\treturn this.append(new Arc(x, y, radius, startAngle, endAngle, anticlockwise));\n\t}\n\n\t/**\n\t * Draws a quadratic curve from the current drawing point to (x, y) using the control point (cpx, cpy).\n\t * A tiny API method \"qt\" also exists.\n\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-quadraticcurveto \"WHATWG spec\"}\n\t * @param {Number} cpx\n\t * @param {Number} cpy\n\t * @param {Number} x\n\t * @param {Number} y\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tquadraticCurveTo (cpx, cpy, x, y) {\n\t\treturn this.append(new QuadraticCurveTo(cpx, cpy, x, y));\n\t}\n\n\t/**\n\t * Draws a bezier curve from the current drawing point to (x, y) using the control points (cp1x, cp1y) and (cp2x, cp2y).\n\t * A tiny API method \"bt\" also exists.\n\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-beziercurveto \"WHATWG spec\"}\n\t * @param {Number} cp1x\n\t * @param {Number} cp1y\n\t * @param {Number} cp2x\n\t * @param {Number} cp2y\n\t * @param {Number} x\n\t * @param {Number} y\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tbezierCurveTo (cp1x, cp1y, cp2x, cp2y, x, y) {\n\t\treturn this.append(new BezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y));\n\t}\n\n\t/**\n\t * Draws a rectangle at (x, y) with the specified width and height using the current fill and/or stroke.\n\t * A tiny API method \"r\" also exists.\n\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-rect \"WHATWG spec\"}\n\t * @param {Number} x\n\t * @param {Number} y\n\t * @param {Number} w Width of the rectangle\n\t * @param {Number} h Height of the rectangle\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\trect (x, y, w, h) {\n\t\treturn this.append(new Rect(x, y, w, h));\n\t}\n\n\t/**\n\t * Closes the current path, effectively drawing a line from the current drawing point to the first drawing point specified\n\t * since the fill or stroke was last set.\n\t * A tiny API method \"cp\" also exists.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tclosePath () {\n\t\treturn this._activeInstructions.length ? this.append(new ClosePath()) : this;\n\t}\n\n\t/**\n\t * Clears all drawing instructions, effectively resetting this Graphics instance. Any line and fill styles will need\n\t * to be redefined to draw shapes following a clear call.\n\t * A tiny API method \"c\" also exists.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tclear () {\n\t\tthis._instructions.length = this._activeInstructions.length = this._commitIndex = 0;\n\t\tthis._strokeStyle = this._oldStrokeStyle = this._stroke = this._fill = this._strokeDash = this._oldStrokeDash = null;\n\t\tthis._dirty = this._strokeIgnoreScale = false;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Begins a fill with the specified color. This ends the current sub-path.\n\t * A tiny API method \"f\" also exists.\n\t * @param {String} color A CSS compatible color value (ex. \"red\", \"#FF0000\", or \"rgba(255,0,0,0.5)\"). Setting to\n\t * null will result in no fill.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tbeginFill (color) {\n\t\treturn this._setFill(color ? new Fill(color) : null);\n\t}\n\n\t/**\n\t * Begins a linear gradient fill defined by the line (x0, y0) to (x1, y1).\n\t * A tiny API method \"lf\" also exists.\n\t *\n\t * @example
Define a black to white vertical gradient ranging from 20px to 120px, and draw a square to display it
\n\t * graphics.beginLinearGradientFill([\"#000\",\"#FFF\"], [0, 1], 0, 20, 0, 120).drawRect(20, 20, 120, 120);\n\t *\n\t * @param {Array} colors An array of CSS compatible color values. For example, [\"#F00\",\"#00F\"] would define a gradient\n\t * drawing from red to blue.\n\t * @param {Array} ratios An array of gradient positions which correspond to the colors. For example, [0.1, 0.9] would draw\n\t * the first color to 10% then interpolating to the second color at 90%.\n\t * @param {Number} x0 The position of the first point defining the line that defines the gradient direction and size.\n\t * @param {Number} y0 The position of the first point defining the line that defines the gradient direction and size.\n\t * @param {Number} x1 The position of the second point defining the line that defines the gradient direction and size.\n\t * @param {Number} y1 The position of the second point defining the line that defines the gradient direction and size.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tbeginLinearGradientFill (colors, ratios, x0, y0, x1, y1) {\n\t\treturn this._setFill(new Fill().linearGradient(colors, ratios, x0, y0, x1, y1));\n\t}\n\n\t/**\n\t * Begins a radial gradient fill. This ends the current sub-path.\n\t * A tiny API method \"rf\" also exists.\n\t *\n\t * @example
Define a red to blue radial gradient centered at (100, 100), with a radius of 50, and draw a circle to display it
\n\t * graphics.beginRadialGradientFill([\"#F00\",\"#00F\"], [0, 1], 100, 100, 0, 100, 100, 50).drawCircle(100, 100, 50);\n\t *\n\t * @param {Array} colors An array of CSS compatible color values. For example, [\"#F00\",\"#00F\"] would define\n\t * a gradient drawing from red to blue.\n\t * @param {Array} ratios An array of gradient positions which correspond to the colors. For example, [0.1,\n\t * 0.9] would draw the first color to 10% then interpolating to the second color at 90%.\n\t * @param {Number} x0 Center position of the inner circle that defines the gradient.\n\t * @param {Number} y0 Center position of the inner circle that defines the gradient.\n\t * @param {Number} r0 Radius of the inner circle that defines the gradient.\n\t * @param {Number} x1 Center position of the outer circle that defines the gradient.\n\t * @param {Number} y1 Center position of the outer circle that defines the gradient.\n\t * @param {Number} r1 Radius of the outer circle that defines the gradient.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tbeginRadialGradientFill (colors, ratios, x0, y0, r0, x1, y1, r1) {\n\t\treturn this._setFill(new Fill().radialGradient(colors, ratios, x0, y0, r0, x1, y1, r1));\n\t}\n\n\t/**\n\t * Begins a pattern fill using the specified image. This ends the current sub-path.\n\t * A tiny API method \"bf\" also exists.\n\t * @param {HTMLImageElement | HTMLCanvasElement | HTMLVideoElement} image The Image, Canvas, or Video object to use\n\t * as the pattern. Must be loaded prior to creating a bitmap fill, or the fill will be empty.\n\t * @param {String} repetition Optional. Indicates whether to repeat the image in the fill area. One of \"repeat\",\n\t * \"repeat-x\", \"repeat-y\", or \"no-repeat\". Defaults to \"repeat\". Note that Firefox does not support \"repeat-x\" or\n\t * \"repeat-y\" (latest tests were in FF 20.0), and will default to \"repeat\".\n\t * @param {easeljs.Matrix2D} matrix Optional. Specifies a transformation matrix for the bitmap fill. This transformation\n\t * will be applied relative to the parent transform.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tbeginBitmapFill (image, repetition, matrix) {\n\t\treturn this._setFill(new Fill(null, matrix).bitmap(image, repetition));\n\t}\n\n\t/**\n\t * Ends the current sub-path, and begins a new one with no fill. Functionally identical to `beginFill(null)`.\n\t * A tiny API method \"ef\" also exists.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tendFill () {\n\t\treturn this.beginFill();\n\t}\n\n\t/**\n\t * Sets the stroke style.\n\t * A tiny API method \"ss\" also exists.\n\t *\n\t * @example\n\t * graphics.setStrokeStyle(8,\"round\").beginStroke(\"#F00\");\n\t *\n\t * @param {Number} thickness The width of the stroke.\n\t * @param {String | Number} [caps=0] Indicates the type of caps to use at the end of lines. One of butt,\n\t * round, or square. Defaults to \"butt\". Also accepts the values 0 (butt), 1 (round), and 2 (square) for use with\n\t * the tiny API.\n\t * @param {String | Number} [joints=0] Specifies the type of joints that should be used where two lines meet.\n\t * One of bevel, round, or miter. Defaults to \"miter\". Also accepts the values 0 (miter), 1 (round), and 2 (bevel)\n\t * for use with the tiny API.\n\t * @param {Number} [miterLimit=10] If joints is set to \"miter\", then you can specify a miter limit ratio which\n\t * controls at what point a mitered joint will be clipped.\n\t * @param {Boolean} [ignoreScale=false] If true, the stroke will be drawn at the specified thickness regardless\n\t * of active transformations.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tsetStrokeStyle (thickness, caps = 0, joints = 0, miterLimit = 10, ignoreScale = false) {\n\t\tthis._updateInstructions(true);\n\t\tthis._strokeStyle = this.command = new StrokeStyle(thickness, caps, joints, miterLimit, ignoreScale);\n\n\t\t// ignoreScale lives on Stroke, not StrokeStyle, so we do a little trickery:\n\t\tif (this._stroke) { this._stroke.ignoreScale = ignoreScale; }\n\t\tthis._strokeIgnoreScale = ignoreScale;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets or clears the stroke dash pattern.\n\t * A tiny API method `sd` also exists.\n\t *\n\t * @example\n\t * graphics.setStrokeDash([20, 10], 0);\n\t *\n\t * @param {Array} [segments] An array specifying the dash pattern, alternating between line and gap.\n\t * For example, `[20,10]` would create a pattern of 20 pixel lines with 10 pixel gaps between them.\n\t * Passing null or an empty array will clear the existing stroke dash.\n\t * @param {Number} [offset=0] The offset of the dash pattern. For example, you could increment this value to create a \"marching ants\" effect.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tsetStrokeDash (segments, offset = 0) {\n\t\tthis._updateInstructions(true);\n\t\tthis._strokeDash = this.command = new StrokeDash(segments, offset);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Begins a stroke with the specified color. This ends the current sub-path.\n\t * A tiny API method \"s\" also exists.\n\t *\n\t * @param {String} color A CSS compatible color value (ex. \"#FF0000\", \"red\", or \"rgba(255,0,0,0.5)\"). Setting to\n\t * null will result in no stroke.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tbeginStroke (color) {\n\t\treturn this._setStroke(color ? new Stroke(color) : null);\n\t}\n\n\t/**\n\t * Begins a linear gradient stroke defined by the line (x0, y0) to (x1, y1). This ends the current sub-path.\n\t * A tiny API method \"ls\" also exists.\n\t *\n\t * @example
Define a black to white vertical gradient ranging from 20px to 120px, and draw a square to display it
\n\t * graphics.setStrokeStyle(10)\n\t * .beginLinearGradientStroke([\"#000\",\"#FFF\"], [0, 1], 0, 20, 0, 120)\n\t * .drawRect(20, 20, 120, 120);\n\t *\n\t * @param {Array} colors An array of CSS compatible color values. For example, [\"#F00\",\"#00F\"] would define\n\t * a gradient drawing from red to blue.\n\t * @param {Array} ratios An array of gradient positions which correspond to the colors. For example, [0.1,\n\t * 0.9] would draw the first color to 10% then interpolating to the second color at 90%.\n\t * @param {Number} x0 The position of the first point defining the line that defines the gradient direction and size.\n\t * @param {Number} y0 The position of the first point defining the line that defines the gradient direction and size.\n\t * @param {Number} x1 The position of the second point defining the line that defines the gradient direction and size.\n\t * @param {Number} y1 The position of the second point defining the line that defines the gradient direction and size.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tbeginLinearGradientStroke (colors, ratios, x0, y0, x1, y1) {\n\t\treturn this._setStroke(new Stroke().linearGradient(colors, ratios, x0, y0, x1, y1));\n\t}\n\n\t/**\n\t * Begins a radial gradient stroke. This ends the current sub-path.\n\t * A tiny API method \"rs\" also exists.\n\t *\n\t * @example
Define a red to blue radial gradient centered at (100, 100), with a radius of 50, and draw a rectangle to display it
\n\t * graphics.setStrokeStyle(10)\n\t * .beginRadialGradientStroke([\"#F00\",\"#00F\"], [0, 1], 100, 100, 0, 100, 100, 50)\n\t * .drawRect(50, 90, 150, 110);\n\t *\n\t * @param {Array} colors An array of CSS compatible color values. For example, [\"#F00\",\"#00F\"] would define\n\t * a gradient drawing from red to blue.\n\t * @param {Array} ratios An array of gradient positions which correspond to the colors. For example, [0.1,\n\t * 0.9] would draw the first color to 10% then interpolating to the second color at 90%, then draw the second color\n\t * to 100%.\n\t * @param {Number} x0 Center position of the inner circle that defines the gradient.\n\t * @param {Number} y0 Center position of the inner circle that defines the gradient.\n\t * @param {Number} r0 Radius of the inner circle that defines the gradient.\n\t * @param {Number} x1 Center position of the outer circle that defines the gradient.\n\t * @param {Number} y1 Center position of the outer circle that defines the gradient.\n\t * @param {Number} r1 Radius of the outer circle that defines the gradient.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tbeginRadialGradientStroke (colors, ratios, x0, y0, r0, x1, y1, r1) {\n\t\treturn this._setStroke(new Stroke().radialGradient(colors, ratios, x0, y0, r0, x1, y1, r1));\n\t}\n\n\t/**\n\t * Begins a pattern fill using the specified image. This ends the current sub-path. Note that unlike bitmap fills,\n\t * strokes do not currently support a matrix parameter due to limitations in the canvas API.\n\t * A tiny API method \"bs\" also exists.\n\t *\n\t * @param {HTMLImageElement | HTMLCanvasElement | HTMLVideoElement} image The Image, Canvas, or Video object to use\n\t * as the pattern. Must be loaded prior to creating a bitmap fill, or the fill will be empty.\n\t * @param {String} [repetition=\"repeat\"] Indicates whether to repeat the image in the fill area. One of\n\t * \"repeat\", \"repeat-x\", \"repeat-y\", or \"no-repeat\". Defaults to \"repeat\".\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tbeginBitmapStroke (image, repetition = \"repeat\") {\n\t\t// NOTE: matrix is not supported for stroke because transforms on strokes also affect the drawn stroke width.\n\t\treturn this._setStroke(new Stroke().bitmap(image, repetition));\n\t}\n\n\t/**\n\t * Ends the current sub-path, and begins a new one with no stroke. Functionally identical to `beginStroke(null)`.\n\t * A tiny API method \"es\" also exists.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tendStroke () {\n\t\treturn this.beginStroke();\n\t}\n\n\t/**\n\t * Draws a rounded rectangle with all corners with the specified radius.\n\t * @param {Number} x\n\t * @param {Number} y\n\t * @param {Number} w\n\t * @param {Number} h\n\t * @param {Number} radius Corner radius.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tdrawRoundRect (x, y, w, h, radius) {\n\t\treturn this.drawRoundRectComplex(x, y, w, h, radius, radius, radius, radius);\n\t}\n\n\t/**\n\t * Draws a rounded rectangle with different corner radii. Supports positive and negative corner radii.\n\t * A tiny API method \"rc\" also exists.\n\t * @param {Number} x The horizontal coordinate to draw the round rect.\n\t * @param {Number} y The vertical coordinate to draw the round rect.\n\t * @param {Number} w The width of the round rect.\n\t * @param {Number} h The height of the round rect.\n\t * @param {Number} radiusTL Top left corner radius.\n\t * @param {Number} radiusTR Top right corner radius.\n\t * @param {Number} radiusBR Bottom right corner radius.\n\t * @param {Number} radiusBL Bottom left corner radius.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tdrawRoundRectComplex (x, y, w, h, radiusTL, radiusTR, radiusBR, radiusBL) {\n\t\treturn this.append(new RoundRect(x, y, w, h, radiusTL, radiusTR, radiusBR, radiusBL));\n\t}\n\n\t/**\n\t * Draws a circle with the specified radius at (x, y).\n\t * A tiny API method \"dc\" also exists.\n\t *\n\t * @example\n\t * let g = new Graphics();\n\t * g.setStrokeStyle(1);\n\t * g.beginStroke(Graphics.getRGB(0,0,0));\n\t * g.beginFill(Graphics.getRGB(255,0,0));\n\t * g.drawCircle(0,0,3);\n\t * let s = new Shape(g);\n\t * s.x = 100;\n\t * s.y = 100;\n\t * stage.addChild(s);\n\t * stage.update();\n\t *\n\t * @param {Number} x x coordinate center point of circle.\n\t * @param {Number} y y coordinate center point of circle.\n\t * @param {Number} radius Radius of circle.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tdrawCircle (x, y, radius) {\n\t\treturn this.append(new Circle(x, y, radius));\n\t}\n\n\t/**\n\t * Draws an ellipse (oval) with a specified width (w) and height (h). Similar to {@link easels.Graphics#drawCircle},\n\t * except the width and height can be different.\n\t * A tiny API method \"de\" also exists.\n\t * @param {Number} x The left coordinate point of the ellipse. Note that this is different from {@link easels.Graphics#drawCircle}\n\t * which draws from center.\n\t * @param {Number} y The top coordinate point of the ellipse. Note that this is different from {@link easels.Graphics#drawCircle}\n\t * which draws from the center.\n\t * @param {Number} w The height (horizontal diameter) of the ellipse. The horizontal radius will be half of this\n\t * number.\n\t * @param {Number} h The width (vertical diameter) of the ellipse. The vertical radius will be half of this number.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tdrawEllipse (x, y, w, h) {\n\t\treturn this.append(new Ellipse(x, y, w, h));\n\t}\n\n\t/**\n\t * Draws a star if pointSize is greater than 0, or a regular polygon if pointSize is 0 with the specified number of points.\n\t * A tiny API method \"dp\" also exists.\n\t *\n\t * @example
Draw a 5 pointed star shape centered at 100, 100 and with a radius of 50
\n\t * graphics.beginFill(\"#FF0\").drawPolyStar(100, 100, 50, 5, 0.6, -90);\n\t * // Note: -90 makes the first point vertical\n\t *\n\t * @param {Number} x Position of the center of the shape.\n\t * @param {Number} y Position of the center of the shape.\n\t * @param {Number} radius The outer radius of the shape.\n\t * @param {Number} sides The number of points on the star or sides on the polygon.\n\t * @param {Number} pointSize The depth or \"pointy-ness\" of the star points. A pointSize of 0 will draw a regular\n\t * polygon (no points), a pointSize of 1 will draw nothing because the points are infinitely pointy.\n\t * @param {Number} angle The angle of the first point / corner. For example a value of 0 will draw the first point\n\t * directly to the right of the center.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tdrawPolyStar (x, y, radius, sides, pointSize, angle) {\n\t\treturn this.append(new PolyStar(x, y, radius, sides, pointSize, angle));\n\t}\n\n\t/**\n\t * Appends a graphics command object to the graphics queue. Command objects expose an \"exec\" method\n\t * that accepts two parameters: the Context2D to operate on, and an arbitrary data object passed into\n\t * {@link easeljs.Graphics#draw}. The latter will usually be the Shape instance that called draw.\n\t *\n\t * This method is used internally by Graphics methods, such as drawCircle, but can also be used directly to insert\n\t * built-in or custom graphics commands.\n\t *\n\t * @example\n\t * // attach data to our shape, so we can access it during the draw:\n\t * shape.color = \"red\";\n\t *\n\t * // append a Circle command object:\n\t * shape.graphics.append(new Graphics.Circle(50, 50, 30));\n\t *\n\t * // append a custom command object with an exec method that sets the fill style\n\t * // based on the shape's data, and then fills the circle.\n\t * shape.graphics.append({\n\t * exec: (ctx, shape) => {\n\t * ctx.fillStyle = shape.color;\n\t * ctx.fill();\n\t * }\n\t * });\n\t *\n\t * @param {Object} command A graphics command object exposing an \"exec\" method.\n\t * @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.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tappend (command, clean) {\n\t\tthis._activeInstructions.push(command);\n\t\tthis.command = command;\n\t\tif (!clean) { this._dirty = true; }\n\t\treturn this;\n\t}\n\n\t/**\n\t * Decodes a compact encoded path string into a series of draw instructions.\n\t * This format is not intended to be human readable, and is meant for use by authoring tools.\n\t * The format uses a base64 character set, with each character representing 6 bits, to define a series of draw\n\t * commands.\n\t *\n\t * Each command is comprised of a single \"header\" character followed by a variable number of alternating x and y\n\t * position values. Reading the header bits from left to right (most to least significant): bits 1 to 3 specify the\n\t * type of operation (0-moveTo, 1-lineTo, 2-quadraticCurveTo, 3-bezierCurveTo, 4-closePath, 5-7 unused). Bit 4\n\t * indicates whether position values use 12 bits (2 characters) or 18 bits (3 characters), with a one indicating the\n\t * latter. Bits 5 and 6 are currently unused.\n\t *\n\t * Following the header is a series of 0 (closePath), 2 (moveTo, lineTo), 4 (quadraticCurveTo), or 6 (bezierCurveTo)\n\t * parameters. These parameters are alternating x/y positions represented by 2 or 3 characters (as indicated by the\n\t * 4th bit in the command char). These characters consist of a 1 bit sign (1 is negative, 0 is positive), followed\n\t * by an 11 (2 char) or 17 (3 char) bit integer value. All position values are in tenths of a pixel. Except in the\n\t * case of move operations which are absolute, this value is a delta from the previous x or y position (as\n\t * appropriate).\n\t *\n\t * For example, the string \"A3cAAMAu4AAA\" represents a line starting at -150,0 and ending at 150,0.\n\t * A - bits 000000. First 3 bits (000) indicate a moveTo operation. 4th bit (0) indicates 2 chars per\n\t * parameter.\n\t * n0 - 110111011100. Absolute x position of -150.0px. First bit indicates a negative value, remaining bits\n\t * indicate 1500 tenths of a pixel.\n\t * AA - 000000000000. Absolute y position of 0.\n\t * I - 001100. First 3 bits (001) indicate a lineTo operation. 4th bit (1) indicates 3 chars per parameter.\n\t * Au4 - 000000101110111000. An x delta of 300.0px, which is added to the previous x value of -150.0px to\n\t * provide an absolute position of +150.0px.\n\t * AAA - 000000000000000000. A y delta value of 0.\n\t *\n\t * A tiny API method \"p\" also exists.\n\t *\n\t * @param {String} str The path string to decode.\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tdecodePath (str) {\n\t\tlet instructions = [this.moveTo, this.lineTo, this.quadraticCurveTo, this.bezierCurveTo, this.closePath];\n\t\tlet paramCount = [2, 2, 4, 6, 0];\n\t\tlet i = 0;\n\t\tconst l = str.length;\n\t\tlet params = [];\n\t\tlet x = 0, y = 0;\n\t\tlet base64 = Graphics._BASE_64;\n\n\t\twhile (i < l) {\n\t\t\tlet c = str.charAt(i);\n\t\t\tlet n = base64[c];\n\t\t\tlet fi = n>>3; // highest order bits 1-3 code for operation.\n\t\t\tlet f = instructions[fi];\n\t\t\t// check that we have a valid instruction & that the unused bits are empty:\n\t\t\tif (!f || (n&3)) { throw `Bad path data (@${i}):c`; }\n\t\t\tconst pl = paramCount[fi];\n\t\t\tif (!fi) { x=y=0; } // move operations reset the position.\n\t\t\tparams.length = 0;\n\t\t\ti++;\n\t\t\tlet charCount = (n>>2&1)+2; // 4th header bit indicates number size for this operation.\n\t\t\tfor (let p = 0; p < pl; p++) {\n\t\t\t\tlet num = base64[str.charAt(i)];\n\t\t\t\tlet sign = (num>>5) ? -1 : 1;\n\t\t\t\tnum = ((num&31)<<6)|(base64[str.charAt(i+1)]);\n\t\t\t\tif (charCount === 3) { num = (num<<6)|(base64[str.charAt(i+2)]); }\n\t\t\t\tnum = sign*num/10;\n\t\t\t\tif (p%2) { x = (num += x); }\n\t\t\t\telse { y = (num += y); }\n\t\t\t\tparams[p] = num;\n\t\t\t\ti += charCount;\n\t\t\t}\n\t\t\tf.apply(this, params);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/**\n\t * Stores all graphics commands so they won't be executed in future draws. Calling store() a second time adds to\n\t * the existing store. This also affects `drawAsPath()`.\n\t *\n\t * This is useful in cases where you are creating vector graphics in an iterative manner (ex. generative art), so\n\t * that only new graphics need to be drawn (which can provide huge performance benefits), but you wish to retain all\n\t * of the vector instructions for later use (ex. scaling, modifying, or exporting).\n\t *\n\t * Note that calling store() will force the active path (if any) to be ended in a manner similar to changing\n\t * the fill or stroke.\n\t *\n\t * For example, consider a application where the user draws lines with the mouse. As each line segment (or collection of\n\t * segments) are added to a Shape, it can be rasterized using {@link easeljs.DisplayObject#updateCache},\n\t * and then stored, so that it can be redrawn at a different scale when the application is resized, or exported to SVGraphics.\n\t *\n\t * @example\n\t * // set up cache:\n\t * shape.cache(0,0,500,500,scale);\n\t *\n\t * // when the user drags, draw a new line:\n\t * shape.graphics.moveTo(oldX,oldY).lineTo(newX,newY);\n\t * // then draw it into the existing cache:\n\t * shape.updateCache(\"source-over\");\n\t * // store the new line, so it isn't redrawn next time:\n\t * shape.store();\n\t *\n\t * // then, when the window resizes, we can re-render at a different scale:\n\t * // first, unstore all our lines:\n\t * shape.unstore();\n\t * // then cache using the new scale:\n\t * shape.cache(0,0,500,500,newScale);\n\t * // finally, store the existing commands again:\n\t * shape.store();\n\t *\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tstore () {\n\t\tthis._updateInstructions(true);\n\t\tthis._storeIndex = this._instructions.length;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Unstores any graphics commands that were previously stored using {@link easeljs.Graphics#store}\n\t * so that they will be executed in subsequent draw calls.\n\t *\n\t * @return {easeljs.Graphics} The Graphics instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tunstore () {\n\t\tthis._storeIndex = 0;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns a clone of this Graphics instance. Note that the individual command objects are not cloned.\n\t * @return {easeljs.Graphics} A clone of the current Graphics instance.\n\t */\n\tclone () {\n\t\tlet o = new Graphics();\n\t\to.command = this.command;\n\t\to._stroke = this._stroke;\n\t\to._strokeStyle = this._strokeStyle;\n\t\to._strokeDash = this._strokeDash;\n\t\to._strokeIgnoreScale = this._strokeIgnoreScale;\n\t\to._fill = this._fill;\n\t\to._instructions = this._instructions.slice();\n\t\to._commitIndex = this._commitIndex;\n\t\to._activeInstructions = this._activeInstructions.slice();\n\t\to._dirty = this._dirty;\n\t\to._storeIndex = this._storeIndex;\n\t\treturn o;\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name}]`;\n\t}\n\n\t/**\n\t * @param {Boolean} commit\n\t * @protected\n\t */\n\t_updateInstructions (commit) {\n\t\tlet instr = this._instructions, active = this._activeInstructions, commitIndex = this._commitIndex;\n\n\t\tif (this._dirty && active.length) {\n\t\t\tinstr.length = commitIndex; // remove old, uncommitted commands\n\t\t\tinstr.push(Graphics.beginCmd);\n\n\t\t\tconst l = active.length, ll = instr.length;\n\t\t\tinstr.length = ll+l;\n\t\t\tfor (let i = 0; i < l; i++) { instr[i+ll] = active[i]; }\n\n\t\t\tif (this._fill) { instr.push(this._fill); }\n\t\t\tif (this._stroke) {\n\t\t\t\t// doesn't need to be re-applied if it hasn't changed.\n\t\t\t\tif (this._strokeDash !== this._oldStrokeDash) {\n\t\t\t\t\tinstr.push(this._strokeDash);\n\t\t\t\t}\n\t\t\t\tif (this._strokeStyle !== this._oldStrokeStyle) {\n\t\t\t\t\tinstr.push(this._strokeStyle);\n\t\t\t\t}\n\t\t\t\tif (commit) {\n\t\t\t\t\tthis._oldStrokeDash = this._strokeDash;\n\t\t\t\t\tthis._oldStrokeStyle = this._strokeStyle;\n\t\t\t\t}\n\t\t\t\tinstr.push(this._stroke);\n\t\t\t}\n\n\t\t\tthis._dirty = false;\n\t\t}\n\n\t\tif (commit) {\n\t\t\tactive.length = 0;\n\t\t\tthis._commitIndex = instr.length;\n\t\t}\n\t};\n\n\t/**\n\t * @param {easeljs.Graphics.Fill} fill\n\t * @protected\n\t */\n\t_setFill (fill) {\n\t\tthis._updateInstructions(true);\n\t\tthis.command = this._fill = fill;\n\t\treturn this;\n\t}\n\n\t/**\n\t * @param {easeljs.Graphics.Stroke} stroke\n\t * @protected\n\t */\n\t_setStroke (stroke) {\n\t\tthis._updateInstructions(true);\n\t\tif (this.command = this._stroke = stroke) {\n\t\t\tstroke.ignoreScale = this._strokeIgnoreScale;\n\t\t}\n\t\treturn this;\n\t}\n\n\tstatic get LineTo () { return LineTo; }\n\tstatic get MoveTo () { return MoveTo; }\n\tstatic get ArcTo () { return ArcTo; }\n\tstatic get Arc () { return Arc; }\n\tstatic get QuadraticCurveTo () { return QuadraticCurveTo; }\n\tstatic get BezierCurveTo () { return BezierCurveTo; }\n\tstatic get Rect () { return Rect; }\n\tstatic get ClosePath () { return ClosePath; }\n\tstatic get BeginPath () { return BeginPath; }\n\tstatic get Fill () { return Fill; }\n\tstatic get Stroke () { return Stroke; }\n\tstatic get StrokeStyle () { return StrokeStyle; }\n\tstatic get StrokeDash () { return StrokeDash; }\n\tstatic get RoundRect () { return RoundRect; }\n\tstatic get Circle () { return Circle; }\n\tstatic get Ellipse () { return Ellipse; }\n\tstatic get PolyStar () { return PolyStar; }\n\n}\n\n/**\n * @see {@link easeljs.Graphics#lineTo}\n * @alias easeljs.Graphics.LineTo\n * @param {Number} x\n * @param {Number} y\n */\nclass LineTo {\n\tconstructor (x, y) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.x = x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y = y;\n\t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n\texec (ctx) {\n\t\tctx.lineTo(this.x, this.y);\n\t}\n}\n\n/**\n * @see {@link easeljs.Graphics#moveTo}\n * @alias easeljs.Graphics.MoveTo\n * @param {Number} x\n * @param {Number} y\n */\nclass MoveTo {\n \tconstructor (x, y) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n \t\tthis.x = x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y = y;\n \t}\n\t/**\n\t * @param {CanvasRenderingContext2D} ctx\n\t */\n \texec (ctx) {\n \t\tctx.moveTo(this.x, this.y);\n \t}\n}\n\n\n/**\n * @see {@link easeljs.Graphics#arcTo}\n * @alias easeljs.Graphics.ArcTo\n * @param {Number} x1\n * @param {Number} y1\n * @param {Number} x2\n * @param {Number} y2\n * @param {Number} radius\n */\nclass ArcTo {\n \tconstructor (x1, y1, x2, y2, radius) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.x1 = x1;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y1 = y1;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.x2 = x2;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y2 = y2;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.radius = radius;\n \t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tctx.arcTo(this.x1, this.y1, this.x2, this.y2, this.radius);\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#arc}\n * @alias easeljs.Graphics.Arc\n * @param {Number} x\n * @param {Number} y\n * @param {Number} radius\n * @param {Number} startAngle\n * @param {Number} endAngle\n * @param {Boolean} [anticlockwise=false]\n */\nclass Arc {\n \tconstructor (x, y, radius, startAngle, endAngle, anticlockwise = false) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.x = x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y = y;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.radius = radius;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.startAngle = startAngle;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.endAngle = endAngle;\n\t\t/**\n\t\t * @type {Boolean}\n\t\t */\n\t \tthis.anticlockwise = anticlockwise;\n \t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tctx.arc(this.x, this.y, this.radius, this.startAngle, this.endAngle, this.anticlockwise);\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#quadraticCurveTo}\n * @alias easeljs.Graphics.QuadraticCurveTo\n * @param {Number} cpx\n * @param {Number} cpy\n * @param {Number} x\n * @param {Number} y\n */\nclass QuadraticCurveTo {\n \tconstructor (cpx, cpy, x, y) {\n\t\t/**\n\t\t * @property cpx\n\t\t * @type Number\n\t\t */\n\t \tthis.cpx = cpx;\n\t\t/**\n\t\t * @property cpy\n\t\t * @type Number\n\t\t */\n\t\tthis.cpy = cpy;\n\t\t/**\n\t\t * @property x\n\t\t * @type Number\n\t\t */\n\t \tthis.x = x;\n\t\t/**\n\t\t * @property y\n\t\t * @type Number\n\t\t */\n\t\tthis.y = y;\n \t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tctx.quadraticCurveTo(this.cpx, this.cpy, this.x, this.y);\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#bezierCurveTo}\n * @alias easeljs.Graphics.BezierCurveTo\n * @param {Number} cp1x\n * @param {Number} cp1y\n * @param {Number} cp2x\n * @param {Number} cp2y\n * @param {Number} x\n * @param {Number} y\n */\nclass BezierCurveTo {\n \tconstructor (cp1x, cp1y, cp2x, cp2y, x, y) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.cp1x = cp1x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.cp1y = cp1y;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.cp2x = cp2x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.cp2y = cp2y;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.x = x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y = y;\n \t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tctx.bezierCurveTo(this.cp1x, this.cp1y, this.cp2x, this.cp2y, this.x, this.y);\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#rect}\n * @alias easeljs.Graphics.Rect\n * @param {Number} x\n * @param {Number} y\n * @param {Number} w\n * @param {Number} h\n */\nclass Rect {\n \tconstructor (x, y, w, h) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.x = x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y = y;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.w = w;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.h = h;\n \t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tctx.rect(this.x, this.y, this.w, this.h);\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#closePath}\n * @alias easeljs.Graphics.ClosePath\n */\nclass ClosePath {\n \tconstructor () { }\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tctx.closePath();\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#beginPath}\n * @alias easeljs.Graphics.BeginPath\n */\nclass BeginPath {\n \tconstructor () { }\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tctx.beginPath();\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#beginFill}\n * @alias easeljs.Graphics.Fill\n * @param {Object} style A valid Context2D fillStyle.\n * @param {Matrix2D} matrix\n */\nclass Fill {\n\tconstructor (style, matrix) {\n\t\t/**\n\t\t * A valid Context2D fillStyle.\n\t\t * @type {Object}\n\t\t */\n\t\tthis.style = style;\n\t\t/**\n\t\t * @type {easeljs.Matrix2D}\n\t\t */\n\t\tthis.matrix = matrix;\n\t\t/**\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis.path = false;\n\t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n\texec (ctx) {\n\t\tif (!this.style) { return; }\n\t\tctx.fillStyle = this.style;\n\t\tlet mtx = this.matrix;\n\t\tif (mtx) { ctx.save(); ctx.transform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx, mtx.ty); }\n\t\tctx.fill();\n\t\tif (mtx) { ctx.restore(); }\n\t}\n\t/**\n\t * Creates a linear gradient style and assigns it to {@link easeljs.Graphics.Fill#style}.\n\t * @see {@link easeljs.Graphics#beginLinearGradientFill}\n\t * @param {Array} colors\n\t * @param {Array} ratios\n\t * @param {Number} x0\n\t * @param {Number} y0\n\t * @param {Number} x1\n\t * @param {Number} y1\n\t * @return {easeljs.Graphics.Fill} Returns this Fill object for chaining or assignment.\n\t */\n\tlinearGradient (colors, ratios, x0, y0, x1, y1) {\n\t\tlet o = this.style = Graphics._ctx.createLinearGradient(x0, y0, x1, y1);\n\t\tconst l = colors.length;\n\t\tfor (let i = 0; i < l; i++) { o.addColorStop(ratios[i], colors[i]); }\n\t\to.props = {colors, ratios, x0, y0, x1, y1, type:\"linear\"};\n\t\treturn this;\n\t}\n\t/**\n\t * Creates a linear gradient style and assigns it to {@link easeljs.Graphics.Fill#style}.\n\t * @see {@link easeljs.Graphics#beginRadialGradientFill}\n\t * @param {Array} colors\n\t * @param {Array} ratios\n\t * @param {Number} x0\n\t * @param {Number} y0\n\t * @param {Number} r0\n\t * @param {Number} x1\n\t * @param {Number} y1\n\t * @param {Number} r1\n\t * @return {easeljs.Graphics.Fill} Returns this Fill object for chaining or assignment.\n\t */\n\tradialGradient (colors, ratios, x0, y0, r0, x1, y1, r1) {\n\t\tlet o = this.style = Graphics._ctx.createRadialGradient(x0, y0, r0, x1, y1, r1);\n\t\tconst l = colors.length;\n\t\tfor (let i = 0; i < l; i++) { o.addColorStop(ratios[i], colors[i]); }\n\t\to.props = {colors, ratios, x0, y0, r0, x1, y1, r1, type: \"radial\"};\n\t\treturn this;\n\t}\n\t/**\n\t * Creates a linear gradient style and assigns it to {@link easeljs.Graphics.Fill#style}.\n\t * @see {@link easeljs.Graphics#beginBitmapFill}\n\t * @param {HTMLImageElement | HTMLCanvasElement | HTMLVideoElement} image Must be loaded prior to creating a bitmap fill, or the fill will be empty.\n\t * @param {String} [repetition=\"\"] One of: repeat, repeat-x, repeat-y, or no-repeat.\n\t * @return {easeljs.Graphics.Fill} Returns this Fill object for chaining or assignment.\n\t */\n\tbitmap (image, repetition = \"\") {\n\t\tif (image.naturalWidth || image.getContext || image.readyState >= 2) {\n\t\t\tlet o = this.style = Graphics._ctx.createPattern(image, repetition);\n\t\t\to.props = {image, repetition, type: \"bitmap\"};\n\t\t}\n\t\treturn this;\n\t}\n}\n\n/**\n * @see {@link easeljs.Graphics#beginStroke}\n * @alias easeljs.Graphics.Stroke\n * @extends easeljs.Graphics.Fill\n * @param {Object} style A valid Context2D fillStyle.\n * @param {Boolean} ignoreScale\n */\nclass Stroke extends Fill {\n\tconstructor (style, ignoreScale) {\n\t\tsuper();\n\t\t/**\n\t\t * A valid Context2D strokeStyle.\n\t\t * @type {Object}\n\t\t */\n\t\tthis.style = style;\n\t\t/**\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis.ignoreScale = ignoreScale;\n\t\t/**\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis.path = false;\n\t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @override\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n\texec (ctx) {\n\t\tif (!this.style) { return; }\n\t\tctx.strokeStyle = this.style;\n\t\tif (this.ignoreScale) { ctx.save(); ctx.setTransform(1,0,0,1,0,0); }\n\t\tctx.stroke();\n\t\tif (this.ignoreScale) { ctx.restore(); }\n\t}\n}\n\n/**\n * @see {@link easeljs.Graphics#setStrokeStyle}\n * @alias easeljs.Graphics.StrokeStyle\n * @param {Number} [width=1]\n * @param {String} [caps=butt]\n * @param {String} [joints=miter]\n * @param {Number} [miterLimit=10]\n * @param {Boolean} [ignoreScale=false]\n */\nclass StrokeStyle {\n\tconstructor (width=1, caps=\"butt\", joints=\"miter\", miterLimit=10, ignoreScale=false) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.width = width;\n\t\t/**\n\t\t * One of: butt, round, square\n\t\t * @type {String}\n\t\t */\n\t\tthis.caps = caps;\n\t\t/**\n\t\t * One of: round, bevel, miter\n\t\t * @type {String}\n\t\t */\n\t\tthis.joints = joints;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.miterLimit = miterLimit;\n\t\t/**\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis.ignoreScale = ignoreScale;\n\t\t/**\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis.path = false;\n\t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n\texec (ctx) {\n\t\tctx.lineWidth = this.width;\n\t\tctx.lineCap = (isNaN(this.caps) ? this.caps : Graphics._STROKE_CAPS_MAP[this.caps]);\n\t\tctx.lineJoin = (isNaN(this.joints) ? this.joints : Graphics._STROKE_JOINTS_MAP[this.joints]);\n\t\tctx.miterLimit = this.miterLimit;\n\t\tctx.ignoreScale = this.ignoreScale;\n\t}\n}\n\n/**\n * @see {@link easeljs.Graphics#setStrokeDash}\n * @alias easeljs.Graphics.StrokeDash\n * @param {Array} [segments=[]]\n * @param {Number} [offset=0]\n */\nclass StrokeDash {\n \tconstructor (segments=[], offset=0) {\n\t\t/**\n\t\t * @type {Array}\n\t\t */\n\t \tthis.segments = segments;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.offset = offset;\n \t}\n\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tif (ctx.setLineDash) { // feature detection.\n\t \t\tctx.setLineDash(this.segments);\n\t \t\tctx.lineDashOffset = this.offset;\n\t \t}\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#drawRoundRectComplex}\n * @alias easeljs.Graphics.RoundRect\n * @param {Number} x\n * @param {Number} y\n * @param {Number} w\n * @param {Number} h\n * @param {Number} radiusTL\n * @param {Number} radiusTR\n * @param {Number} radiusBR\n * @param {Number} radiusBL\n */\nclass RoundRect {\n \tconstructor (x, y, w, h, radiusTL, radiusTR, radiusBR, radiusBL) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.x = x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y = y;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.w = w;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.h = h;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.radiusTL = radiusTL;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.radiusTR = radiusTR;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.radiusBR = radiusBR;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.radiusBL = radiusBL;\n \t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tlet max = (this.w max) { rTL = max; }\n\t \tif (rTR < 0) { rTR *= (mTR=-1); }\n\t \tif (rTR > max) { rTR = max; }\n\t \tif (rBR < 0) { rBR *= (mBR=-1); }\n\t \tif (rBR > max) { rBR = max; }\n\t \tif (rBL < 0) { rBL *= (mBL=-1); }\n\t \tif (rBL > max) { rBL = max; }\n\n\t \tctx.moveTo(x+w-rTR, y);\n\t \tctx.arcTo(x+w+rTR*mTR, y-rTR*mTR, x+w, y+rTR, rTR);\n\t \tctx.lineTo(x+w, y+h-rBR);\n\t \tctx.arcTo(x+w+rBR*mBR, y+h+rBR*mBR, x+w-rBR, y+h, rBR);\n\t \tctx.lineTo(x+rBL, y+h);\n\t \tctx.arcTo(x-rBL*mBL, y+h+rBL*mBL, x, y+h-rBL, rBL);\n\t \tctx.lineTo(x, y+rTL);\n\t \tctx.arcTo(x-rTL*mTL, y-rTL*mTL, x+rTL, y, rTL);\n\t \tctx.closePath();\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#drawCircle}\n * @alias easeljs.Graphics.Circle\n * @param {Number} x\n * @param {Number} y\n * @param {Number} radius\n */\nclass Circle {\n \tconstructor (x, y, radius) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.x = x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y = y;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.radius = radius;\n \t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tctx.arc(this.x, this.y, this.radius, 0, Math.PI*2);\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#drawEllipse}\n * @alias easeljs.Graphics.Ellipse\n * @param {Number} x\n * @param {Number} y\n * @param {Number} w\n * @param {Number} h\n */\nclass Ellipse {\n \tconstructor (x, y, w, h) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.x = x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y = y;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.w = w;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.h = h;\n \t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tlet x = this.x, y = this.y;\n\t \tlet w = this.w, h = this.h;\n\n\t \tlet k = 0.5522848;\n\t \tlet ox = (w / 2) * k;\n\t \tlet oy = (h / 2) * k;\n\t \tlet xe = x + w;\n\t \tlet ye = y + h;\n\t \tlet xm = x + w / 2;\n\t \tlet ym = y + h / 2;\n\n\t \tctx.moveTo(x, ym);\n\t \tctx.bezierCurveTo(x, ym-oy, xm-ox, y, xm, y);\n\t \tctx.bezierCurveTo(xm+ox, y, xe, ym-oy, xe, ym);\n\t \tctx.bezierCurveTo(xe, ym+oy, xm+ox, ye, xm, ye);\n\t \tctx.bezierCurveTo(xm-ox, ye, x, ym+oy, x, ym);\n \t}\n}\n\n/**\n * @see {@link easeljs.Graphics#drawPolyStar}\n * @alias easeljs.Graphics.PolyStar\n * @param {Number} x\n * @param {Number} y\n * @param {Number} radius\n * @param {Number} sides\n * @param {Number} [pointSize=0]\n * @param {Number} [angle=0]\n */\nclass PolyStar {\n \tconstructor (x, y, radius, sides, pointSize=0, angle=0) {\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.x = x;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t\tthis.y = y;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.radius = radius;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.sides = sides;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.pointSize = pointSize;\n\t\t/**\n\t\t * @type {Number}\n\t\t */\n\t \tthis.angle = angle;\n \t}\n\t/**\n\t * Execute the Graphics command in the provided Canvas context.\n\t * @param {CanvasRenderingContext2D} ctx The canvas rendering context\n\t */\n \texec (ctx) {\n \t\tlet x = this.x, y = this.y;\n\t \tlet radius = this.radius;\n\t \tlet angle = this.angle/180*Math.PI;\n\t \tlet sides = this.sides;\n\t \tlet ps = 1-this.pointSize;\n\t \tlet a = Math.PI/sides;\n\n\t \tctx.moveTo(x+Math.cos(angle)*radius, y+Math.sin(angle)*radius);\n\t \tfor (let i = 0; i < sides; i++) {\n\t \t\tangle += a;\n\t \t\tif (ps != 1) {\n\t \t\t\tctx.lineTo(x+Math.cos(angle)*radius*ps, y+Math.sin(angle)*radius*ps);\n\t \t\t}\n\t \t\tangle += a;\n\t \t\tctx.lineTo(x+Math.cos(angle)*radius, y+Math.sin(angle)*radius);\n\t \t}\n\t \tctx.closePath();\n \t}\n}\n\n/**\n * A reusable instance of {@link easeljs.Graphics.BeginPath} to avoid unnecessary instantiation.\n * @static\n * @readonly\n * @type {easeljs.Graphics.BeginPath}\n */\nGraphics.beginCmd = new BeginPath();\n/**\n * Map of Base64 characters to values. Used by {@link easeljs.Graphics#decodePath}.\n * @static\n * @readonly\n * @protected\n * @type {Object}\n */\nGraphics._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};\n/**\n * Maps numeric values for the caps parameter of {@link easeljs.Graphics#setStrokeStyle} to\n * corresponding string values. This is primarily for use with the tiny API. \n * The mappings are as follows:\n *
\n *
0 to \"butt\"
\n *
1 to \"round\"
\n *
2 to \"square\".
\n *
\n *\n * @example
Set line caps to \"square\"
\n * graphics.ss(16, 2);\n *\n * @static\n * @readonly\n * @protected\n * @type {Array}\n */\nGraphics._STROKE_CAPS_MAP = [\"butt\",\"round\",\"square\"];\n/**\n * Maps numeric values for the joints parameter of {@link easeljs.Graphics#setStrokeStyle} to\n * corresponding string values. This is primarily for use with the tiny API. \n * The mappings are as follows:\n *
\n *
0 to \"miter\"
\n *
1 to \"round\"
\n *
2 to \"bevel\".
\n *
\n *\n * @example
Set the line joints to \"bevel\"
\n * graphics.ss(16, 0, 2);\n *\n * @static\n * @readonly\n * @protected\n * @type {Array}\n */\nGraphics._STROKE_JOINTS_MAP = [\"miter\", \"round\", \"bevel\"];\n/**\n * @static\n * @readonly\n * @protected\n * @type {CanvasRenderingContext2D}\n */\nGraphics._ctx = createCanvas().getContext(\"2d\");\n","/**\n * @license MovieClip\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Container from \"./Container\";\nimport DisplayObject from \"./DisplayObject\";\nimport { Tween, Timeline } from \"@createjs/tweenjs\";\n\n/**\n * The MovieClip class associates a TweenJS Timeline with an EaselJS {@link easeljs.Container}. It allows\n * you to create objects which encapsulate timeline animations, state changes, and synched actions. Due to the\n * complexities inherent in correctly setting up a MovieClip, it is largely intended for tool output and is not included\n * in the main EaselJS library.\n *\n * Currently MovieClip only works properly if it is tick based (as opposed to time based) though some concessions have\n * been made to support time-based timelines in the future.\n *\n * It is recommended to use `tween.to()` to animate and set properties (use no duration to have it set\n * immediately), and the `tween.wait()` method to create delays between animations. Note that using the\n * `tween.set()` method to affect properties will likely not provide the desired result.\n *\n * @memberof easeljs\n * @example
Animate two shapes back and forth
\n * let stage = new Stage(\"canvas\");\n * Ticker.addEventListener(\"tick\", stage);\n *\n * let mc = new MovieClip(null, 0, true, {start:20});\n * stage.addChild(mc);\n *\n * let child1 = new Shape(\n * new Graphics().beginFill(\"#999999\").drawCircle(30,30,30)\n * );\n * let child2 = new Shape(\n * new Graphics().beginFill(\"#5a9cfb\").drawCircle(30,30,30)\n * );\n *\n * mc.timeline.addTween(\n * Tween.get(child1).to({x:0}).to({x:60}, 50).to({x:0}, 50)\n * );\n * mc.timeline.addTween(\n * Tween.get(child2).to({x:60}).to({x:0}, 50).to({x:60}, 50)\n * );\n *\n * mc.gotoAndPlay(\"start\");\n *\n * @extends easeljs.Container\n * @param {Object} [props] The configuration properties to apply to this instances.\n * This object will also be passed into the Timeline instance associated with this MovieClip.\n * See the documentation for Timeline for a list of supported props.\n */\nexport default class MovieClip extends Container {\n\n\tconstructor (props) {\n\t\tsuper();\n\t\t!MovieClip.inited && MovieClip.init();\n\n\t\t/**\n\t\t * Controls how this MovieClip advances its time. Must be one of 0 (INDEPENDENT), 1 (SINGLE_FRAME), or 2 (SYNCHED).\n\t\t * See each constant for a description of the behaviour.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.mode = props.mode != null ? props.mode : MovieClip.INDEPENDENT;\n\n\t\t/**\n\t\t * Specifies what the first frame to play in this movieclip, or the only frame to display if mode is SINGLE_FRAME.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.startPosition = props.startPosition != null ? props.startPosition : 0;\n\n\t\t/**\n * Specifies how many times this MovieClip should loop. A value of -1 indicates it should loop indefinitely. A value of\n * 1 would cause it to loop once (ie. play a total of twice).\n * @property loop\n\t\t * @type {Number}\n\t\t * @default -1\n\t\t */\n\t\tif (typeof props.loop === \"number\") {\n\t\t\tthis.loop = props.loop;\n\t\t} else if (props.loop === false) {\n\t\t\tthis.loop = 0;\n\t\t} else {\n\t\t\tthis.loop = -1;\n\t\t}\n\n\t\t/**\n\t\t * The current frame of the movieclip.\n\t\t * @type Number\n\t\t * @default 0\n\t\t * @readonly\n\t\t */\n\t\tthis.currentFrame = 0;\n\n\t\t/**\n * The TweenJS Timeline that is associated with this MovieClip. This is created automatically when the MovieClip\n * instance is initialized. Animations are created by adding TweenJS Tween\n * instances to the timeline.\n *\n * Elements can be added and removed from the timeline by toggling an \"_off\" property\n * using the `tweenInstance.to()` method. Note that using `Tween.set` is not recommended to\n * create MovieClip animations. The following example will toggle the target off on frame 0, and then back on for\n * frame 1. You can use the \"visible\" property to achieve the same effect.\n *\n * @example\n * let tween = Tween.get(target).to({x:0}).to({x:100}, 30);\n * let mc = new MovieClip();\n * mc.timeline.addTween(tween);\n *\n * @example\n * Tween.get(target).to({_off:false})\n * .wait(1).to({_off:true})\n * .wait(1).to({_off:false});\n *\n * @type {easeljs.Timeline}\n\t\t */\n\t\tthis.timeline = new Timeline(Object.assign({ useTicks: true, paused: true }, props));\n\n\t\t/**\n\t\t * If true, the MovieClip's position will not advance when ticked.\n\t\t * @type {Boolean}\n\t\t * @default false\n\t\t */\n\t\tthis.paused = props.paused != null ? props.paused : false;\n\n\t\t/**\n\t\t * If true, actions in this MovieClip's tweens will be run when the playhead advances.\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.actionsEnabled = true;\n\n\t\t/**\n\t\t * If true, the MovieClip will automatically be reset to its first frame whenever the timeline adds\n\t\t * it back onto the display list. This only applies to MovieClip instances with mode=INDEPENDENT.\n\t\t *
\n\t\t * For example, if you had a character animation with a \"body\" child MovieClip instance\n\t\t * with different costumes on each frame, you could set `body.autoReset = false`, so that\n\t\t * you can manually change the frame it is on, without worrying that it will be reset\n\t\t * automatically.\n\t\t * @type {Boolean}\n\t\t * @default true\n\t\t */\n\t\tthis.autoReset = true;\n\n\t\t/**\n\t\t * An array of bounds for each frame in the MovieClip. This is mainly intended for tool output.\n\t\t * @type {Array}\n\t\t */\n\t\tthis.frameBounds = this.frameBounds || props.frameBounds; // frameBounds are set on the prototype in Animate.\n\n\t\t/**\n\t\t * By default MovieClip instances advance one frame per tick. Specifying a framerate for the MovieClip\n\t\t * will cause it to advance based on elapsed time between ticks as appropriate to maintain the target\n\t\t * framerate.\n\t\t *\n\t\t * For example, if a MovieClip with a framerate of 10 is placed on a Stage being updated at 40fps, then the MovieClip will\n\t\t * advance roughly one frame every 4 ticks. This will not be exact, because the time between each tick will\n\t\t * vary slightly between frames.\n\t\t *\n\t\t * This feature is dependent on the tick event object (or an object with an appropriate \"delta\" property) being\n\t\t * passed into {@link easeljs.Stage#update}.\n\t\t * @type {Number}\n\t\t * @default null\n\t\t */\n\t\tthis.framerate = null;\n\n\t\t/**\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t * @private\n\t\t */\n\t\tthis._synchOffset = 0;\n\n\t\t/**\n\t\t * @type {Number}\n\t\t * @default -1\n\t\t * @private\n\t\t */\n\t\tthis._rawPosition = -1; // TODO: evaluate using a ._reset Boolean prop instead of -1.\n\n\t\t/**\n\t\t * The time remaining from the previous tick, only applicable when .framerate is set.\n\t\t * @type {Number}\n\t\t * @private\n\t\t */\n\t\tthis._t = 0;\n\n\t\t/**\n\t\t * List of display objects that are actively being managed by the MovieClip.\n\t\t * @type {Object}\n\t\t * @private\n\t\t */\n\t\tthis._managed = {};\n\n\t\t/**\n\t\t * @type {Function}\n\t\t * @private\n\t\t */\n\t\tthis._bound_resolveState = this._resolveState.bind(this);\n\t}\n\n\tstatic init () {\n\t\tif (MovieClip.inited) { return; }\n\t\t// plugins introduce some overhead to Tween, so we only install this if an MC is instantiated.\n\t\tMovieClipPlugin.install();\n\t\tMovieClip.inited = true;\n\t}\n\n\t// TODO: can we just proxy `get currentFrame` to timeline.position as well? Ditto for `get loop` (or just remove entirely).\n\t//\n\t/**\n\t * Returns an array of objects with label and position (aka frame) properties, sorted by position.\n\t * @see {@link tweenjs.Timeline#labels}\n\t * @type {Array}\n\t * @readonly\n\t */\n\tget labels () {\n\t\treturn this.timeline.labels;\n\t}\n\n\t/**\n\t * Returns the name of the label on or immediately before the current frame.\n\t * @see {@link tweenjs.Timeline#currentLabel}\n\t * for more information.\n\t * @type {String}\n\t * @readonly\n\t */\n\tget currentLabel () {\n\t\treturn this.timeline.currentLabel;\n\t}\n\n\t /**\n \t * Returns the duration of this MovieClip in seconds or ticks.\n \t * @see {@link tweenjs.Timeline#duration}\n \t * @type {Number}\n \t * @readonly\n \t */\n \tget duration () {\n\t\treturn this.timeline.duration;\n\t}\n\n\t/**\n\t * Returns the duration of this MovieClip in seconds or ticks. Identical to {@link easeljs.MovieClip#duration}\n\t * and provided for Adobe Flash/Animate API compatibility.\n\t * @see {@link tweenjs.Timeline#duration}\n\t * @type {Number}\n\t * @readonly\n\t */\n\tget totalFrames () {\n\t\treturn this.duration;\n\t}\n\n\tisVisible () {\n\t\t// children are placed in draw, so we can't determine if we have content.\n\t\treturn !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0);\n\t}\n\n\tdraw (ctx, ignoreCache) {\n\t\t// draw to cache first:\n\t\tif (this.drawCache(ctx, ignoreCache)) { return true; }\n this._updateState();\n\t\tsuper.draw(ctx, ignoreCache);\n\t\treturn true;\n\t}\n\n\t/**\n\t * Sets paused to false.\n\t */\n\tplay () {\n\t\tthis.paused = false;\n\t}\n\n\t/**\n\t * Sets paused to true.\n\t */\n\tstop () {\n\t\tthis.paused = true;\n\t}\n\n\t/**\n\t * Advances this movie clip to the specified position or label and plays the timeline.\n\t * @param {String | Number} positionOrLabel The animation name or frame number to go to.\n\t */\n\tgotoAndPlay (positionOrLabel) {\n\t\tthis.play();\n\t\tthis._goto(positionOrLabel);\n\t}\n\n\t/**\n\t * Advances this movie clip to the specified position or label and stops the timeline.\n\t * @param {String | Number} positionOrLabel The animation or frame name to go to.\n\t */\n\tgotoAndStop (positionOrLabel) {\n\t\tthis.stop();\n\t\tthis._goto(positionOrLabel);\n\t}\n\n\t/**\n\t * Advances the playhead. This occurs automatically each tick by default.\n\t * @param {Number} [time] The amount of time in ms to advance by. Only applicable if framerate is set.\n\t*/\n\tadvance (time) {\n\t\tif (this.mode !== MovieClip.INDEPENDENT) { return; } // update happens in draw for synched clips\n\t\t// if this MC doesn't have a framerate, hunt ancestors for one:\n\t\tlet o = this, fps = o.framerate;\n\t\twhile ((o = o.parent) && fps === null) {\n\t\t\tif (o.mode === MovieClip.INDEPENDENT) { fps = o._framerate; }\n\t\t}\n\t\tthis._framerate = fps;\n\n\t\tif (this.paused) { return; }\n\t\t// calculate how many frames to advance:\n\t\tlet t = (fps !== null && fps !== -1 && time !== null) ? time / (1000 / fps) + this._t : 1;\n\t\tlet frames = t | 0;\n\t\tthis._t = t - frames; // leftover time, save to add to next advance.\n\n\t\twhile (frames--) {\n\t\t\tthis._updateTimeline(this._rawPosition + 1, false);\n\t\t}\n\t}\n\n\t/**\n\t * MovieClip instances cannot be cloned.\n\t * @throws MovieClip cannot be cloned.\n\t */\n\tclone () {\n\t\t// TODO: add support for this? Need to clone the Timeline & retarget tweens - pretty complex.\n\t\tthrow \"MovieClip cannot be cloned.\";\n\t}\n\n\t_updateState () {\n\t\tif (this._rawPosition === -1 || this.mode !== MovieClip.INDEPENDENT) { this._updateTimeline(-1); }\n\t}\n\n\t_tick (evtObj) {\n\t\tthis.advance(evtObj && evtObj.delta);\n\t\tsuper._tick(evtObj);\n\t}\n\n\t/**\n\t * @param {String | Number} positionOrLabel The animation name or frame number to go to.\n\t * @protected\n\t */\n\t_goto (positionOrLabel) {\n\t\tlet pos = this.timeline.resolve(positionOrLabel);\n\t\tif (pos == null) { return; }\n\t\tthis._t = 0;\n\t\tthis._updateTimeline(pos, true);\n\t}\n\n\t/**\n\t * @private\n\t */\n\t_reset () {\n\t\tthis._rawPosition = -1;\n\t\tthis._t = this.currentFrame = 0;\n\t\tthis.paused = false;\n\t}\n\n\t/**\n\t * @param {Number} rawPosition\n\t * @param {Boolean} jump Indicates whether this update is due to jumping (via gotoAndXX) to a new position.\n\t * @protected\n\t */\n\t_updateTimeline (rawPosition, jump) {\n\t\tlet synced = this.mode !== MovieClip.INDEPENDENT, tl = this.timeline;\n\t\tif (synced) { rawPosition = this.startPosition + (this.mode === MovieClip.SINGLE_FRAME ? 0 : this._synchOffset); }\n\t\tif (rawPosition < 1) { rawPosition = 0; }\n\t\tif (this._rawPosition === rawPosition && !synced) { return; }\n\t\tthis._rawPosition = rawPosition;\n\n\t\t// update timeline position, ignoring actions if this is a graphic.\n\t\ttl.loop = this.loop; // TODO: should we maintain this on MovieClip, or just have it on timeline?\n\t\ttl.setPosition(rawPosition, synced || !this.actionsEnabled, jump, this._bound_resolveState);\n\t}\n\n\t/**\n\t * Renders position 0 without running actions or updating _rawPosition.\n\t * Primarily used by Animate CC to build out the first frame in the constructor of MC symbols.\n\t * NOTE: not tested when run after the MC advances past the first frame.\n\t * @protected\n\t */\n\t_renderFirstFrame () {\n\t\tconst tl = this.timeline, pos = tl.rawPosition;\n\t\ttl.setPosition(0, true, true, this._bound_resolveState);\n\t\ttl.rawPosition = pos;\n\t}\n\n\t/**\n\t * Runs via a callback after timeline property updates and before actions.\n\t * @protected\n\t */\n\t_resolveState () {\n\t\tlet tl = this.timeline;\n\t\tthis.currentFrame = tl.position;\n\n\t\tfor (let n in this._managed) { this._managed[n] = 1; }\n\n\t\tlet tweens = tl.tweens;\n\t\tfor (let tween of tweens) {\n\t\t\tlet target = tween.target;\n\t\t\tif (target === this || tween.passive) { continue; } // TODO: this assumes the actions tween from Animate has `this` as the target. Likely a better approach.\n\t\t\tlet offset = tween._stepPosition;\n\n\t\t\tif (target instanceof DisplayObject) {\n\t\t\t\t// motion tween.\n\t\t\t\tthis._addManagedChild(target, offset);\n\t\t\t} else {\n\t\t\t\t// state tween.\n\t\t\t\tthis._setState(target.state, offset);\n\t\t\t}\n\t\t}\n\n\t\tlet kids = this.children;\n\t\tfor (let i=kids.length-1; i>=0; i--) {\n\t\t\tlet id = kids[i].id;\n\t\t\tif (this._managed[id] === 1) {\n\t\t\t\tthis.removeChildAt(i);\n\t\t\t\tdelete(this._managed[id]);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @param {Array} state\n\t * @param {Number} offset\n\t * @protected\n\t */\n\t_setState (state, offset) {\n\t\tif (!state) { return; }\n\t\tfor (let i = state.length - 1; i >= 0; i--) {\n\t\t\tlet o = state[i];\n\t\t\tlet target = o.t;\n\t\t\tlet props = o.p;\n\t\t\tfor (let n in props) { target[n] = props[n]; }\n\t\t\tthis._addManagedChild(target, offset);\n\t\t}\n\t}\n\n\t/**\n\t * Adds a child to the timeline, and sets it up as a managed child.\n\t * @param {easeljs.MovieClip} child The child MovieClip to manage\n\t * @param {Number} offset\n\t * @private\n\t */\n\t_addManagedChild (child, offset) {\n\t\tif (child._off) { return; }\n\t\tthis.addChildAt(child, 0);\n\n\t\tif (child instanceof MovieClip) {\n\t\t\tchild._synchOffset = offset;\n\t\t\t// TODO: this does not precisely match Adobe Flash/Animate, which loses track of the clip if it is renamed or removed from the timeline, which causes it to reset.\n // TODO: should also reset when MovieClip loops, though that will be a bit tricky to detect.\n\t\t\tif (child.mode === MovieClip.INDEPENDENT && child.autoReset && !this._managed[child.id]) { child._reset(); }\n\t\t}\n\t\tthis._managed[child.id] = 2;\n\t}\n\n\t/**\n\t * @param {easeljs.Matrix2D} matrix\n\t * @param {Boolean} ignoreTransform\n\t * @return {easeljs.Rectangle}\n\t * @protected\n\t */\n\t_getBounds (matrix, ignoreTransform) {\n\t\tlet bounds = this.getBounds();\n\t\tif (!bounds && this.frameBounds) { bounds = this._rectangle.copy(this.frameBounds[this.currentFrame]); }\n\t\tif (bounds) { return this._transformBounds(bounds, matrix, ignoreTransform); }\n\t\treturn super._getBounds(matrix, ignoreTransform);\n\t}\n\n}\n\n/**\n * The MovieClip will advance independently of its parent, even if its parent is paused.\n * This is the default mode.\n * @static\n * @type {String}\n * @default independent\n * @readonly\n */\nMovieClip.INDEPENDENT = \"independent\";\n/**\n * The MovieClip will only display a single frame (as determined by the startPosition property).\n * @static\n * @type {String}\n * @default single\n * @readonly\n */\nMovieClip.SINGLE_FRAME = \"single\";\n/**\n * The MovieClip will be advanced only when its parent advances and will be synched to the position of\n * the parent MovieClip.\n * @static\n * @type {String}\n * @default synched\n * @readonly\n */\nMovieClip.SYNCHED = \"synched\";\n/**\n * Has the MovieClipPlugin been installed to TweenJS yet?\n * @static\n * @type {Boolean}\n * @default false\n * @readonly\n */\nMovieClip.inited = false;\n\n/**\n * This plugin works with TweenJS to prevent the startPosition property from tweening.\n * @todo update to new plugin model\n * @static\n * @inner\n */\nclass MovieClipPlugin {\n\n\tconstructor () {\n\t\tthrow \"MovieClipPlugin cannot be instantiated.\";\n\t}\n\n\t/**\n\t * @private\n\t */\n\tstatic install () {\n\t\tTween.installPlugin(MovieClipPlugin);\n\t}\n\n\t/**\n\t * @param {tweenjs.Tween} tween\n\t * @param {String} prop\n\t * @param {String|Number|Boolean} value\n\t * @private\n\t */\n\tstatic init (tween, prop, value) {\n\t\treturn value;\n\t}\n\n\t/**\n\t * @param {tweenjs.Tween} tween\n\t * @param {String} prop\n\t * @param {String | Number | Boolean} value\n\t * @param {Array} startValues\n\t * @param {Array} endValues\n\t * @param {Number} ratio\n\t * @param {Object} wait\n\t * @param {Object} end\n\t * @return {*}\n\t */\n\tstatic tween (tween, prop, value, startValues, endValues, ratio, wait, end) {\n\t\tif (!(tween.target instanceof MovieClip)) { return value; }\n\t\treturn (ratio === 1 ? endValues[prop] : startValues[prop]);\n\t}\n\n}\n\n/**\n * @static\n * @type {Number}\n * @default 100\n * @readonly\n */\nMovieClipPlugin.priority = 100;\n","/**\n * @license Shape\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport DisplayObject from \"./DisplayObject\";\nimport Graphics from \"./Graphics\";\n\n/**\n * A Shape allows you to display vector art in the display list. It composites a {@link easeljs.Graphics}\n * instance which exposes all of the vector drawing methods. The Graphics instance can be shared between multiple Shape\n * instances to display the same vector graphics with different positions or transforms.\n *\n * If the vector art will not change between draws, you may want to use the {@link easeljs.DisplayObject#cache}\n * method to reduce the rendering cost.\n *\n * @memberof easeljs\n * @example\n * var graphics = new Graphics().beginFill(\"#ff0000\").drawRect(0, 0, 100, 100);\n * var shape = new Shape(graphics);\n * // Alternatively use can also use the graphics property of the Shape class to renderer the same as above.\n * var shape = new Shape();\n * shape.graphics.beginFill(\"#ff0000\").drawRect(0, 0, 100, 100);\n *\n * @extends easeljs.DisplayObject\n * @param {easeljs.Graphics} [graphics] The graphics instance to display. If null, a new Graphics instance will be created.\n */\nexport default class Shape extends DisplayObject {\n\n\tconstructor (graphics = new Graphics()) {\n\t\tsuper();\n\n\t\t/**\n\t\t * The graphics instance to display.\n\t\t * @type {easeljs.Graphics}\n\t\t */\n\t\tthis.graphics = graphics;\n\t}\n\n\tisVisible () {\n\t\tlet hasContent = this.cacheCanvas || (this.graphics && !this.graphics.isEmpty());\n\t\treturn !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && hasContent);\n\t}\n\n\tdraw (ctx, ignoreCache = false) {\n\t\tif (super.draw(ctx, ignoreCache)) { return true; }\n\t\tthis.graphics.draw(ctx, this);\n\t\treturn true;\n\t}\n\n\t/**\n\t * Returns a clone of this Shape. Some properties that are specific to this instance's current context are reverted to\n\t * their defaults (for example .parent).\n\t * @override\n\t * @param {Boolean} [recursive=false] If true, this Shape's {@link easeljs.Graphics} instance will also be\n\t * cloned. If false, the Graphics instance will be shared with the new Shape.\n\t */\n\tclone (recursive = false) {\n\t\tlet g = (recursive && this.graphics) ? this.graphics.clone() : this.graphics;\n\t\treturn this._cloneProps(new Shape(g));\n\t}\n\n}\n","/**\n * @license SpriteSheet\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPliED, INCLUDING BUT NOT liMITED TO THE WARRANTIES\n * OF MERCHANTABIliTY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HolDERS BE liABLE FOR ANY CLAIM, DAMAGES OR OTHER liABIliTY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEAliNGS IN THE SOFTWARE.\n */\n\nimport { EventDispatcher, Event } from \"@createjs/core\";\nimport Rectangle from \"../geom/Rectangle\";\n\n/**\n * Encapsulates the properties and methods associated with a sprite sheet. A sprite sheet is a series of images (usually\n * animation frames) combined into a larger image (or images). For example, an animation consisting of eight 100x100\n * images could be combined into a single 400x200 sprite sheet (4 frames across by 2 high).\n * \n * The data passed to the SpriteSheet constructor defines:\n * \n * \t
The source image or images to use.
\n * \t
The positions of individual image frames.
\n * \t
Sequences of frames that form named animations. Optional.
\n * \t
The target playback framerate. Optional.
\n * \n *\n *
SpriteSheet Format
\n * SpriteSheets are an object with two required properties (`images` and `frames`), and two optional properties\n * (`framerate` and `animations`). This makes them easy to define in javascript code, or in JSON.\n *\n *
images
\n * An array of source images. Images can be either an HTMlimage\n * instance, or a uri to an image. The former is recommended to control preloading.\n *\n * \timages: [image1, \"path/to/image2.png\"],\n *\n *
frames
\n * Defines the individual frames. There are two supported formats for frame data:\n * When all of the frames are the same size (in a grid), use an object with `width`, `height`, `regX`, `regY`,\n * and `count` properties.\n *\n *
\n *
`width` & `height` are required and specify the dimensions of the frames
\n *
`regX` & `regY` indicate the registration point or \"origin\" of the frames
\n *
`spacing` indicate the spacing between frames
\n *
`margin` specify the margin around the image(s)
\n *
`count` allows you to specify the total number of frames in the spritesheet; if omitted, this will\n * be calculated based on the dimensions of the source images and the frames. Frames will be assigned\n * indexes based on their position in the source images (left to right, top to bottom).
\n *
\n *\n * \tframes: {width:64, height:64, count:20, regX: 32, regY:64, spacing:0, margin:0}\n *\n * If the frames are of different sizes, use an array of frame definitions. Each definition is itself an array\n * with 4 required and 3 optional entries, in the order:\n *\n *
\n *
The first four, `x`, `y`, `width`, and `height` are required and define the frame rectangle.
\n *
The fifth, `imageIndex`, specifies the index of the source image (defaults to 0)
\n *
The last two, `regX` and `regY` specify the registration point of the frame
\n * Optional. An object defining sequences of frames to play as named animations. Each property corresponds to an\n * animation of the same name. Each animation must specify the frames to play, and may\n * also include a relative playback `speed` (ex. 2 would playback at double speed, 0.5 at half), and\n * the name of the `next` animation to sequence to after it completes.\n *\n * There are three formats supported for defining the frames in an animation, which can be mixed and matched as appropriate:\n * \n * \t
for a single frame animation, you can simply specify the frame index\n *\n * \t\tanimations: {\n * \t\t\tsit: 7\n * \t\t}\n *\n *
\n *
\n * for an animation of consecutive frames, you can use an array with two required, and two optional entries\n * \t\tin the order: `start`, `end`, `next`, and `speed`. This will play the frames from start to end inclusive.\n *\n * \t\tanimations: {\n * \t\t\t// start, end, next*, speed*\n * \t\t\trun: [0, 8],\n * \t\t\tjump: [9, 12, \"run\", 2]\n * \t\t}\n *\n *
\n *
\n * for non-consecutive frames, you can use an object with a `frames` property defining an array of frame\n * indexes to play in order. The object can also specify `next` and `speed` properties.\n *\n * \t\tanimations: {\n * \t\t\twalk: {\n * \t\t\t\tframes: [1,2,3,3,2,1]\n * \t\t\t},\n * \t\t\tshoot: {\n * \t\t\t\tframes: [1,4,5,6],\n * \t\t\t\tnext: \"walk\",\n * \t\t\t\tspeed: 0.5\n * \t\t\t}\n * \t\t}\n *\n *
\n * \n * Note: the `speed` property was added in EaselJS 0.7.0. Earlier versions had a `frequency`\n * property instead, which was the inverse of `speed`. For example, a value of \"4\" would be 1/4 normal speed in\n * earlier versions, but is 4x normal speed in EaselJS 0.7.0+.\n *\n *
framerate
\n * Optional. Indicates the default framerate to play this spritesheet at in frames per second. See\n * {{#crossLink \"SpriteSheet/framerate:property\"}}{{/crossLink}} for more information.\n *\n * \t\tframerate: 20\n *\n * Note that the Sprite framerate will only work if the stage update method is provided with the {{#crossLink \"Ticker/tick:event\"}}{{/crossLink}}\n * event generated by the {{#crossLink \"Ticker\"}}{{/crossLink}}.\n *\n * \t\tcreatejs.Ticker.on(\"tick\", handleTick);\n * \t\tfunction handleTick(event) {\n *\t\t\tstage.update(event);\n *\t\t}\n *\n *
Example
\n * To define a simple sprite sheet, with a single image \"sprites.jpg\" arranged in a regular 50x50 grid with three\n * animations: \"stand\" showing the first frame, \"run\" looping frame 1-5 inclusive, and \"jump\" playing frame 6-8 and\n * sequencing back to run.\n *\n * \t\tvar data = {\n * \t\t\timages: [\"sprites.jpg\"],\n * \t\t\tframes: {width:50, height:50},\n * \t\t\tanimations: {\n * \t\t\t\tstand:0,\n * \t\t\t\trun:[1,5],\n * \t\t\t\tjump:[6,8,\"run\"]\n * \t\t\t}\n * \t\t};\n * \t\tvar spriteSheet = new createjs.SpriteSheet(data);\n * \t\tvar animation = new createjs.Sprite(spriteSheet, \"run\");\n *\n *
Generating SpriteSheet Images
\n * Spritesheets can be created manually by combining images in PhotoShop, and specifying the frame size or\n * coordinates manually, however there are a number of tools that facilitate this.\n *
\n *
Exporting SpriteSheets or HTML5 content from Adobe Flash/Animate supports the EaselJS SpriteSheet format.
SWF animations in Adobe Flash/Animate can be exported to SpriteSheets using
\n *
\n *\n *
Cross Origin Issues
\n * Warning: Images loaded cross-origin will throw cross-origin security errors when interacted with\n * using:\n *
\n *
a mouse
\n *
methods such as {{#crossLink \"Container/getObjectUnderPoint\"}}{{/crossLink}}
\n *
Filters (see {{#crossLink \"Filter\"}}{{/crossLink}})
\n *
caching (see {{#crossLink \"DisplayObject/cache\"}}{{/crossLink}})
\n *
\n * You can get around this by setting `crossOrigin` property on your images before passing them to EaselJS, or\n * setting the `crossOrigin` property on PreloadJS' LoadQueue or LoadItems.\n *\n * \t\tvar image = new Image();\n * \t\timg.crossOrigin=\"Anonymous\";\n * \t\timg.src = \"http://server-with-CORS-support.com/path/to/image.jpg\";\n *\n * If you pass string paths to SpriteSheets, they will not work cross-origin. The server that stores the image must\n * support cross-origin requests, or this will not work. For more information, check out\n * CORS overview on MDN.\n *\n * @memberof easeljs\n * @extends core.EventDispatcher\n * @param {Object} data An object describing the SpriteSheet data.\n */\nexport default class SpriteSheet extends EventDispatcher {\n\n\tconstructor (data) {\n\t\tsuper();\n\n\t\t/**\n\t\t * Indicates whether all images are finished loading.\n\t\t * @type {Boolean}\n\t\t * @readonly\n\t\t */\n\t\tthis.complete = true;\n\n\t\t/**\n\t\t * Specifies the framerate to use by default for Sprite instances using the SpriteSheet. See the Sprite class\n\t\t * {@link easeljs.Sprite#framerate} for more information.\n\t\t * @type Number\n\t\t */\n\t\tthis.framerate = 0;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Array}\n\t\t */\n\t\tthis._animations = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Array}\n\t\t */\n\t\tthis._frames = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Array}\n\t\t */\n\t\tthis._images = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Object}\n\t\t */\n\t\tthis._data = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._loadCount = 0;\n\n\t\t// only used for simple frame defs:\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._frameHeight = 0;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._frameWidth = 0;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._numFrames = 0;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._regX = 0;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._regY = 0;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._spacing = 0;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._margin = 0;\n\n\t\tthis._parseData(data);\n\t}\n\n\t/**\n\t * Returns an array of all available animation names available on this sprite sheet as strings.\n\t * @type {Array}\n\t * @readonly\n\t */\n\tget animations () {\n\t\treturn this._animations.slice();\n\t}\n\n\t/**\n\t * Returns the total number of frames in the specified animation, or in the whole sprite\n\t * sheet if the animation param is omitted. Returns 0 if the spritesheet relies on calculated frame counts, and\n\t * the images have not been fully loaded.\n\t * @param {String} animation The name of the animation to get a frame count for.\n\t * @return {Number} The number of frames in the animation, or in the entire sprite sheet if the animation param is omitted.\n\t */\n\tgetNumFrames (animation) {\n\t\tif (animation == null) {\n\t\t\treturn this._frames ? this._frames.length : this._numFrames || 0;\n\t\t} else {\n\t\t\tlet data = this._data[animation];\n\t\t\tif (data == null) { return 0; }\n\t\t\telse { return data.frames.length; }\n\t\t}\n\t}\n\n\t/**\n\t * Returns an object defining the specified animation. The returned object contains:\n\t *
\n\t * \t
frames: an array of the frame ids in the animation
\n\t * \t
speed: the playback speed for this animation
\n\t * \t
name: the name of the animation
\n\t * \t
next: the default animation to play next. If the animation loops, the name and next property will be the same.
\n\t *
\n\t * @param {String} name The name of the animation to get.\n\t * @return {Object} a generic object with frames, speed, name, and next properties.\n\t */\n\tgetAnimation (name) {\n\t\treturn this._data[name];\n\t}\n\n\t/**\n\t * Returns an object specifying the image and source rect of the specified frame. The returned object has:\n\t *
\n\t * \t
an image property holding a reference to the image object in which the frame is found
\n\t * \t
a rect property containing a Rectangle instance which defines the boundaries for the frame within that image.
\n\t * \t
A regX and regY property corresponding to the regX/Y values for the frame.\n\t *
\n\t * @param {Number} frameIndex The index of the frame.\n\t * @return {Object} a generic object with image and rect properties. Returns null if the frame does not exist.\n\t */\n\tgetFrame (frameIndex) {\n\t\tlet frame;\n\t\tif (this._frames && (frame = this._frames[frameIndex])) { return frame; }\n\t\treturn null;\n\t}\n\n\t/**\n\t * Returns a {@link easeljs.Rectangle} instance defining the bounds of the specified frame relative\n\t * to the origin.\n\t *\n\t * @param {Number} frameIndex The index of the frame.\n\t * @param {easeljs.Rectangle} [rectangle] A Rectangle instance to copy the values into. By default a new instance is created.\n\t * @return {easeljs.Rectangle} A Rectangle instance. Returns null if the frame does not exist, or the image is not fully loaded.\n\t */\n\tgetFrameBounds (frameIndex, rectangle = new Rectangle()) {\n\t\tlet frame = this.getFrame(frameIndex);\n\t\treturn frame ? rectangle.setValues(-frame.regX, -frame.regY, frame.rect.width, frame.rect.height) : null;\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name}]`;\n\t}\n\n\t/**\n\t * SpriteSheet cannot be cloned. A SpriteSheet can be shared by multiple Sprite instances without cloning it.\n\t * @override\n\t * @throws SpriteSheet cannot be cloned.\n\t */\n\tclone () {\n\t\tthrow \"SpriteSheet cannot be cloned.\";\n\t}\n\n\t/**\n\t * @param {Object} data An object describing the SpriteSheet data.\n\t * @protected\n\t */\n\t_parseData (data) {\n\t\tif (data == null) { return; }\n\t\tthis.framerate = data.framerate||0;\n\n\t\t// parse images:\n\t\tif (data.images) {\n\t\t\tfor (let img of data.images) {\n\t\t\t\tlet a = this._images = [];\n\t\t\t\tlet src;\n\t\t\t\tif (typeof img === \"string\") {\n\t\t\t\t\tsrc = img;\n\t\t\t\t\timg = document.createElement(\"img\");\n\t\t\t\t\timg.src = src;\n\t\t\t\t}\n\t\t\t\ta.push(img);\n\t\t\t\tif (!img.getContext && !img.naturalWidth) {\n\t\t\t\t\tthis._loadCount++;\n\t\t\t\t\tthis.complete = false;\n\t\t\t\t\timg.onload = () => this._handleImageLoad(src);\n\t\t\t\t\timg.onerror = () => this._handleImageError(src);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// parse frames:\n\t\tif (data.frames != null) {\n\t\t\tif (Array.isArray(data.frames)) {\n\t\t\t\tthis._frames = [];\n\t\t\t\tfor (let arr of data.frames) {\n\t\t\t\t\tthis._frames.push({image:this._images[arr[4]?arr[4]:0], rect:new Rectangle(arr[0],arr[1],arr[2],arr[3]), regX:arr[5]||0, regY:arr[6]||0 });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlet o = data.frames;\n\t\t\t\tthis._frameWidth = o.width;\n\t\t\t\tthis._frameHeight = o.height;\n\t\t\t\tthis._regX = o.regX||0;\n\t\t\t\tthis._regY = o.regY||0;\n\t\t\t\tthis._spacing = o.spacing||0;\n\t\t\t\tthis._margin = o.margin||0;\n\t\t\t\tthis._numFrames = o.count;\n\t\t\t\tif (this._loadCount === 0) { this._calculateFrames(); }\n\t\t\t}\n\t\t}\n\n\t\t// parse animations:\n\t\tthis._animations = [];\n\t\tif (data.animations != null) {\n\t\t\tthis._data = {};\n\t\t\tlet o = data.animations;\n\t\t\tfor (let name in o) {\n\t\t\t\tlet anim = { name };\n\t\t\t\tlet obj = o[name];\n\t\t\t\tlet a;\n\t\t\t\tif (typeof obj === \"number\") { // single frame\n\t\t\t\t\ta = anim.frames = [obj];\n\t\t\t\t} else if (Array.isArray(obj)) { // simple\n\t\t\t\t\tif (obj.length === 1) { anim.frames = [obj[0]]; }\n\t\t\t\t\telse {\n\t\t\t\t\t\tanim.speed = obj[3];\n\t\t\t\t\t\tanim.next = obj[2];\n\t\t\t\t\t\ta = anim.frames = [];\n\t\t\t\t\t\tfor (let i=obj[0];i<=obj[1];i++) {\n\t\t\t\t\t\t\ta.push(i);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else { // complex\n\t\t\t\t\tanim.speed = obj.speed;\n\t\t\t\t\tanim.next = obj.next;\n\t\t\t\t\tlet frames = obj.frames;\n\t\t\t\t\ta = anim.frames = (typeof frames === \"number\") ? [frames] : frames.slice(0);\n\t\t\t\t}\n\t\t\t\tif (anim.next === true || anim.next === undefined) { anim.next = name; } // loop\n\t\t\t\tif (anim.next === false || (a.length < 2 && anim.next === name)) { anim.next = null; } // stop\n\t\t\t\tif (!anim.speed) { anim.speed = 1; }\n\t\t\t\tthis._animations.push(name);\n\t\t\t\tthis._data[name] = anim;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @emits easeljs.SpriteSheet#event:complete\n\t * @protected\n\t * @param {Object} src\n\t */\n\t _handleImageLoad (src) {\n\t\tif (--this._loadCount === 0) {\n\t\t\tthis._calculateFrames();\n\t\t\tthis.complete = true;\n\t\t\tthis.dispatchEvent(\"complete\");\n\t\t}\n\t}\n\n\t/**\n\t * @emits easeljs.SpriteSheet#event:complete\n\t * @emits easeljs.SpriteSheet#event:error\n\t * @protected\n\t * @param {Object} src\n\t */\n\t_handleImageError (src) {\n\t\tlet errorEvent = new Event(\"error\");\n\t\terrorEvent.src = src;\n\t\tthis.dispatchEvent(errorEvent);\n\n\t\t// Complete is still dispatched.\n\t\tif (--this._loadCount === 0) {\n\t\t\tthis.dispatchEvent(\"complete\");\n\t\t}\n\t}\n\n\t/**\n\t * @protected\n\t */\n\t_calculateFrames () {\n\t\tif (this._frames || this._frameWidth === 0) { return; }\n\n\t\tthis._frames = [];\n\n\t\tlet maxFrames = this._numFrames || 100000; // if we go over this, something is wrong.\n\t\tlet frameCount = 0, frameWidth = this._frameWidth, frameHeight = this._frameHeight;\n\t\tlet spacing = this._spacing, margin = this._margin;\n\n\t\timgLoop:\n\t\tfor (let i=0, imgs=this._images, l=imgs.length; i= maxFrames) { break imgLoop; }\n\t\t\t\t\tframeCount++;\n\t\t\t\t\tthis._frames.push({\n\t\t\t\t\t\timage: img,\n\t\t\t\t\t\trect: new Rectangle(x, y, frameWidth, frameHeight),\n\t\t\t\t\t\tregX: this._regX,\n\t\t\t\t\t\tregY: this._regY\n\t\t\t\t\t});\n\t\t\t\t\tx += frameWidth+spacing;\n\t\t\t\t}\n\t\t\t\ty += frameHeight+spacing;\n\t\t\t}\n\t\t}\n\t\tthis._numFrames = frameCount;\n\t}\n\n}\n\n/**\n * Dispatched when all images are loaded. Note that this only fires if the images\n * were not fully loaded when the sprite sheet was initialized. You should check the complete property\n * to prior to adding a listener. Ex.\n *\n * \tvar sheet = new createjs.SpriteSheet(data);\n * \tif (!sheet.complete) {\n * \t\t// not preloaded, listen for the complete event:\n * \t\tsheet.addEventListener(\"complete\", handler);\n * \t}\n *\n * @event easeljs.SpriteSheet#complete\n * @property {Object} target The object that dispatched the event.\n * @property {String} type The event type.\n * @since 0.6.0\n */\n\n/**\n * Dispatched when getFrame is called with a valid frame index. This is primarily intended for use by {@link easeljs.SpriteSheetBuilder}\n * when doing on-demand rendering.\n * @event easeljs.SpriteSheet#getframe\n * @property {Number} index The frame index.\n * @property {Object} frame The frame object that getFrame will return.\n */\n\n/**\n * Dispatched when an image encounters an error. A SpriteSheet will dispatch an error event for each image that\n * encounters an error, and will still dispatch a {@link easeljs.SpriteSheet#event:complete}\n * event once all images are finished processing, even if an error is encountered.\n * @event easeljs.SpriteSheet#error\n * @property {String} src The source of the image that failed to load.\n * @since 0.8.2\n */\n","/**\n * @license Text\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport DisplayObject from \"./DisplayObject\";\nimport createCanvas from \"../utils/Canvas\";\n\n/**\n * Display one or more lines of dynamic text (not user editable) in the display list. Line wrapping support (using the\n * lineWidth) is very basic, wrapping on spaces and tabs only. Note that as an alternative to Text, you can position HTML\n * text above or below the canvas relative to items in the display list using the {@link easeljs.DisplayObject#localToGlobal}\n * method, or using {@link easeljs.DOMElement}.\n *\n * Please note that Text does not support HTML text, and can only display one font style at a time. To use\n * multiple font styles, you will need to create multiple text instances, and position them manually.\n *\n * CreateJS Text supports web fonts (the same rules as Canvas). The font must be loaded and supported by the browser\n * before it can be displayed.\n *\n * Note: Text can be expensive to generate, so cache instances where possible. Be aware that not all\n * browsers will render Text exactly the same.\n *\n * @memberof easeljs\n * @extends easeljs.DisplayObject\n * @example\n * let text = new Text(\"Hello World\", \"20px Arial\", \"#ff7700\");\n * text.x = 100;\n * text.textBaseline = \"alphabetic\";\n *\n * @param {String} [text] The text to display.\n * @param {String} [font] The font style to use. Any valid value for the CSS font attribute is acceptable (ex. \"bold\n * 36px Arial\").\n * @param {String} [color] The color to draw the text in. Any valid value for the CSS color attribute is acceptable (ex.\n * \"#F00\", \"red\", or \"#FF0000\").\n */\nexport default class Text extends DisplayObject {\n\n\tconstructor (text, font, color) {\n\t\tsuper();\n\n\t\t/**\n\t\t * The text to display.\n\t\t * @type {String}\n\t\t */\n\t\tthis.text = text;\n\n\t\t/**\n\t\t * The font style to use. Any valid value for the CSS font attribute is acceptable (ex. \"bold 36px Arial\").\n\t\t * @type {String}\n\t\t */\n\t\tthis.font = font;\n\n\t\t/**\n\t\t * The color to draw the text in. Any valid value for the CSS color attribute is acceptable (ex. \"#F00\"). Default is \"#000\".\n\t\t * It will also accept valid canvas fillStyle values.\n\t\t * @type {String}\n\t\t */\n\t\tthis.color = color;\n\n\t\t/**\n\t\t * The horizontal text alignment. Any of \"start\", \"end\", \"left\", \"right\", and \"center\".\n\t\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#text-styles \"WHATWG spec\"}\n\t\t * @type {String}\n\t\t * @default left\n\t\t */\n\t\tthis.textAlign = \"left\";\n\n\t\t/**\n\t\t * The vertical alignment point on the font. Any of \"top\", \"hanging\", \"middle\", \"alphabetic\", \"ideographic\", or \"bottom\".\n\t\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#text-styles \"WHATWG spec\"}\n\t\t * @type {String}\n\t\t * @default top\n\t\t*/\n\t\tthis.textBaseline = \"top\";\n\n\t\t/**\n\t\t * The maximum width to draw the text. If maxWidth is specified (not null), the text will be condensed or\n\t\t * shrunk to make it fit in this width.\n\t\t * @see {@link http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#text-styles \"WHATWG spec\"}\n\t\t * @type {Number}\n\t\t*/\n\t\tthis.maxWidth = null;\n\n\t\t/**\n\t\t * If greater than 0, the text will be drawn as a stroke (outline) of the specified width.\n\t\t * @type {Number}\n\t\t */\n\t\tthis.outline = 0;\n\n\t\t/**\n\t\t * Indicates the line height (vertical distance between baselines) for multi-line text. If null or 0,\n\t\t * the value of getMeasuredLineHeight is used.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.lineHeight = 0;\n\n\t\t/**\n\t\t * Indicates the maximum width for a line of text before it is wrapped to multiple lines. If null,\n\t\t * the text will not be wrapped.\n\t\t * @type {Number}\n\t\t */\n\t\tthis.lineWidth = null;\n\t}\n\n \tisVisible () {\n \t\tlet hasContent = this.cacheCanvas || (this.text != null && this.text !== \"\");\n \t\treturn !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && hasContent);\n \t}\n\n \tdraw (ctx, ignoreCache) {\n \t\tif (super.draw(ctx, ignoreCache)) { return true; }\n\n \t\tlet col = this.color || \"#000\";\n \t\tif (this.outline) { ctx.strokeStyle = col; ctx.lineWidth = this.outline*1; }\n \t\telse { ctx.fillStyle = col; }\n\n \t\tthis._drawText(this._prepContext(ctx));\n \t\treturn true;\n \t}\n\n \t/**\n \t * Returns the measured, untransformed width of the text without wrapping. Use getBounds for a more robust value.\n \t * @return {Number} The measured, untransformed width of the text.\n \t */\n \tgetMeasuredWidth () {\n \t\treturn this._getMeasuredWidth(this.text);\n \t}\n\n \t/**\n \t * Returns an approximate line height of the text, ignoring the lineHeight property. This is based on the measured\n \t * width of a \"M\" character multiplied by 1.2, which provides an approximate line height for most fonts.\n \t * @return {Number} an approximate line height of the text, ignoring the lineHeight property. This is\n \t * based on the measured width of a \"M\" character multiplied by 1.2, which approximates em for most fonts.\n \t */\n \tgetMeasuredLineHeight () {\n \t\treturn this._getMeasuredWidth(\"M\")*1.2;\n \t}\n\n \t/**\n \t * Returns the approximate height of multi-line text by multiplying the number of lines against either the\n \t * `lineHeight` (if specified) or {@link easeljs.Text#getMeasuredLineHeight}. Note that\n \t * this operation requires the text flowing logic to run, which has an associated CPU cost.\n \t * @return {Number} The approximate height of the untransformed multi-line text.\n \t */\n \tgetMeasuredHeight () {\n \t\treturn this._drawText(null, {}).height;\n \t}\n\n \tgetBounds () {\n \t\tlet rect = super.getBounds();\n \t\tif (rect) { return rect; }\n \t\tif (this.text == null || this.text === \"\") { return null; }\n \t\tlet o = this._drawText(null, {});\n \t\tlet w = (this.maxWidth && this.maxWidth < o.width) ? this.maxWidth : o.width;\n \t\tlet x = w * Text.H_OFFSETS[this.textAlign||\"left\"];\n \t\tlet lineHeight = this.lineHeight||this.getMeasuredLineHeight();\n \t\tlet y = lineHeight * Text.V_OFFSETS[this.textBaseline||\"top\"];\n \t\treturn this._rectangle.setValues(x, y, w, o.height);\n \t}\n\n \t/**\n \t * Returns an object with width, height, and lines properties. The width and height are the visual width and height\n \t * of the drawn text. The lines property contains an array of strings, one for\n \t * each line of text that will be drawn, accounting for line breaks and wrapping. These strings have trailing\n \t * whitespace removed.\n \t * @return {Object} An object with width, height, and lines properties.\n \t */\n \tgetMetrics () {\n \t\tlet o = {lines:[]};\n \t\to.lineHeight = this.lineHeight || this.getMeasuredLineHeight();\n \t\to.vOffset = o.lineHeight * Text.V_OFFSETS[this.textBaseline||\"top\"];\n \t\treturn this._drawText(null, o, o.lines);\n \t}\n\n \t/**\n \t * Returns a clone of the Text instance.\n \t * @return {easeljs.Text} a clone of the Text instance.\n \t */\n \tclone () {\n \t\treturn this._cloneProps(new Text(this.text, this.font, this.color));\n \t}\n\n \t/**\n \t * Returns a string representation of this object.\n \t * @override\n \t * @return {String} a string representation of the instance.\n \t */\n \ttoString () {\n \t\treturn `[${this.constructor.name} (text=${this.text.length > 20 ? `${this.text.substr(0, 17)}...` : this.text})]`;\n \t}\n\n \t/**\n \t * @param {easeljs.Text} o\n \t * @protected\n \t * @return {easeljs.Text} o\n \t */\n \t_cloneProps (o) {\n \t\tsuper._cloneProps(o);\n \t\to.textAlign = this.textAlign;\n \t\to.textBaseline = this.textBaseline;\n \t\to.maxWidth = this.maxWidth;\n \t\to.outline = this.outline;\n \t\to.lineHeight = this.lineHeight;\n \t\to.lineWidth = this.lineWidth;\n \t\treturn o;\n \t}\n\n \t/**\n \t * @param {CanvasRenderingContext2D} ctx\n \t * @return {CanvasRenderingContext2D}\n \t * @protected\n \t */\n \t_prepContext (ctx) {\n \t\tctx.font = this.font||\"10px sans-serif\";\n \t\tctx.textAlign = this.textAlign||\"left\";\n \t\tctx.textBaseline = this.textBaseline||\"top\";\n\t\tctx.lineJoin = \"miter\";\n\t\tctx.miterLimit = 2.5;\n\t\treturn ctx;\n\t}\n\n\t/**\n\t * Draws multiline text.\n\t * @param {CanvasRenderingContext2D} ctx\n\t * @param {Object} o\n\t * @param {Array} lines\n\t * @return {Object}\n\t * @protected\n\t */\n \t_drawText (ctx, o, lines) {\n \t\tconst paint = !!ctx;\n \t\tif (!paint) {\n \t\t\tctx = Text._ctx;\n \t\t\tctx.save();\n \t\t\tthis._prepContext(ctx);\n \t\t}\n \t\tlet lineHeight = this.lineHeight||this.getMeasuredLineHeight();\n\n \t\tlet maxW = 0, count = 0;\n \t\tlet hardLines = String(this.text).split(/(?:\\r\\n|\\r|\\n)/);\n \t\tfor (let str of hardLines) {\n \t\t\tlet w = null;\n\n \t\t\tif (this.lineWidth != null && (w = ctx.measureText(str).width) > this.lineWidth) {\n \t\t\t\t// text wrapping:\n \t\t\t\tlet words = str.split(/(\\s)/);\n \t\t\t\tstr = words[0];\n \t\t\t\tw = ctx.measureText(str).width;\n\n\t\t\t\tconst l = words.length;\n \t\t\t\tfor (let i=1; i this.lineWidth) {\n \t\t\t\t\t\tif (paint) { this._drawTextLine(ctx, str, count*lineHeight); }\n \t\t\t\t\t\tif (lines) { lines.push(str); }\n \t\t\t\t\t\tif (w > maxW) { maxW = w; }\n \t\t\t\t\t\tstr = words[i+1];\n \t\t\t\t\t\tw = ctx.measureText(str).width;\n \t\t\t\t\t\tcount++;\n \t\t\t\t\t} else {\n \t\t\t\t\t\tstr += words[i] + words[i+1];\n \t\t\t\t\t\tw += wordW;\n \t\t\t\t\t}\n \t\t\t\t}\n \t\t\t}\n\n \t\t\tif (paint) { this._drawTextLine(ctx, str, count*lineHeight); }\n \t\t\tif (lines) { lines.push(str); }\n \t\t\tif (o && w == null) { w = ctx.measureText(str).width; }\n \t\t\tif (w > maxW) { maxW = w; }\n \t\t\tcount++;\n \t\t}\n\n \t\tif (o) {\n \t\t\to.width = maxW;\n \t\t\to.height = count*lineHeight;\n \t\t}\n \t\tif (!paint) { ctx.restore(); }\n \t\treturn o;\n \t}\n\n \t/**\n \t * @param {CanvasRenderingContext2D} ctx\n \t * @param {String} text\n \t * @param {Number} y\n \t * @protected\n \t */\n \t_drawTextLine (ctx, text, y) {\n \t\t// Chrome 17 will fail to draw the text if the last param is included but null, so we feed it a large value instead:\n \t\tif (this.outline) { ctx.strokeText(text, 0, y, this.maxWidth||0xFFFF); }\n \t\telse { ctx.fillText(text, 0, y, this.maxWidth||0xFFFF); }\n \t}\n\n \t/**\n \t * @param {String} text\n \t * @protected\n \t */\n \t_getMeasuredWidth (text) {\n \t\tlet ctx = Text._ctx;\n \t\tctx.save();\n \t\tlet w = this._prepContext(ctx).measureText(text).width;\n \t\tctx.restore();\n \t\treturn w;\n \t}\n\n}\n\n/**\n * Lookup table for the ratio to offset bounds x calculations based on the textAlign property.\n * @type {Object}\n * @readonly\n * @static\n */\nText.H_OFFSETS = {start: 0, left: 0, center: -0.5, end: -1, right: -1};\n/**\n * Lookup table for the ratio to offset bounds y calculations based on the textBaseline property.\n * @type {Object}\n * @readonly\n * @static\n */\nText.V_OFFSETS = {top: 0, hanging: -0.01, middle: -0.4, alphabetic: -0.8, ideographic: -0.85, bottom: -1};\n\n/**\n * @property _ctx\n * @type {CanvasRenderingContext2D}\n * @private\n * @static\n */\nText._ctx = createCanvas().getContext(\"2d\");\n","/**\n * @license AlphaMapFilter\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Filter from \"./Filter\";\n\n/**\n * Applies a greyscale alpha map image (or canvas) to the target, such that the alpha channel of the result will\n * be copied from the red channel of the map, and the RGB channels will be copied from the target.\n *\n * Generally, it is recommended that you use {@link easeljs.AlphaMaskFilter}, because it has much better performance.\n *\n * @memberof easeljs\n * @extends easeljs.Filter\n * @example *\n * let box = new Shape();\n * box.graphics.beginLinearGradientFill([\"#ff0000\", \"#0000ff\"], [0, 1], 0, 0, 0, 100)\n * box.graphics.drawRect(0, 0, 100, 100);\n * box.cache(0, 0, 100, 100);\n * let bmp = new Bitmap(\"path/to/image.jpg\");\n * bmp.filters = [ new AlphaMapFilter(box.cacheCanvas) ];\n * bmp.cache(0, 0, 100, 100);\n *\n * @param {HTMLImageElement | HTMLCanvasElement} alphaMap The greyscale image (or canvas) to use as the alpha value for the\n * result. This should be exactly the same dimensions as the target.\n */\nexport default class AlphaMapFilter extends Filter {\n\n\tconstructor (alphaMap) {\n\t\tsuper();\n\n\t\t/**\n\t\t * The greyscale image (or canvas) to use as the alpha value for the result. This should be exactly the same\n\t\t * dimensions as the target.\n\t\t * @type {HTMLImageElement | HTMLCanvasElement}\n\t\t */\n\t\tthis.alphaMap = alphaMap;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {HTMLImageElement | HTMLCanvasElement}\n\t\t * @default null\n\t\t */\n\t\tthis._alphaMap = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Uint8ClampedArray}\n\t\t * @default null\n\t\t */\n\t\tthis._mapData = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {*}\n\t\t * @default null\n\t\t */\n\t\tthis._mapTexture = null;\n\n\t\tthis.FRAG_SHADER_BODY = `\n\t\t\tuniform sampler2D uAlphaSampler;\n\n\t\t\tvoid main (void) {\n\t\t\t\tvec4 color = texture2D(uSampler, vRenderCoord);\n\t\t\t\tvec4 alphaMap = texture2D(uAlphaSampler, vTextureCoord);\n\n\t\t\t\t// some image formats can have transparent white rgba(1,1,1, 0) when put on the GPU, this means we need a slight tweak\n\t\t\t\t// using ceil ensure that the colour will be used so long as it exists but pure transparency will be treated black\n\t\t\t\tgl_FragColor = vec4(color.rgb, color.a * (alphaMap.r * ceil(alphaMap.a)));\n\t\t\t}\n\t\t`;\n\t}\n\n\t/**\n\t * @todo docs\n\t * @param {*} gl\n\t * @param {*} stage\n\t * @param {*} shaderProgram\n\t */\n\tshaderParamSetup (gl, stage, shaderProgram) {\n\t\tif (!this._mapTexture) { this._mapTexture = gl.createTexture(); }\n\n\t\tgl.activeTexture(gl.TEXTURE1);\n\t\tgl.bindTexture(gl.TEXTURE_2D, this._mapTexture);\n\t\tstage.setTextureParams(gl);\n\t\tgl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this.alphaMap);\n\n\t\tgl.uniform1i(\n\t\t\tgl.getUniformLocation(shaderProgram, \"uAlphaSampler\"),\n\t\t\t1\n\t\t);\n\t}\n\n\t/**\n\t * @return {easeljs.AlphaMapFilter}\n\t */\n\tclone () {\n\t\tlet o = new AlphaMapFilter(this.alphaMap);\n\t\to._alphaMap = this._alphaMap;\n\t\to._mapData = this._mapData;\n\t\treturn o;\n\t}\n\n\t_applyFilter (imageData) {\n\t\tif (!this.alphaMap) { return true; }\n\t\tif (!this._prepAlphaMap()) { return false; }\n\n\t\t// TODO: update to support scenarios where the target has different dimensions.\n\t\tlet data = imageData.data;\n\t\tlet map = this._mapData;\n\t\tconst l = data.length;\n\t\tfor (let i=0; iIMPORTANT NOTE: This filter currently does not support the targetCtx, or targetX/Y parameters correctly.\n *\n * @memberof easeljs\n * @extends easeljs.Filter\n * @example\n * var box = new Shape();\n * box.graphics.beginLinearGradientFill([\"#000000\", \"rgba(0, 0, 0, 0)\"], [0, 1], 0, 0, 100, 100)\n * box.graphics.drawRect(0, 0, 100, 100);\n * box.cache(0, 0, 100, 100);\n * var bmp = new Bitmap(\"path/to/image.jpg\");\n * bmp.filters = [ new AlphaMaskFilter(box.cacheCanvas) ];\n * bmp.cache(0, 0, 100, 100);\n *\n * @param {HTMLImageElement | HTMLCanvasElement} mask\n */\nexport default class AlphaMaskFilter extends Filter {\n\n\tconstructor (mask) {\n\t\tsuper();\n\n\t\t/**\n\t\t * The image (or canvas) to use as the mask.\n\t\t * @type {HTMLImageElement | HTMLCanvasElement}\n\t\t */\n\t\tthis.mask = mask;\n\n\t\tthis.usesContext = true;\n\n\t\tthis.FRAG_SHADER_BODY = `\n\t\t\tuniform sampler2D uAlphaSampler;\n\n\t\t\tvoid main (void) {\n\t\t\t\tvec4 color = texture2D(uSampler, vRenderCoord);\n\t\t\t\tvec4 alphaMap = texture2D(uAlphaSampler, vTextureCoord);\n\n\t\t\t\tgl_FragColor = vec4(color.rgb, color.a * alphaMap.a);\n\t\t\t}\n\t\t`;\n\t}\n\n\t/**\n\t * Applies the filter to the specified context.\n\t *\n\t * IMPORTANT NOTE: This filter currently does not support the targetCtx, or targetX/Y parameters correctly.\n\t * @param {CanvasRenderingContext2D} ctx The 2D context to use as the source.\n\t * @param {Number} x The x position to use for the source rect.\n\t * @param {Number} y The y position to use for the source rect.\n\t * @param {Number} width The width to use for the source rect.\n\t * @param {Number} height The height to use for the source rect.\n\t * @param {CanvasRenderingContext2D} [targetCtx] NOT SUPPORTED IN THIS FILTER. The 2D context to draw the result to. Defaults to the context passed to ctx.\n\t * @param {Number} [targetX] NOT SUPPORTED IN THIS FILTER. The x position to draw the result to. Defaults to the value passed to x.\n\t * @param {Number} [targetY] NOT SUPPORTED IN THIS FILTER. The y position to draw the result to. Defaults to the value passed to y.\n\t * @return {Boolean} If the filter was applied successfully.\n\t */\n\tapplyFilter (ctx, x, y, width, height, targetCtx, targetX, targetY) {\n\t\tif (!this.mask) { return true; }\n\t\ttargetCtx = targetCtx || ctx;\n\t\tif (targetX == null) { targetX = x; }\n\t\tif (targetY == null) { targetY = y; }\n\n\t\ttargetCtx.save();\n\t\tif (ctx != targetCtx) {\n\t\t\t// TODO: support targetCtx and targetX/Y\n\t\t\t// clearRect, then draw the ctx in?\n\t\t\treturn false;\n\t\t}\n\n\t\ttargetCtx.globalCompositeOperation = \"destination-in\";\n\t\ttargetCtx.drawImage(this.mask, targetX, targetY);\n\t\ttargetCtx.restore();\n\t\treturn true;\n\t}\n\n\t/**\n\t * @return {easeljs.AlphaMaskFilter}\n\t */\n\tclone () {\n\t\treturn new AlphaMaskFilter(this.mask);\n\t}\n\n\t/**\n\t * @todo docs\n\t * @param {*} gl\n\t * @param {*} stage\n\t * @param {*} shaderProgram\n\t */\n\tshaderParamSetup (gl, stage, shaderProgram) {\n\t\tif(!this._mapTexture) { this._mapTexture = gl.createTexture(); }\n\n\t\tgl.activeTexture(gl.TEXTURE1);\n\t\tgl.bindTexture(gl.TEXTURE_2D, this._mapTexture);\n\t\tstage.setTextureParams(gl);\n\t\tgl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this.mask);\n\n\t\tgl.uniform1i(\n\t\t\tgl.getUniformLocation(shaderProgram, \"uAlphaSampler\"),\n\t\t\t1\n\t\t);\n\t}\n\n}\n","/**\n * @license BlurFilter\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * BoxBlur Algorithm by Mario Klingemann, quasimondo.com\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Filter from \"./Filter\";\nimport Rectangle from \"../geom/Rectangle\";\n\n/**\n * Applies a box blur to DisplayObjects. Note that this filter is fairly CPU intensive, particularly if the quality is\n * set higher than 1.\n *\n * @memberof easeljs\n * @extends easeljs.Filter\n * @example\n * let shape = new Shape().set({x:100,y:100});\n * shape.graphics.beginFill(\"#ff0000\").drawCircle(0,0,50);\n * let blurFilter = new BlurFilter(5, 5, 1);\n * shape.filters = [blurFilter];\n * let bounds = blurFilter.getBounds();\n * shape.cache(-50+bounds.x, -50+bounds.y, 100+bounds.width, 100+bounds.height);\n *\n * @param {Number} [blurX=0] The horizontal blur radius in pixels.\n * @param {Number} [blurY=0] The vertical blur radius in pixels.\n * @param {Number} [quality=1] The number of blur iterations.\n */\nexport default class BlurFilter extends Filter {\n\n\tconstructor (blurX = 0, blurY = 0, quality = 1) {\n\t\tsuper();\n\n\t\t/**\n\t\t * @protected\n\t\t * @default 0\n\t\t * @type {Number}\n\t\t */\n\t\tthis._blurX = blurX;\n\t\t/**\n\t\t * @protected\n\t\t * @type {Array}\n\t\t */\n\t\tthis._blurXTable = [];\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default null\n\t\t */\n\t\tthis._lastBlurX = null;\n\n\t\t/**\n\t\t * @default 0\n\t\t * @type {Number}\n\t\t */\n\t\tthis._blurY = blurY;\n\t\t/**\n\t\t * @protected\n\t\t * @type {Array}\n\t\t */\n\t\tthis._blurYTable = [];\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default null\n\t\t */\n\t\tthis._lastBlurY = null;\n\n\t\t/**\n\t\t * Number of blur iterations. For example, a value of 1 will produce a rough blur. A value of 2 will produce a\n\t\t * smoother blur, but take twice as long to run.\n\t\t * @default 1\n\t\t * @type {Number}\n\t\t */\n\t\tthis._quality = (isNaN(quality) || quality < 1) ? 1 : quality;\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t * @default null\n\t\t */\n\t\tthis._lastQuality = null;\n\n\t\tthis.FRAG_SHADER_TEMPLATE = `\n\t\t\tuniform float xWeight[{{blurX}}];\n\t\t\tuniform float yWeight[{{blurY}}];\n\t\t\tuniform vec2 textureOffset;\n\t\t\tvoid main (void) {\n\t\t\t\tvec4 color = vec4(0.0);\n\n\t\t\t\tfloat xAdj = ({{blurX}}.0-1.0)/2.0;\n\t\t\t\tfloat yAdj = ({{blurY}}.0-1.0)/2.0;\n\t\t\t\tvec2 sampleOffset;\n\n\t\t\t\tfor(int i=0; i<{{blurX}}; i++) {\n\t\t\t\t\tfor(int j=0; j<{{blurY}}; j++) {\n\t\t\t\t\t\tsampleOffset = vRenderCoord + (textureOffset * vec2(float(i)-xAdj, float(j)-yAdj));\n\t\t\t\t\t\tcolor += texture2D(uSampler, sampleOffset) * (xWeight[i] * yWeight[j]);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = color.rgba;\n\t\t\t}\n\t\t`;\n\t}\n\n\t/**\n\t * Horizontal blur radius in pixels.\n\t * @type {Number}\n\t */\n\tget blurX () { return this._blurX; }\n\tset blurX (blurX) {\n\t\tif (isNaN(blurX) || blurX < 0) { blurX = 0; }\n\t\tthis._blurX = blurX;\n\t}\n\n\t/**\n\t * Vertical blur radius in pixels.\n\t * @type {Number}\n\t */\n\tget blurY () { return this._blurY; }\n\tset blurY (blurY) {\n\t\tif (isNaN(blurY) || blurY < 0) { blurY = 0; }\n\t\tthis._blurY = blurY;\n\t}\n\n\t/**\n\t * Number of blur iterations. For example, a value of 1 will produce a rough blur. A value of 2 will produce a\n\t * smoother blur, but take twice as long to run.\n\t * @type {Number}\n\t */\n\tget quality () { return this._quality | 0; }\n\tset quality (quality) {\n\t\tif (isNaN(quality) || quality < 0) { quality = 0; }\n\t\tthis._quality = quality;\n\t}\n\n\t/**\n\t * @protected\n\t * @type {*}\n\t */\n\tget _buildShader () {\n\t\tconst xChange = this._lastBlurX !== this._blurX;\n\t\tconst yChange = this._lastBlurY !== this._blurY;\n\t\tconst qChange = this._lastQuality !== this._quality;\n\t\tif (xChange || yChange || qChange) {\n\t\t\t\tif (xChange || qChange) { this._blurXTable = this._getTable(this._blurX * this._quality); }\n\t\t\t\tif (yChange || qChange) { this._blurYTable = this._getTable(this._blurY * this._quality); }\n\t\t\t\tthis._updateShader();\n\t\t\t\tthis._lastBlurX = this._blurX;\n\t\t\t\tthis._lastBlurY = this._blurY;\n\t\t\t\tthis._lastQuality = this._quality;\n\t\t\t\treturn undefined; // force a rebuild\n\t\t}\n\t\treturn this._compiledShader;\n\t}\n\tset _builtShader (value) { this._compiledShader = value; }\n\n\tshaderParamSetup (gl, stage, shaderProgram) {\n\t\t// load the normalized gaussian weight tables\n\t\tgl.uniform1fv(\n\t\t\tgl.getUniformLocation(shaderProgram, \"xWeight\"),\n\t\t\tthis._blurXTable\n\t\t);\n\t\tgl.uniform1fv(\n\t\t\tgl.getUniformLocation(shaderProgram, \"yWeight\"),\n\t\t\tthis._blurYTable\n\t\t);\n\n\t\t// what is the size of a single pixel in -1, 1 (webGL) space\n\t\tgl.uniform2f(\n\t\t\tgl.getUniformLocation(shaderProgram, \"textureOffset\"),\n\t\t\t2/(stage._viewportWidth*this._quality), 2/(stage._viewportHeight*this._quality)\n\t\t);\n\t}\n\n\tgetBounds (rect) {\n\t\tlet x = this.blurX|0, y = this.blurY| 0;\n\t\tif (x <= 0 && y <= 0) { return rect; }\n\t\tlet q = Math.pow(this.quality, 0.2);\n\t\treturn (rect || new Rectangle()).pad(y*q+1,x*q+1,y*q+1,x*q+1);\n\t}\n\n\t/**\n\t * @return {easeljs.BlurFilter}\n\t */\n\tclone () {\n\t\treturn new BlurFilter(this.blurX, this.blurY, this.quality);\n\t}\n\n\t_updateShader () {\n\t\tlet result = this.FRAG_SHADER_TEMPLATE;\n\t\tresult = result.replace(/{{blurX}}/g, this._blurXTable.length.toFixed(0));\n\t\tresult = result.replace(/{{blurY}}/g, this._blurYTable.length.toFixed(0));\n\t\tthis.FRAG_SHADER_BODY = result;\n\t}\n\n\t_getTable (spread) {\n\t\tconst EDGE = 4.2;\n\t\tif (spread <= 1) { return [1]; }\n\n\t\tlet result = [];\n\t\tlet count = Math.ceil(spread*2);\n\t\tcount += (count%2)?0:1;\n\t\tlet adjust = (count/2)|0;\n\t\tfor (let i = -adjust; i<=adjust; i++) {\n\t\t\tlet x = (i/adjust)*EDGE;\n\t\t\tresult.push(1/Math.sqrt(2*Math.PI) * Math.pow(Math.E, -(Math.pow(x,2)/4)));\n\t\t}\n\t\tlet factor = result.reduce((a, b) => a + b, 0);\n\t\treturn result.map(currentValue => currentValue / factor);\n\t}\n\n\t_applyFilter (imageData) {\n\t\tlet radiusX = this._blurX >> 1;\n\t\tif (isNaN(radiusX) || radiusX < 0) return false;\n\t\tlet radiusY = this._blurY >> 1;\n\t\tif (isNaN(radiusY) || radiusY < 0) return false;\n\t\tif (radiusX === 0 && radiusY === 0) return false;\n\n\t\tlet iterations = this.quality;\n\t\tif (isNaN(iterations) || iterations < 1) iterations = 1;\n\t\titerations |= 0;\n\t\tif (iterations > 3) iterations = 3;\n\t\tif (iterations < 1) iterations = 1;\n\n\t\tlet px = imageData.data;\n\t\tlet x=0, y=0, i=0, p=0, yp=0, yi=0, yw=0, r=0, g=0, b=0, a=0, pr=0, pg=0, pb=0, pa=0;\n\n\t\tlet divx = (radiusX + radiusX + 1) | 0;\n\t\tlet divy = (radiusY + radiusY + 1) | 0;\n\t\tlet w = imageData.width | 0;\n\t\tlet h = imageData.height | 0;\n\n\t\tlet w1 = (w - 1) | 0;\n\t\tlet h1 = (h - 1) | 0;\n\t\tlet rxp1 = (radiusX + 1) | 0;\n\t\tlet ryp1 = (radiusY + 1) | 0;\n\n\t\tlet ssx = {r:0,b:0,g:0,a:0};\n\t\tlet sx = ssx;\n\t\tfor ( i = 1; i < divx; i++ )\n\t\t{\n\t\t\tsx = sx.n = {r:0,b:0,g:0,a:0};\n\t\t}\n\t\tsx.n = ssx;\n\n\t\tlet ssy = {r:0,b:0,g:0,a:0};\n\t\tlet sy = ssy;\n\t\tfor ( i = 1; i < divy; i++ )\n\t\t{\n\t\t\tsy = sy.n = {r:0,b:0,g:0,a:0};\n\t\t}\n\t\tsy.n = ssy;\n\n\t\tlet si = null;\n\n\n\t\tlet mtx = BlurFilter.MUL_TABLE[radiusX] | 0;\n\t\tlet stx = BlurFilter.SHG_TABLE[radiusX] | 0;\n\t\tlet mty = BlurFilter.MUL_TABLE[radiusY] | 0;\n\t\tlet sty = BlurFilter.SHG_TABLE[radiusY] | 0;\n\n\t\twhile (iterations-- > 0) {\n\n\t\t\tyw = yi = 0;\n\t\t\tlet ms = mtx;\n\t\t\tlet ss = stx;\n\t\t\tfor (y = h; --y > -1;) {\n\t\t\t\tr = rxp1 * (pr = px[(yi) | 0]);\n\t\t\t\tg = rxp1 * (pg = px[(yi + 1) | 0]);\n\t\t\t\tb = rxp1 * (pb = px[(yi + 2) | 0]);\n\t\t\t\ta = rxp1 * (pa = px[(yi + 3) | 0]);\n\n\t\t\t\tsx = ssx;\n\n\t\t\t\tfor( i = rxp1; --i > -1; )\n\t\t\t\t{\n\t\t\t\t\tsx.r = pr;\n\t\t\t\t\tsx.g = pg;\n\t\t\t\t\tsx.b = pb;\n\t\t\t\t\tsx.a = pa;\n\t\t\t\t\tsx = sx.n;\n\t\t\t\t}\n\n\t\t\t\tfor( i = 1; i < rxp1; i++ )\n\t\t\t\t{\n\t\t\t\t\tp = (yi + ((w1 < i ? w1 : i) << 2)) | 0;\n\t\t\t\t\tr += ( sx.r = px[p]);\n\t\t\t\t\tg += ( sx.g = px[p+1]);\n\t\t\t\t\tb += ( sx.b = px[p+2]);\n\t\t\t\t\ta += ( sx.a = px[p+3]);\n\n\t\t\t\t\tsx = sx.n;\n\t\t\t\t}\n\n\t\t\t\tsi = ssx;\n\t\t\t\tfor ( x = 0; x < w; x++ )\n\t\t\t\t{\n\t\t\t\t\tpx[yi++] = (r * ms) >>> ss;\n\t\t\t\t\tpx[yi++] = (g * ms) >>> ss;\n\t\t\t\t\tpx[yi++] = (b * ms) >>> ss;\n\t\t\t\t\tpx[yi++] = (a * ms) >>> ss;\n\n\t\t\t\t\tp = ((yw + ((p = x + radiusX + 1) < w1 ? p : w1)) << 2);\n\n\t\t\t\t\tr -= si.r - ( si.r = px[p]);\n\t\t\t\t\tg -= si.g - ( si.g = px[p+1]);\n\t\t\t\t\tb -= si.b - ( si.b = px[p+2]);\n\t\t\t\t\ta -= si.a - ( si.a = px[p+3]);\n\n\t\t\t\t\tsi = si.n;\n\n\t\t\t\t}\n\t\t\t\tyw += w;\n\t\t\t}\n\n\t\t\tms = mty;\n\t\t\tss = sty;\n\t\t\tfor (x = 0; x < w; x++) {\n\t\t\t\tyi = (x << 2) | 0;\n\n\t\t\t\tr = (ryp1 * (pr = px[yi])) | 0;\n\t\t\t\tg = (ryp1 * (pg = px[(yi + 1) | 0])) | 0;\n\t\t\t\tb = (ryp1 * (pb = px[(yi + 2) | 0])) | 0;\n\t\t\t\ta = (ryp1 * (pa = px[(yi + 3) | 0])) | 0;\n\n\t\t\t\tsy = ssy;\n\t\t\t\tfor( i = 0; i < ryp1; i++ )\n\t\t\t\t{\n\t\t\t\t\tsy.r = pr;\n\t\t\t\t\tsy.g = pg;\n\t\t\t\t\tsy.b = pb;\n\t\t\t\t\tsy.a = pa;\n\t\t\t\t\tsy = sy.n;\n\t\t\t\t}\n\n\t\t\t\typ = w;\n\n\t\t\t\tfor( i = 1; i <= radiusY; i++ )\n\t\t\t\t{\n\t\t\t\t\tyi = ( yp + x ) << 2;\n\n\t\t\t\t\tr += ( sy.r = px[yi]);\n\t\t\t\t\tg += ( sy.g = px[yi+1]);\n\t\t\t\t\tb += ( sy.b = px[yi+2]);\n\t\t\t\t\ta += ( sy.a = px[yi+3]);\n\n\t\t\t\t\tsy = sy.n;\n\n\t\t\t\t\tif( i < h1 )\n\t\t\t\t\t{\n\t\t\t\t\t\typ += w;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tyi = x;\n\t\t\t\tsi = ssy;\n\t\t\t\tif ( iterations > 0 )\n\t\t\t\t{\n\t\t\t\t\tfor ( y = 0; y < h; y++ )\n\t\t\t\t\t{\n\t\t\t\t\t\tp = yi << 2;\n\t\t\t\t\t\tpx[p+3] = pa =(a * ms) >>> ss;\n\t\t\t\t\t\tif ( pa > 0 )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpx[p] = ((r * ms) >>> ss );\n\t\t\t\t\t\t\tpx[p+1] = ((g * ms) >>> ss );\n\t\t\t\t\t\t\tpx[p+2] = ((b * ms) >>> ss );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tpx[p] = px[p+1] = px[p+2] = 0\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tp = ( x + (( ( p = y + ryp1) < h1 ? p : h1 ) * w )) << 2;\n\n\t\t\t\t\t\tr -= si.r - ( si.r = px[p]);\n\t\t\t\t\t\tg -= si.g - ( si.g = px[p+1]);\n\t\t\t\t\t\tb -= si.b - ( si.b = px[p+2]);\n\t\t\t\t\t\ta -= si.a - ( si.a = px[p+3]);\n\n\t\t\t\t\t\tsi = si.n;\n\n\t\t\t\t\t\tyi += w;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tfor ( y = 0; y < h; y++ )\n\t\t\t\t\t{\n\t\t\t\t\t\tp = yi << 2;\n\t\t\t\t\t\tpx[p+3] = pa =(a * ms) >>> ss;\n\t\t\t\t\t\tif ( pa > 0 )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpa = 255 / pa;\n\t\t\t\t\t\t\tpx[p] = ((r * ms) >>> ss ) * pa;\n\t\t\t\t\t\t\tpx[p+1] = ((g * ms) >>> ss ) * pa;\n\t\t\t\t\t\t\tpx[p+2] = ((b * ms) >>> ss ) * pa;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tpx[p] = px[p+1] = px[p+2] = 0\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tp = ( x + (( ( p = y + ryp1) < h1 ? p : h1 ) * w )) << 2;\n\n\t\t\t\t\t\tr -= si.r - ( si.r = px[p]);\n\t\t\t\t\t\tg -= si.g - ( si.g = px[p+1]);\n\t\t\t\t\t\tb -= si.b - ( si.b = px[p+2]);\n\t\t\t\t\t\ta -= si.a - ( si.a = px[p+3]);\n\n\t\t\t\t\t\tsi = si.n;\n\n\t\t\t\t\t\tyi += w;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\treturn true;\n\t}\n\n}\n\n/**\n * Array of multiply values for blur calculations.\n * @type {Array}\n * @protected\n * @readonly\n * @static\n */\nBlurFilter.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];\n/**\n * Array of shift values for blur calculations.\n * @type {Array}\n * @protected\n * @static\n */\nBlurFilter.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];\n","/**\n * @license ColorFilter\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Filter from \"./Filter\";\n\n/**\n * Applies a color transform to DisplayObjects.\n *\n * @memberof easeljs\n * @extends easeljs.Filter\n * @example\n * let shape = new Shape().set({ x: 100, y: 100 });\n * shape.graphics.beginFill(\"#ff0000\").drawCircle(0,0,50);\n * shape.filters = [ new ColorFilter(0,0,0,1, 0,0,255,0) ];\n * shape.cache(-50, -50, 100, 100);\n *\n * @param {Number} [redMultiplier=1] The amount to multiply against the red channel. This is a range between 0 and 1.\n * @param {Number} [greenMultiplier=1] The amount to multiply against the green channel. This is a range between 0 and 1.\n * @param {Number} [blueMultiplier=1] The amount to multiply against the blue channel. This is a range between 0 and 1.\n * @param {Number} [alphaMultiplier=1] The amount to multiply against the alpha channel. This is a range between 0 and 1.\n * @param {Number} [redOffset=0] The amount to add to the red channel after it has been multiplied. This is a range\n * between -255 and 255.\n * @param {Number} [greenOffset=0] The amount to add to the green channel after it has been multiplied. This is a range\n * between -255 and 255.\n * @param {Number} [blueOffset=0] The amount to add to the blue channel after it has been multiplied. This is a range\n * between -255 and 255.\n * @param {Number} [alphaOffset=0] The amount to add to the alpha channel after it has been multiplied. This is a range\n * between -255 and 255.\n */\nexport default class ColorFilter extends Filter {\n\n\tconstructor (redMultiplier = 1, greenMultiplier = 1, blueMultiplier = 1, alphaMultiplier = 1, redOffset = 0, greenOffset = 0, blueOffset = 0, alphaOffset = 0) {\n\t\tsuper();\n\n\t\t/**\n\t\t * Red channel multiplier.\n\t\t * @type {Number}\n\t\t */\n\t\tthis.redMultiplier = redMultiplier;\n\n\t\t/**\n\t\t * Green channel multiplier.\n\t\t * @type {Number}\n\t\t */\n\t\tthis.greenMultiplier = greenMultiplier;\n\n\t\t/**\n\t\t * Blue channel multiplier.\n\t\t * @type {Number}\n\t\t */\n\t\tthis.blueMultiplier = blueMultiplier;\n\n\t\t/**\n\t\t * Alpha channel multiplier.\n\t\t * @type {Number}\n\t\t */\n\t\tthis.alphaMultiplier = alphaMultiplier;\n\n\t\t/**\n\t\t * Red channel offset (added to value).\n\t\t * @type {Number}\n\t\t */\n\t\tthis.redOffset = redOffset;\n\n\t\t/**\n\t\t * Green channel offset (added to value).\n\t\t * @type {Number}\n\t\t */\n\t\tthis.greenOffset = greenOffset;\n\n\t\t/**\n\t\t * Blue channel offset (added to value).\n\t\t * @type {Number}\n\t\t */\n\t\tthis.blueOffset = blueOffset;\n\n\t\t/**\n\t\t * Alpha channel offset (added to value).\n\t\t * @type {Number}\n\t\t */\n\t\tthis.alphaOffset = alphaOffset;\n\n\t\tthis.FRAG_SHADER_BODY = `\n\t\t\tuniform vec4 uColorMultiplier;\n\t\t\tuniform vec4 uColorOffset;\n\n\t\t\tvoid main (void) {\n\t\t\t\tvec4 color = texture2D(uSampler, vRenderCoord);\n\n\t\t\t\tgl_FragColor = (color * uColorMultiplier) + uColorOffset;\n\t\t\t}\n\t\t`;\n\n\t}\n\n\tshaderParamSetup (gl, stage, shaderProgram) {\n\t\tgl.uniform4f(\n\t\t\tgl.getUniformLocation(shaderProgram, \"uColorMultiplier\"),\n\t\t\tthis.redMultiplier, this.greenMultiplier, this.blueMultiplier, this.alphaMultiplier\n\t\t);\n\n\t\tgl.uniform4f(\n\t\t\tgl.getUniformLocation(shaderProgram, \"uColorOffset\"),\n\t\t\tthis.redOffset/255, this.greenOffset/255, this.blueOffset/255, this.alphaOffset/255\n\t\t);\n\t}\n\n\t/**\n\t * @return {easeljs.ColorFilter}\n\t */\n\tclone () {\n\t\treturn new ColorFilter(\n\t\t\tthis.redMultiplier, this.greenMultiplier, this.blueMultiplier, this.alphaMultiplier,\n\t\t\tthis.redOffset, this.greenOffset, this.blueOffset, this.alphaOffset\n\t\t);\n\t}\n\n\t_applyFilter (imageData) {\n\t\tlet data = imageData.data;\n\t\tconst l = data.length;\n\t\tfor (let i=0; i 0) ? 3*value/100 : value/100);\n\t\tlet lumR = 0.3086;\n\t\tlet lumG = 0.6094;\n\t\tlet lumB = 0.0820;\n\t\tthis._multiplyMatrix([\n\t\t\tlumR*(1-x)+x,lumG*(1-x),lumB*(1-x),0,0,\n\t\t\tlumR*(1-x),lumG*(1-x)+x,lumB*(1-x),0,0,\n\t\t\tlumR*(1-x),lumG*(1-x),lumB*(1-x)+x,0,0,\n\t\t\t0,0,0,1,0,\n\t\t\t0,0,0,0,1\n\t\t]);\n\t\treturn this;\n\t}\n\n\n\t/**\n\t * Adjusts the hue of the pixel color.\n\t * @param {Number} value A value between -180 & 180.\n\t * @return {easeljs.ColorMatrix} The ColorMatrix instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tadjustHue (value) {\n\t\tif (value === 0 || isNaN(value)) { return this; }\n\t\tvalue = this._cleanValue(value, 180)/180*Math.PI;\n\t\tlet cosVal = Math.cos(value);\n\t\tlet sinVal = Math.sin(value);\n\t\tlet lumR = 0.213;\n\t\tlet lumG = 0.715;\n\t\tlet lumB = 0.072;\n\t\tthis._multiplyMatrix([\n\t\t\tlumR+cosVal*(1-lumR)+sinVal*(-lumR),lumG+cosVal*(-lumG)+sinVal*(-lumG),lumB+cosVal*(-lumB)+sinVal*(1-lumB),0,0,\n\t\t\tlumR+cosVal*(-lumR)+sinVal*(0.143),lumG+cosVal*(1-lumG)+sinVal*(0.140),lumB+cosVal*(-lumB)+sinVal*(-0.283),0,0,\n\t\t\tlumR+cosVal*(-lumR)+sinVal*(-(1-lumR)),lumG+cosVal*(-lumG)+sinVal*(lumG),lumB+cosVal*(1-lumB)+sinVal*(lumB),0,0,\n\t\t\t0,0,0,1,0,\n\t\t\t0,0,0,0,1\n\t\t]);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Concatenates (multiplies) the specified matrix with this one.\n\t * @param {Array} matrix An array or ColorMatrix instance.\n\t * @return {easeljs.ColorMatrix} The ColorMatrix instance the method is called on (useful for chaining calls.)\n\t * @chainable\n\t */\n\tconcat (matrix) {\n\t\tmatrix = this._fixMatrix(matrix);\n\t\tif (matrix.length != ColorMatrix.LENGTH) { return this; }\n\t\tthis._multiplyMatrix(matrix);\n\t\treturn this;\n\t}\n\n\t/**\n\t * @return {easeljs.ColorMatrix} A clone of this ColorMatrix.\n\t */\n\tclone () {\n\t\treturn (new ColorMatrix()).copy(this);\n\t}\n\n\t/**\n\t * Return a length 25 (5x5) array instance containing this matrix's values.\n\t * @return {Array} An array holding this matrix's values.\n\t */\n\ttoArray () {\n\t\tconst arr = [];\n\t\tconst l = ColorMatrix.LENGTH;\n\t\tfor (let i=0; i ColorMatrix.LENGTH) {\n\t\t\tmatrix = matrix.slice(0, ColorMatrix.LENGTH);\n\t\t}\n\t\treturn matrix;\n\t}\n\n}\n\n/**\n * Array of delta values for contrast calculations.\n * @type {Array}\n * @protected\n * @readonly\n * @static\n */\nColorMatrix.DELTA_INDEX = Object.freeze([\n \t0, 0.01, 0.02, 0.04, 0.05, 0.06, 0.07, 0.08, 0.1, 0.11,\n \t0.12, 0.14, 0.15, 0.16, 0.17, 0.18, 0.20, 0.21, 0.22, 0.24,\n \t0.25, 0.27, 0.28, 0.30, 0.32, 0.34, 0.36, 0.38, 0.40, 0.42,\n \t0.44, 0.46, 0.48, 0.5, 0.53, 0.56, 0.59, 0.62, 0.65, 0.68,\n \t0.71, 0.74, 0.77, 0.80, 0.83, 0.86, 0.89, 0.92, 0.95, 0.98,\n \t1.0, 1.06, 1.12, 1.18, 1.24, 1.30, 1.36, 1.42, 1.48, 1.54,\n \t1.60, 1.66, 1.72, 1.78, 1.84, 1.90, 1.96, 2.0, 2.12, 2.25,\n \t2.37, 2.50, 2.62, 2.75, 2.87, 3.0, 3.2, 3.4, 3.6, 3.8,\n \t4.0, 4.3, 4.7, 4.9, 5.0, 5.5, 6.0, 6.5, 6.8, 7.0,\n \t7.3, 7.5, 7.8, 8.0, 8.4, 8.7, 9.0, 9.4, 9.6, 9.8,\n \t10.0\n]);\n/**\n * Identity matrix values.\n * @type {Array}\n * @protected\n * @readonly\n * @static\n */\nColorMatrix.IDENTITY_MATRIX = Object.freeze([\n \t1,0,0,0,0,\n \t0,1,0,0,0,\n \t0,0,1,0,0,\n \t0,0,0,1,0,\n \t0,0,0,0,1\n]);\n/**\n * The constant length of a color matrix.\n * @type {Number}\n * @protected\n * @readonly\n * @static\n */\nColorMatrix.LENGTH = 25;\n","/**\n * @license ColorMatrixFilter\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport Filter from \"./Filter\";\n\n/**\n * Allows you to carry out complex color operations such as modifying saturation, brightness, or inverting. See the\n * {@link easeljs.ColorMatrix} for more information on changing colors. For an easier color transform,\n * consider the {@link easeljs.ColorFilter}.\n *\n *\n * @memberof easeljs\n * @extends easeljs.Filter\n * @example\n * let shape = new Shape().set({ x: 100, y: 100 });\n * shape.graphics.beginFill(\"#ff0000\").drawCircle(0, 0, 50);\n * let matrix = new ColorMatrix().adjustHue(180).adjustSaturation(100);\n * shape.filters = [ new ColorMatrixFilter(matrix) ];\n * shape.cache(-50, -50, 100, 100);\n *\n * @param {Array | easeljs.ColorMatrix} matrix A 4x5 matrix describing the color operation to perform.\n */\nexport default class ColorMatrixFilter extends Filter {\n\n\tconstructor (matrix) {\n\t\tsuper();\n\n\t\t/**\n\t\t * A 4x5 matrix describing the color operation to perform.\n\t\t * @type {Array | easeljs.ColorMatrix}\n\t\t */\n\t\tthis.matrix = matrix;\n\n\t\tthis.FRAG_SHADER_BODY = `\n\t\t\tuniform mat4 uColorMatrix;\n\t\t\tuniform vec4 uColorMatrixOffset;\n\n\t\t\tvoid main (void) {\n\t\t\t\tvec4 color = texture2D(uSampler, vRenderCoord);\n\n\t\t\t\tmat4 m = uColorMatrix;\n\t\t\t\tvec4 newColor = vec4(0,0,0,0);\n\t\t\t\tnewColor.r = color.r*m[0][0] + color.g*m[0][1] + color.b*m[0][2] + color.a*m[0][3];\n\t\t\t\tnewColor.g = color.r*m[1][0] + color.g*m[1][1] + color.b*m[1][2] + color.a*m[1][3];\n\t\t\t\tnewColor.b = color.r*m[2][0] + color.g*m[2][1] + color.b*m[2][2] + color.a*m[2][3];\n\t\t\t\tnewColor.a = color.r*m[3][0] + color.g*m[3][1] + color.b*m[3][2] + color.a*m[3][3];\n\n\t\t\t\tgl_FragColor = newColor + uColorMatrixOffset;\n\t\t\t}\n\t\t`;\n\t}\n\n\tshaderParamSetup (gl, stage, shaderProgram) {\n\t\tlet mat = this.matrix;\n\t\tlet colorMatrix = new Float32Array([\n\t\t\tmat[0],mat[1],mat[2],mat[3],\n\t\t\tmat[5],mat[6],mat[7],mat[8],\n\t\t\tmat[10],mat[11],mat[12],mat[13],\n\t\t\tmat[15],mat[16],mat[17],mat[18]\n\t\t]);\n\n\t\tgl.uniformMatrix4fv(\n\t\t\tgl.getUniformLocation(shaderProgram, \"uColorMatrix\"),\n\t\t\tfalse, colorMatrix\n\t\t);\n\t\tgl.uniform4f(\n\t\t\tgl.getUniformLocation(shaderProgram, \"uColorMatrixOffset\"),\n\t\t\tmat[4]/255, mat[9]/255, mat[14]/255, mat[19]/255\n\t\t);\n\t}\n\n\t/**\n\t * @return {easeljs.ColorMatrixFilter}\n\t */\n\tclone () {\n\t\treturn new ColorMatrixFilter(this.matrix);\n\t}\n\n\t_applyFilter (imageData) {\n\t\tlet data = imageData.data;\n\t\tconst l = data.length;\n\t\tlet r,g,b,a;\n\t\tlet mtx = this.matrix;\n\t\tlet m0 = mtx[0], m1 = mtx[1], m2 = mtx[2], m3 = mtx[3], m4 = mtx[4];\n\t\tlet m5 = mtx[5], m6 = mtx[6], m7 = mtx[7], m8 = mtx[8], m9 = mtx[9];\n\t\tlet m10 = mtx[10], m11 = mtx[11], m12 = mtx[12], m13 = mtx[13], m14 = mtx[14];\n\t\tlet m15 = mtx[15], m16 = mtx[16], m17 = mtx[17], m18 = mtx[18], m19 = mtx[19];\n\n\t\tfor (let i=0; i {\n * // clicked\n * }));\n *\n * @param {easeljs.Sprite | easeljs.MovieClip} target The instance to manage.\n * @param {String} [outLabel=\"out\"] The label or animation to go to when the user rolls out of the button.\n * @param {String} [overLabel=\"over\"] The label or animation to go to when the user rolls over the button.\n * @param {String} [downLabel=\"down\"] The label or animation to go to when the user presses the button.\n * @param {Boolean} [play=false] If the helper should call \"gotoAndPlay\" or \"gotoAndStop\" on the button when changing\n * states.\n * @param {easeljs.DisplayObject} [hitArea] An optional item to use as the hit state for the button. If this is not defined,\n * then the button's visible states will be used instead. Note that the same instance as the \"target\" argument can be\n * used for the hitState.\n * @param {String} [hitLabel] The label or animation on the hitArea instance that defines the hitArea bounds. If this is\n * null, then the default state of the hitArea will be used.\n */\nexport default class ButtonHelper {\n\n\tconstructor (target, outLabel = \"out\", overLabel = \"over\", downLabel = \"down\", play = false, hitArea, hitLabel) {\n\t\tif (!target.addEventListener) { return; }\n\n\t\t/**\n\t\t * The target for this button helper.\n\t\t * @type {easeljs.MovieClip | easeljs.Sprite}\n\t\t * @readonly\n\t\t */\n\t\tthis.target = target;\n\n\t\t/**\n\t\t * The label name or frame number to display when the user mouses out of the target.\n\t\t * @default \"over\"\n\t\t * @type {String | Number}\n\t\t */\n\t\tthis.overLabel = overLabel;\n\n\t\t/**\n\t\t * The label name or frame number to display when the user mouses over the target.\n\t\t * @default \"out\"\n\t\t * @type {String | Number}\n\t\t */\n\t\tthis.outLabel = outLabel;\n\n\t\t/**\n\t\t * The label name or frame number to display when the user presses on the target.\n\t\t * @default \"down\"\n\t\t * @type {String | Number}\n\t\t */\n\t\tthis.downLabel = downLabel == null;\n\n\t\t/**\n\t\t * If true, then ButtonHelper will call gotoAndPlay, if false, it will use gotoAndStop.\n\t\t * @default false\n\t\t * @type {Boolean}\n\t\t */\n\t\tthis.play = play;\n\n\t\t/**\n\t\t * @type {Boolean}\n\t\t * @protected\n\t\t */\n\t\tthis._isPressed = false;\n\n\t\t/**\n\t\t * @type {Boolean}\n\t\t * @protected\n\t\t */\n\t\tthis._isOver = false;\n\n\t\t/**\n\t\t * @type {Boolean}\n\t\t * @protected\n\t\t */\n\t\tthis._enabled = false;\n\n\t\ttarget.mouseChildren = false; // prevents issues when children are removed from the display list when state changes.\n\t\tthis.enabled = true;\n\t\tthis.handleEvent({});\n\t\tif (hitArea) {\n\t\t\tif (hitLabel) {\n\t\t\t\thitArea.actionsEnabled = false;\n\t\t\t\thitArea.gotoAndStop&&hitArea.gotoAndStop(hitLabel);\n\t\t\t}\n\t\t\ttarget.hitArea = hitArea;\n\t\t}\n\t}\n\n\t/**\n\t * Enables or disables the button functionality on the target.\n\t * @type {Boolean}\n\t */\n\tget enabled () { return this._enabled; }\n\tset enabled (enabled) {\n\t\tif (enabled === this._enabled) { return; }\n\t\tlet o = this.target;\n\t\tthis._enabled = enabled;\n\t\tif (enabled) {\n\t\t\to.cursor = \"pointer\";\n\t\t\to.addEventListener(\"rollover\", this);\n\t\t\to.addEventListener(\"rollout\", this);\n\t\t\to.addEventListener(\"mousedown\", this);\n\t\t\to.addEventListener(\"pressup\", this);\n\t\t\tif (o._reset) { o.__reset = o._reset; o._reset = this._reset;}\n\t\t} else {\n\t\t\to.cursor = null;\n\t\t\to.removeEventListener(\"rollover\", this);\n\t\t\to.removeEventListener(\"rollout\", this);\n\t\t\to.removeEventListener(\"mousedown\", this);\n\t\t\to.removeEventListener(\"pressup\", this);\n\t\t\tif (o.__reset) { o._reset = o.__reset; delete(o.__reset); }\n\t\t}\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name}]`;\n\t}\n\n\t/**\n\t * @param {Object} evt The mouse event to handle.\n\t * @protected\n\t */\n\thandleEvent (evt) {\n\t\tlet label, t = this.target, type = evt.type;\n\t\tif (type === \"mousedown\") {\n\t\t\tthis._isPressed = true;\n\t\t\tlabel = this.downLabel;\n\t\t} else if (type === \"pressup\") {\n\t\t\tthis._isPressed = false;\n\t\t\tlabel = this._isOver ? this.overLabel : this.outLabel;\n\t\t} else if (type === \"rollover\") {\n\t\t\tthis._isOver = true;\n\t\t\tlabel = this._isPressed ? this.downLabel : this.overLabel;\n\t\t} else { // rollout and default\n\t\t\tthis._isOver = false;\n\t\t\tlabel = this._isPressed ? this.overLabel : this.outLabel;\n\t\t}\n\t\tif (this.play) {\n\t\t\tt.gotoAndPlay&&t.gotoAndPlay(label);\n\t\t} else {\n\t\t\tt.gotoAndStop&&t.gotoAndStop(label);\n\t\t}\n\t}\n\n\t/**\n\t * Injected into target. Preserves the paused state through a reset.\n\t * @protected\n\t */\n\t_reset () {\n\t\t// TODO: explore better ways to handle this issue. This is hacky & disrupts object signatures.\n\t\tlet p = this.paused;\n\t\tthis.__reset();\n\t\tthis.paused = p;\n\t}\n\n}\n","/**\n * @license Touch\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * Global utility for working with multi-touch enabled devices in EaselJS. Currently supports W3C Touch API (iOS and\n * modern Android browser) and the Pointer API (IE), including ms-prefixed events in IE10, and unprefixed in IE11.\n *\n * Ensure that you {{#crossLink \"Touch/disable\"}}{{/crossLink}} touch when cleaning up your application. You do not have\n * to check if touch is supported to enable it, as it will fail gracefully if it is not supported.\n *\n * Note: It is important to disable Touch on a stage that you are no longer using:\n *\n * @memberof easeljs\n * @name easeljs.Touch\n * @example\n * let stage = new Stage(\"canvasId\");\n * Touch.enable(stage);\n */\nexport default {\n\n\t/**\n\t * Returns `true` if touch is supported in the current browser.\n\t * @return {Boolean} Indicates whether touch is supported in the current browser.\n\t */\n\tisSupported () {\n\t\treturn\t!!(('ontouchstart' in window) // iOS & Android\n\t\t\t|| (window.MSPointerEvent && window.navigator.msMaxTouchPoints > 0) // IE10\n\t\t\t|| (window.PointerEvent && window.navigator.maxTouchPoints > 0)); // IE11+\n\t},\n\n\t/**\n\t * Enables touch interaction for the specified EaselJS {@link easeljs.Stage}. Currently supports iOS\n\t * (and compatible browsers, such as modern Android browsers), and IE10/11. Supports both single touch and\n\t * multi-touch modes. Extends the EaselJS {@link easeljs.MouseEvent} model, but without support for\n\t * double click or over/out events.\n\t * @param {easeljs.Stage} stage The Stage to enable touch on.\n\t * @param {Boolean} [singleTouch=false] If `true`, only a single touch will be active at a time.\n\t * @param {Boolean} [allowDefault=false] If `true`, then default gesture actions (ex. scrolling, zooming) will be\n\t * allowed when the user is interacting with the target canvas.\n\t * @return {Boolean} Returns `true` if touch was successfully enabled on the target stage.\n\t */\n\tenable (stage, singleTouch = false, allowDefault = false) {\n\t\tif (!stage || !stage.canvas || !this.isSupported()) { return false; }\n\t\tif (stage.__touch) { return true; }\n\n\t\t// inject required properties on stage:\n\t\tstage.__touch = {pointers:{}, multitouch:!singleTouch, preventDefault:!allowDefault, count:0};\n\n\t\t// note that in the future we may need to disable the standard mouse event model before adding\n\t\t// these to prevent duplicate calls. It doesn't seem to be an issue with iOS devices though.\n\t\tif ('ontouchstart' in window) { this._IOS_enable(stage); }\n\t\telse if (window.PointerEvent || window.MSPointerEvent) { this._IE_enable(stage); }\n\t\treturn true;\n\t},\n\n\t/**\n\t * Removes all listeners that were set up when calling `Touch.enable()` on a stage.\n\t * @param {easeljs.Stage} stage The Stage to disable touch on.\n\t */\n\tdisable (stage) {\n\t\tif (!stage) { return; }\n\t\tif ('ontouchstart' in window) { this._IOS_disable(stage); }\n\t\telse if (window.PointerEvent || window.MSPointerEvent) { this._IE_disable(stage); }\n\t\tdelete stage.__touch;\n\t},\n\n\t/**\n\t * @private\n\t * @param {easeljs.Stage} stage\n\t */\n\t_IOS_enable (stage) {\n\t\tlet canvas = stage.canvas;\n\t\tlet f = stage.__touch.f = e => this._IOS_handleEvent(stage, e);\n\t\tcanvas.addEventListener(\"touchstart\", f, false);\n\t\tcanvas.addEventListener(\"touchmove\", f, false);\n\t\tcanvas.addEventListener(\"touchend\", f, false);\n\t\tcanvas.addEventListener(\"touchcancel\", f, false);\n\t},\n\n\t/**\n\t * @private\n\t * @param {easeljs.Stage} stage\n\t */\n\t_IOS_disable (stage) {\n\t\tlet canvas = stage.canvas;\n\t\tif (!canvas) { return; }\n\t\tlet f = stage.__touch.f;\n\t\tcanvas.removeEventListener(\"touchstart\", f, false);\n\t\tcanvas.removeEventListener(\"touchmove\", f, false);\n\t\tcanvas.removeEventListener(\"touchend\", f, false);\n\t\tcanvas.removeEventListener(\"touchcancel\", f, false);\n\t},\n\n\t/**\n\t * @private\n\t * @param {easeljs.Stage} stage\n\t * @param {Object} e The event to handle\n\t */\n\t_IOS_handleEvent (stage, e) {\n\t\tif (!stage) { return; }\n\t\tif (stage.__touch.preventDefault) { e.preventDefault&&e.preventDefault(); }\n\t\tlet touches = e.changedTouches;\n\t\tlet type = e.type;\n\t\tconst l = touches.length;\n\t\tfor (let touch of touches) {\n\t\t\tlet id = touch.identifier;\n\t\t\tif (touch.target != stage.canvas) { continue; }\n\n\t\t\tif (type === \"touchstart\") {\n\t\t\t\tthis._handleStart(stage, id, e, touch.pageX, touch.pageY);\n\t\t\t} else if (type === \"touchmove\") {\n\t\t\t\tthis._handleMove(stage, id, e, touch.pageX, touch.pageY);\n\t\t\t} else if (type === \"touchend\" || type === \"touchcancel\") {\n\t\t\t\tthis._handleEnd(stage, id, e);\n\t\t\t}\n\t\t}\n\t},\n\n\t/**\n\t * @private\n\t * @param {easeljs.Stage} stage\n\t */\n\t_IE_enable (stage) {\n\t\tlet canvas = stage.canvas;\n\t\tlet f = stage.__touch.f = e => this._IE_handleEvent(stage,e);\n\n\t\tif (window.PointerEvent === undefined) {\n\t\t\tcanvas.addEventListener(\"MSPointerDown\", f, false);\n\t\t\twindow.addEventListener(\"MSPointerMove\", f, false);\n\t\t\twindow.addEventListener(\"MSPointerUp\", f, false);\n\t\t\twindow.addEventListener(\"MSPointerCancel\", f, false);\n\t\t\tif (stage.__touch.preventDefault) { canvas.style.msTouchAction = \"none\"; }\n\t\t} else {\n\t\t\tcanvas.addEventListener(\"pointerdown\", f, false);\n\t\t\twindow.addEventListener(\"pointermove\", f, false);\n\t\t\twindow.addEventListener(\"pointerup\", f, false);\n\t\t\twindow.addEventListener(\"pointercancel\", f, false);\n\t\t\tif (stage.__touch.preventDefault) { canvas.style.touchAction = \"none\"; }\n\n\t\t}\n\t\tstage.__touch.activeIDs = {};\n\t},\n\n\t/**\n\t * @private\n\t * @param {easeljs.Stage} stage\n\t */\n\t_IE_disable (stage) {\n\t\tlet f = stage.__touch.f;\n\n\t\tif (window.PointerEvent === undefined) {\n\t\t\twindow.removeEventListener(\"MSPointerMove\", f, false);\n\t\t\twindow.removeEventListener(\"MSPointerUp\", f, false);\n\t\t\twindow.removeEventListener(\"MSPointerCancel\", f, false);\n\t\t\tif (stage.canvas) {\n\t\t\t\tstage.canvas.removeEventListener(\"MSPointerDown\", f, false);\n\t\t\t}\n\t\t} else {\n\t\t\twindow.removeEventListener(\"pointermove\", f, false);\n\t\t\twindow.removeEventListener(\"pointerup\", f, false);\n\t\t\twindow.removeEventListener(\"pointercancel\", f, false);\n\t\t\tif (stage.canvas) {\n\t\t\t\tstage.canvas.removeEventListener(\"pointerdown\", f, false);\n\t\t\t}\n\t\t}\n\t},\n\n\t/**\n\t * @private\n\t * @param {easeljs.Stage} stage\n\t * @param {Object} e The event to handle.\n\t */\n\t_IE_handleEvent (stage, e) {\n\t\tif (!stage) { return; }\n\t\tif (stage.__touch.preventDefault) { e.preventDefault && e.preventDefault(); }\n\t\tlet type = e.type;\n\t\tlet id = e.pointerId;\n\t\tlet ids = stage.__touch.activeIDs;\n\n\t\tif (type === \"MSPointerDown\" || type === \"pointerdown\") {\n\t\t\tif (e.srcElement != stage.canvas) { return; }\n\t\t\tids[id] = true;\n\t\t\tthis._handleStart(stage, id, e, e.pageX, e.pageY);\n\t\t} else if (ids[id]) { // it's an id we're watching\n\t\t\tif (type === \"MSPointerMove\" || type === \"pointermove\") {\n\t\t\t\tthis._handleMove(stage, id, e, e.pageX, e.pageY);\n\t\t\t} else if (type === \"MSPointerUp\" || type === \"MSPointerCancel\"\n\t\t\t\t\t|| type === \"pointerup\" || type === \"pointercancel\") {\n\t\t\t\tdelete(ids[id]);\n\t\t\t\tthis._handleEnd(stage, id, e);\n\t\t\t}\n\t\t}\n\t},\n\n\t/**\n\t * @private\n\t * @param {easeljs.Stage} stage\n\t * @param {String | Number} id\n\t * @param {Object} e\n\t * @param {Number} x\n\t * @param {Number} y\n\t */\n\t_handleStart (stage, id, e, x, y) {\n\t\tlet props = stage.__touch;\n\t\tif (!props.multitouch && props.count) { return; }\n\t\tlet ids = props.pointers;\n\t\tif (ids[id]) { return; }\n\t\tids[id] = true;\n\t\tprops.count++;\n\t\tstage._handlePointerDown(id, e, x, y);\n\t},\n\n\t/**\n\t * @private\n\t * @param {easeljs.Stage} stage\n\t * @param {String | Number} id\n\t * @param {Object} e\n\t * @param {Number} x\n\t * @param {Number} y\n\t */\n\t_handleMove (stage, id, e, x, y) {\n\t\tif (!stage.__touch.pointers[id]) { return; }\n\t\tstage._handlePointerMove(id, e, x, y);\n\t},\n\n\t/**\n\t * @private\n\t * @param {easeljs.Stage} stage\n\t * @param {String | Number} id\n\t * @param {Object} e\n\t */\n\t_handleEnd (stage, id, e) {\n\t\t// TODO: cancel should be handled differently for proper UI (ex. an up would trigger a click, a cancel would more closely resemble an out).\n\t\tlet props = stage.__touch;\n\t\tlet ids = props.pointers;\n\t\tif (!ids[id]) { return; }\n\t\tprops.count--;\n\t\tstage._handlePointerUp(id, e, true);\n\t\tdelete(ids[id]);\n\t}\n\n}\n","/**\n * @license SpriteSheetBuilder\n * Visit http://createjs.com/ for documentation, updates and examples.\n *\n * Copyright (c) 2017 gskinner.com, inc.\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the\n * Software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\nimport { EventDispatcher, Event } from \"@createjs/core\";\nimport Rectangle from \"../geom/Rectangle\";\nimport SpriteSheet from \"../display/SpriteSheet\";\n\n/**\n * The SpriteSheetBuilder allows you to generate {@link easeljs.SpriteSheet} instances at run time\n * from any display object. This can allow you to maintain your assets as vector graphics (for low file size), and\n * render them at run time as SpriteSheets for better performance.\n *\n * SpriteSheets can be built either synchronously, or asynchronously, so that large SpriteSheets can be generated\n * without locking the UI.\n *\n * Note that the \"images\" used in the generated SpriteSheet are actually canvas elements, and that they will be\n * sized to the nearest power of 2 up to the value of {@link easeljs.SpriteSheetBuilder#maxWidth}\n * or {@link easeljs.SpriteSheetBuilder#maxHeight}.\n *\n * @memberof easeljs\n * @extends core.EventDispatcher\n *\n * @param {Number} [framerate=0] The {{#crossLink \"SpriteSheet/framerate:property\"}}{{/crossLink}} of\n * {@link easeljs.SpriteSheet} instances that are created.\n */\nexport default class SpriteSheetBuilder extends EventDispatcher {\n\n\tconstructor (framerate = 0) {\n\t\tsuper();\n\n\t\t/**\n\t\t * The maximum width for the images (not individual frames) in the generated SpriteSheet. It is recommended to\n\t\t * use a power of 2 for this value (ex. 1024, 2048, 4096). If the frames cannot all fit within the max\n\t\t * dimensions, then additional images will be created as needed.\n\t\t * @type {Number}\n\t\t * @default 2048\n\t\t*/\n\t\tthis.maxWidth = 2048;\n\n\t\t/**\n\t\t * The maximum height for the images (not individual frames) in the generated SpriteSheet. It is recommended to\n\t\t * use a power of 2 for this value (ex. 1024, 2048, 4096). If the frames cannot all fit within the max\n\t\t * dimensions, then additional images will be created as needed.\n\t\t * @type {Number}\n\t\t * @default 2048\n\t\t */\n\t\tthis.maxHeight = 2048;\n\n\t\t/**\n\t\t * The SpriteSheet that was generated. This will be null before a build is completed successfully.\n\t\t * @type {easeljs.SpriteSheet}\n\t\t */\n\t\tthis.spriteSheet = null;\n\n\t\t/**\n\t\t * The scale to apply when drawing all frames to the SpriteSheet. This is multiplied against any scale specified\n\t\t * in the addFrame call. This can be used, for example, to generate a SpriteSheet at run time that is tailored\n\t\t * to the a specific device resolution (ex. tablet vs mobile).\n\t\t * @type {Number}\n\t\t * @default 1\n\t\t */\n\t\tthis.scale = 1;\n\n\t\t/**\n\t\t* The padding to use between frames. This is helpful to preserve antialiasing on drawn vector content.\n\t\t* @type {Number}\n\t\t* @default 1\n\t\t*/\n\t\tthis.padding = 1;\n\n\t\t/**\n\t\t * A number from 0.01 to 0.99 that indicates what percentage of time the builder can use. This can be\n\t\t * thought of as the number of seconds per second the builder will use. For example, with a timeSlice value of 0.3,\n\t\t * the builder will run 20 times per second, using approximately 15ms per build (30% of available time, or 0.3s per second).\n\t\t * Defaults to 0.3.\n\t\t * @type {Number}\n\t\t * @default 0.3\n\t\t */\n\t\tthis.timeSlice = 0.3;\n\n\t\t/**\n\t\t * A value between 0 and 1 that indicates the progress of a build, or -1 if a build has not\n\t\t * been initiated.\n\t\t * @type {Number}\n\t\t * @default -1\n\t\t * @readonly\n\t\t */\n\t\tthis.progress = -1;\n\n\t\t/**\n\t\t * A {@link easeljs.SpriteSheet#framerate} value that will be passed to new SpriteSheet instances that are\n\t\t * created. If no framerate is specified (or it is 0), then SpriteSheets will use the {@link core.Ticker} framerate.\n\t\t * @type {Number}\n\t\t * @default 0\n\t\t */\n\t\tthis.framerate = framerate;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Array}\n\t\t */\n\t\tthis._frames = [];\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Array}\n\t\t */\n\t\tthis._animations = {};\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Array}\n\t\t */\n\t\tthis._data = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._nextFrameIndex = 0;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._index = 0;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._timerID = null;\n\n\t\t/**\n\t\t * @protected\n\t\t * @type {Number}\n\t\t */\n\t\tthis._scale = 1;\n\t}\n\n\t/**\n\t * Adds a frame to the {@link easeljs.SpriteSheet}. Note that the frame will not be drawn until you\n\t * call {@link easeljs.SpriteSheetBuilder#build} method. The optional setup params allow you to have\n\t * a function run immediately before the draw occurs. For example, this allows you to add a single source multiple\n\t * times, but manipulate it or its children to change it to generate different frames.\n\t *\n\t * Note that the source's transformations (x, y, scale, rotate, alpha) will be ignored, except for regX/Y. To apply\n\t * transforms to a source object and have them captured in the SpriteSheet, simply place it into a {@link easeljs.Container}\n\t * and pass in the Container as the source.\n\t * @param {easeljs.DisplayObject} source The source {{#crossLink \"DisplayObject\"}}{{/crossLink}} to draw as the frame.\n\t * @param {easeljs.Rectangle} [sourceRect] A {{#crossLink \"Rectangle\"}}{{/crossLink}} defining the portion of the\n\t * source to draw to the frame. If not specified, it will look for a `getBounds` method, bounds property, or\n\t * `nominalBounds` property on the source to use. If one is not found, the frame will be skipped.\n\t * @param {Number} [scale=1] Optional. The scale to draw this frame at. Default is 1.\n\t * @param {Function} [setupFunction] A function to call immediately before drawing this frame. It will be called with two parameters: the source, and setupData.\n\t * @param {Object} [setupData] Arbitrary setup data to pass to setupFunction as the second parameter.\n\t * @return {Number} The index of the frame that was just added, or null if a sourceRect could not be determined.\n\t */\n\taddFrame (source, sourceRect, scale = 1, setupFunction, setupData) {\n\t\tif (this._data) { throw SpriteSheetBuilder.ERR_RUNNING; }\n\t\tlet rect = sourceRect||source.bounds||source.nominalBounds||(source.getBounds&&source.getBounds());\n\t\tif (!rect) { return null; }\n\t\treturn this._frames.push({ source, sourceRect: rect, scale, funct: setupFunction, data: setupData, index: this._frames.length, height: rect.height*scale }) - 1;\n\t}\n\n\t/**\n\t * Adds an animation that will be included in the created {@link easeljs.SpriteSheet}.\n\t * @param {String} name The name for the animation.\n\t * @param {Array} frames An array of frame indexes that comprise the animation. Ex. [3,6,5] would describe an animation\n\t * that played frame indexes 3, 6, and 5 in that order.\n\t * @param {String} [next] Specifies the name of the animation to continue to after this animation ends. You can\n\t * also pass false to have the animation stop when it ends. By default it will loop to the start of the same animation.\n\t * @param {Number} [speed] Specifies a frame advance speed for this animation. For example, a value of 0.5 would\n\t * cause the animation to advance every second tick. Note that earlier versions used `frequency` instead, which had\n\t * the opposite effect.\n\t */\n\taddAnimation (name, frames, next, speed) {\n\t\tif (this._data) { throw SpriteSheetBuilder.ERR_RUNNING; }\n\t\tthis._animations[name] = { frames, next, speed };\n\t}\n\n\t/**\n\t * This will take a {@link easeljs.MovieClip} instance, and add its frames and labels to this\n\t * builder. Labels will be added as an animation running from the label index to the next label. For example, if\n\t * there is a label named \"foo\" at frame 0 and a label named \"bar\" at frame 10, in a MovieClip with 15 frames, it\n\t * will add an animation named \"foo\" that runs from frame index 0 to 9, and an animation named \"bar\" that runs from\n\t * frame index 10 to 14.\n\t *\n\t * Note that this will iterate through the full MovieClip with {@link easeljs.MovieClip#actionsEnabled}\n\t * set to `false`, ending on the last frame.\n\t * @param {easeljs.MovieClip} source The source MovieClip instance to add to the SpriteSheet.\n\t * @param {easeljs.Rectangle} [sourceRect] A Rectangle defining the portion of the source to\n\t * draw to the frame. If not specified, it will look for a {{#crossLink \"DisplayObject/getBounds\"}}{{/crossLink}}\n\t * method, `frameBounds` Array, `bounds` property, or `nominalBounds` property on the source to use. If one is not\n\t * found, the MovieClip will be skipped.\n\t * @param {Number} [scale=1] The scale to draw the movie clip at.\n\t * @param {Function} [setupFunction] A function to call immediately before drawing each frame. It will be called\n\t * with three parameters: the source, setupData, and the frame index.\n\t * @param {Object} [setupData] Arbitrary setup data to pass to setupFunction as the second parameter.\n\t * @param {Function} [labelFunction] This method will be called for each MovieClip label that is added with four\n\t * parameters: the label name, the source MovieClip instance, the starting frame index (in the movieclip timeline)\n\t * and the end index. It must return a new name for the label/animation, or `false` to exclude the label.\n\t */\n\taddMovieClip (source, sourceRect, scale = 1, setupFunction, setupData, labelFunction) {\n\t\tif (this._data) { throw SpriteSheetBuilder.ERR_RUNNING; }\n\t\tlet rects = source.frameBounds;\n\t\tlet rect = sourceRect||source.bounds||source.nominalBounds||(source.getBounds&&source.getBounds());\n\t\tif (!rect && !rects) { return; }\n\n\t\tlet baseFrameIndex = this._frames.length;\n\t\tconst duration = source.timeline.duration;\n\t\tfor (let i=0; i a.index-b.index);\n\t\t\tfor (let i=0,l=lbls.length; i this._run(), 50-Math.max(0.01, Math.min(0.99, this.timeSlice||0.3))*50);\n\t}\n\n\t/**\n\t * Stops the current asynchronous build.\n\t */\n\tstopAsync () {\n\t\tclearTimeout(this._timerID);\n\t\tthis._data = null;\n\t}\n\n\t/**\n\t * Returns a string representation of this object.\n\t * @override\n\t * @return {String} a string representation of the instance.\n\t */\n\ttoString () {\n\t\treturn `[${this.constructor.name}]`;\n\t}\n\n\t/**\n\t * @protected\n\t */\n\t_startBuild () {\n\t\tlet pad = this.padding||0;\n\t\tthis.progress = 0;\n\t\tthis.spriteSheet = null;\n\t\tthis._index = 0;\n\t\tthis._scale = this.scale;\n\t\tlet dataFrames = [];\n\t\tthis._data = {\n\t\t\timages: [],\n\t\t\tframes: dataFrames,\n\t\t\tframerate: this.framerate,\n\t\t\tanimations: this._animations // TODO: should we \"clone\" _animations in case someone adds more animations after a build?\n\t\t};\n\n\t\tlet frames = this._frames.slice();\n\t\tframes.sort((a, b) => (a.height<=b.height) ? -1 : 1);\n\n\t\tif (frames[frames.length-1].height+pad*2 > this.maxHeight) { throw SpriteSheetBuilder.ERR_DIMENSIONS; }\n\t\tlet y=0, x=0;\n\t\tlet img = 0;\n\t\twhile (frames.length) {\n\t\t\tlet o = this._fillRow(frames, y, img, dataFrames, pad);\n\t\t\tif (o.w > x) { x = o.w; }\n\t\t\ty += o.h;\n\t\t\tif (!o.h || !frames.length) {\n\t\t\t\tlet canvas = window.createjs&&createjs.createCanvas?createjs.createCanvas():document.createElement(\"canvas\");\n\t\t\t\tcanvas.width = this._getSize(x,this.maxWidth);\n\t\t\t\tcanvas.height = this._getSize(y,this.maxHeight);\n\t\t\t\tthis._data.images[img] = canvas;\n\t\t\t\tif (!o.h) {\n\t\t\t\t\tx=y=0;\n\t\t\t\t\timg++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\n\t/**\n\t * @protected\n\t * @return {Number} The width & height of the row.\n\t */\n\t_setupMovieClipFrame (source, data) {\n\t\tlet ae = source.actionsEnabled;\n\t\tsource.actionsEnabled = false;\n\t\tsource.gotoAndStop(data.i);\n\t\tsource.actionsEnabled = ae;\n\t\tdata.f&&data.f(source, data.d, data.i);\n\t}\n\n\t/**\n\t * @protected\n\t * @return {Number} The width & height of the row.\n\t */\n\t_getSize (size, max) {\n\t\tlet pow = 4;\n\t\twhile (Math.pow(2, ++pow) < size) {}\n\t\treturn Math.min(max, Math.pow(2, pow));\n\t};\n\n\t/**\n\t * @protected\n\t * @param {Array} frames\n\t * @param {Number} y\n\t * @param {HTMLImageElement} img\n\t * @param {Object} dataFrames\n\t * @param {Number} pad\n\t * @return {Number} The width & height of the row.\n\t */\n\t_fillRow (frames, y, img, dataFrames, pad) {\n\t\tlet w = this.maxWidth;\n\t\tlet maxH = this.maxHeight;\n\t\ty += pad;\n\t\tlet h = maxH-y;\n\t\tlet x = pad;\n\t\tlet height = 0;\n\t\tfor (let i=frames.length-1; i>=0; i--) {\n\t\t\tlet frame = frames[i];\n\t\t\tlet sc = this._scale*frame.scale;\n\t\t\tlet rect = frame.sourceRect;\n\t\t\tlet source = frame.source;\n\t\t\tlet rx = Math.floor(sc*rect.x-pad);\n\t\t\tlet ry = Math.floor(sc*rect.y-pad);\n\t\t\tlet rh = Math.ceil(sc*rect.height+pad*2);\n\t\t\tlet rw = Math.ceil(sc*rect.width+pad*2);\n\t\t\tif (rw > w) { throw SpriteSheetBuilder.ERR_DIMENSIONS; }\n\t\t\tif (rh > h || x+rw > w) { continue; }\n\t\t\tframe.img = img;\n\t\t\tframe.rect = new Rectangle(x,y,rw,rh);\n\t\t\theight = height || rh;\n\t\t\tframes.splice(i,1);\n\t\t\tdataFrames[frame.index] = [x,y,rw,rh,img,Math.round(-rx+sc*source.regX-pad),Math.round(-ry+sc*source.regY-pad)];\n\t\t\tx += rw;\n\t\t}\n\t\treturn {w:x, h:height};\n\t}\n\n\t/**\n\t * @protected\n\t */\n\t_endBuild () {\n\t\tthis.spriteSheet = new SpriteSheet(this._data);\n\t\tthis._data = null;\n\t\tthis.progress = 1;\n\t\tthis.dispatchEvent(\"complete\");\n\t}\n\n\t/**\n\t * @protected\n\t */\n\t_run () {\n\t\tlet ts = Math.max(0.01, Math.min(0.99, this.timeSlice||0.3))*50;\n\t\tlet t = (new Date()).getTime()+ts;\n\t\tlet complete = false;\n\t\twhile (t > (new Date()).getTime()) {\n\t\t\tif (!this._drawNext()) { complete = true; break; }\n\t\t}\n\t\tif (complete) {\n\t\t\tthis._endBuild();\n\t\t} else {\n\t\t\tthis._timerID = setTimeout(() => this._run(), 50-ts);\n\t\t}\n\t\tlet p = this.progress = this._index/this._frames.length;\n\t\tif (this.hasEventListener(\"progress\")) {\n\t\t\tlet evt = new Event(\"progress\");\n\t\t\tevt.progress = p;\n\t\t\tthis.dispatchEvent(evt);\n\t\t}\n\t}\n\n\t/**\n\t * @protected\n\t * @return {Boolean} Returns false if this is the last draw.\n\t */\n\t_drawNext () {\n\t\tlet frame = this._frames[this._index];\n\t\tlet sc = frame.scale*this._scale;\n\t\tlet rect = frame.rect;\n\t\tlet sourceRect = frame.sourceRect;\n\t\tlet canvas = this._data.images[frame.img];\n\t\tlet ctx = canvas.getContext(\"2d\");\n\t\tframe.funct&&frame.funct(frame.source, frame.data);\n\t\tctx.save();\n\t\tctx.beginPath();\n\t\tctx.rect(rect.x, rect.y, rect.width, rect.height);\n\t\tctx.clip();\n\t\tctx.translate(Math.ceil(rect.x-sourceRect.x*sc), Math.ceil(rect.y-sourceRect.y*sc));\n\t\tctx.scale(sc,sc);\n\t\tframe.source.draw(ctx); // display object will draw itself.\n\t\tctx.restore();\n\t\treturn (++this._index) < this._frames.length;\n\t}\n\n}\n\n/**\n * @static\n * @readonly\n * @protected\n * @type {String}\n */\nSpriteSheetBuilder.ERR_DIMENSIONS = \"frame dimensions exceed max spritesheet dimensions\";\n/**\n * @static\n * @readonly\n * @protected\n * @type {String}\n */\nSpriteSheetBuilder.ERR_RUNNING = \"a build is already running\";\n\n/**\n * Dispatched when a build completes.\n * @event easeljs.SpriteSheetBuilder#complete\n * @property {Object} target The object that dispatched the event.\n * @property {String} type The event type.\n * @since 0.6.0\n */\n\n/**\n * Dispatched when an asynchronous build has progress.\n * @event easeljs.SpriteSheetBuilder#progress\n * @property {Object} target The object that dispatched the event.\n * @property {String} type The event type.\n * @property {Number} progress The current progress value (0-1).\n * @since 0.6.0\n */\n","/*\n* @license SpriteSheetUtils\n* Visit http://createjs.com/ for documentation, updates and examples.\n*\n* Copyright (c) 2017 gskinner.com, inc.\n*\n* Permission is hereby granted, free of charge, to any person\n* obtaining a copy of this software and associated documentation\n* files (the \"Software\"), to deal in the Software without\n* restriction, including without limitation the rights to use,\n* copy, modify, merge, publish, distribute, sublicense, and/or sell\n* copies of the Software, and to permit persons to whom the\n* Software is furnished to do so, subject to the following\n* conditions:\n*\n* The above copyright notice and this permission notice shall be\n* included in all copies or substantial portions of the Software.\n*\n* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n* OTHER DEALINGS IN THE SOFTWARE.\n*/\n\nimport createCanvas from \"./Canvas\";\n\n/**\n * The SpriteSheetUtils class is a collection of static methods for working with {{#crossLink \"SpriteSheet\"}}{{/crossLink}}s.\n * A sprite sheet is a series of images (usually animation frames) combined into a single image on a regular grid. For\n * example, an animation consisting of 8 100x100 images could be combined into a 400x200 sprite sheet (4 frames across\n * by 2 high). The SpriteSheetUtils class uses a static interface and should not be instantiated.\n *\n * @memberof easeljs\n * @name easeljs.SpriteSheetUtils\n */\nexport default {\n\n\t/**\n\t * @protected\n\t * @type {HTMLCanvasElement | Object}\n\t */\n\t_workingCanvas: createCanvas(),\n\n\t/**\n\t * @protected\n\t * @type {CanvasRenderingContext2D}\n\t */\n\tget _workingContext () { return this._workingCanvas.getContext(\"2d\"); },\n\n\t/**\n\t * Returns a single frame of the specified sprite sheet as a new PNG image. An example of when this may be useful is\n\t * to use a spritesheet frame as the source for a bitmap fill.\n\t *\n\t * WARNING: In almost all cases it is better to display a single frame using a {@link easeljs.Sprite}\n\t * with a {@link easeljs.Sprite#gotoAndStop} call than it is to slice out a frame using this\n\t * method and display it with a Bitmap instance. You can also crop an image using the {@link easeljs.Bitmap#sourceRect}\n\t * property of {@link easeljs.Bitmap}.\n\t *\n\t * The extractFrame method may cause cross-domain warnings since it accesses pixels directly on the canvas.\n\t *\n\t * @param {easeljs.SpriteSheet} spriteSheet The SpriteSheet instance to extract a frame from.\n\t * @param {Number | String} frameOrAnimation The frame number or animation name to extract. If an animation\n\t * name is specified, only the first frame of the animation will be extracted.\n\t * @return {HTMLImageElement} a single frame of the specified sprite sheet as a new PNG image.\n\t */\n\textractFrame (spriteSheet, frameOrAnimation) {\n\t\tif (isNaN(frameOrAnimation)) {\n\t\t\tframeOrAnimation = spriteSheet.getAnimation(frameOrAnimation).frames[0];\n\t\t}\n\t\tlet data = spriteSheet.getFrame(frameOrAnimation);\n\t\tif (!data) { return null; }\n\t\tlet r = data.rect;\n\t\tlet canvas = this._workingCanvas;\n\t\tcanvas.width = r.width;\n\t\tcanvas.height = r.height;\n\t\tthis._workingContext.drawImage(data.image, r.x, r.y, r.width, r.height, 0, 0, r.width, r.height);\n\t\tlet img = document.createElement(\"img\");\n\t\timg.src = canvas.toDataURL(\"image/png\");\n\t\treturn img;\n\t},\n\n\t/**\n\t * @protected\n\t * @param {easeljs.SpriteSheet} spriteSheet\n\t * @param {Number} count\n\t * @param {Number} h\n\t * @param {Number} v\n\t */\n\t_flip (spriteSheet, count, h, v) {\n\t\tlet imgs = spriteSheet._images;\n\t\tlet canvas = this._workingCanvas;\n\t\tlet ctx = this._workingContext;\n\t\tconst il = imgs.length/count;\n\t\tfor (let i=0; i {\n\t\t\tif (a.element._drawID === stage._drawID) { return 1; }\n\t\t\tif (a.element._drawID < b.element._drawID) { return -1; }\n\t\t\treturn 0;\n\t\t});\n\n\t\tconst l = output.length;\n\t\tfor (let i=0; i=.97*(this._interval-1)&&this._tick()},t._handleRAF=function(){this._timerId=null,this._setupTick(),this._tick()},t._handleTimeout=function(){this._timerId=null,this._setupTick(),this._tick()},t._setupTick=function(){if(null==this._timerId){var t=this.timingMode||this._raf&&i.RAF;if(t===i.RAF_SYNCHED||t===i.RAF){var e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;if(e)return this._timerId=e(t===i.RAF?this._handleRAF.bind(this):this._handleSynch.bind(this)),void(this._raf=!0)}this._raf=!1,this._timerId=setTimeout(this._handleTimeout.bind(this),this._interval)}},t._tick=function(){var t=this.paused,e=this._getTime(),i=e-this._lastTime;if(this._lastTime=e,this._ticks++,t&&(this._pausedTicks++,this._pausedTime+=i),this.hasEventListener("tick")){var n=new h("tick"),r=this.maxDelta;n.delta=r&&rthis.x+this.width&&(this.width=t+i-this.x),e+n>this.y+this.height&&(this.height=e+n-this.y),t=this.x&&t+i<=this.x+this.width&&e>=this.y&&e+n<=this.y+this.height},t.union=function(t){return this.clone().extend(t.x,t.y,t.width,t.height)},t.intersection=function(t){var e=t.x,i=t.y,n=e+t.width,r=i+t.height;return this.x>e&&(e=this.x),this.y>i&&(i=this.y),this.x+this.widththis.children.length)return e[n-2];if(2this.children.length-1)return!1;var i=this.children[t];return i&&(i.parent=null),this.children.splice(t,1),e||i.dispatchEvent("removed"),!0},t._getObjectsUnderPoint=function(t,e,i,n,r,s){if(void 0===s&&(s=0),!s&&!this._testMask(this,t,e))return null;var a,o=w._hitTestContext;r=r||n&&this._hasMouseEventListener();for(var h=this.children,u=h.length-1;0<=u;u--){var l=h[u],c=l.hitArea;if(l.visible&&(c||l.isVisible())&&(!n||l.mouseEnabled)&&(c||this._testMask(l,t,e)))if(!c&&l instanceof p){var d=l._getObjectsUnderPoint(t,e,i,n,r,s+1);if(!i&&d)return n&&!this.mouseChildren?this:d}else{if(n&&!r&&!l._hasMouseEventListener())continue;var f=l.getConcatenatedDisplayProps(l._props);if(a=f.matrix,c&&(a.appendMatrix(c.getMatrix(c._props.matrix)),f.alpha=c.alpha),o.globalAlpha=f.alpha,o.setTransform(a.a,a.b,a.c,a.d,a.tx-t,a.ty-e),(c||l).draw(o),!this._testHit(o))continue;if(o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,2,2),!i)return n&&!this.mouseChildren?this:l;i.push(l)}}return null},t._testMask=function(t,e,i){var n=t.mask;if(!n||!n.graphics||n.graphics.isEmpty())return!0;var r=this._props.matrix,s=t.parent;r=s?s.getConcatenatedMatrix(r):r.identity(),r=n.getMatrix(n._props.matrix).prependMatrix(r);var a=w._hitTestContext;return a.setTransform(r.a,r.b,r.c,r.d,r.tx-e,r.ty-i),n.graphics.drawAsPath(a),a.fillStyle="#000",a.fill(),!!this._testHit(a)&&(a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,2,2),!0)},t._getBounds=function(t,e){var i=h.prototype.getBounds.call(this);if(i)return this._transformBounds(i,t,e);var n=this._props.matrix;n=e?n.identity():this.getMatrix(n),t&&n.prependMatrix(t);for(var r=this.children.length,s=null,a=0;a=h)return this._normalizeFrame()}n=0|this._currentFrame,this.currentFrame!=n&&(this.currentFrame=n,this.dispatchEvent("change"))},e._dispatchAnimationEnd=function(t,e,i,n,r){var s=t?t.name:null;if(this.hasEventListener("animationend")){var a=new h("animationend");a.name=s,a.next=n,this.dispatchEvent(a)}var o=this._animation!=t||this._currentFrame!=e;return o||i||!this.paused||(this.currentAnimationFrame=r,o=!0),o},e._goto=function(t,e){if(void 0===e&&(e=0),this.currentAnimationFrame=0,isNaN(t)){var i=this.spriteSheet.getAnimation(t);i&&(this._animation=i,this.currentAnimation=t,this._normalizeFrame(e))}else this.currentAnimation=this._animation=null,this._currentFrame=t,this._normalizeFrame()},t}(w),D=function(n){function m(t,e){var i;return void 0===t&&(t=""),void 0===e&&(e=null),(i=n.call(this)||this).text=t,i.spriteSheet=e,i.lineHeight=0,i.letterSpacing=0,i.spaceWidth=0,i._oldProps={text:0,spriteSheet:0,lineHeight:0,letterSpacing:0,spaceWidth:0},i._oldStage=null,i._drawAction=null,i}l(m,n);var t=m.prototype;return t.draw=function(t,e){this.drawCache(t,e)||(this._updateState(),n.prototype.draw.call(this,t,e))},t.getBounds=function(){return this._updateText(),n.prototype.getBounds.call(this)},t.isVisible=function(){var t=this.cacheCanvas||this.spriteSheet&&this.spriteSheet.complete&&this.text;return!!(this.visible&&0m.maxPoolSize&&(h.length=m.maxPoolSize)}},m}(b);D.maxPoolSize=100,D._spritePool=[];var L=function(n){function t(t){var e;e=n.call(this)||this,"string"==typeof t&&(t=document.getElementById(t)),e.mouseEnabled=!1;var i=t.style;return i.position="absolute",i.transformOrigin=i.WebkitTransformOrigin=i.msTransformOrigin=i.MozTransformOrigin=i.OTransformOrigin="0% 0%",e.htmlElement=t,e._oldProps=null,e._oldStage=null,e._drawAction=null,e}l(t,n);var e=t.prototype;return e.isVisible=function(){return null!=this.htmlElement},e.draw=function(t,e){return!0},e.cache=function(){},e.uncache=function(){},e.updateCache=function(){},e.hitTest=function(){},e.localToGlobal=function(){},e.globalToLocal=function(){},e.localToLocal=function(){},e.clone=function(){throw"DOMElement cannot be cloned."},e._tick=function(t){var e=this.stage;null!=e&&e!==this._oldStage&&(this._drawAction&&e.off("drawend",this._drawAction),this._drawAction=e.on("drawend",this._handleDrawEnd,this),this._oldStage=e),n.prototype._tick.call(this,t)},e._handleDrawEnd=function(t){var e=this.htmlElement;if(e){var i=e.style,n=this.getConcatenatedDisplayProps(this._props),r=n.matrix,s=n.visible?"visible":"hidden";if(s!=i.visibility&&(i.visibility=s),n.visible){var a=this._oldProps,o=a&&a.matrix,h=1e4;if(!o||!o.equals(r)){var u="matrix("+(r.a*h|0)/h+","+(r.b*h|0)/h+","+(r.c*h|0)/h+","+(r.d*h|0)/h+","+(r.tx+.5|0);i.transform=i.WebkitTransform=i.OTransform=i.msTransform=u+","+(r.ty+.5|0)+")",i.MozTransform=u+"px,"+(r.ty+.5|0)+"px)",a||(a=this._oldProps=new v(!0,null)),a.matrix.copy(r)}a.alpha!=n.alpha&&(i.opacity=""+(n.alpha*h|0)/h,a.alpha=n.alpha)}}},t}(w),A=function(){function g(){this.command=null,this._stroke=null,this._strokeStyle=null,this._oldStrokeStyle=null,this._strokeDash=null,this._oldStrokeDash=null,this._fill=null,this._strokeIgnoreScale=!1,this._commitIndex=0,this._instructions=[],this._activeInstructions=[],this._dirty=!1,this._storeIndex=0,this.curveTo=this.quadraticCurveTo,this.drawRect=this.rect,this.mt=this.moveTo,this.lt=this.lineTo,this.at=this.arcTo,this.bt=this.bezierCurveTo,this.qt=this.quadraticCurveTo,this.a=this.arc,this.r=this.rect,this.cp=this.closePath,this.c=this.clear,this.f=this.beginFill,this.lf=this.beginLinearGradientFill,this.rf=this.beginRadialGradientFill,this.bf=this.beginBitmapFill,this.ef=this.endFill,this.ss=this.setStrokeStyle,this.sd=this.setStrokeDash,this.s=this.beginStroke,this.ls=this.beginLinearGradientStroke,this.rs=this.beginRadialGradientStroke,this.bs=this.beginBitmapStroke,this.es=this.endStroke,this.dr=this.drawRect,this.rr=this.drawRoundRect,this.rc=this.drawRoundRectComplex,this.dc=this.drawCircle,this.de=this.drawEllipse,this.dp=this.drawPolyStar,this.p=this.decodePath,this.clear()}g.getRGB=function(t,e,i,n){return null!=t&&null==i&&(n=e,i=255&t,e=t>>8&255,t=t>>16&255),null==n?"rgb("+t+","+e+","+i+")":"rgba("+t+","+e+","+i+","+n+")"},g.getHSL=function(t,e,i,n){return null==n?"hsl("+t%360+","+e+"%,"+i+"%)":"hsl("+t%360+","+e+"%,"+i+"%,"+n+")"};var t=g.prototype;return t.isEmpty=function(){return!(this._instructions.length||this._activeInstructions.length)},t.draw=function(t,e){this._updateInstructions();for(var i=this._instructions,n=i.length,r=this._storeIndex;r>3,c=e[l];if(!c||3&u)throw"Bad path data (@"+n+"):c";var d=i[l];l||(a=o=0),n++;for(var f=2+(u>>2&1),p=s.length=0;p>5?-1:1;_=(31&_)<<6|h[t.charAt(n+1)],3===f&&(_=_<<6|h[t.charAt(n+2)]),_=v*_/10,p%2?a=_+=a:o=_+=o,s[p]=_,n+=f}c.apply(this,s)}return this},t.store=function(){return this._updateInstructions(!0),this._storeIndex=this._instructions.length,this},t.unstore=function(){return this._storeIndex=0,this},t.clone=function(){var t=new g;return t.command=this.command,t._stroke=this._stroke,t._strokeStyle=this._strokeStyle,t._strokeDash=this._strokeDash,t._strokeIgnoreScale=this._strokeIgnoreScale,t._fill=this._fill,t._instructions=this._instructions.slice(),t._commitIndex=this._commitIndex,t._activeInstructions=this._activeInstructions.slice(),t._dirty=this._dirty,t._storeIndex=this._storeIndex,t},t.toString=function(){return"["+this.constructor.name+"]"},t._updateInstructions=function(t){var e=this._instructions,i=this._activeInstructions,n=this._commitIndex;if(this._dirty&&i.length){e.length=n,e.push(g.beginCmd);var r=i.length,s=e.length;e.length=s+r;for(var a=0;a=i.length)break;s=i[r++]}else{if((r=i.next()).done)break;s=r.value}var a=s,o=a.target;if(o!==this&&!a.passive){var h=a._stepPosition;o instanceof w?this._addManagedChild(o,h):this._setState(o.state,h)}}for(var u=this.children,l=u.length-1;0<=l;l--){var c=u[l].id;1===this._managed[c]&&(this.removeChildAt(l),delete this._managed[c])}},t._setState=function(t,e){if(t)for(var i=t.length-1;0<=i;i--){var n=t[i],r=n.t,s=n.p;for(var a in s)r[a]=s[a];this._addManagedChild(r,e)}},t._addManagedChild=function(t,e){t._off||(this.addChildAt(t,0),t instanceof s&&(t._synchOffset=e,t.mode===s.INDEPENDENT&&t.autoReset&&!this._managed[t.id]&&t._reset()),this._managed[t.id]=2)},t._getBounds=function(t,e){var i=this.getBounds();return!i&&this.frameBounds&&(i=this._rectangle.copy(this.frameBounds[this.currentFrame])),i?this._transformBounds(i,t,e):n.prototype._getBounds.call(this,t,e)},o(s,[{key:"labels",get:function(){return this.timeline.labels}},{key:"currentLabel",get:function(){return this.timeline.currentLabel}},{key:"duration",get:function(){return this.timeline.duration}},{key:"totalFrames",get:function(){return this.duration}}]),s}(b);J.INDEPENDENT="independent",J.SINGLE_FRAME="single",J.SYNCHED="synched",J.inited=!1;var Q=function(){function t(){throw"MovieClipPlugin cannot be instantiated."}return t.install=function(){i.Tween.installPlugin(t)},t.init=function(t,e,i){return i},t.tween=function(t,e,i,n,r,s,a,o){return t.target instanceof J?1===s?r[e]:n[e]:i},t}();Q.priority=100;var K=function(i){function n(t){var e;return void 0===t&&(t=new A),(e=i.call(this)||this).graphics=t,e}l(n,i);var t=n.prototype;return t.isVisible=function(){var t=this.cacheCanvas||this.graphics&&!this.graphics.isEmpty();return!!(this.visible&&0=r.length)return"break";o=r[a++]}else{if((a=r.next()).done)return"break";o=a.value}var t=o,e=n._images=[],i=void 0;"string"==typeof t&&(i=t,(t=document.createElement("img")).src=i),e.push(t),t.getContext||t.naturalWidth||(n._loadCount++,n.complete=!1,t.onload=function(){return n._handleImageLoad(i)},t.onerror=function(){return n._handleImageError(i)})},r=t.images,s=Array.isArray(r),a=0;for(r=s?r:r[Symbol.iterator]();;){var o;if("break"===e())break}}if(null!=t.frames)if(Array.isArray(t.frames)){this._frames=[];var i=t.frames,h=Array.isArray(i),u=0;for(i=h?i:i[Symbol.iterator]();;){var l;if(h){if(u>=i.length)break;l=i[u++]}else{if((u=i.next()).done)break;l=u.value}var c=l;this._frames.push({image:this._images[c[4]?c[4]:0],rect:new x(c[0],c[1],c[2],c[3]),regX:c[5]||0,regY:c[6]||0})}}else{var d=t.frames;this._frameWidth=d.width,this._frameHeight=d.height,this._regX=d.regX||0,this._regY=d.regY||0,this._spacing=d.spacing||0,this._margin=d.margin||0,this._numFrames=d.count,0===this._loadCount&&this._calculateFrames()}if(this._animations=[],null!=t.animations){this._data={};var f=t.animations;for(var p in f){var _={name:p},v=f[p],g=void 0;if("number"==typeof v)g=_.frames=[v];else if(Array.isArray(v))if(1===v.length)_.frames=[v[0]];else{_.speed=v[3],_.next=v[2],g=_.frames=[];for(var m=v[0];m<=v[1];m++)g.push(m)}else{_.speed=v.speed,_.next=v.next;var w=v.frames;g=_.frames="number"==typeof w?[w]:w.slice(0)}!0!==_.next&&void 0!==_.next||(_.next=p),(!1===_.next||g.length<2&&_.next===p)&&(_.next=null),_.speed||(_.speed=1),this._animations.push(p),this._data[p]=_}}}},e._handleImageLoad=function(t){0==--this._loadCount&&(this._calculateFrames(),this.complete=!0,this.dispatchEvent("complete"))},e._handleImageError=function(t){var e=new h("error");e.src=t,this.dispatchEvent(e),0==--this._loadCount&&this.dispatchEvent("complete")},e._calculateFrames=function(){if(!this._frames&&0!==this._frameWidth){this._frames=[];var t=this._numFrames||1e5,e=0,i=this._frameWidth,n=this._frameHeight,r=this._spacing,s=this._margin;t:for(var a=0,o=this._images,h=o.length;a=o.length)break;l=o[u++]}else{if((u=o.next()).done)break;l=u.value}var c=l,d=null;if(null!=this.lineWidth&&(d=t.measureText(c).width)>this.lineWidth){var f=c.split(/(\s)/);c=f[0],d=t.measureText(c).width;for(var p=f.length,_=1;_
+
+
diff --git a/examples/WebGL/README.md b/examples/WebGL/README.md
index fa61233ab..96b25fbd1 100755
--- a/examples/WebGL/README.md
+++ b/examples/WebGL/README.md
@@ -1,11 +1,15 @@
# WebGL Examples
-These examples are specific to the new WebGL public preview for EaselJS. These demos must all be run from a server, and are dependent on the ../../libs and ../assets directory.
+These examples are specific to the new WebGL classes for EaselJS. These demos MUST all be run from a server, and are dependent on the ../../libs and ../assets directory.
+
+## Sparkles
+
+Benchmarking and an example of a minimal StageGL implementation
## Runners
-Example showing SpriteStage, SpriteContainer, Sprite, BitmapText, and Bitmap in use in WebGL. Also shows the use of vector hit areas, and using the SpriteStage.isWebGL property to scale content when WebGL is not supported.
+Example showing StageGL, Sprite, BitmapText, and Bitmap in use in WebGL. Also shows the use of vector hit areas, and using the StageGL.isWebGL property to scale content when WebGL is not supported.
## TwoStages
-Demonstrates the use of Stage.nextStage to seamlessly pass mouse (and touch) interactions from a Context2D Stage to a WebGL SpriteStage layered beneath it.
\ No newline at end of file
+Demonstrates the use of Stage.nextStage to seamlessly pass mouse (and touch) interactions from a Context2D Stage to a WebGL StageGL layered beneath it.
\ No newline at end of file
diff --git a/examples/WebGL/Runners.html b/examples/WebGL/Runners.html
index e6b886ef9..5d5d0b1ac 100755
--- a/examples/WebGL/Runners.html
+++ b/examples/WebGL/Runners.html
@@ -2,239 +2,276 @@
- EaselJS Example: WebGL Basics
-
-
-
+
+
+
-
+
+
+
-
-
-
WebGL Rendering
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
WebGL Rendering
+
+
This sample demonstrates WebGL rendering where available, and reducing
+ effect complexity (in this case particle count)
+ when WebGL is not supported. Uses StageGL.
+ Append "?c2d" to the url to disable WebGL & notice how the
+ particle count is reduced.
Example showing how to use simple animated Sprite instances
+ with stagemousemove and stagemousedown events.
+ Move your mouse and click
+ on the canvas. It also demonstrates displaying the current measured
+ framerate with Ticker.getMeasuredFramerate()
+ and Text. Click repeatedly to generate lots of sparkles and
+ slow down the framerate.
+
Output of common WebGL context variables using the WebGLInspector, useful for investigation or debugging. For in-depth and related statistics visit WebGL Stats
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/WebGL/TwoStages.html b/examples/WebGL/TwoStages.html
index cbd1e6191..8a517d870 100755
--- a/examples/WebGL/TwoStages.html
+++ b/examples/WebGL/TwoStages.html
@@ -3,11 +3,10 @@
- EaselJS Example: Passing interactions between a Context2D and WebGL
- stage.
+ EaselJS Example: Passing interactions between a Context2D and WebGL stage.
-
-
+
+