From 137b309d5b2971f1af9043001834531a0026a9ae Mon Sep 17 00:00:00 2001
From: Ali Shakiba <ali@shakiba.me>
Date: Wed, 8 Jul 2015 19:01:45 +0430
Subject: [PATCH] v0.8.2

---
 CHANGELOG.md              |   52 +-
 dist/stage.cordova.js     | 1573 +++++++++++++++++++++++----------------------
 dist/stage.cordova.min.js |   12 +-
 dist/stage.web.js         | 1560 ++++++++++++++++++++++----------------------
 dist/stage.web.min.js     |   12 +-
 package.json              |    2 +-
 template/dist.js          |    6 +-
 7 files changed, 1613 insertions(+), 1604 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 14cdbe1..696f36e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,15 +1,20 @@
+#### v0.8.2
+* `render.js` renamed to `loop.js`
+* `node.js` renamed to `tree.js`
+* cordova starts by mousemove
+
 #### v0.8.1
-* `node.scaleTo()` shortcut pinning method is added
+* `node.scaleTo()` shortcut pinning method added
 * `node.matrix(true)` returns relative matrix instead of absolute
 
 #### v0.8.0
-* **default .tween() behavior is changed from append to replace**
-* `.tween(duration, delay)` is changed to `.tween(duration, delay, append = false)`
-* `tween.clear()` is deprecated and no-op
-* `tween.end()` is replaced by `tween.done()`
+* **default `.tween()` behavior changed from append to replace**
+* `.tween(duration, delay)` changed to `.tween(duration, delay, append = false)`
+* `tween.clear()` deprecated and no-op
+* `tween.end()` replaced by `tween.done()`
 
 #### v0.7.1
-* `tween.then()` is replaced by `tween.end()`
+* `tween.then()` replaced by `tween.end()`
 * `tween.remove/hide()` are added
 
 #### v0.7.0
@@ -24,7 +29,7 @@
 * preloadScript('url') removed
 
 #### v0.6.5
-* **.preload('url.js') is added**
+* **.preload('url.js') added**
 
 #### v0.6.4
 * pinning shortcuts are added to nodes
@@ -41,12 +46,12 @@
 
 #### v0.5.0
 * atlas spec changed
-* **.preload(fn) is added**
+* **.preload(fn) added**
 * node.insert/append/prepend() methods accept array
 * node.id() renamed to node.label()
 * Cut.addTexture() removed
-* image.cropY/cropY() is removed
-* anim.gotoLabel() is removed
+* image.cropY/cropY() removed
+* anim.gotoLabel() removed
 * Cut.Anim.FPS is not public anymore
 * drawing() replaced with .canvas()
 * **Texture renamed to Atlas, new Texture class replaced Cut.Out**
@@ -68,26 +73,26 @@
 
 #### v0.4.3
 * pin set/get is refactored
-* resize in/out is replace with scale in-pad/out-crop
+* resize in/out replace with scale in-pad/out-crop
 * default viewbox mode is 'in-pad'
 
 #### v0.4.0
 * **CommonJS/Node.js files and project structure**
 * Source files moved to `lib` and platform files to `platform`
 * extension files moved to ext
-* `lib/main` is set as npm `main`
-* texture name is made optional in cutout selector: `"[texture:]cutout"`
+* `lib/main` set as npm `main`
+* texture name made optional in cutout selector: `"[texture:]cutout"`
 * FastContext support added to Cordova, FastCanvas loader removed
 
-* `Cut.Out.select` is replaced with `Cut.cutout`
+* `Cut.Out.select` replaced with `Cut.cutout`
 * `Cut.config` and `Cut.start(configs)` are added
 * `Cut.init` and `Loader.loadImage` replaced with `"app-loader"` and `"image-loader"` configs
 * `Loader` merged with `Root`
 * `Loader.start/pause/resume` replaced with `Cut.start/pause/resume`
 * `root._ratio` replaced with `root.viewport().ratio`
 * `_isCut` replaced with `Cut._ensure`
-* `Texture` is reorganized
-* `Root`'s `resize` renamed to `viewport`
+* `Texture` reorganized
+* `root.resize()` renamed to `viewport()`
 
 #### v0.3.1
 * Remove `Mouse(..., captureAnyMove)` and use flag instead
@@ -99,17 +104,18 @@
 * New `off` method to remove listeners
 * New `data` parameter for `visit` methods
 * `_listens` renamed to `_flag`
-* `_isFunc`, `_function`, `_options` and `_status` are removed and `_extend`'s signature is changed
+* `_isFunc`, `_function`, `_options` and `_status` are removed 
+* `_extend` signature changed
 
 #### v0.2.1
 * `setImage/Value/Frames/Font` deprecated and replaced by `image/value/frames`
 
 #### v0.2.0
-* `Mouse` events signature changed from `(rawEvent, point)` to `(point)` where new `point.raw` is old `rawEvent`
-* `viewport` callback signature changed from `(width, height)` to `(viewport)`
-* replaced `Cut.addTexture(...)` with `Cut(...)`
-* replaced `spy(true)` with `attr('spy', true)`
-* support pinning shorthand names for tweening
+* mouse event listener signature changed from `(rawEvent, {x, y})` to `({x, y, raw})`
+* `viewport` listener signature changed from `(width, height)` to `({width, height})`
+* `Cut.addTexture(...)` is replaced with `Cut(...)`
+* `spy(true)` is replaced with `attr('spy', true)`
+* tweening support for pinning XY-shorthands added 
 * `drawing` signature changed from `([name], width, height, [ratio], callback, [def])` to `([name], width, height, [ratio], [callback])` and `(def, [callback])`
-* node.trigger() method is added, calls .publish() and  returns `this`
+* node.trigger() method added, calls .publish() and returns `this`
 * using deep listeners count instead of `spy` to optimized mouse event distribution
diff --git a/dist/stage.cordova.js b/dist/stage.cordova.js
index 64d9c8c..e2dcefc 100644
--- a/dist/stage.cordova.js
+++ b/dist/stage.cordova.js
@@ -1,8 +1,8 @@
 /*
- * Stage.js 0.8.1
- * Copyright (c) 2015 Ali Shakiba, Piqnt LLC
- * Available under the MIT license
- * @license
+ * Stage.js 0.8.2
+ * 
+ * @copyright 2015 Ali Shakiba, Piqnt LLC
+ * @license The MIT License
  */
 
 !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Stage=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
@@ -29,7 +29,7 @@ module.exports._extend = require("../lib/util/extend");
 module.exports._create = require("../lib/util/create");
 
 require("../lib/loader/cordova");
-},{"../lib/":11,"../lib/addon/mouse":3,"../lib/addon/tween":4,"../lib/anim":5,"../lib/canvas":7,"../lib/image":10,"../lib/layout":12,"../lib/loader/cordova":13,"../lib/str":19,"../lib/util/create":22,"../lib/util/extend":24,"../lib/util/math":26}],2:[function(require,module,exports){
+},{"../lib/":11,"../lib/addon/mouse":3,"../lib/addon/tween":4,"../lib/anim":5,"../lib/canvas":7,"../lib/image":10,"../lib/layout":12,"../lib/loader/cordova":13,"../lib/str":18,"../lib/util/create":22,"../lib/util/extend":24,"../lib/util/math":26}],2:[function(require,module,exports){
 function _identity(x) {
     return x;
 }
@@ -587,7 +587,7 @@ var Class = require("./core");
 
 require("./pin");
 
-require("./render");
+require("./loop");
 
 var create = require("./util/create");
 
@@ -716,7 +716,7 @@ Anim.prototype.stop = function(frame) {
 };
 
 
-},{"./core":8,"./pin":16,"./render":17,"./util/create":22,"./util/math":26}],6:[function(require,module,exports){
+},{"./core":8,"./loop":14,"./pin":16,"./util/create":22,"./util/math":26}],6:[function(require,module,exports){
 if (typeof DEBUG === "undefined") DEBUG = true;
 
 var Class = require("./core");
@@ -932,7 +932,7 @@ function deprecated(hash, name, msg) {
 module.exports = Atlas;
 
 
-},{"./core":8,"./texture":20,"./util/create":22,"./util/extend":24,"./util/is":25,"./util/string":30}],7:[function(require,module,exports){
+},{"./core":8,"./texture":19,"./util/create":22,"./util/extend":24,"./util/is":25,"./util/string":30}],7:[function(require,module,exports){
 var Class = require("./core");
 
 var Texture = require("./texture");
@@ -980,7 +980,7 @@ Class.canvas = function(type, attributes, callback) {
 };
 
 
-},{"./core":8,"./texture":20}],8:[function(require,module,exports){
+},{"./core":8,"./texture":19}],8:[function(require,module,exports){
 if (typeof DEBUG === "undefined") DEBUG = true;
 
 var stats = require("./util/stats");
@@ -1210,7 +1210,7 @@ var Class = require("./core");
 
 require("./pin");
 
-require("./render");
+require("./loop");
 
 var repeat = require("./util/repeat");
 
@@ -1279,7 +1279,7 @@ Image.prototype._repeat = function(stretch, inner) {
 };
 
 
-},{"./core":8,"./pin":16,"./render":17,"./util/create":22,"./util/repeat":28}],11:[function(require,module,exports){
+},{"./core":8,"./loop":14,"./pin":16,"./util/create":22,"./util/repeat":28}],11:[function(require,module,exports){
 module.exports = require("./core");
 
 module.exports.Matrix = require("./matrix");
@@ -1288,23 +1288,23 @@ module.exports.Texture = require("./texture");
 
 require("./atlas");
 
-require("./node");
+require("./tree");
 
 require("./event");
 
 require("./pin");
 
-require("./render");
+require("./loop");
 
 require("./root");
 
 
-},{"./atlas":6,"./core":8,"./event":9,"./matrix":14,"./node":15,"./pin":16,"./render":17,"./root":18,"./texture":20}],12:[function(require,module,exports){
+},{"./atlas":6,"./core":8,"./event":9,"./loop":14,"./matrix":15,"./pin":16,"./root":17,"./texture":19,"./tree":20}],12:[function(require,module,exports){
 var Class = require("./core");
 
 require("./pin");
 
-require("./render");
+require("./loop");
 
 var create = require("./util/create");
 
@@ -1436,7 +1436,7 @@ Class.prototype.spacing = function(space) {
 };
 
 
-},{"./core":8,"./pin":16,"./render":17,"./util/create":22}],13:[function(require,module,exports){
+},{"./core":8,"./loop":14,"./pin":16,"./util/create":22}],13:[function(require,module,exports){
 /**
  * Cordova/PhoneGap loader with FastContext support.
  */
@@ -1453,17 +1453,20 @@ if (typeof FastContext === "undefined") {
 window.addEventListener("load", function() {
     DEBUG && console.log("On load.");
     var start = once(function(msg) {
-        DEBUG && msg && console.log(msg);
+        DEBUG && msg && console.log("Started on " + msg);
         Class.start();
     });
     // setTimeout(function() {
-    // start('On deviceready timeout.');
-    // }, 2000);
+    // start('timeout');
+    // }, 3000);
     document.addEventListener("click", function() {
-        start("Started by click.");
+        start("click");
+    }, false);
+    document.addEventListener("mousemove", function() {
+        start("mousemove");
     }, false);
     document.addEventListener("deviceready", function() {
-        start("On deviceready.");
+        start("deviceready");
     }, false);
     document.addEventListener("pause", function() {
         Class.pause();
@@ -1574,6 +1577,124 @@ function ImageLoader(src, success, error) {
 
 
 },{"../core":8,"../util/once":27}],14:[function(require,module,exports){
+var Class = require("./core");
+
+require("./pin");
+
+var stats = require("./util/stats");
+
+Class.prototype._textures = null;
+
+Class.prototype._alpha = 1;
+
+Class.prototype.render = function(context) {
+    if (!this._visible) {
+        return;
+    }
+    stats.node++;
+    var m = this.matrix();
+    context.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
+    // move this elsewhere!
+    this._alpha = this._pin._alpha * (this._parent ? this._parent._alpha : 1);
+    var alpha = this._pin._textureAlpha * this._alpha;
+    if (context.globalAlpha != alpha) {
+        context.globalAlpha = alpha;
+    }
+    if (this._textures !== null) {
+        for (var i = 0, n = this._textures.length; i < n; i++) {
+            this._textures[i].draw(context);
+        }
+    }
+    if (context.globalAlpha != this._alpha) {
+        context.globalAlpha = this._alpha;
+    }
+    var child, next = this._first;
+    while (child = next) {
+        next = child._next;
+        child.render(context);
+    }
+};
+
+Class.prototype._tickBefore = null;
+
+Class.prototype._tickAfter = null;
+
+Class.prototype.MAX_ELAPSE = Infinity;
+
+Class.prototype._tick = function(elapsed, now, last) {
+    if (!this._visible) {
+        return;
+    }
+    if (elapsed > this.MAX_ELAPSE) {
+        elapsed = this.MAX_ELAPSE;
+    }
+    var ticked = false;
+    if (this._tickBefore !== null) {
+        for (var i = 0, n = this._tickBefore.length; i < n; i++) {
+            stats.tick++;
+            ticked = this._tickBefore[i].call(this, elapsed, now, last) === true || ticked;
+        }
+    }
+    var child, next = this._first;
+    while (child = next) {
+        next = child._next;
+        if (child._flag("_tick")) {
+            ticked = child._tick(elapsed, now, last) === true ? true : ticked;
+        }
+    }
+    if (this._tickAfter !== null) {
+        for (var i = 0, n = this._tickAfter.length; i < n; i++) {
+            stats.tick++;
+            ticked = this._tickAfter[i].call(this, elapsed, now, last) === true || ticked;
+        }
+    }
+    return ticked;
+};
+
+Class.prototype.tick = function(ticker, before) {
+    if (typeof ticker !== "function") {
+        return;
+    }
+    if (before) {
+        if (this._tickBefore === null) {
+            this._tickBefore = [];
+        }
+        this._tickBefore.push(ticker);
+    } else {
+        if (this._tickAfter === null) {
+            this._tickAfter = [];
+        }
+        this._tickAfter.push(ticker);
+    }
+    this._flag("_tick", this._tickAfter !== null && this._tickAfter.length > 0 || this._tickBefore !== null && this._tickBefore.length > 0);
+};
+
+Class.prototype.untick = function(ticker) {
+    if (typeof ticker !== "function") {
+        return;
+    }
+    var i;
+    if (this._tickBefore !== null && (i = this._tickBefore.indexOf(ticker)) >= 0) {
+        this._tickBefore.splice(i, 1);
+    }
+    if (this._tickAfter !== null && (i = this._tickAfter.indexOf(ticker)) >= 0) {
+        this._tickAfter.splice(i, 1);
+    }
+};
+
+Class.prototype.timeout = function(fn, time) {
+    this.tick(function timer(t) {
+        if ((time -= t) < 0) {
+            this.untick(timer);
+            fn.call(this);
+        } else {
+            return true;
+        }
+    });
+};
+
+
+},{"./core":8,"./pin":16,"./util/stats":29}],15:[function(require,module,exports){
 function Matrix(a, b, c, d, e, f) {
     this.reset(a, b, c, d, e, f);
 }
@@ -1731,460 +1852,116 @@ Matrix.prototype.mapY = function(x, y) {
 module.exports = Matrix;
 
 
-},{}],15:[function(require,module,exports){
+},{}],16:[function(require,module,exports){
 var Class = require("./core");
 
-var is = require("./util/is");
+var Matrix = require("./matrix");
 
 var iid = 0;
 
-// TODO: do not clear next/prev/parent on remove
-Class.prototype._label = "";
-
-Class.prototype._visible = true;
-
-Class.prototype._parent = null;
-
-Class.prototype._next = null;
-
-Class.prototype._prev = null;
-
-Class.prototype._first = null;
-
-Class.prototype._last = null;
-
-Class.prototype._attrs = null;
-
-Class.prototype._flags = null;
+Class._init(function() {
+    this._pin = new Pin(this);
+});
 
-Class.prototype.toString = function() {
-    return "[" + this._label + "]";
+Class.prototype.matrix = function(relative) {
+    if (relative === true) {
+        return this._pin.relativeMatrix();
+    }
+    return this._pin.absoluteMatrix();
 };
 
-/**
- * @deprecated Use label()
- */
-Class.prototype.id = function(id) {
-    return this.label(id);
+Class.prototype.pin = function(a, b) {
+    if (typeof a === "object") {
+        this._pin.set(a);
+        return this;
+    } else if (typeof a === "string") {
+        if (typeof b === "undefined") {
+            return this._pin.get(a);
+        } else {
+            this._pin.set(a, b);
+            return this;
+        }
+    } else if (typeof a === "undefined") {
+        return this._pin;
+    }
 };
 
-Class.prototype.label = function(label) {
-    if (typeof label === "undefined") {
-        return this._label;
-    }
-    this._label = label;
-    return this;
+function Pin(owner) {
+    this._owner = owner;
+    this._parent = null;
+    // relative to parent
+    this._relativeMatrix = new Matrix();
+    // relative to stage
+    this._absoluteMatrix = new Matrix();
+    this.reset();
+}
+
+Pin.prototype.reset = function() {
+    this._textureAlpha = 1;
+    this._alpha = 1;
+    this._width = 0;
+    this._height = 0;
+    this._scaleX = 1;
+    this._scaleY = 1;
+    this._skewX = 0;
+    this._skewY = 0;
+    this._rotation = 0;
+    // scale/skew/rotate center
+    this._pivoted = false;
+    this._pivotX = null;
+    this._pivotY = null;
+    // self pin point
+    this._handled = false;
+    this._handleX = 0;
+    this._handleY = 0;
+    // parent pin point
+    this._aligned = false;
+    this._alignX = 0;
+    this._alignY = 0;
+    // as seen by parent px
+    this._offsetX = 0;
+    this._offsetY = 0;
+    this._boxX = 0;
+    this._boxY = 0;
+    this._boxWidth = this._width;
+    this._boxHeight = this._height;
+    // TODO: also set for owner
+    this._ts_translate = ++iid;
+    this._ts_transform = ++iid;
+    this._ts_matrix = ++iid;
 };
 
-Class.prototype.attr = function(name, value) {
-    if (typeof value === "undefined") {
-        return this._attrs !== null ? this._attrs[name] : undefined;
+Pin.prototype._update = function() {
+    this._parent = this._owner._parent && this._owner._parent._pin;
+    // if handled and transformed then be translated
+    if (this._handled && this._mo_handle != this._ts_transform) {
+        this._mo_handle = this._ts_transform;
+        this._ts_translate = ++iid;
+    }
+    if (this._aligned && this._parent && this._mo_align != this._parent._ts_transform) {
+        this._mo_align = this._parent._ts_transform;
+        this._ts_translate = ++iid;
     }
-    (this._attrs !== null ? this._attrs : this._attrs = {})[name] = value;
     return this;
 };
 
-Class.prototype.visible = function(visible) {
-    if (typeof visible === "undefined") {
-        return this._visible;
-    }
-    this._visible = visible;
-    this._parent && (this._parent._ts_children = ++iid);
-    this._ts_pin = ++iid;
-    this.touch();
-    return this;
+Pin.prototype.toString = function() {
+    return this._owner + " (" + (this._parent ? this._parent._owner : null) + ")";
 };
 
-Class.prototype.hide = function() {
-    return this.visible(false);
-};
-
-Class.prototype.show = function() {
-    return this.visible(true);
-};
-
-Class.prototype.parent = function() {
-    return this._parent;
-};
-
-Class.prototype.next = function(visible) {
-    var next = this._next;
-    while (next && visible && !next._visible) {
-        next = next._next;
-    }
-    return next;
-};
-
-Class.prototype.prev = function(visible) {
-    var prev = this._prev;
-    while (prev && visible && !prev._visible) {
-        prev = prev._prev;
-    }
-    return prev;
-};
-
-Class.prototype.first = function(visible) {
-    var next = this._first;
-    while (next && visible && !next._visible) {
-        next = next._next;
-    }
-    return next;
-};
-
-Class.prototype.last = function(visible) {
-    var prev = this._last;
-    while (prev && visible && !prev._visible) {
-        prev = prev._prev;
-    }
-    return prev;
-};
-
-Class.prototype.visit = function(visitor, data) {
-    var reverse = visitor.reverse;
-    var visible = visitor.visible;
-    if (visitor.start && visitor.start(this, data)) {
-        return;
-    }
-    var child, next = reverse ? this.last(visible) : this.first(visible);
-    while (child = next) {
-        next = reverse ? child.prev(visible) : child.next(visible);
-        if (child.visit(visitor, data)) {
-            return true;
-        }
-    }
-    return visitor.end && visitor.end(this, data);
-};
-
-Class.prototype.append = function(child, more) {
-    if (is.array(child)) for (var i = 0; i < child.length; i++) append(this, child[i]); else if (typeof more !== "undefined") // deprecated
-    for (var i = 0; i < arguments.length; i++) append(this, arguments[i]); else if (typeof child !== "undefined") append(this, child);
-    return this;
-};
-
-Class.prototype.prepend = function(child, more) {
-    if (is.array(child)) for (var i = child.length - 1; i >= 0; i--) prepend(this, child[i]); else if (typeof more !== "undefined") // deprecated
-    for (var i = arguments.length - 1; i >= 0; i--) prepend(this, arguments[i]); else if (typeof child !== "undefined") prepend(this, child);
-    return this;
-};
-
-Class.prototype.appendTo = function(parent) {
-    append(parent, this);
-    return this;
-};
-
-Class.prototype.prependTo = function(parent) {
-    prepend(parent, this);
-    return this;
-};
-
-Class.prototype.insertNext = function(sibling, more) {
-    if (is.array(sibling)) for (var i = 0; i < sibling.length; i++) insertAfter(sibling[i], this); else if (typeof more !== "undefined") // deprecated
-    for (var i = 0; i < arguments.length; i++) insertAfter(arguments[i], this); else if (typeof sibling !== "undefined") insertAfter(sibling, this);
-    return this;
-};
-
-Class.prototype.insertPrev = function(sibling, more) {
-    if (is.array(sibling)) for (var i = sibling.length - 1; i >= 0; i--) insertBefore(sibling[i], this); else if (typeof more !== "undefined") // deprecated
-    for (var i = arguments.length - 1; i >= 0; i--) insertBefore(arguments[i], this); else if (typeof sibling !== "undefined") insertBefore(sibling, this);
-    return this;
-};
-
-Class.prototype.insertAfter = function(prev) {
-    insertAfter(this, prev);
-    return this;
-};
-
-Class.prototype.insertBefore = function(next) {
-    insertBefore(this, next);
-    return this;
-};
-
-function append(parent, child) {
-    _ensure(child);
-    _ensure(parent);
-    child.remove();
-    if (parent._last) {
-        parent._last._next = child;
-        child._prev = parent._last;
-    }
-    child._parent = parent;
-    parent._last = child;
-    if (!parent._first) {
-        parent._first = child;
-    }
-    child._parent._flag(child, true);
-    child._ts_parent = ++iid;
-    parent._ts_children = ++iid;
-    parent.touch();
-}
-
-function prepend(parent, child) {
-    _ensure(child);
-    _ensure(parent);
-    child.remove();
-    if (parent._first) {
-        parent._first._prev = child;
-        child._next = parent._first;
-    }
-    child._parent = parent;
-    parent._first = child;
-    if (!parent._last) {
-        parent._last = child;
-    }
-    child._parent._flag(child, true);
-    child._ts_parent = ++iid;
-    parent._ts_children = ++iid;
-    parent.touch();
-}
-
-function insertBefore(self, next) {
-    _ensure(self);
-    _ensure(next);
-    self.remove();
-    var parent = next._parent;
-    var prev = next._prev;
-    next._prev = self;
-    prev && (prev._next = self) || parent && (parent._first = self);
-    self._parent = parent;
-    self._prev = prev;
-    self._next = next;
-    self._parent._flag(self, true);
-    self._ts_parent = ++iid;
-    self.touch();
-}
-
-function insertAfter(self, prev) {
-    _ensure(self);
-    _ensure(prev);
-    self.remove();
-    var parent = prev._parent;
-    var next = prev._next;
-    prev._next = self;
-    next && (next._prev = self) || parent && (parent._last = self);
-    self._parent = parent;
-    self._prev = prev;
-    self._next = next;
-    self._parent._flag(self, true);
-    self._ts_parent = ++iid;
-    self.touch();
-}
-
-Class.prototype.remove = function(child, more) {
-    if (typeof child !== "undefined") {
-        if (is.array(child)) {
-            for (var i = 0; i < child.length; i++) _ensure(child[i]).remove();
-        } else if (typeof more !== "undefined") {
-            for (var i = 0; i < arguments.length; i++) _ensure(arguments[i]).remove();
-        } else {
-            _ensure(child).remove();
-        }
-        return this;
-    }
-    if (this._prev) {
-        this._prev._next = this._next;
-    }
-    if (this._next) {
-        this._next._prev = this._prev;
-    }
-    if (this._parent) {
-        if (this._parent._first === this) {
-            this._parent._first = this._next;
-        }
-        if (this._parent._last === this) {
-            this._parent._last = this._prev;
-        }
-        this._parent._flag(this, false);
-        this._parent._ts_children = ++iid;
-        this._parent.touch();
-    }
-    this._prev = this._next = this._parent = null;
-    this._ts_parent = ++iid;
-    // this._parent.touch();
-    return this;
-};
-
-Class.prototype.empty = function() {
-    var child, next = this._first;
-    while (child = next) {
-        next = child._next;
-        child._prev = child._next = child._parent = null;
-        this._flag(child, false);
-    }
-    this._first = this._last = null;
-    this._ts_children = ++iid;
-    this.touch();
-    return this;
-};
-
-Class.prototype.touch = function() {
-    this._ts_touch = ++iid;
-    this._parent && this._parent.touch();
-    return this;
-};
-
-/**
- * Deep flags used for optimizing event distribution.
- */
-Class.prototype._flag = function(obj, name) {
-    if (typeof name === "undefined") {
-        return this._flags !== null && this._flags[obj] || 0;
-    }
-    if (typeof obj === "string") {
-        if (name) {
-            this._flags = this._flags || {};
-            if (!this._flags[obj] && this._parent) {
-                this._parent._flag(obj, true);
-            }
-            this._flags[obj] = (this._flags[obj] || 0) + 1;
-        } else if (this._flags && this._flags[obj] > 0) {
-            if (this._flags[obj] == 1 && this._parent) {
-                this._parent._flag(obj, false);
-            }
-            this._flags[obj] = this._flags[obj] - 1;
-        }
-    }
-    if (typeof obj === "object") {
-        if (obj._flags) {
-            for (var type in obj._flags) {
-                if (obj._flags[type] > 0) {
-                    this._flag(type, name);
-                }
-            }
-        }
-    }
-    return this;
-};
-
-/**
- * @private
- */
-Class.prototype.hitTest = function(hit) {
-    if (this.attr("spy")) {
-        return true;
-    }
-    return hit.x >= 0 && hit.x <= this._pin._width && hit.y >= 0 && hit.y <= this._pin._height;
-};
-
-function _ensure(obj) {
-    if (obj && obj instanceof Class) {
-        return obj;
-    }
-    throw "Invalid node: " + obj;
-}
-
-module.exports = Class;
-
-
-},{"./core":8,"./util/is":25}],16:[function(require,module,exports){
-var Class = require("./core");
-
-var Matrix = require("./matrix");
-
-var iid = 0;
-
-Class._init(function() {
-    this._pin = new Pin(this);
-});
-
-Class.prototype.matrix = function(relative) {
-    if (relative === true) {
-        return this._pin.relativeMatrix();
-    }
-    return this._pin.absoluteMatrix();
-};
-
-Class.prototype.pin = function(a, b) {
-    if (typeof a === "object") {
-        this._pin.set(a);
-        return this;
-    } else if (typeof a === "string") {
-        if (typeof b === "undefined") {
-            return this._pin.get(a);
-        } else {
-            this._pin.set(a, b);
-            return this;
-        }
-    } else if (typeof a === "undefined") {
-        return this._pin;
-    }
-};
-
-function Pin(owner) {
-    this._owner = owner;
-    this._parent = null;
-    // relative to parent
-    this._relativeMatrix = new Matrix();
-    // relative to stage
-    this._absoluteMatrix = new Matrix();
-    this.reset();
-}
-
-Pin.prototype.reset = function() {
-    this._textureAlpha = 1;
-    this._alpha = 1;
-    this._width = 0;
-    this._height = 0;
-    this._scaleX = 1;
-    this._scaleY = 1;
-    this._skewX = 0;
-    this._skewY = 0;
-    this._rotation = 0;
-    // scale/skew/rotate center
-    this._pivoted = false;
-    this._pivotX = null;
-    this._pivotY = null;
-    // self pin point
-    this._handled = false;
-    this._handleX = 0;
-    this._handleY = 0;
-    // parent pin point
-    this._aligned = false;
-    this._alignX = 0;
-    this._alignY = 0;
-    // as seen by parent px
-    this._offsetX = 0;
-    this._offsetY = 0;
-    this._boxX = 0;
-    this._boxY = 0;
-    this._boxWidth = this._width;
-    this._boxHeight = this._height;
-    // TODO: also set for owner
-    this._ts_translate = ++iid;
-    this._ts_transform = ++iid;
-    this._ts_matrix = ++iid;
-};
-
-Pin.prototype._update = function() {
-    this._parent = this._owner._parent && this._owner._parent._pin;
-    // if handled and transformed then be translated
-    if (this._handled && this._mo_handle != this._ts_transform) {
-        this._mo_handle = this._ts_transform;
-        this._ts_translate = ++iid;
-    }
-    if (this._aligned && this._parent && this._mo_align != this._parent._ts_transform) {
-        this._mo_align = this._parent._ts_transform;
-        this._ts_translate = ++iid;
-    }
-    return this;
-};
-
-Pin.prototype.toString = function() {
-    return this._owner + " (" + (this._parent ? this._parent._owner : null) + ")";
-};
-
-// TODO: ts fields require refactoring
-Pin.prototype.absoluteMatrix = function() {
-    this._update();
-    var ts = Math.max(this._ts_transform, this._ts_translate, this._parent ? this._parent._ts_matrix : 0);
-    if (this._mo_abs == ts) {
-        return this._absoluteMatrix;
-    }
-    this._mo_abs = ts;
-    var abs = this._absoluteMatrix;
-    abs.reset(this.relativeMatrix());
-    this._parent && abs.concat(this._parent._absoluteMatrix);
-    this._ts_matrix = ++iid;
-    return abs;
+// TODO: ts fields require refactoring
+Pin.prototype.absoluteMatrix = function() {
+    this._update();
+    var ts = Math.max(this._ts_transform, this._ts_translate, this._parent ? this._parent._ts_matrix : 0);
+    if (this._mo_abs == ts) {
+        return this._absoluteMatrix;
+    }
+    this._mo_abs = ts;
+    var abs = this._absoluteMatrix;
+    abs.reset(this.relativeMatrix());
+    this._parent && abs.concat(this._parent._absoluteMatrix);
+    this._ts_matrix = ++iid;
+    return abs;
 };
 
 Pin.prototype.relativeMatrix = function() {
@@ -2583,437 +2360,663 @@ Pin._add_shortcuts = function(Class) {
         if (typeof ta !== "undefined") {
             this.pin("textureAlpha", ta);
         }
-        return this;
-    };
+        return this;
+    };
+};
+
+Pin._add_shortcuts(Class);
+
+module.exports = Pin;
+
+
+},{"./core":8,"./matrix":15}],17:[function(require,module,exports){
+var Class = require("./core");
+
+require("./pin");
+
+require("./loop");
+
+var stats = require("./util/stats");
+
+var create = require("./util/create");
+
+var extend = require("./util/extend");
+
+Root._super = Class;
+
+Root.prototype = create(Root._super.prototype);
+
+Class.root = function(request, render) {
+    return new Root(request, render);
+};
+
+function Root(request, render) {
+    Root._super.call(this);
+    this.label("Root");
+    var paused = true;
+    var self = this;
+    var lastTime = 0;
+    var loop = function(now) {
+        if (paused === true) {
+            return;
+        }
+        stats.tick = stats.node = stats.draw = 0;
+        var last = lastTime || now;
+        var elapsed = now - last;
+        lastTime = now;
+        var ticked = self._tick(elapsed, now, last);
+        if (self._mo_touch != self._ts_touch) {
+            self._mo_touch = self._ts_touch;
+            render(self);
+            request(loop);
+        } else if (ticked) {
+            request(loop);
+        } else {
+            paused = true;
+        }
+        stats.fps = elapsed ? 1e3 / elapsed : 0;
+    };
+    this.start = function() {
+        return this.resume();
+    };
+    this.resume = function() {
+        if (paused) {
+            paused = false;
+            request(loop);
+        }
+        return this;
+    };
+    this.pause = function() {
+        paused = true;
+        return this;
+    };
+    this.touch_root = this.touch;
+    this.touch = function() {
+        this.resume();
+        return this.touch_root();
+    };
+}
+
+Root.prototype.background = function(color) {
+    // to be implemented by loaders
+    return this;
+};
+
+Root.prototype.viewport = function(width, height, ratio) {
+    if (typeof width === "undefined") {
+        return extend({}, this._viewport);
+    }
+    this._viewport = {
+        width: width,
+        height: height,
+        ratio: ratio || 1
+    };
+    this.viewbox();
+    var data = extend({}, this._viewport);
+    this.visit({
+        start: function(node) {
+            if (!node._flag("viewport")) {
+                return true;
+            }
+            node.publish("viewport", [ data ]);
+        }
+    });
+    return this;
 };
 
-Pin._add_shortcuts(Class);
-
-module.exports = Pin;
+// TODO: static/fixed viewbox
+Root.prototype.viewbox = function(width, height, mode) {
+    if (typeof width === "number" && typeof height === "number") {
+        this._viewbox = {
+            width: width,
+            height: height,
+            mode: /^(in|out|in-pad|out-crop)$/.test(mode) ? mode : "in-pad"
+        };
+    }
+    var box = this._viewbox;
+    var size = this._viewport;
+    if (size && box) {
+        this.pin({
+            width: box.width,
+            height: box.height
+        });
+        this.scaleTo(size.width, size.height, box.mode);
+    } else if (size) {
+        this.pin({
+            width: size.width,
+            height: size.height
+        });
+    }
+    return this;
+};
 
 
-},{"./core":8,"./matrix":14}],17:[function(require,module,exports){
+},{"./core":8,"./loop":14,"./pin":16,"./util/create":22,"./util/extend":24,"./util/stats":29}],18:[function(require,module,exports){
 var Class = require("./core");
 
 require("./pin");
 
-var stats = require("./util/stats");
+require("./loop");
 
-Class.prototype._textures = null;
+var create = require("./util/create");
 
-Class.prototype._alpha = 1;
+var is = require("./util/is");
 
-Class.prototype.render = function(context) {
-    if (!this._visible) {
-        return;
-    }
-    stats.node++;
-    var m = this.matrix();
-    context.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
-    // move this elsewhere!
-    this._alpha = this._pin._alpha * (this._parent ? this._parent._alpha : 1);
-    var alpha = this._pin._textureAlpha * this._alpha;
-    if (context.globalAlpha != alpha) {
-        context.globalAlpha = alpha;
-    }
-    if (this._textures !== null) {
-        for (var i = 0, n = this._textures.length; i < n; i++) {
-            this._textures[i].draw(context);
-        }
-    }
-    if (context.globalAlpha != this._alpha) {
-        context.globalAlpha = this._alpha;
-    }
-    var child, next = this._first;
-    while (child = next) {
-        next = child._next;
-        child.render(context);
-    }
+Class.string = function(frames) {
+    return new Str().frames(frames);
 };
 
-Class.prototype._tickBefore = null;
+Str._super = Class;
 
-Class.prototype._tickAfter = null;
+Str.prototype = create(Str._super.prototype);
 
-Class.prototype.MAX_ELAPSE = Infinity;
+function Str() {
+    Str._super.call(this);
+    this.label("String");
+    this._textures = [];
+}
 
-Class.prototype._tick = function(elapsed, now, last) {
-    if (!this._visible) {
-        return;
+/**
+ * @deprecated Use frames
+ */
+Str.prototype.setFont = function(a, b, c) {
+    return this.frames(a, b, c);
+};
+
+Str.prototype.frames = function(frames) {
+    this._textures = [];
+    if (typeof frames == "string") {
+        frames = Class.texture(frames);
+        this._item = function(value) {
+            return frames.one(value);
+        };
+    } else if (typeof frames === "object") {
+        this._item = function(value) {
+            return frames[value];
+        };
+    } else if (typeof frames === "function") {
+        this._item = frames;
     }
-    if (elapsed > this.MAX_ELAPSE) {
-        elapsed = this.MAX_ELAPSE;
+    return this;
+};
+
+/**
+ * @deprecated Use value
+ */
+Str.prototype.setValue = function(a, b, c) {
+    return this.value(a, b, c);
+};
+
+Str.prototype.value = function(value) {
+    if (typeof value === "undefined") {
+        return this._value;
     }
-    var ticked = false;
-    if (this._tickBefore !== null) {
-        for (var i = 0, n = this._tickBefore.length; i < n; i++) {
-            stats.tick++;
-            ticked = this._tickBefore[i].call(this, elapsed, now, last) === true || ticked;
-        }
+    if (this._value === value) {
+        return this;
     }
-    var child, next = this._first;
-    while (child = next) {
-        next = child._next;
-        if (child._flag("_tick")) {
-            ticked = child._tick(elapsed, now, last) === true ? true : ticked;
-        }
+    this._value = value;
+    if (value === null) {
+        value = "";
+    } else if (typeof value !== "string" && !is.array(value)) {
+        value = value.toString();
     }
-    if (this._tickAfter !== null) {
-        for (var i = 0, n = this._tickAfter.length; i < n; i++) {
-            stats.tick++;
-            ticked = this._tickAfter[i].call(this, elapsed, now, last) === true || ticked;
-        }
+    this._spacing = this._spacing || 0;
+    var width = 0, height = 0;
+    for (var i = 0; i < value.length; i++) {
+        var image = this._textures[i] = this._item(value[i]);
+        width += i > 0 ? this._spacing : 0;
+        image.dest(width, 0);
+        width = width + image.width;
+        height = Math.max(height, image.height);
     }
-    return ticked;
+    this.pin("width", width);
+    this.pin("height", height);
+    this._textures.length = value.length;
+    return this;
 };
 
-Class.prototype.tick = function(ticker, before) {
-    if (typeof ticker !== "function") {
-        return;
+
+},{"./core":8,"./loop":14,"./pin":16,"./util/create":22,"./util/is":25}],19:[function(require,module,exports){
+var stats = require("./util/stats");
+
+var math = require("./util/math");
+
+function Texture(image, ratio) {
+    if (typeof image === "object") {
+        this.src(image, ratio);
     }
-    if (before) {
-        if (this._tickBefore === null) {
-            this._tickBefore = [];
-        }
-        this._tickBefore.push(ticker);
+}
+
+Texture.prototype.pipe = function() {
+    return new Texture(this);
+};
+
+/**
+ * Signatures: (image), (x, y, w, h), (w, h)
+ */
+Texture.prototype.src = function(x, y, w, h) {
+    if (typeof x === "object") {
+        var image = x, ratio = y || 1;
+        this._image = image;
+        this._sx = this._dx = 0;
+        this._sy = this._dy = 0;
+        this._sw = this._dw = image.width / ratio;
+        this._sh = this._dh = image.height / ratio;
+        this.width = image.width / ratio;
+        this.height = image.height / ratio;
+        this.ratio = ratio;
     } else {
-        if (this._tickAfter === null) {
-            this._tickAfter = [];
+        if (typeof w === "undefined") {
+            w = x, h = y;
+        } else {
+            this._sx = x, this._sy = y;
         }
-        this._tickAfter.push(ticker);
+        this._sw = this._dw = w;
+        this._sh = this._dh = h;
+        this.width = w;
+        this.height = h;
     }
-    this._flag("_tick", this._tickAfter !== null && this._tickAfter.length > 0 || this._tickBefore !== null && this._tickBefore.length > 0);
+    return this;
 };
 
-Class.prototype.untick = function(ticker) {
-    if (typeof ticker !== "function") {
-        return;
-    }
-    var i;
-    if (this._tickBefore !== null && (i = this._tickBefore.indexOf(ticker)) >= 0) {
-        this._tickBefore.splice(i, 1);
-    }
-    if (this._tickAfter !== null && (i = this._tickAfter.indexOf(ticker)) >= 0) {
-        this._tickAfter.splice(i, 1);
+/**
+ * Signatures: (x, y, w, h), (x, y)
+ */
+Texture.prototype.dest = function(x, y, w, h) {
+    this._dx = x, this._dy = y;
+    this._dx = x, this._dy = y;
+    if (typeof w !== "undefined") {
+        this._dw = w, this._dh = h;
+        this.width = w, this.height = h;
     }
+    return this;
 };
 
-Class.prototype.timeout = function(fn, time) {
-    this.tick(function timer(t) {
-        if ((time -= t) < 0) {
-            this.untick(timer);
-            fn.call(this);
+Texture.prototype.draw = function(context, x1, y1, x2, y2, x3, y3, x4, y4) {
+    var image = this._image;
+    if (image === null || typeof image !== "object") {
+        return;
+    }
+    var sx = this._sx, sy = this._sy;
+    var sw = this._sw, sh = this._sh;
+    var dx = this._dx, dy = this._dy;
+    var dw = this._dw, dh = this._dh;
+    if (typeof x3 !== "undefined") {
+        x1 = math.limit(x1, 0, this._sw), x2 = math.limit(x2, 0, this._sw - x1);
+        y1 = math.limit(y1, 0, this._sh), y2 = math.limit(y2, 0, this._sh - y1);
+        sx += x1, sy += y1, sw = x2, sh = y2;
+        dx = x3, dy = y3, dw = x4, dh = y4;
+    } else if (typeof x2 !== "undefined") {
+        dx = x1, dy = y1, dw = x2, dh = y2;
+    } else if (typeof x1 !== "undefined") {
+        dw = x1, dh = y1;
+    }
+    var ratio = this.ratio || 1;
+    sx *= ratio, sy *= ratio, sw *= ratio, sh *= ratio;
+    try {
+        if (typeof image.draw === "function") {
+            image.draw(context, sx, sy, sw, sh, dx, dy, dw, dh);
         } else {
-            return true;
+            stats.draw++;
+            context.drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh);
+        }
+    } catch (ex) {
+        if (!image._draw_failed) {
+            console.log("Unable to draw: ", image);
+            console.log(ex);
+            image._draw_failed = true;
         }
-    });
+    }
 };
 
+module.exports = Texture;
+
 
-},{"./core":8,"./pin":16,"./util/stats":29}],18:[function(require,module,exports){
+},{"./util/math":26,"./util/stats":29}],20:[function(require,module,exports){
 var Class = require("./core");
 
-require("./pin");
+var is = require("./util/is");
 
-require("./render");
+var iid = 0;
 
-var stats = require("./util/stats");
+// TODO: do not clear next/prev/parent on remove
+Class.prototype._label = "";
 
-var create = require("./util/create");
+Class.prototype._visible = true;
 
-var extend = require("./util/extend");
+Class.prototype._parent = null;
 
-Root._super = Class;
+Class.prototype._next = null;
 
-Root.prototype = create(Root._super.prototype);
+Class.prototype._prev = null;
 
-Class.root = function(request, render) {
-    return new Root(request, render);
+Class.prototype._first = null;
+
+Class.prototype._last = null;
+
+Class.prototype._attrs = null;
+
+Class.prototype._flags = null;
+
+Class.prototype.toString = function() {
+    return "[" + this._label + "]";
 };
 
-function Root(request, render) {
-    Root._super.call(this);
-    this.label("Root");
-    var paused = true;
-    var self = this;
-    var lastTime = 0;
-    var loop = function(now) {
-        if (paused === true) {
-            return;
-        }
-        stats.tick = stats.node = stats.draw = 0;
-        var last = lastTime || now;
-        var elapsed = now - last;
-        lastTime = now;
-        var ticked = self._tick(elapsed, now, last);
-        if (self._mo_touch != self._ts_touch) {
-            self._mo_touch = self._ts_touch;
-            render(self);
-            request(loop);
-        } else if (ticked) {
-            request(loop);
-        } else {
-            paused = true;
-        }
-        stats.fps = elapsed ? 1e3 / elapsed : 0;
-    };
-    this.start = function() {
-        return this.resume();
-    };
-    this.resume = function() {
-        if (paused) {
-            paused = false;
-            request(loop);
-        }
-        return this;
-    };
-    this.pause = function() {
-        paused = true;
-        return this;
-    };
-    this.touch_root = this.touch;
-    this.touch = function() {
-        this.resume();
-        return this.touch_root();
-    };
-}
+/**
+ * @deprecated Use label()
+ */
+Class.prototype.id = function(id) {
+    return this.label(id);
+};
 
-Root.prototype.background = function(color) {
-    // to be implemented by loaders
+Class.prototype.label = function(label) {
+    if (typeof label === "undefined") {
+        return this._label;
+    }
+    this._label = label;
     return this;
 };
 
-Root.prototype.viewport = function(width, height, ratio) {
-    if (typeof width === "undefined") {
-        return extend({}, this._viewport);
+Class.prototype.attr = function(name, value) {
+    if (typeof value === "undefined") {
+        return this._attrs !== null ? this._attrs[name] : undefined;
     }
-    this._viewport = {
-        width: width,
-        height: height,
-        ratio: ratio || 1
-    };
-    this.viewbox();
-    var data = extend({}, this._viewport);
-    this.visit({
-        start: function(node) {
-            if (!node._flag("viewport")) {
-                return true;
-            }
-            node.publish("viewport", [ data ]);
-        }
-    });
+    (this._attrs !== null ? this._attrs : this._attrs = {})[name] = value;
     return this;
 };
 
-// TODO: static/fixed viewbox
-Root.prototype.viewbox = function(width, height, mode) {
-    if (typeof width === "number" && typeof height === "number") {
-        this._viewbox = {
-            width: width,
-            height: height,
-            mode: /^(in|out|in-pad|out-crop)$/.test(mode) ? mode : "in-pad"
-        };
-    }
-    var box = this._viewbox;
-    var size = this._viewport;
-    if (size && box) {
-        this.pin({
-            width: box.width,
-            height: box.height
-        });
-        this.scaleTo(size.width, size.height, box.mode);
-    } else if (size) {
-        this.pin({
-            width: size.width,
-            height: size.height
-        });
+Class.prototype.visible = function(visible) {
+    if (typeof visible === "undefined") {
+        return this._visible;
     }
+    this._visible = visible;
+    this._parent && (this._parent._ts_children = ++iid);
+    this._ts_pin = ++iid;
+    this.touch();
     return this;
 };
 
+Class.prototype.hide = function() {
+    return this.visible(false);
+};
 
-},{"./core":8,"./pin":16,"./render":17,"./util/create":22,"./util/extend":24,"./util/stats":29}],19:[function(require,module,exports){
-var Class = require("./core");
+Class.prototype.show = function() {
+    return this.visible(true);
+};
 
-require("./pin");
+Class.prototype.parent = function() {
+    return this._parent;
+};
 
-require("./render");
+Class.prototype.next = function(visible) {
+    var next = this._next;
+    while (next && visible && !next._visible) {
+        next = next._next;
+    }
+    return next;
+};
 
-var create = require("./util/create");
+Class.prototype.prev = function(visible) {
+    var prev = this._prev;
+    while (prev && visible && !prev._visible) {
+        prev = prev._prev;
+    }
+    return prev;
+};
 
-var is = require("./util/is");
+Class.prototype.first = function(visible) {
+    var next = this._first;
+    while (next && visible && !next._visible) {
+        next = next._next;
+    }
+    return next;
+};
 
-Class.string = function(frames) {
-    return new Str().frames(frames);
+Class.prototype.last = function(visible) {
+    var prev = this._last;
+    while (prev && visible && !prev._visible) {
+        prev = prev._prev;
+    }
+    return prev;
 };
 
-Str._super = Class;
+Class.prototype.visit = function(visitor, data) {
+    var reverse = visitor.reverse;
+    var visible = visitor.visible;
+    if (visitor.start && visitor.start(this, data)) {
+        return;
+    }
+    var child, next = reverse ? this.last(visible) : this.first(visible);
+    while (child = next) {
+        next = reverse ? child.prev(visible) : child.next(visible);
+        if (child.visit(visitor, data)) {
+            return true;
+        }
+    }
+    return visitor.end && visitor.end(this, data);
+};
 
-Str.prototype = create(Str._super.prototype);
+Class.prototype.append = function(child, more) {
+    if (is.array(child)) for (var i = 0; i < child.length; i++) append(this, child[i]); else if (typeof more !== "undefined") // deprecated
+    for (var i = 0; i < arguments.length; i++) append(this, arguments[i]); else if (typeof child !== "undefined") append(this, child);
+    return this;
+};
 
-function Str() {
-    Str._super.call(this);
-    this.label("String");
-    this._textures = [];
-}
+Class.prototype.prepend = function(child, more) {
+    if (is.array(child)) for (var i = child.length - 1; i >= 0; i--) prepend(this, child[i]); else if (typeof more !== "undefined") // deprecated
+    for (var i = arguments.length - 1; i >= 0; i--) prepend(this, arguments[i]); else if (typeof child !== "undefined") prepend(this, child);
+    return this;
+};
 
-/**
- * @deprecated Use frames
- */
-Str.prototype.setFont = function(a, b, c) {
-    return this.frames(a, b, c);
+Class.prototype.appendTo = function(parent) {
+    append(parent, this);
+    return this;
 };
 
-Str.prototype.frames = function(frames) {
-    this._textures = [];
-    if (typeof frames == "string") {
-        frames = Class.texture(frames);
-        this._item = function(value) {
-            return frames.one(value);
-        };
-    } else if (typeof frames === "object") {
-        this._item = function(value) {
-            return frames[value];
-        };
-    } else if (typeof frames === "function") {
-        this._item = frames;
-    }
+Class.prototype.prependTo = function(parent) {
+    prepend(parent, this);
+    return this;
+};
+
+Class.prototype.insertNext = function(sibling, more) {
+    if (is.array(sibling)) for (var i = 0; i < sibling.length; i++) insertAfter(sibling[i], this); else if (typeof more !== "undefined") // deprecated
+    for (var i = 0; i < arguments.length; i++) insertAfter(arguments[i], this); else if (typeof sibling !== "undefined") insertAfter(sibling, this);
+    return this;
+};
+
+Class.prototype.insertPrev = function(sibling, more) {
+    if (is.array(sibling)) for (var i = sibling.length - 1; i >= 0; i--) insertBefore(sibling[i], this); else if (typeof more !== "undefined") // deprecated
+    for (var i = arguments.length - 1; i >= 0; i--) insertBefore(arguments[i], this); else if (typeof sibling !== "undefined") insertBefore(sibling, this);
+    return this;
+};
+
+Class.prototype.insertAfter = function(prev) {
+    insertAfter(this, prev);
     return this;
 };
 
-/**
- * @deprecated Use value
- */
-Str.prototype.setValue = function(a, b, c) {
-    return this.value(a, b, c);
+Class.prototype.insertBefore = function(next) {
+    insertBefore(this, next);
+    return this;
 };
 
-Str.prototype.value = function(value) {
-    if (typeof value === "undefined") {
-        return this._value;
+function append(parent, child) {
+    _ensure(child);
+    _ensure(parent);
+    child.remove();
+    if (parent._last) {
+        parent._last._next = child;
+        child._prev = parent._last;
     }
-    if (this._value === value) {
-        return this;
+    child._parent = parent;
+    parent._last = child;
+    if (!parent._first) {
+        parent._first = child;
     }
-    this._value = value;
-    if (value === null) {
-        value = "";
-    } else if (typeof value !== "string" && !is.array(value)) {
-        value = value.toString();
+    child._parent._flag(child, true);
+    child._ts_parent = ++iid;
+    parent._ts_children = ++iid;
+    parent.touch();
+}
+
+function prepend(parent, child) {
+    _ensure(child);
+    _ensure(parent);
+    child.remove();
+    if (parent._first) {
+        parent._first._prev = child;
+        child._next = parent._first;
     }
-    this._spacing = this._spacing || 0;
-    var width = 0, height = 0;
-    for (var i = 0; i < value.length; i++) {
-        var image = this._textures[i] = this._item(value[i]);
-        width += i > 0 ? this._spacing : 0;
-        image.dest(width, 0);
-        width = width + image.width;
-        height = Math.max(height, image.height);
+    child._parent = parent;
+    parent._first = child;
+    if (!parent._last) {
+        parent._last = child;
     }
-    this.pin("width", width);
-    this.pin("height", height);
-    this._textures.length = value.length;
-    return this;
-};
+    child._parent._flag(child, true);
+    child._ts_parent = ++iid;
+    parent._ts_children = ++iid;
+    parent.touch();
+}
 
+function insertBefore(self, next) {
+    _ensure(self);
+    _ensure(next);
+    self.remove();
+    var parent = next._parent;
+    var prev = next._prev;
+    next._prev = self;
+    prev && (prev._next = self) || parent && (parent._first = self);
+    self._parent = parent;
+    self._prev = prev;
+    self._next = next;
+    self._parent._flag(self, true);
+    self._ts_parent = ++iid;
+    self.touch();
+}
 
-},{"./core":8,"./pin":16,"./render":17,"./util/create":22,"./util/is":25}],20:[function(require,module,exports){
-var stats = require("./util/stats");
+function insertAfter(self, prev) {
+    _ensure(self);
+    _ensure(prev);
+    self.remove();
+    var parent = prev._parent;
+    var next = prev._next;
+    prev._next = self;
+    next && (next._prev = self) || parent && (parent._last = self);
+    self._parent = parent;
+    self._prev = prev;
+    self._next = next;
+    self._parent._flag(self, true);
+    self._ts_parent = ++iid;
+    self.touch();
+}
 
-var math = require("./util/math");
+Class.prototype.remove = function(child, more) {
+    if (typeof child !== "undefined") {
+        if (is.array(child)) {
+            for (var i = 0; i < child.length; i++) _ensure(child[i]).remove();
+        } else if (typeof more !== "undefined") {
+            for (var i = 0; i < arguments.length; i++) _ensure(arguments[i]).remove();
+        } else {
+            _ensure(child).remove();
+        }
+        return this;
+    }
+    if (this._prev) {
+        this._prev._next = this._next;
+    }
+    if (this._next) {
+        this._next._prev = this._prev;
+    }
+    if (this._parent) {
+        if (this._parent._first === this) {
+            this._parent._first = this._next;
+        }
+        if (this._parent._last === this) {
+            this._parent._last = this._prev;
+        }
+        this._parent._flag(this, false);
+        this._parent._ts_children = ++iid;
+        this._parent.touch();
+    }
+    this._prev = this._next = this._parent = null;
+    this._ts_parent = ++iid;
+    // this._parent.touch();
+    return this;
+};
 
-function Texture(image, ratio) {
-    if (typeof image === "object") {
-        this.src(image, ratio);
+Class.prototype.empty = function() {
+    var child, next = this._first;
+    while (child = next) {
+        next = child._next;
+        child._prev = child._next = child._parent = null;
+        this._flag(child, false);
     }
-}
+    this._first = this._last = null;
+    this._ts_children = ++iid;
+    this.touch();
+    return this;
+};
 
-Texture.prototype.pipe = function() {
-    return new Texture(this);
+Class.prototype.touch = function() {
+    this._ts_touch = ++iid;
+    this._parent && this._parent.touch();
+    return this;
 };
 
 /**
- * Signatures: (image), (x, y, w, h), (w, h)
+ * Deep flags used for optimizing event distribution.
  */
-Texture.prototype.src = function(x, y, w, h) {
-    if (typeof x === "object") {
-        var image = x, ratio = y || 1;
-        this._image = image;
-        this._sx = this._dx = 0;
-        this._sy = this._dy = 0;
-        this._sw = this._dw = image.width / ratio;
-        this._sh = this._dh = image.height / ratio;
-        this.width = image.width / ratio;
-        this.height = image.height / ratio;
-        this.ratio = ratio;
-    } else {
-        if (typeof w === "undefined") {
-            w = x, h = y;
-        } else {
-            this._sx = x, this._sy = y;
+Class.prototype._flag = function(obj, name) {
+    if (typeof name === "undefined") {
+        return this._flags !== null && this._flags[obj] || 0;
+    }
+    if (typeof obj === "string") {
+        if (name) {
+            this._flags = this._flags || {};
+            if (!this._flags[obj] && this._parent) {
+                this._parent._flag(obj, true);
+            }
+            this._flags[obj] = (this._flags[obj] || 0) + 1;
+        } else if (this._flags && this._flags[obj] > 0) {
+            if (this._flags[obj] == 1 && this._parent) {
+                this._parent._flag(obj, false);
+            }
+            this._flags[obj] = this._flags[obj] - 1;
+        }
+    }
+    if (typeof obj === "object") {
+        if (obj._flags) {
+            for (var type in obj._flags) {
+                if (obj._flags[type] > 0) {
+                    this._flag(type, name);
+                }
+            }
         }
-        this._sw = this._dw = w;
-        this._sh = this._dh = h;
-        this.width = w;
-        this.height = h;
     }
     return this;
 };
 
 /**
- * Signatures: (x, y, w, h), (x, y)
+ * @private
  */
-Texture.prototype.dest = function(x, y, w, h) {
-    this._dx = x, this._dy = y;
-    this._dx = x, this._dy = y;
-    if (typeof w !== "undefined") {
-        this._dw = w, this._dh = h;
-        this.width = w, this.height = h;
+Class.prototype.hitTest = function(hit) {
+    if (this.attr("spy")) {
+        return true;
     }
-    return this;
+    return hit.x >= 0 && hit.x <= this._pin._width && hit.y >= 0 && hit.y <= this._pin._height;
 };
 
-Texture.prototype.draw = function(context, x1, y1, x2, y2, x3, y3, x4, y4) {
-    var image = this._image;
-    if (image === null || typeof image !== "object") {
-        return;
-    }
-    var sx = this._sx, sy = this._sy;
-    var sw = this._sw, sh = this._sh;
-    var dx = this._dx, dy = this._dy;
-    var dw = this._dw, dh = this._dh;
-    if (typeof x3 !== "undefined") {
-        x1 = math.limit(x1, 0, this._sw), x2 = math.limit(x2, 0, this._sw - x1);
-        y1 = math.limit(y1, 0, this._sh), y2 = math.limit(y2, 0, this._sh - y1);
-        sx += x1, sy += y1, sw = x2, sh = y2;
-        dx = x3, dy = y3, dw = x4, dh = y4;
-    } else if (typeof x2 !== "undefined") {
-        dx = x1, dy = y1, dw = x2, dh = y2;
-    } else if (typeof x1 !== "undefined") {
-        dw = x1, dh = y1;
-    }
-    var ratio = this.ratio || 1;
-    sx *= ratio, sy *= ratio, sw *= ratio, sh *= ratio;
-    try {
-        if (typeof image.draw === "function") {
-            image.draw(context, sx, sy, sw, sh, dx, dy, dw, dh);
-        } else {
-            stats.draw++;
-            context.drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh);
-        }
-    } catch (ex) {
-        if (!image._draw_failed) {
-            console.log("Unable to draw: ", image);
-            console.log(ex);
-            image._draw_failed = true;
-        }
+function _ensure(obj) {
+    if (obj && obj instanceof Class) {
+        return obj;
     }
-};
+    throw "Invalid node: " + obj;
+}
 
-module.exports = Texture;
+module.exports = Class;
 
 
-},{"./util/math":26,"./util/stats":29}],21:[function(require,module,exports){
+},{"./core":8,"./util/is":25}],21:[function(require,module,exports){
 module.exports = function() {
     var await = 0;
     function fork(fn, n) {
@@ -3295,7 +3298,7 @@ is.hex = function(value) {
 },{}],26:[function(require,module,exports){
 var create = require("./create");
 
-var M = Math;
+var native = Math;
 
 module.exports = create(Math);
 
@@ -3305,7 +3308,7 @@ module.exports.random = function(min, max) {
     } else if (typeof max === "undefined") {
         max = min, min = 0;
     }
-    return min == max ? min : M.random() * (max - min) + min;
+    return min == max ? min : native.random() * (max - min) + min;
 };
 
 module.exports.rotate = function(num, min, max) {
@@ -3334,7 +3337,7 @@ module.exports.limit = function(num, min, max) {
 };
 
 module.exports.length = function(x, y) {
-    return Math.sqrt(x * x + y * y);
+    return native.sqrt(x * x + y * y);
 };
 
 
diff --git a/dist/stage.cordova.min.js b/dist/stage.cordova.min.js
index 2fb2447..984c6b9 100644
--- a/dist/stage.cordova.min.js
+++ b/dist/stage.cordova.min.js
@@ -1,8 +1,8 @@
 /*
- * Stage.js 0.8.1
- * Copyright (c) 2015 Ali Shakiba, Piqnt LLC
- * Available under the MIT license
- * @license
+ * Stage.js 0.8.2
+ * 
+ * @copyright 2015 Ali Shakiba, Piqnt LLC
+ * @license The MIT License
  */
-!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Stage=t()}}(function(){return function t(e,i,n){function r(o,h){if(!i[o]){if(!e[o]){var a="function"==typeof require&&require;if(!h&&a)return a(o,!0);if(s)return s(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var f=i[o]={exports:{}};e[o][0].call(f.exports,function(t){var i=e[o][1][t];return r(i?i:t)},f,f.exports,t,e,i,n)}return i[o].exports}for(var s="function"==typeof require&&require,o=0;o<n.length;o++)r(n[o]);return r}({1:[function(t,e){e.exports=t("../lib/"),t("../lib/canvas"),t("../lib/image"),t("../lib/anim"),t("../lib/str"),t("../lib/layout"),t("../lib/addon/tween"),e.exports.Mouse=t("../lib/addon/mouse"),e.exports.Math=t("../lib/util/math"),e.exports._extend=t("../lib/util/extend"),e.exports._create=t("../lib/util/create"),t("../lib/loader/cordova")},{"../lib/":11,"../lib/addon/mouse":3,"../lib/addon/tween":4,"../lib/anim":5,"../lib/canvas":7,"../lib/image":10,"../lib/layout":12,"../lib/loader/cordova":13,"../lib/str":19,"../lib/util/create":22,"../lib/util/extend":24,"../lib/util/math":26}],2:[function(t,e){function i(t){return t}function n(t){if("function"==typeof t)return t;if("string"!=typeof t)return i;var e=r[t];if(e)return e;var n=/^(\w+)(-(in|out|in-out|out-in))?(\((.*)\))?$/i.exec(t);return n&&n.length?(easing=o[n[1]],mode=s[n[3]],params=n[5],e=easing&&easing.fn?easing.fn:easing&&easing.fc?easing.fc.apply(easing.fc,params&&params.replace(/\s+/,"").split(",")):i,mode&&(e=mode.fn(e)),r[t]=e,e):i}var r={},s={},o={};n.add=function(t){for(var e=(t.name||t.mode).split(/\s+/),i=0;i<e.length;i++){var n=e[i];n&&((t.name?o:s)[n]=t)}},n.add({mode:"in",fn:function(t){return t}}),n.add({mode:"out",fn:function(t){return function(e){return 1-t(1-e)}}}),n.add({mode:"in-out",fn:function(t){return function(e){return.5>e?t(2*e)/2:1-t(2*(1-e))/2}}}),n.add({mode:"out-in",fn:function(t){return function(e){return.5>e?1-t(2*(1-e))/2:t(2*e)/2}}}),n.add({name:"linear",fn:function(t){return t}}),n.add({name:"quad",fn:function(t){return t*t}}),n.add({name:"cubic",fn:function(t){return t*t*t}}),n.add({name:"quart",fn:function(t){return t*t*t*t}}),n.add({name:"quint",fn:function(t){return t*t*t*t*t}}),n.add({name:"sin sine",fn:function(t){return 1-Math.cos(t*Math.PI/2)}}),n.add({name:"exp expo",fn:function(t){return 0==t?0:Math.pow(2,10*(t-1))}}),n.add({name:"circle circ",fn:function(t){return 1-Math.sqrt(1-t*t)}}),n.add({name:"bounce",fn:function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}}),n.add({name:"poly",fc:function(t){return function(e){return Math.pow(e,t)}}}),n.add({name:"elastic",fc:function(t,e){e=e||.45,t=t||1;var i=e/(2*Math.PI)*Math.asin(1/t);return function(n){return 1+t*Math.pow(2,-10*n)*Math.sin(2*(n-i)*Math.PI/e)}}}),n.add({name:"back",fc:function(t){return t="undefined"!=typeof t?t:1.70158,function(e){return e*e*((t+1)*e-t)}}}),e.exports=n},{}],3:[function(t,e){function i(t,e){if(this instanceof i){var n=t.viewport().ratio||1;t.on("viewport",function(t){n=t.ratio||n}),this.x=0,this.y=0,this.toString=function(){return(0|this.x)+"x"+(0|this.y)},this.locate=function(t){r(e,t,this),this.x*=n,this.y*=n},this.lookup=function(e,i){this.type=e,this.root=t,this.event=null,i.length=0,this.collect=i,this.root.visit(this.visitor,this)},this.publish=function(e,i,n){if(this.type=e,this.root=t,this.event=i,this.collect=!1,this.timeStamp=Date.now(),"mousemove"!==e&&"touchmove"!==e&&DEBUG&&console.log(this.type+" "+this),n){for(;n.length&&!this.visitor.end(n.shift(),this););n.length=0}else this.root.visit(this.visitor,this)},this.visitor={reverse:!0,visible:!0,start:function(t,e){return!t._flag(e.type)},end:function(t,e){s.raw=e.event,s.type=e.type,s.timeStamp=e.timeStamp,s.abs.x=e.x,s.abs.y=e.y;var i=t.listeners(e.type);if(i&&(t.matrix().inverse().map(e,s),(t===e.root||t.hitTest(s))&&(e.collect&&e.collect.push(t),e.event))){for(var n=!1,r=0;r<i.length;r++)n=i[r].call(t,s)?!0:n;return n}}}}}function n(t,e,i){Object.defineProperty(t,e,{value:i})}function r(t,e,i){e.touches&&e.touches.length?(i.x=e.touches[0].clientX,i.y=e.touches[0].clientY):(i.x=e.clientX,i.y=e.clientY);var n=t.getBoundingClientRect();return i.x-=n.left,i.y-=n.top,i.x-=0|t.clientLeft,i.y-=0|t.clientTop,i}"undefined"==typeof DEBUG&&(DEBUG=!0),t("../core")._load(function(t,e){i.subscribe(t,e)}),i.CLICK="click",i.START="touchstart mousedown",i.MOVE="touchmove mousemove",i.END="touchend mouseup",i.CANCEL="touchcancel mousecancel",i.subscribe=function(t,e){function n(e){e.preventDefault(),t.mouse.locate(e),t.mouse.publish(e.type,e),t.mouse.lookup("click",h),t.mouse.lookup("mousecancel",a)}function r(e){e.preventDefault(),t.mouse.locate(e),t.mouse.publish(e.type,e)}function s(e){e.preventDefault(),t.mouse.publish(e.type,e),h.length&&t.mouse.publish("click",e,h),a.length=0}function o(e){a.length&&t.mouse.publish("mousecancel",e,a),h.length=0}if(!t.mouse){t.mouse=new i(t,e),e.addEventListener("touchstart",n),e.addEventListener("touchend",s),e.addEventListener("touchmove",r),e.addEventListener("touchcancel",o),e.addEventListener("mousedown",n),e.addEventListener("mouseup",s),e.addEventListener("mousemove",r),document.addEventListener("mouseup",o),window.addEventListener("blur",o);var h=[],a=[]}};var s={},o={};n(s,"clone",function(t){return t=t||{},t.x=this.x,t.y=this.y,t}),n(s,"toString",function(){return(0|this.x)+"x"+(0|this.y)+" ("+this.abs+")"}),n(s,"abs",o),n(o,"clone",function(t){return t=t||{},t.x=this.x,t.y=this.y,t}),n(o,"toString",function(){return(0|this.x)+"x"+(0|this.y)}),e.exports=i},{"../core":8}],4:[function(t,e){function i(t,e,i){this._end={},this._duration=e||400,this._delay=i||0,this._owner=t,this._time=0}function n(t,e,i,n){"number"==typeof t.pin(i)?e[i]=n:"number"==typeof t.pin(i+"X")&&"number"==typeof t.pin(i+"Y")&&(e[i+"X"]=n,e[i+"Y"]=n)}var r=t("./easing"),s=t("../core"),o=t("../pin");s.prototype.tween=function(t,e,n){if("number"!=typeof t?(n=t,e=0,t=0):"number"!=typeof e&&(n=e,e=0),!this._tweens){this._tweens=[];var r=0;this.tick(function(t,e,i){if(this._tweens.length){var n=r!=i;if(r=e,n)return!0;var s=this._tweens[0].tick(this,t,e,i);return s&&this._tweens.shift(),"object"==typeof s&&this._tweens.unshift(s),!0}},!0)}this.touch(),n||(this._tweens.length=0);var s=new i(this,t,e);return this._tweens.push(s),s},i.prototype.tick=function(t,e){if(this._time+=e,!(this._time<this._delay)){var i=this._time-this._delay;if(!this._start){this._start={};for(var n in this._end)this._start[n]=this._owner.pin(n)}var r,s;i<this._duration?(r=i/this._duration,s=!1):(r=1,s=!0),r="function"==typeof this._easing?this._easing(r):r;var o=1-r;for(var n in this._end)this._owner.pin(n,this._start[n]*o+this._end[n]*r);if(s){try{this._done&&this._done.call(this._owner)}catch(h){console.log(h)}return this._next||!0}}},i.prototype.tween=function(t,e){return this._next=new i(this._owner,t,e)},i.prototype.duration=function(t){return this._duration=t,this},i.prototype.delay=function(t){return this._delay=t,this},i.prototype.ease=function(t){return this._easing=r(t),this},i.prototype.done=function(t){return this._done=t,this},i.prototype.hide=function(){return this.done(function(){this.hide()}),this},i.prototype.remove=function(){return this.done(function(){this.remove()}),this},i.prototype.pin=function(t,e){if("object"==typeof t)for(var i in t)n(this._owner,this._end,i,t[i]);else"undefined"!=typeof e&&n(this._owner,this._end,t,e);return this},o._add_shortcuts(i),i.prototype.then=function(t){return this.done(t),this},i.prototype.then=function(t){return this.done(t),this},i.prototype.clear=function(){return this},e.exports=i},{"../core":8,"../pin":16,"./easing":2}],5:[function(t){function e(){e._super.call(this),this.label("Anim"),this._textures=[],this._fps=i.Anim.FPS,this._ft=1e3/this._fps,this._time=-1,this._repeat=0,this._index=0,this._frames=[];var t=0;this.tick(function(e,i,n){if(!(this._time<0||this._frames.length<=1)){var r=t!=n;if(t=i,r)return!0;if(this._time+=e,this._time<this._ft)return!0;var s=this._time/this._ft|0;return this._time-=s*this._ft,this.moveFrame(s),this._repeat>0&&(this._repeat-=s)<=0?(this.stop(),this._callback&&this._callback(),!1):!0}},!1)}var i=t("./core");t("./pin"),t("./render");var n=t("./util/create"),r=t("./util/math");i.anim=function(t,i){var n=new e;return n.frames(t).gotoFrame(0),i&&n.fps(i),n},e._super=i,e.prototype=n(e._super.prototype),i.Anim={FPS:15},e.prototype.fps=function(t){return"undefined"==typeof t?this._fps:(this._fps=t>0?t:i.Anim.FPS,this._ft=1e3/this._fps,this)},e.prototype.setFrames=function(t,e,i){return this.frames(t,e,i)},e.prototype.frames=function(t){return this._index=0,this._frames=i.texture(t).array(),this.touch(),this},e.prototype.length=function(){return this._frames?this._frames.length:0},e.prototype.gotoFrame=function(t,e){return this._index=0|r.rotate(t,this._frames.length),e=e||!this._textures[0],this._textures[0]=this._frames[this._index],e&&(this.pin("width",this._textures[0].width),this.pin("height",this._textures[0].height)),this.touch(),this},e.prototype.moveFrame=function(t){return this.gotoFrame(this._index+t)},e.prototype.repeat=function(t,e){return this._repeat=t*this._frames.length-1,this._callback=e,this.play(),this},e.prototype.play=function(t){return"undefined"!=typeof t?(this.gotoFrame(t),this._time=0):this._time<0&&(this._time=0),this.touch(),this},e.prototype.stop=function(t){return this._time=-1,"undefined"!=typeof t&&this.gotoFrame(t),this}},{"./core":8,"./pin":16,"./render":17,"./util/create":22,"./util/math":26}],6:[function(t,e){function i(t){function e(t){if(!t||u.fn(t.draw))return t;t=h({},t),u.fn(a)&&(t=a(t)),1!=c&&(t.x*=c,t.y*=c,t.width*=c,t.height*=c,t.top*=c,t.bottom*=c,t.left*=c,t.right*=c),0!=p&&(t.x+=p,t.y+=p,t.width-=2*p,t.height-=2*p,t.top-=p,t.bottom-=p,t.left-=p,t.right-=p);var e=o.pipe();return e.top=t.top,e.bottom=t.bottom,e.left=t.left,e.right=t.right,e.src(t.x,t.y,t.width,t.height),e}function s(t){if(l){if(u.fn(l))return l(t);if(u.hash(l))return l[t]}if(d){for(var e=null,i=0,n=0;n<d.length;n++)f.startsWith(d[n].name,t)&&(0===i?e=d[n]:1===i?e=[e,d[n]]:e.push(d[n]),i++);return 0===i&&u.fn(_)&&(e=function(e){return _(t+(e?e:""))}),e}}i._super.call(this);var o=this;r(t,"filter"),r(t,"cutouts"),r(t,"sprites"),r(t,"factory");var a=t.map||t.filter,c=t.ppu||t.ratio||1,p=t.trim||0,l=t.textures,_=t.factory,d=t.cutouts||t.sprites;this.select=function(t){if(!t)return new n(this.pipe());var i=s(t);return i?new n(i,s,e):void 0}}function n(t,e,i){function n(t,r){return t?u.fn(t.draw)?t:u.hash(t)&&u.number(t.width)&&u.number(t.height)&&u.fn(i)?i(t):u.hash(t)&&u.defined(r)?n(t[r]):u.fn(t)?n(t(r)):u.array(t)?n(t[0]):u.string(t)&&u.fn(e)?n(e(t)):void 0:l}this.one=function(e){return n(t,e)},this.array=function(e){var i=u.array(e)?e:[];if(u.array(t))for(var r=0;r<t.length;r++)i[r]=n(t[r]);else i[0]=n(t);return i}}function r(t,e,i){e in t&&console.log(i?i.replace("%name",e):"'"+e+"' field of texture atlas is deprecated.")}"undefined"==typeof DEBUG&&(DEBUG=!0);var s=t("./core"),o=t("./texture"),h=t("./util/extend"),a=t("./util/create"),u=t("./util/is"),f=t("./util/string"),c={},p=[];s.atlas=function(t){var e=u.fn(t.draw)?t:new i(t);t.name&&(c[t.name]=e),p.push(e),r(t,"imagePath"),r(t,"imageRatio");var n=t.imagePath,o=t.imageRatio||1;return u.string(t.image)?n=t.image:u.hash(t.image)&&(n=t.image.src||t.image.url,o=t.image.ratio||o),n&&s.preload(function(t){n=s.resolve(n),DEBUG&&console.log("Loading atlas: "+n);var i=s.config("image-loader");i(n,function(i){DEBUG&&console.log("Image loaded: "+n),e.src(i,o),t()},function(e){DEBUG&&console.log("Error loading atlas: "+n,e),t()})}),e},i._super=o,i.prototype=a(i._super.prototype);var l=new o;l.x=l.y=l.width=l.height=0,l.pipe=l.src=l.dest=function(){return this},l.draw=function(){};var _=new n(l);s.texture=function(t){if(!u.string(t))return new n(t);var e,i,r=null;for((i=t.indexOf(":"))>0&&t.length>i+1&&(e=c[t.slice(0,i)],r=e&&e.select(t.slice(i+1))),!r&&(e=c[t])&&(r=e.select()),i=0;!r&&i<p.length;i++)r=p[i].select(t);return r||(console.error("Texture not found: "+t),r=_),r},e.exports=i},{"./core":8,"./texture":20,"./util/create":22,"./util/extend":24,"./util/is":25,"./util/string":30}],7:[function(t){var e=t("./core"),i=t("./texture");e.canvas=function(t,e,n){"string"==typeof t?"object"==typeof e||("function"==typeof e&&(n=e),e={}):("function"==typeof t&&(n=t),e={},t="2d");var r=document.createElement("canvas"),s=r.getContext(t,e),o=new i(r);return o.context=function(){return s},o.size=function(t,e,i){return i=i||1,r.width=t*i,r.height=e*i,this.src(r,i),this},o.canvas=function(t){return"function"==typeof t?t.call(this,s):"undefined"==typeof t&&"function"==typeof n&&n.call(this,s),this},"function"==typeof n&&n.call(o,s),o}},{"./core":8,"./texture":20}],8:[function(t,e){function i(t){if(!(this instanceof i))return o.fn(t)?i.app.apply(i,arguments):o.object(t)?i.atlas.apply(i,arguments):t;r.create++;for(var e=0;e<a.length;e++)a[e].call(this)}function n(t,e){var i=document.createElement("script");i.addEventListener("load",function(){e()}),i.addEventListener("error",function(i){e(i||"Error loading script: "+t)}),i.src=t,i.id="preload-"+Date.now(),document.body.appendChild(i)}"undefined"==typeof DEBUG&&(DEBUG=!0);var r=t("./util/stats"),s=t("./util/extend"),o=t("./util/is"),h=t("./util/await");r.create=0;var a=[];i._init=function(t){a.push(t)};var u=[];i._load=function(t){u.push(t)};var f={};i.config=function(){return 1===arguments.length&&o.string(arguments[0])?f[arguments[0]]:(1===arguments.length&&o.object(arguments[0])&&s(f,arguments[0]),void(2===arguments.length&&o.string(arguments[0])&&f[(arguments[0],arguments[1])]))};var c=[],p=[],l=!1,_=!1;i.app=function(t,e){if(!l)return void c.push(arguments);DEBUG&&console.log("Creating app...");var n=i.config("app-loader");n(function(e,i){DEBUG&&console.log("Initing app...");for(var n=0;n<u.length;n++)u[n].call(this,e,i);t(e,i),p.push(e),DEBUG&&console.log("Starting app..."),e.start()},e)};var d=h();i.preload=function(t){if("string"==typeof t){var e=i.resolve(t);/\.js($|\?|\#)/.test(e)&&(DEBUG&&console.log("Loading script: "+e),t=function(t){n(e,t)})}"function"==typeof t&&t(d())},i.start=function(t){DEBUG&&console.log("Starting..."),i.config(t),d.then(function(){for(DEBUG&&console.log("Loading apps..."),l=!0;c.length;){var t=c.shift();i.app.apply(i,t)}})},i.pause=function(){if(!_){_=!0;for(var t=p.length-1;t>=0;t--)p[t].pause()}},i.resume=function(){if(_){_=!1;for(var t=p.length-1;t>=0;t--)p[t].resume()}},i.create=function(){return new i},i.resolve=function(){function t(){if(document.currentScript)return document.currentScript.src;var t;try{var i=new Error;if(!i.stack)throw i;t=i.stack}catch(i){t=i.stack}if("string"==typeof t){t=t.split("\n");for(var n=t.length;n--;){var r=t[n].match(/(\w+\:\/\/[^\/]*?\/.+?)(:\d+)(:\d+)?/);if(r)return r[1]}}if(e.length&&"readyState"in e[0])for(var n=e.length;n--;)if("interactive"===e[n].readyState)return e[n].src;return location.href}if("undefined"==typeof window||"undefined"==typeof document)return function(t){return t};var e=document.getElementsByTagName("script");return function(e){if(/^\.\//.test(e)){var i=t(),n=i.substring(0,i.lastIndexOf("/")+1);e=n+e.substring(2)}return e}}(),e.exports=i},{"./util/await":21,"./util/extend":24,"./util/is":25,"./util/stats":29}],9:[function(t){t("./util/event")(t("./core").prototype,function(t,e,i){t._flag(e,i)})},{"./core":8,"./util/event":23}],10:[function(t){function e(){e._super.call(this),this.label("Image"),this._textures=[],this._image=null}var i=t("./core");t("./pin"),t("./render");var n=t("./util/repeat"),r=t("./util/create");i.image=function(t){var i=new e;return t&&i.image(t),i},e._super=i,e.prototype=r(e._super.prototype),e.prototype.setImage=function(t,e,i){return this.image(t,e,i)},e.prototype.image=function(t){return this._image=i.texture(t).one(),this.pin("width",this._image?this._image.width:0),this.pin("height",this._image?this._image.height:0),this._textures[0]=this._image.pipe(),this._textures.length=1,this},e.prototype.tile=function(t){return this._repeat(!1,t),this},e.prototype.stretch=function(t){return this._repeat(!0,t),this},e.prototype._repeat=function(t,e){function i(t,e,i,n,s,o,h,a,u){var f=r._textures.length>t?r._textures[t]:r._textures[t]=r._image.pipe();f.src(e,i,n,s),f.dest(o,h,a,u)}var r=this;this.untick(this._repeatTicker),this.tick(this._repeatTicker=function(){if(this._mo_stretch!=this._pin._ts_transform){this._mo_stretch=this._pin._ts_transform;var r=this.pin("width"),s=this.pin("height");this._textures.length=n(this._image,r,s,t,e,i)}})}},{"./core":8,"./pin":16,"./render":17,"./util/create":22,"./util/repeat":28}],11:[function(t,e){e.exports=t("./core"),e.exports.Matrix=t("./matrix"),e.exports.Texture=t("./texture"),t("./atlas"),t("./node"),t("./event"),t("./pin"),t("./render"),t("./root")},{"./atlas":6,"./core":8,"./event":9,"./matrix":14,"./node":15,"./pin":16,"./render":17,"./root":18,"./texture":20}],12:[function(t){var e=t("./core");t("./pin"),t("./render");t("./util/create");e.row=function(t){return e.create().row(t).label("Row")},e.prototype.row=function(t){return this.sequence("row",t),this},e.column=function(t){return e.create().column(t).label("Row")},e.prototype.column=function(t){return this.sequence("column",t),this},e.sequence=function(t,i){return e.create().sequence(t,i).label("Sequence")},e.prototype.sequence=function(t,e){return this._padding=this._padding||0,this._spacing=this._spacing||0,this.untick(this._layoutTiker),this.tick(this._layoutTiker=function(){if(this._mo_seq!=this._ts_touch){this._mo_seq=this._ts_touch;var i=this._mo_seqAlign!=this._ts_children;this._mo_seqAlign=this._ts_children;for(var n,r=0,s=0,o=this.first(!0),h=!0;n=o;){o=n.next(!0),n.matrix(!0);var a=n.pin("boxWidth"),u=n.pin("boxHeight");"column"==t?(!h&&(s+=this._spacing),n.pin("offsetY")!=s&&n.pin("offsetY",s),r=Math.max(r,a),s+=u,i&&n.pin("alignX",e)):"row"==t&&(!h&&(r+=this._spacing),n.pin("offsetX")!=r&&n.pin("offsetX",r),r+=a,s=Math.max(s,u),i&&n.pin("alignY",e)),h=!1}r+=2*this._padding,s+=2*this._padding,this.pin("width")!=r&&this.pin("width",r),this.pin("height")!=s&&this.pin("height",s)}}),this},e.box=function(){return e.create().box().label("Box")},e.prototype.box=function(){return this._padding=this._padding||0,this.untick(this._layoutTiker),this.tick(this._layoutTiker=function(){if(this._mo_box!=this._ts_touch){this._mo_box=this._ts_touch;for(var t,e=0,i=0,n=this.first(!0);t=n;){n=t.next(!0),t.matrix(!0);var r=t.pin("boxWidth"),s=t.pin("boxHeight");e=Math.max(e,r),i=Math.max(i,s)}e+=2*this._padding,i+=2*this._padding,this.pin("width")!=e&&this.pin("width",e),this.pin("height")!=i&&this.pin("height",i)}}),this},e.layer=function(){return e.create().layer().label("Layer")},e.prototype.layer=function(){return this.untick(this._layoutTiker),this.tick(this._layoutTiker=function(){var t=this.parent();if(t){var e=t.pin("width");this.pin("width")!=e&&this.pin("width",e);var i=t.pin("height");this.pin("height")!=i&&this.pin("height",i)}},!0),this},e.prototype.padding=function(t){return this._padding=t,this},e.prototype.spacing=function(t){return this._spacing=t,this}},{"./core":8,"./pin":16,"./render":17,"./util/create":22}],13:[function(t){function e(t,e){function i(){o.isFast?(o.clear(),o.setTransform(1,0,0,1,0,0)):(o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,a,u)),d.render(o)}function r(){h?(a=window.innerWidth>0?window.innerWidth:screen.width,u=window.innerHeight>0?window.innerHeight:screen.height,s.style.width=a+"px",s.style.height=u+"px"):(a=s.clientWidth,u=s.clientHeight),a*=f,u*=f,(s.width!==a||s.height!==u)&&(s.width=a,s.height=u,DEBUG&&console.log("Resize: "+a+" x "+u+" / "+f),d.viewport(a,u,f),i())}e=e||{};var s=e.canvas,o=null,h=!1,a=0,u=0,f=1;if("string"==typeof s&&(s=document.getElementById(s)),s||(s=document.getElementById("cutjs")||document.getElementById("stage")),!s){h=!0,DEBUG&&console.log("Creating Canvas..."),s=document.createElement("canvas"),s.style.position="absolute";var c=document.body;c.insertBefore(s,c.firstChild)}o=s.getContext("2d",{fastcontext:!0}),o.isFast=!!o.isFast,h=h||o.isFast,DEBUG&&console.log("FastContext: "+o.isFast);var p=window.devicePixelRatio||1,l=o.webkitBackingStorePixelRatio||o.mozBackingStorePixelRatio||o.msBackingStorePixelRatio||o.oBackingStorePixelRatio||o.backingStorePixelRatio||1;f=p/l;var _=window.requestAnimationFrame||window.msRequestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.oRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)};DEBUG&&console.log("Creating stage...");var d=n.root(_,i);d.background=function(t){return o.isFast?o.setBackgroundColor&&o.setBackgroundColor(t):s.style.backgroundColor=t,this},t(d,s),r(),window.addEventListener("resize",r,!1),window.addEventListener("orientationchange",r,!1)}function i(t,e,i){function n(){e(r)}DEBUG&&console.log("Loading image: "+t);var r;FastContext?r=FastContext.createImage(t,n,i):(r=new Image,r.onload=n,r.onerror=i,r.src=t)}"undefined"==typeof DEBUG&&(DEBUG=!0);var n=t("../core"),r=t("../util/once");"undefined"==typeof FastContext&&(FastContext=window.FastContext),window.addEventListener("load",function(){DEBUG&&console.log("On load.");var t=r(function(t){DEBUG&&t&&console.log(t),n.start()});document.addEventListener("click",function(){t("Started by click.")},!1),document.addEventListener("deviceready",function(){t("On deviceready.")},!1),document.addEventListener("pause",function(){n.pause()},!1),document.addEventListener("resume",function(){n.resume()},!1)},!1),n.config({"app-loader":e,"image-loader":i})},{"../core":8,"../util/once":27}],14:[function(t,e){function i(t,e,i,n,r,s){this.reset(t,e,i,n,r,s)}i.prototype.toString=function(){return"["+this.a+", "+this.b+", "+this.c+", "+this.d+", "+this.e+", "+this.f+"]"},i.prototype.clone=function(){return new i(this.a,this.b,this.c,this.d,this.e,this.f)},i.prototype.reset=function(t,e,i,n,r,s){return this._dirty=!0,"object"==typeof t?(this.a=t.a,this.d=t.d,this.b=t.b,this.c=t.c,this.e=t.e,this.f=t.f):(this.a=t||1,this.d=n||1,this.b=e||0,this.c=i||0,this.e=r||0,this.f=s||0),this},i.prototype.identity=function(){return this._dirty=!0,this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this},i.prototype.rotate=function(t){if(!t)return this;this._dirty=!0;var e=t?Math.cos(t):1,i=t?Math.sin(t):0,n=e*this.a-i*this.b,r=e*this.b+i*this.a,s=e*this.c-i*this.d,o=e*this.d+i*this.c,h=e*this.e-i*this.f,a=e*this.f+i*this.e;return this.a=n,this.b=r,this.c=s,this.d=o,this.e=h,this.f=a,this},i.prototype.translate=function(t,e){return t||e?(this._dirty=!0,this.e+=t,this.f+=e,this):this},i.prototype.scale=function(t,e){return t-1||e-1?(this._dirty=!0,this.a*=t,this.b*=e,this.c*=t,this.d*=e,this.e*=t,this.f*=e,this):this},i.prototype.skew=function(t,e){if(!t&&!e)return this;this._dirty=!0;var i=this.a+this.b*t,n=this.b+this.a*e,r=this.c+this.d*t,s=this.d+this.c*e,o=this.e+this.f*t,h=this.f+this.e*e;return this.a=i,this.b=n,this.c=r,this.d=s,this.e=o,this.f=h,this},i.prototype.concat=function(t){this._dirty=!0;var e=this,i=e.a*t.a+e.b*t.c,n=e.b*t.d+e.a*t.b,r=e.c*t.a+e.d*t.c,s=e.d*t.d+e.c*t.b,o=e.e*t.a+t.e+e.f*t.c,h=e.f*t.d+t.f+e.e*t.b;return this.a=i,this.b=n,this.c=r,this.d=s,this.e=o,this.f=h,this},i.prototype.inverse=i.prototype.reverse=function(){if(this._dirty){this._dirty=!1,this.inversed=this.inversed||new i;var t=this.a*this.d-this.b*this.c;this.inversed.a=this.d/t,this.inversed.b=-this.b/t,this.inversed.c=-this.c/t,this.inversed.d=this.a/t,this.inversed.e=(this.c*this.f-this.e*this.d)/t,this.inversed.f=(this.e*this.b-this.a*this.f)/t}return this.inversed},i.prototype.map=function(t,e){return e=e||{},e.x=this.a*t.x+this.c*t.y+this.e,e.y=this.b*t.x+this.d*t.y+this.f,e},i.prototype.mapX=function(t,e){return"object"==typeof t&&(e=t.y,t=t.x),this.a*t+this.c*e+this.e},i.prototype.mapY=function(t,e){return"object"==typeof t&&(e=t.y,t=t.x),this.b*t+this.d*e+this.f},e.exports=i},{}],15:[function(t,e){function i(t,e){o(e),o(t),e.remove(),t._last&&(t._last._next=e,e._prev=t._last),e._parent=t,t._last=e,t._first||(t._first=e),e._parent._flag(e,!0),e._ts_parent=++u,t._ts_children=++u,t.touch()}function n(t,e){o(e),o(t),e.remove(),t._first&&(t._first._prev=e,e._next=t._first),e._parent=t,t._first=e,t._last||(t._last=e),e._parent._flag(e,!0),e._ts_parent=++u,t._ts_children=++u,t.touch()}function r(t,e){o(t),o(e),t.remove();var i=e._parent,n=e._prev;e._prev=t,n&&(n._next=t)||i&&(i._first=t),t._parent=i,t._prev=n,t._next=e,t._parent._flag(t,!0),t._ts_parent=++u,t.touch()}function s(t,e){o(t),o(e),t.remove();var i=e._parent,n=e._next;e._next=t,n&&(n._prev=t)||i&&(i._last=t),t._parent=i,t._prev=e,t._next=n,t._parent._flag(t,!0),t._ts_parent=++u,t.touch()}function o(t){if(t&&t instanceof h)return t;throw"Invalid node: "+t}var h=t("./core"),a=t("./util/is"),u=0;h.prototype._label="",h.prototype._visible=!0,h.prototype._parent=null,h.prototype._next=null,h.prototype._prev=null,h.prototype._first=null,h.prototype._last=null,h.prototype._attrs=null,h.prototype._flags=null,h.prototype.toString=function(){return"["+this._label+"]"},h.prototype.id=function(t){return this.label(t)},h.prototype.label=function(t){return"undefined"==typeof t?this._label:(this._label=t,this)},h.prototype.attr=function(t,e){return"undefined"==typeof e?null!==this._attrs?this._attrs[t]:void 0:((null!==this._attrs?this._attrs:this._attrs={})[t]=e,this)},h.prototype.visible=function(t){return"undefined"==typeof t?this._visible:(this._visible=t,this._parent&&(this._parent._ts_children=++u),this._ts_pin=++u,this.touch(),this)},h.prototype.hide=function(){return this.visible(!1)},h.prototype.show=function(){return this.visible(!0)},h.prototype.parent=function(){return this._parent},h.prototype.next=function(t){for(var e=this._next;e&&t&&!e._visible;)e=e._next;return e},h.prototype.prev=function(t){for(var e=this._prev;e&&t&&!e._visible;)e=e._prev;return e},h.prototype.first=function(t){for(var e=this._first;e&&t&&!e._visible;)e=e._next;return e},h.prototype.last=function(t){for(var e=this._last;e&&t&&!e._visible;)e=e._prev;return e},h.prototype.visit=function(t,e){var i=t.reverse,n=t.visible;if(!t.start||!t.start(this,e)){for(var r,s=i?this.last(n):this.first(n);r=s;)if(s=i?r.prev(n):r.next(n),r.visit(t,e))return!0;return t.end&&t.end(this,e)}},h.prototype.append=function(t,e){if(a.array(t))for(var n=0;n<t.length;n++)i(this,t[n]);else if("undefined"!=typeof e)for(var n=0;n<arguments.length;n++)i(this,arguments[n]);else"undefined"!=typeof t&&i(this,t);return this},h.prototype.prepend=function(t,e){if(a.array(t))for(var i=t.length-1;i>=0;i--)n(this,t[i]);else if("undefined"!=typeof e)for(var i=arguments.length-1;i>=0;i--)n(this,arguments[i]);else"undefined"!=typeof t&&n(this,t);return this},h.prototype.appendTo=function(t){return i(t,this),this},h.prototype.prependTo=function(t){return n(t,this),this},h.prototype.insertNext=function(t,e){if(a.array(t))for(var i=0;i<t.length;i++)s(t[i],this);else if("undefined"!=typeof e)for(var i=0;i<arguments.length;i++)s(arguments[i],this);else"undefined"!=typeof t&&s(t,this);return this},h.prototype.insertPrev=function(t,e){if(a.array(t))for(var i=t.length-1;i>=0;i--)r(t[i],this);else if("undefined"!=typeof e)for(var i=arguments.length-1;i>=0;i--)r(arguments[i],this);else"undefined"!=typeof t&&r(t,this);return this},h.prototype.insertAfter=function(t){return s(this,t),this},h.prototype.insertBefore=function(t){return r(this,t),this},h.prototype.remove=function(t,e){if("undefined"!=typeof t){if(a.array(t))for(var i=0;i<t.length;i++)o(t[i]).remove();else if("undefined"!=typeof e)for(var i=0;i<arguments.length;i++)o(arguments[i]).remove();else o(t).remove();return this}return this._prev&&(this._prev._next=this._next),this._next&&(this._next._prev=this._prev),this._parent&&(this._parent._first===this&&(this._parent._first=this._next),this._parent._last===this&&(this._parent._last=this._prev),this._parent._flag(this,!1),this._parent._ts_children=++u,this._parent.touch()),this._prev=this._next=this._parent=null,this._ts_parent=++u,this},h.prototype.empty=function(){for(var t,e=this._first;t=e;)e=t._next,t._prev=t._next=t._parent=null,this._flag(t,!1);return this._first=this._last=null,this._ts_children=++u,this.touch(),this},h.prototype.touch=function(){return this._ts_touch=++u,this._parent&&this._parent.touch(),this},h.prototype._flag=function(t,e){if("undefined"==typeof e)return null!==this._flags&&this._flags[t]||0;if("string"==typeof t&&(e?(this._flags=this._flags||{},!this._flags[t]&&this._parent&&this._parent._flag(t,!0),this._flags[t]=(this._flags[t]||0)+1):this._flags&&this._flags[t]>0&&(1==this._flags[t]&&this._parent&&this._parent._flag(t,!1),this._flags[t]=this._flags[t]-1)),"object"==typeof t&&t._flags)for(var i in t._flags)t._flags[i]>0&&this._flag(i,e);return this},h.prototype.hitTest=function(t){return this.attr("spy")?!0:t.x>=0&&t.x<=this._pin._width&&t.y>=0&&t.y<=this._pin._height},e.exports=h},{"./core":8,"./util/is":25}],16:[function(t,e){function i(t){this._owner=t,this._parent=null,this._relativeMatrix=new s,this._absoluteMatrix=new s,this.reset()}function n(t,e,i,n){var r="number"==typeof e,s="number"==typeof i,h="string"==typeof n;t._ts_transform=++o,r&&(t._scaleX=e/t._width_,t._width=t._width_),s&&(t._scaleY=i/t._height_,t._height=t._height_),r&&s&&h&&("out"==n||"out-crop"==n?t._scaleX=t._scaleY=Math.max(t._scaleX,t._scaleY):("in"==n||"in-pad"==n)&&(t._scaleX=t._scaleY=Math.min(t._scaleX,t._scaleY)),("out-crop"==n||"in-pad"==n)&&(t._width=e/t._scaleX,t._height=i/t._scaleY))}var r=t("./core"),s=t("./matrix"),o=0;r._init(function(){this._pin=new i(this)}),r.prototype.matrix=function(t){return t===!0?this._pin.relativeMatrix():this._pin.absoluteMatrix()},r.prototype.pin=function(t,e){return"object"==typeof t?(this._pin.set(t),this):"string"==typeof t?"undefined"==typeof e?this._pin.get(t):(this._pin.set(t,e),this):"undefined"==typeof t?this._pin:void 0},i.prototype.reset=function(){this._textureAlpha=1,this._alpha=1,this._width=0,this._height=0,this._scaleX=1,this._scaleY=1,this._skewX=0,this._skewY=0,this._rotation=0,this._pivoted=!1,this._pivotX=null,this._pivotY=null,this._handled=!1,this._handleX=0,this._handleY=0,this._aligned=!1,this._alignX=0,this._alignY=0,this._offsetX=0,this._offsetY=0,this._boxX=0,this._boxY=0,this._boxWidth=this._width,this._boxHeight=this._height,this._ts_translate=++o,this._ts_transform=++o,this._ts_matrix=++o},i.prototype._update=function(){return this._parent=this._owner._parent&&this._owner._parent._pin,this._handled&&this._mo_handle!=this._ts_transform&&(this._mo_handle=this._ts_transform,this._ts_translate=++o),this._aligned&&this._parent&&this._mo_align!=this._parent._ts_transform&&(this._mo_align=this._parent._ts_transform,this._ts_translate=++o),this},i.prototype.toString=function(){return this._owner+" ("+(this._parent?this._parent._owner:null)+")"},i.prototype.absoluteMatrix=function(){this._update();var t=Math.max(this._ts_transform,this._ts_translate,this._parent?this._parent._ts_matrix:0);if(this._mo_abs==t)return this._absoluteMatrix;this._mo_abs=t;var e=this._absoluteMatrix;return e.reset(this.relativeMatrix()),this._parent&&e.concat(this._parent._absoluteMatrix),this._ts_matrix=++o,e},i.prototype.relativeMatrix=function(){this._update();var t=Math.max(this._ts_transform,this._ts_translate,this._parent?this._parent._ts_transform:0);if(this._mo_rel==t)return this._relativeMatrix;this._mo_rel=t;var e=this._relativeMatrix;if(e.identity(),this._pivoted&&e.translate(-this._pivotX*this._width,-this._pivotY*this._height),e.scale(this._scaleX,this._scaleY),e.skew(this._skewX,this._skewY),e.rotate(this._rotation),this._pivoted&&e.translate(this._pivotX*this._width,this._pivotY*this._height),this._pivoted)this._boxX=0,this._boxY=0,this._boxWidth=this._width,this._boxHeight=this._height;
-else{var i,n;e.a>0&&e.c>0||e.a<0&&e.c<0?(i=0,n=e.a*this._width+e.c*this._height):(i=e.a*this._width,n=e.c*this._height),i>n?(this._boxX=n,this._boxWidth=i-n):(this._boxX=i,this._boxWidth=n-i),e.b>0&&e.d>0||e.b<0&&e.d<0?(i=0,n=e.b*this._width+e.d*this._height):(i=e.b*this._width,n=e.d*this._height),i>n?(this._boxY=n,this._boxHeight=i-n):(this._boxY=i,this._boxHeight=n-i)}return this._x=this._offsetX,this._y=this._offsetY,this._x-=this._boxX+this._handleX*this._boxWidth,this._y-=this._boxY+this._handleY*this._boxHeight,this._aligned&&this._parent&&(this._parent.relativeMatrix(),this._x+=this._alignX*this._parent._width,this._y+=this._alignY*this._parent._height),e.translate(this._x,this._y),this._relativeMatrix},i.prototype.get=function(t){return"function"==typeof h[t]?h[t](this):void 0},i.prototype.set=function(t,e){if("string"==typeof t)"function"==typeof a[t]&&"undefined"!=typeof e&&a[t](this,e);else if("object"==typeof t)for(e in t)"function"==typeof a[e]&&"undefined"!=typeof t[e]&&a[e](this,t[e],t);return this._owner&&(this._owner._ts_pin=++o,this._owner.touch()),this};var h={alpha:function(t){return t._alpha},textureAlpha:function(t){return t._textureAlpha},width:function(t){return t._width},height:function(t){return t._height},boxWidth:function(t){return t._boxWidth},boxHeight:function(t){return t._boxHeight},scaleX:function(t){return t._scaleX},scaleY:function(t){return t._scaleY},skewX:function(t){return t._skewX},skewY:function(t){return t._skewY},rotation:function(t){return t._rotation},pivotX:function(t){return t._pivotX},pivotY:function(t){return t._pivotY},offsetX:function(t){return t._offsetX},offsetY:function(t){return t._offsetY},alignX:function(t){return t._alignX},alignY:function(t){return t._alignY},handleX:function(t){return t._handleX},handleY:function(t){return t._handleY}},a={alpha:function(t,e){t._alpha=e},textureAlpha:function(t,e){t._textureAlpha=e},width:function(t,e){t._width_=e,t._width=e,t._ts_transform=++o},height:function(t,e){t._height_=e,t._height=e,t._ts_transform=++o},scale:function(t,e){t._scaleX=e,t._scaleY=e,t._ts_transform=++o},scaleX:function(t,e){t._scaleX=e,t._ts_transform=++o},scaleY:function(t,e){t._scaleY=e,t._ts_transform=++o},skew:function(t,e){t._skewX=e,t._skewY=e,t._ts_transform=++o},skewX:function(t,e){t._skewX=e,t._ts_transform=++o},skewY:function(t,e){t._skewY=e,t._ts_transform=++o},rotation:function(t,e){t._rotation=e,t._ts_transform=++o},pivot:function(t,e){t._pivotX=e,t._pivotY=e,t._pivoted=!0,t._ts_transform=++o},pivotX:function(t,e){t._pivotX=e,t._pivoted=!0,t._ts_transform=++o},pivotY:function(t,e){t._pivotY=e,t._pivoted=!0,t._ts_transform=++o},offset:function(t,e){t._offsetX=e,t._offsetY=e,t._ts_translate=++o},offsetX:function(t,e){t._offsetX=e,t._ts_translate=++o},offsetY:function(t,e){t._offsetY=e,t._ts_translate=++o},align:function(t,e){this.alignX(t,e),this.alignY(t,e)},alignX:function(t,e){t._alignX=e,t._aligned=!0,t._ts_translate=++o,this.handleX(t,e)},alignY:function(t,e){t._alignY=e,t._aligned=!0,t._ts_translate=++o,this.handleY(t,e)},handle:function(t,e){this.handleX(t,e),this.handleY(t,e)},handleX:function(t,e){t._handleX=e,t._handled=!0,t._ts_translate=++o},handleY:function(t,e){t._handleY=e,t._handled=!0,t._ts_translate=++o},resizeMode:function(t,e,i){i&&("in"==e?e="in-pad":"out"==e&&(e="out-crop"),n(t,i.resizeWidth,i.resizeHeight,e))},resizeWidth:function(t,e,i){i&&i.resizeMode||n(t,e,null)},resizeHeight:function(t,e,i){i&&i.resizeMode||n(t,null,e)},scaleMode:function(t,e,i){i&&n(t,i.scaleWidth,i.scaleHeight,e)},scaleWidth:function(t,e,i){i&&i.scaleMode||n(t,e,null)},scaleHeight:function(t,e,i){i&&i.scaleMode||n(t,null,e)},matrix:function(t,e){this.scaleX(t,e.a),this.skewX(t,e.c/e.d),this.skewY(t,e.b/e.a),this.scaleY(t,e.d),this.offsetX(t,e.e),this.offsetY(t,e.f),this.rotation(t,0)}};r.prototype.scaleTo=function(t,e,i){return"object"==typeof t&&(i=e,e=t.y,t=t.x),n(this._pin,t,e,i),this},i._add_shortcuts=function(t){t.prototype.size=function(t,e){return this.pin("width",t),this.pin("height",e),this},t.prototype.width=function(t){return"undefined"==typeof t?this.pin("width"):(this.pin("width",t),this)},t.prototype.height=function(t){return"undefined"==typeof t?this.pin("height"):(this.pin("height",t),this)},t.prototype.offset=function(t,e){return"object"==typeof t&&(e=t.y,t=t.x),this.pin("offsetX",t),this.pin("offsetY",e),this},t.prototype.rotate=function(t){return this.pin("rotation",t),this},t.prototype.skew=function(t,e){return"object"==typeof t?(e=t.y,t=t.x):"undefined"==typeof e&&(e=t),this.pin("skewX",t),this.pin("skewY",e),this},t.prototype.scale=function(t,e){return"object"==typeof t?(e=t.y,t=t.x):"undefined"==typeof e&&(e=t),this.pin("scaleX",t),this.pin("scaleY",e),this},t.prototype.alpha=function(t,e){return this.pin("alpha",t),"undefined"!=typeof e&&this.pin("textureAlpha",e),this}},i._add_shortcuts(r),e.exports=i},{"./core":8,"./matrix":14}],17:[function(t){var e=t("./core");t("./pin");var i=t("./util/stats");e.prototype._textures=null,e.prototype._alpha=1,e.prototype.render=function(t){if(this._visible){i.node++;var e=this.matrix();t.setTransform(e.a,e.b,e.c,e.d,e.e,e.f),this._alpha=this._pin._alpha*(this._parent?this._parent._alpha:1);var n=this._pin._textureAlpha*this._alpha;if(t.globalAlpha!=n&&(t.globalAlpha=n),null!==this._textures)for(var r=0,s=this._textures.length;s>r;r++)this._textures[r].draw(t);t.globalAlpha!=this._alpha&&(t.globalAlpha=this._alpha);for(var o,h=this._first;o=h;)h=o._next,o.render(t)}},e.prototype._tickBefore=null,e.prototype._tickAfter=null,e.prototype.MAX_ELAPSE=1/0,e.prototype._tick=function(t,e,n){if(this._visible){t>this.MAX_ELAPSE&&(t=this.MAX_ELAPSE);var r=!1;if(null!==this._tickBefore)for(var s=0,o=this._tickBefore.length;o>s;s++)i.tick++,r=this._tickBefore[s].call(this,t,e,n)===!0||r;for(var h,a=this._first;h=a;)a=h._next,h._flag("_tick")&&(r=h._tick(t,e,n)===!0?!0:r);if(null!==this._tickAfter)for(var s=0,o=this._tickAfter.length;o>s;s++)i.tick++,r=this._tickAfter[s].call(this,t,e,n)===!0||r;return r}},e.prototype.tick=function(t,e){"function"==typeof t&&(e?(null===this._tickBefore&&(this._tickBefore=[]),this._tickBefore.push(t)):(null===this._tickAfter&&(this._tickAfter=[]),this._tickAfter.push(t)),this._flag("_tick",null!==this._tickAfter&&this._tickAfter.length>0||null!==this._tickBefore&&this._tickBefore.length>0))},e.prototype.untick=function(t){if("function"==typeof t){var e;null!==this._tickBefore&&(e=this._tickBefore.indexOf(t))>=0&&this._tickBefore.splice(e,1),null!==this._tickAfter&&(e=this._tickAfter.indexOf(t))>=0&&this._tickAfter.splice(e,1)}},e.prototype.timeout=function(t,e){this.tick(function i(n){return(e-=n)<0?(this.untick(i),void t.call(this)):!0})}},{"./core":8,"./pin":16,"./util/stats":29}],18:[function(t){function e(t,i){e._super.call(this),this.label("Root");var r=!0,s=this,o=0,h=function(e){if(r!==!0){n.tick=n.node=n.draw=0;var a=o||e,u=e-a;o=e;var f=s._tick(u,e,a);s._mo_touch!=s._ts_touch?(s._mo_touch=s._ts_touch,i(s),t(h)):f?t(h):r=!0,n.fps=u?1e3/u:0}};this.start=function(){return this.resume()},this.resume=function(){return r&&(r=!1,t(h)),this},this.pause=function(){return r=!0,this},this.touch_root=this.touch,this.touch=function(){return this.resume(),this.touch_root()}}var i=t("./core");t("./pin"),t("./render");var n=t("./util/stats"),r=t("./util/create"),s=t("./util/extend");e._super=i,e.prototype=r(e._super.prototype),i.root=function(t,i){return new e(t,i)},e.prototype.background=function(){return this},e.prototype.viewport=function(t,e,i){if("undefined"==typeof t)return s({},this._viewport);this._viewport={width:t,height:e,ratio:i||1},this.viewbox();var n=s({},this._viewport);return this.visit({start:function(t){return t._flag("viewport")?void t.publish("viewport",[n]):!0}}),this},e.prototype.viewbox=function(t,e,i){"number"==typeof t&&"number"==typeof e&&(this._viewbox={width:t,height:e,mode:/^(in|out|in-pad|out-crop)$/.test(i)?i:"in-pad"});var n=this._viewbox,r=this._viewport;return r&&n?(this.pin({width:n.width,height:n.height}),this.scaleTo(r.width,r.height,n.mode)):r&&this.pin({width:r.width,height:r.height}),this}},{"./core":8,"./pin":16,"./render":17,"./util/create":22,"./util/extend":24,"./util/stats":29}],19:[function(t){function e(){e._super.call(this),this.label("String"),this._textures=[]}var i=t("./core");t("./pin"),t("./render");var n=t("./util/create"),r=t("./util/is");i.string=function(t){return(new e).frames(t)},e._super=i,e.prototype=n(e._super.prototype),e.prototype.setFont=function(t,e,i){return this.frames(t,e,i)},e.prototype.frames=function(t){return this._textures=[],"string"==typeof t?(t=i.texture(t),this._item=function(e){return t.one(e)}):"object"==typeof t?this._item=function(e){return t[e]}:"function"==typeof t&&(this._item=t),this},e.prototype.setValue=function(t,e,i){return this.value(t,e,i)},e.prototype.value=function(t){if("undefined"==typeof t)return this._value;if(this._value===t)return this;this._value=t,null===t?t="":"string"==typeof t||r.array(t)||(t=t.toString()),this._spacing=this._spacing||0;for(var e=0,i=0,n=0;n<t.length;n++){var s=this._textures[n]=this._item(t[n]);e+=n>0?this._spacing:0,s.dest(e,0),e+=s.width,i=Math.max(i,s.height)}return this.pin("width",e),this.pin("height",i),this._textures.length=t.length,this}},{"./core":8,"./pin":16,"./render":17,"./util/create":22,"./util/is":25}],20:[function(t,e){function i(t,e){"object"==typeof t&&this.src(t,e)}var n=t("./util/stats"),r=t("./util/math");i.prototype.pipe=function(){return new i(this)},i.prototype.src=function(t,e,i,n){if("object"==typeof t){var r=t,s=e||1;this._image=r,this._sx=this._dx=0,this._sy=this._dy=0,this._sw=this._dw=r.width/s,this._sh=this._dh=r.height/s,this.width=r.width/s,this.height=r.height/s,this.ratio=s}else"undefined"==typeof i?(i=t,n=e):(this._sx=t,this._sy=e),this._sw=this._dw=i,this._sh=this._dh=n,this.width=i,this.height=n;return this},i.prototype.dest=function(t,e,i,n){return this._dx=t,this._dy=e,this._dx=t,this._dy=e,"undefined"!=typeof i&&(this._dw=i,this._dh=n,this.width=i,this.height=n),this},i.prototype.draw=function(t,e,i,s,o,h,a,u,f){var c=this._image;if(null!==c&&"object"==typeof c){var p=this._sx,l=this._sy,_=this._sw,d=this._sh,g=this._dx,y=this._dy,m=this._dw,v=this._dh;"undefined"!=typeof h?(e=r.limit(e,0,this._sw),s=r.limit(s,0,this._sw-e),i=r.limit(i,0,this._sh),o=r.limit(o,0,this._sh-i),p+=e,l+=i,_=s,d=o,g=h,y=a,m=u,v=f):"undefined"!=typeof s?(g=e,y=i,m=s,v=o):"undefined"!=typeof e&&(m=e,v=i);var x=this.ratio||1;p*=x,l*=x,_*=x,d*=x;try{"function"==typeof c.draw?c.draw(t,p,l,_,d,g,y,m,v):(n.draw++,t.drawImage(c,p,l,_,d,g,y,m,v))}catch(b){c._draw_failed||(console.log("Unable to draw: ",c),console.log(b),c._draw_failed=!0)}}},e.exports=i},{"./util/math":26,"./util/stats":29}],21:[function(t,e){e.exports=function(){function t(t,n){return i+=n="number"==typeof n&&n>=1?n:1,function(){t&&t.apply(this,arguments),n>0&&(n--,i--,e())}}function e(){if(0===i)for(;n.length;)setTimeout(n.shift(),0)}var i=0,n=[];return t.then=function(t){0===i?setTimeout(t,0):n.push(t)},t}},{}],22:[function(t,e){function i(){}e.exports="function"==typeof Object.create?function(t,e){return Object.create.call(Object,t,e)}:function(t,e){if(e)throw Error("Second argument is not supported!");if("object"!=typeof t||null===t)throw Error("Invalid prototype!");return i.prototype=t,new i}},{}],23:[function(t,e){e.exports=function(t,e){t._listeners=null,t.on=t.listen=function(t,i){if(!t||!t.length||"function"!=typeof i)return this;null===this._listeners&&(this._listeners={});var n="string"!=typeof t&&"function"==typeof t.join;if(t=(n?t.join(" "):t).match(/\S+/g))for(var r=0;r<t.length;r++){var s=t[r];this._listeners[s]=this._listeners[s]||[],this._listeners[s].push(i),"function"==typeof e&&e(this,s,!0)}return this},t.off=function(t,i){if(!t||!t.length||"function"!=typeof i)return this;if(null===this._listeners)return this;var n="string"!=typeof t&&"function"==typeof t.join;if(t=(n?t.join(" "):t).match(/\S+/g))for(var r=0;r<t.length;r++){var s,o=t[r],h=this._listeners[o];h&&(s=h.indexOf(i))>=0&&(h.splice(s,1),h.length||delete this._listeners[o],"function"==typeof e&&e(this,o,!1))}return this},t.listeners=function(t){return this._listeners&&this._listeners[t]},t.publish=function(t,e){var i=this.listeners(t);if(!i||!i.length)return 0;for(var n=0;n<i.length;n++)i[n].apply(this,e);return i.length},t.trigger=function(t,e){return this.publish(t,e),this}}},{}],24:[function(t,e){e.exports=function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])}return t}},{}],25:[function(t,e){var i=Object.prototype,n=i.hasOwnProperty,r=i.toString,s=/^[A-Fa-f0-9]+$/,o=e.exports={};o.a=o.an=o.type=function(t,e){return typeof t===e},o.defined=function(t){return"undefined"!=typeof t},o.empty=function(t){var e,i=r.call(t);if("[object Array]"===i||"[object Arguments]"===i||"[object String]"===i)return 0===t.length;if("[object Object]"===i){for(e in t)if(n.call(t,e))return!1;return!0}return!t},o.equal=function(t,e){if(t===e)return!0;var i,n=r.call(t);if(n!==r.call(e))return!1;if("[object Object]"===n){for(i in t)if(!(o.equal(t[i],e[i])&&i in e))return!1;for(i in e)if(!(o.equal(t[i],e[i])&&i in t))return!1;return!0}if("[object Array]"===n){if(i=t.length,i!==e.length)return!1;for(;--i;)if(!o.equal(t[i],e[i]))return!1;return!0}return"[object Function]"===n?t.prototype===e.prototype:"[object Date]"===n?t.getTime()===e.getTime():!1},o.instance=function(t,e){return t instanceof e},o.nil=function(t){return null===t},o.undef=function(t){return"undefined"==typeof t},o.array=function(t){return"[object Array]"===r.call(t)},o.emptyarray=function(t){return o.array(t)&&0===t.length},o.arraylike=function(t){return!!t&&!o["boolean"](t)&&n.call(t,"length")&&isFinite(t.length)&&o.number(t.length)&&t.length>=0},o["boolean"]=function(t){return"[object Boolean]"===r.call(t)},o.element=function(t){return void 0!==t&&"undefined"!=typeof HTMLElement&&t instanceof HTMLElement&&1===t.nodeType},o.fn=function(t){return"[object Function]"===r.call(t)},o.number=function(t){return"[object Number]"===r.call(t)},o.nan=function(t){return!o.number(t)||t!==t},o.object=function(t){return"[object Object]"===r.call(t)},o.hash=function(t){return o.object(t)&&t.constructor===Object&&!t.nodeType&&!t.setInterval},o.regexp=function(t){return"[object RegExp]"===r.call(t)},o.string=function(t){return"[object String]"===r.call(t)},o.hex=function(t){return o.string(t)&&(!t.length||s.test(t))}},{}],26:[function(t,e){var i=t("./create"),n=Math;e.exports=i(Math),e.exports.random=function(t,e){return"undefined"==typeof t?(e=1,t=0):"undefined"==typeof e&&(e=t,t=0),t==e?t:n.random()*(e-t)+t},e.exports.rotate=function(t,e,i){return"undefined"==typeof e?(i=1,e=0):"undefined"==typeof i&&(i=e,e=0),i>e?(t=(t-e)%(i-e),t+(0>t?i:e)):(t=(t-i)%(e-i),t+(0>=t?e:i))},e.exports.limit=function(t,e,i){return e>t?e:t>i?i:t},e.exports.length=function(t,e){return Math.sqrt(t*t+e*e)}},{"./create":22}],27:[function(t,e){e.exports=function(t,e){var i=!1;return function(){i||(i=!0,t.apply(e,arguments))}}},{}],28:[function(t,e){e.exports=function(t,e,i,n,r,s){var o=t.width,h=t.height,a=t.left,u=t.right,f=t.top,c=t.bottom;a="number"==typeof a&&a===a?a:0,u="number"==typeof u&&u===u?u:0,f="number"==typeof f&&f===f?f:0,c="number"==typeof c&&c===c?c:0,o=o-a-u,h=h-f-c,r||(e=Math.max(e-a-u,0),i=Math.max(i-f-c,0));var p=0;if(f>0&&a>0&&s(p++,0,0,a,f,0,0,a,f),c>0&&a>0&&s(p++,0,h+f,a,c,0,i+f,a,c),f>0&&u>0&&s(p++,o+a,0,u,f,e+a,0,u,f),c>0&&u>0&&s(p++,o+a,h+f,u,c,e+a,i+f,u,c),n)f>0&&s(p++,a,0,o,f,a,0,e,f),c>0&&s(p++,a,h+f,o,c,a,i+f,e,c),a>0&&s(p++,0,f,a,h,0,f,a,i),u>0&&s(p++,o+a,f,u,h,e+a,f,u,i),s(p++,a,f,o,h,a,f,e,i);else for(var l,_=a,d=e;d>0;){l=Math.min(o,d),d-=o;for(var g,y=f,m=i;m>0;)g=Math.min(h,m),m-=h,s(p++,a,f,l,g,_,y,l,g),0>=d&&(a&&s(p++,0,f,a,g,0,y,a,g),u&&s(p++,o+a,f,u,g,_+l,y,u,g)),y+=g;f&&s(p++,a,0,l,f,_,0,l,f),c&&s(p++,a,h+f,l,c,_,y,l,c),_+=l}return p}},{}],29:[function(t,e){e.exports={}},{}],30:[function(t,e){e.exports.startsWith=function(t,e){return"string"==typeof t&&"string"==typeof e&&t.substring(0,e.length)==e}},{}]},{},[1])(1)});
\ No newline at end of file
+!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Stage=t()}}(function(){return function t(e,i,n){function r(o,h){if(!i[o]){if(!e[o]){var a="function"==typeof require&&require;if(!h&&a)return a(o,!0);if(s)return s(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var f=i[o]={exports:{}};e[o][0].call(f.exports,function(t){var i=e[o][1][t];return r(i?i:t)},f,f.exports,t,e,i,n)}return i[o].exports}for(var s="function"==typeof require&&require,o=0;o<n.length;o++)r(n[o]);return r}({1:[function(t,e){e.exports=t("../lib/"),t("../lib/canvas"),t("../lib/image"),t("../lib/anim"),t("../lib/str"),t("../lib/layout"),t("../lib/addon/tween"),e.exports.Mouse=t("../lib/addon/mouse"),e.exports.Math=t("../lib/util/math"),e.exports._extend=t("../lib/util/extend"),e.exports._create=t("../lib/util/create"),t("../lib/loader/cordova")},{"../lib/":11,"../lib/addon/mouse":3,"../lib/addon/tween":4,"../lib/anim":5,"../lib/canvas":7,"../lib/image":10,"../lib/layout":12,"../lib/loader/cordova":13,"../lib/str":18,"../lib/util/create":22,"../lib/util/extend":24,"../lib/util/math":26}],2:[function(t,e){function i(t){return t}function n(t){if("function"==typeof t)return t;if("string"!=typeof t)return i;var e=r[t];if(e)return e;var n=/^(\w+)(-(in|out|in-out|out-in))?(\((.*)\))?$/i.exec(t);return n&&n.length?(easing=o[n[1]],mode=s[n[3]],params=n[5],e=easing&&easing.fn?easing.fn:easing&&easing.fc?easing.fc.apply(easing.fc,params&&params.replace(/\s+/,"").split(",")):i,mode&&(e=mode.fn(e)),r[t]=e,e):i}var r={},s={},o={};n.add=function(t){for(var e=(t.name||t.mode).split(/\s+/),i=0;i<e.length;i++){var n=e[i];n&&((t.name?o:s)[n]=t)}},n.add({mode:"in",fn:function(t){return t}}),n.add({mode:"out",fn:function(t){return function(e){return 1-t(1-e)}}}),n.add({mode:"in-out",fn:function(t){return function(e){return.5>e?t(2*e)/2:1-t(2*(1-e))/2}}}),n.add({mode:"out-in",fn:function(t){return function(e){return.5>e?1-t(2*(1-e))/2:t(2*e)/2}}}),n.add({name:"linear",fn:function(t){return t}}),n.add({name:"quad",fn:function(t){return t*t}}),n.add({name:"cubic",fn:function(t){return t*t*t}}),n.add({name:"quart",fn:function(t){return t*t*t*t}}),n.add({name:"quint",fn:function(t){return t*t*t*t*t}}),n.add({name:"sin sine",fn:function(t){return 1-Math.cos(t*Math.PI/2)}}),n.add({name:"exp expo",fn:function(t){return 0==t?0:Math.pow(2,10*(t-1))}}),n.add({name:"circle circ",fn:function(t){return 1-Math.sqrt(1-t*t)}}),n.add({name:"bounce",fn:function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}}),n.add({name:"poly",fc:function(t){return function(e){return Math.pow(e,t)}}}),n.add({name:"elastic",fc:function(t,e){e=e||.45,t=t||1;var i=e/(2*Math.PI)*Math.asin(1/t);return function(n){return 1+t*Math.pow(2,-10*n)*Math.sin(2*(n-i)*Math.PI/e)}}}),n.add({name:"back",fc:function(t){return t="undefined"!=typeof t?t:1.70158,function(e){return e*e*((t+1)*e-t)}}}),e.exports=n},{}],3:[function(t,e){function i(t,e){if(this instanceof i){var n=t.viewport().ratio||1;t.on("viewport",function(t){n=t.ratio||n}),this.x=0,this.y=0,this.toString=function(){return(0|this.x)+"x"+(0|this.y)},this.locate=function(t){r(e,t,this),this.x*=n,this.y*=n},this.lookup=function(e,i){this.type=e,this.root=t,this.event=null,i.length=0,this.collect=i,this.root.visit(this.visitor,this)},this.publish=function(e,i,n){if(this.type=e,this.root=t,this.event=i,this.collect=!1,this.timeStamp=Date.now(),"mousemove"!==e&&"touchmove"!==e&&DEBUG&&console.log(this.type+" "+this),n){for(;n.length&&!this.visitor.end(n.shift(),this););n.length=0}else this.root.visit(this.visitor,this)},this.visitor={reverse:!0,visible:!0,start:function(t,e){return!t._flag(e.type)},end:function(t,e){s.raw=e.event,s.type=e.type,s.timeStamp=e.timeStamp,s.abs.x=e.x,s.abs.y=e.y;var i=t.listeners(e.type);if(i&&(t.matrix().inverse().map(e,s),(t===e.root||t.hitTest(s))&&(e.collect&&e.collect.push(t),e.event))){for(var n=!1,r=0;r<i.length;r++)n=i[r].call(t,s)?!0:n;return n}}}}}function n(t,e,i){Object.defineProperty(t,e,{value:i})}function r(t,e,i){e.touches&&e.touches.length?(i.x=e.touches[0].clientX,i.y=e.touches[0].clientY):(i.x=e.clientX,i.y=e.clientY);var n=t.getBoundingClientRect();return i.x-=n.left,i.y-=n.top,i.x-=0|t.clientLeft,i.y-=0|t.clientTop,i}"undefined"==typeof DEBUG&&(DEBUG=!0),t("../core")._load(function(t,e){i.subscribe(t,e)}),i.CLICK="click",i.START="touchstart mousedown",i.MOVE="touchmove mousemove",i.END="touchend mouseup",i.CANCEL="touchcancel mousecancel",i.subscribe=function(t,e){function n(e){e.preventDefault(),t.mouse.locate(e),t.mouse.publish(e.type,e),t.mouse.lookup("click",h),t.mouse.lookup("mousecancel",a)}function r(e){e.preventDefault(),t.mouse.locate(e),t.mouse.publish(e.type,e)}function s(e){e.preventDefault(),t.mouse.publish(e.type,e),h.length&&t.mouse.publish("click",e,h),a.length=0}function o(e){a.length&&t.mouse.publish("mousecancel",e,a),h.length=0}if(!t.mouse){t.mouse=new i(t,e),e.addEventListener("touchstart",n),e.addEventListener("touchend",s),e.addEventListener("touchmove",r),e.addEventListener("touchcancel",o),e.addEventListener("mousedown",n),e.addEventListener("mouseup",s),e.addEventListener("mousemove",r),document.addEventListener("mouseup",o),window.addEventListener("blur",o);var h=[],a=[]}};var s={},o={};n(s,"clone",function(t){return t=t||{},t.x=this.x,t.y=this.y,t}),n(s,"toString",function(){return(0|this.x)+"x"+(0|this.y)+" ("+this.abs+")"}),n(s,"abs",o),n(o,"clone",function(t){return t=t||{},t.x=this.x,t.y=this.y,t}),n(o,"toString",function(){return(0|this.x)+"x"+(0|this.y)}),e.exports=i},{"../core":8}],4:[function(t,e){function i(t,e,i){this._end={},this._duration=e||400,this._delay=i||0,this._owner=t,this._time=0}function n(t,e,i,n){"number"==typeof t.pin(i)?e[i]=n:"number"==typeof t.pin(i+"X")&&"number"==typeof t.pin(i+"Y")&&(e[i+"X"]=n,e[i+"Y"]=n)}var r=t("./easing"),s=t("../core"),o=t("../pin");s.prototype.tween=function(t,e,n){if("number"!=typeof t?(n=t,e=0,t=0):"number"!=typeof e&&(n=e,e=0),!this._tweens){this._tweens=[];var r=0;this.tick(function(t,e,i){if(this._tweens.length){var n=r!=i;if(r=e,n)return!0;var s=this._tweens[0].tick(this,t,e,i);return s&&this._tweens.shift(),"object"==typeof s&&this._tweens.unshift(s),!0}},!0)}this.touch(),n||(this._tweens.length=0);var s=new i(this,t,e);return this._tweens.push(s),s},i.prototype.tick=function(t,e){if(this._time+=e,!(this._time<this._delay)){var i=this._time-this._delay;if(!this._start){this._start={};for(var n in this._end)this._start[n]=this._owner.pin(n)}var r,s;i<this._duration?(r=i/this._duration,s=!1):(r=1,s=!0),r="function"==typeof this._easing?this._easing(r):r;var o=1-r;for(var n in this._end)this._owner.pin(n,this._start[n]*o+this._end[n]*r);if(s){try{this._done&&this._done.call(this._owner)}catch(h){console.log(h)}return this._next||!0}}},i.prototype.tween=function(t,e){return this._next=new i(this._owner,t,e)},i.prototype.duration=function(t){return this._duration=t,this},i.prototype.delay=function(t){return this._delay=t,this},i.prototype.ease=function(t){return this._easing=r(t),this},i.prototype.done=function(t){return this._done=t,this},i.prototype.hide=function(){return this.done(function(){this.hide()}),this},i.prototype.remove=function(){return this.done(function(){this.remove()}),this},i.prototype.pin=function(t,e){if("object"==typeof t)for(var i in t)n(this._owner,this._end,i,t[i]);else"undefined"!=typeof e&&n(this._owner,this._end,t,e);return this},o._add_shortcuts(i),i.prototype.then=function(t){return this.done(t),this},i.prototype.then=function(t){return this.done(t),this},i.prototype.clear=function(){return this},e.exports=i},{"../core":8,"../pin":16,"./easing":2}],5:[function(t){function e(){e._super.call(this),this.label("Anim"),this._textures=[],this._fps=i.Anim.FPS,this._ft=1e3/this._fps,this._time=-1,this._repeat=0,this._index=0,this._frames=[];var t=0;this.tick(function(e,i,n){if(!(this._time<0||this._frames.length<=1)){var r=t!=n;if(t=i,r)return!0;if(this._time+=e,this._time<this._ft)return!0;var s=this._time/this._ft|0;return this._time-=s*this._ft,this.moveFrame(s),this._repeat>0&&(this._repeat-=s)<=0?(this.stop(),this._callback&&this._callback(),!1):!0}},!1)}var i=t("./core");t("./pin"),t("./loop");var n=t("./util/create"),r=t("./util/math");i.anim=function(t,i){var n=new e;return n.frames(t).gotoFrame(0),i&&n.fps(i),n},e._super=i,e.prototype=n(e._super.prototype),i.Anim={FPS:15},e.prototype.fps=function(t){return"undefined"==typeof t?this._fps:(this._fps=t>0?t:i.Anim.FPS,this._ft=1e3/this._fps,this)},e.prototype.setFrames=function(t,e,i){return this.frames(t,e,i)},e.prototype.frames=function(t){return this._index=0,this._frames=i.texture(t).array(),this.touch(),this},e.prototype.length=function(){return this._frames?this._frames.length:0},e.prototype.gotoFrame=function(t,e){return this._index=0|r.rotate(t,this._frames.length),e=e||!this._textures[0],this._textures[0]=this._frames[this._index],e&&(this.pin("width",this._textures[0].width),this.pin("height",this._textures[0].height)),this.touch(),this},e.prototype.moveFrame=function(t){return this.gotoFrame(this._index+t)},e.prototype.repeat=function(t,e){return this._repeat=t*this._frames.length-1,this._callback=e,this.play(),this},e.prototype.play=function(t){return"undefined"!=typeof t?(this.gotoFrame(t),this._time=0):this._time<0&&(this._time=0),this.touch(),this},e.prototype.stop=function(t){return this._time=-1,"undefined"!=typeof t&&this.gotoFrame(t),this}},{"./core":8,"./loop":14,"./pin":16,"./util/create":22,"./util/math":26}],6:[function(t,e){function i(t){function e(t){if(!t||u.fn(t.draw))return t;t=h({},t),u.fn(a)&&(t=a(t)),1!=c&&(t.x*=c,t.y*=c,t.width*=c,t.height*=c,t.top*=c,t.bottom*=c,t.left*=c,t.right*=c),0!=p&&(t.x+=p,t.y+=p,t.width-=2*p,t.height-=2*p,t.top-=p,t.bottom-=p,t.left-=p,t.right-=p);var e=o.pipe();return e.top=t.top,e.bottom=t.bottom,e.left=t.left,e.right=t.right,e.src(t.x,t.y,t.width,t.height),e}function s(t){if(l){if(u.fn(l))return l(t);if(u.hash(l))return l[t]}if(d){for(var e=null,i=0,n=0;n<d.length;n++)f.startsWith(d[n].name,t)&&(0===i?e=d[n]:1===i?e=[e,d[n]]:e.push(d[n]),i++);return 0===i&&u.fn(_)&&(e=function(e){return _(t+(e?e:""))}),e}}i._super.call(this);var o=this;r(t,"filter"),r(t,"cutouts"),r(t,"sprites"),r(t,"factory");var a=t.map||t.filter,c=t.ppu||t.ratio||1,p=t.trim||0,l=t.textures,_=t.factory,d=t.cutouts||t.sprites;this.select=function(t){if(!t)return new n(this.pipe());var i=s(t);return i?new n(i,s,e):void 0}}function n(t,e,i){function n(t,r){return t?u.fn(t.draw)?t:u.hash(t)&&u.number(t.width)&&u.number(t.height)&&u.fn(i)?i(t):u.hash(t)&&u.defined(r)?n(t[r]):u.fn(t)?n(t(r)):u.array(t)?n(t[0]):u.string(t)&&u.fn(e)?n(e(t)):void 0:l}this.one=function(e){return n(t,e)},this.array=function(e){var i=u.array(e)?e:[];if(u.array(t))for(var r=0;r<t.length;r++)i[r]=n(t[r]);else i[0]=n(t);return i}}function r(t,e,i){e in t&&console.log(i?i.replace("%name",e):"'"+e+"' field of texture atlas is deprecated.")}"undefined"==typeof DEBUG&&(DEBUG=!0);var s=t("./core"),o=t("./texture"),h=t("./util/extend"),a=t("./util/create"),u=t("./util/is"),f=t("./util/string"),c={},p=[];s.atlas=function(t){var e=u.fn(t.draw)?t:new i(t);t.name&&(c[t.name]=e),p.push(e),r(t,"imagePath"),r(t,"imageRatio");var n=t.imagePath,o=t.imageRatio||1;return u.string(t.image)?n=t.image:u.hash(t.image)&&(n=t.image.src||t.image.url,o=t.image.ratio||o),n&&s.preload(function(t){n=s.resolve(n),DEBUG&&console.log("Loading atlas: "+n);var i=s.config("image-loader");i(n,function(i){DEBUG&&console.log("Image loaded: "+n),e.src(i,o),t()},function(e){DEBUG&&console.log("Error loading atlas: "+n,e),t()})}),e},i._super=o,i.prototype=a(i._super.prototype);var l=new o;l.x=l.y=l.width=l.height=0,l.pipe=l.src=l.dest=function(){return this},l.draw=function(){};var _=new n(l);s.texture=function(t){if(!u.string(t))return new n(t);var e,i,r=null;for((i=t.indexOf(":"))>0&&t.length>i+1&&(e=c[t.slice(0,i)],r=e&&e.select(t.slice(i+1))),!r&&(e=c[t])&&(r=e.select()),i=0;!r&&i<p.length;i++)r=p[i].select(t);return r||(console.error("Texture not found: "+t),r=_),r},e.exports=i},{"./core":8,"./texture":19,"./util/create":22,"./util/extend":24,"./util/is":25,"./util/string":30}],7:[function(t){var e=t("./core"),i=t("./texture");e.canvas=function(t,e,n){"string"==typeof t?"object"==typeof e||("function"==typeof e&&(n=e),e={}):("function"==typeof t&&(n=t),e={},t="2d");var r=document.createElement("canvas"),s=r.getContext(t,e),o=new i(r);return o.context=function(){return s},o.size=function(t,e,i){return i=i||1,r.width=t*i,r.height=e*i,this.src(r,i),this},o.canvas=function(t){return"function"==typeof t?t.call(this,s):"undefined"==typeof t&&"function"==typeof n&&n.call(this,s),this},"function"==typeof n&&n.call(o,s),o}},{"./core":8,"./texture":19}],8:[function(t,e){function i(t){if(!(this instanceof i))return o.fn(t)?i.app.apply(i,arguments):o.object(t)?i.atlas.apply(i,arguments):t;r.create++;for(var e=0;e<a.length;e++)a[e].call(this)}function n(t,e){var i=document.createElement("script");i.addEventListener("load",function(){e()}),i.addEventListener("error",function(i){e(i||"Error loading script: "+t)}),i.src=t,i.id="preload-"+Date.now(),document.body.appendChild(i)}"undefined"==typeof DEBUG&&(DEBUG=!0);var r=t("./util/stats"),s=t("./util/extend"),o=t("./util/is"),h=t("./util/await");r.create=0;var a=[];i._init=function(t){a.push(t)};var u=[];i._load=function(t){u.push(t)};var f={};i.config=function(){return 1===arguments.length&&o.string(arguments[0])?f[arguments[0]]:(1===arguments.length&&o.object(arguments[0])&&s(f,arguments[0]),void(2===arguments.length&&o.string(arguments[0])&&f[(arguments[0],arguments[1])]))};var c=[],p=[],l=!1,_=!1;i.app=function(t,e){if(!l)return void c.push(arguments);DEBUG&&console.log("Creating app...");var n=i.config("app-loader");n(function(e,i){DEBUG&&console.log("Initing app...");for(var n=0;n<u.length;n++)u[n].call(this,e,i);t(e,i),p.push(e),DEBUG&&console.log("Starting app..."),e.start()},e)};var d=h();i.preload=function(t){if("string"==typeof t){var e=i.resolve(t);/\.js($|\?|\#)/.test(e)&&(DEBUG&&console.log("Loading script: "+e),t=function(t){n(e,t)})}"function"==typeof t&&t(d())},i.start=function(t){DEBUG&&console.log("Starting..."),i.config(t),d.then(function(){for(DEBUG&&console.log("Loading apps..."),l=!0;c.length;){var t=c.shift();i.app.apply(i,t)}})},i.pause=function(){if(!_){_=!0;for(var t=p.length-1;t>=0;t--)p[t].pause()}},i.resume=function(){if(_){_=!1;for(var t=p.length-1;t>=0;t--)p[t].resume()}},i.create=function(){return new i},i.resolve=function(){function t(){if(document.currentScript)return document.currentScript.src;var t;try{var i=new Error;if(!i.stack)throw i;t=i.stack}catch(i){t=i.stack}if("string"==typeof t){t=t.split("\n");for(var n=t.length;n--;){var r=t[n].match(/(\w+\:\/\/[^\/]*?\/.+?)(:\d+)(:\d+)?/);if(r)return r[1]}}if(e.length&&"readyState"in e[0])for(var n=e.length;n--;)if("interactive"===e[n].readyState)return e[n].src;return location.href}if("undefined"==typeof window||"undefined"==typeof document)return function(t){return t};var e=document.getElementsByTagName("script");return function(e){if(/^\.\//.test(e)){var i=t(),n=i.substring(0,i.lastIndexOf("/")+1);e=n+e.substring(2)}return e}}(),e.exports=i},{"./util/await":21,"./util/extend":24,"./util/is":25,"./util/stats":29}],9:[function(t){t("./util/event")(t("./core").prototype,function(t,e,i){t._flag(e,i)})},{"./core":8,"./util/event":23}],10:[function(t){function e(){e._super.call(this),this.label("Image"),this._textures=[],this._image=null}var i=t("./core");t("./pin"),t("./loop");var n=t("./util/repeat"),r=t("./util/create");i.image=function(t){var i=new e;return t&&i.image(t),i},e._super=i,e.prototype=r(e._super.prototype),e.prototype.setImage=function(t,e,i){return this.image(t,e,i)},e.prototype.image=function(t){return this._image=i.texture(t).one(),this.pin("width",this._image?this._image.width:0),this.pin("height",this._image?this._image.height:0),this._textures[0]=this._image.pipe(),this._textures.length=1,this},e.prototype.tile=function(t){return this._repeat(!1,t),this},e.prototype.stretch=function(t){return this._repeat(!0,t),this},e.prototype._repeat=function(t,e){function i(t,e,i,n,s,o,h,a,u){var f=r._textures.length>t?r._textures[t]:r._textures[t]=r._image.pipe();f.src(e,i,n,s),f.dest(o,h,a,u)}var r=this;this.untick(this._repeatTicker),this.tick(this._repeatTicker=function(){if(this._mo_stretch!=this._pin._ts_transform){this._mo_stretch=this._pin._ts_transform;var r=this.pin("width"),s=this.pin("height");this._textures.length=n(this._image,r,s,t,e,i)}})}},{"./core":8,"./loop":14,"./pin":16,"./util/create":22,"./util/repeat":28}],11:[function(t,e){e.exports=t("./core"),e.exports.Matrix=t("./matrix"),e.exports.Texture=t("./texture"),t("./atlas"),t("./tree"),t("./event"),t("./pin"),t("./loop"),t("./root")},{"./atlas":6,"./core":8,"./event":9,"./loop":14,"./matrix":15,"./pin":16,"./root":17,"./texture":19,"./tree":20}],12:[function(t){var e=t("./core");t("./pin"),t("./loop");t("./util/create");e.row=function(t){return e.create().row(t).label("Row")},e.prototype.row=function(t){return this.sequence("row",t),this},e.column=function(t){return e.create().column(t).label("Row")},e.prototype.column=function(t){return this.sequence("column",t),this},e.sequence=function(t,i){return e.create().sequence(t,i).label("Sequence")},e.prototype.sequence=function(t,e){return this._padding=this._padding||0,this._spacing=this._spacing||0,this.untick(this._layoutTiker),this.tick(this._layoutTiker=function(){if(this._mo_seq!=this._ts_touch){this._mo_seq=this._ts_touch;var i=this._mo_seqAlign!=this._ts_children;this._mo_seqAlign=this._ts_children;for(var n,r=0,s=0,o=this.first(!0),h=!0;n=o;){o=n.next(!0),n.matrix(!0);var a=n.pin("boxWidth"),u=n.pin("boxHeight");"column"==t?(!h&&(s+=this._spacing),n.pin("offsetY")!=s&&n.pin("offsetY",s),r=Math.max(r,a),s+=u,i&&n.pin("alignX",e)):"row"==t&&(!h&&(r+=this._spacing),n.pin("offsetX")!=r&&n.pin("offsetX",r),r+=a,s=Math.max(s,u),i&&n.pin("alignY",e)),h=!1}r+=2*this._padding,s+=2*this._padding,this.pin("width")!=r&&this.pin("width",r),this.pin("height")!=s&&this.pin("height",s)}}),this},e.box=function(){return e.create().box().label("Box")},e.prototype.box=function(){return this._padding=this._padding||0,this.untick(this._layoutTiker),this.tick(this._layoutTiker=function(){if(this._mo_box!=this._ts_touch){this._mo_box=this._ts_touch;for(var t,e=0,i=0,n=this.first(!0);t=n;){n=t.next(!0),t.matrix(!0);var r=t.pin("boxWidth"),s=t.pin("boxHeight");e=Math.max(e,r),i=Math.max(i,s)}e+=2*this._padding,i+=2*this._padding,this.pin("width")!=e&&this.pin("width",e),this.pin("height")!=i&&this.pin("height",i)}}),this},e.layer=function(){return e.create().layer().label("Layer")},e.prototype.layer=function(){return this.untick(this._layoutTiker),this.tick(this._layoutTiker=function(){var t=this.parent();if(t){var e=t.pin("width");this.pin("width")!=e&&this.pin("width",e);var i=t.pin("height");this.pin("height")!=i&&this.pin("height",i)}},!0),this},e.prototype.padding=function(t){return this._padding=t,this},e.prototype.spacing=function(t){return this._spacing=t,this}},{"./core":8,"./loop":14,"./pin":16,"./util/create":22}],13:[function(t){function e(t,e){function i(){o.isFast?(o.clear(),o.setTransform(1,0,0,1,0,0)):(o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,a,u)),d.render(o)}function r(){h?(a=window.innerWidth>0?window.innerWidth:screen.width,u=window.innerHeight>0?window.innerHeight:screen.height,s.style.width=a+"px",s.style.height=u+"px"):(a=s.clientWidth,u=s.clientHeight),a*=f,u*=f,(s.width!==a||s.height!==u)&&(s.width=a,s.height=u,DEBUG&&console.log("Resize: "+a+" x "+u+" / "+f),d.viewport(a,u,f),i())}e=e||{};var s=e.canvas,o=null,h=!1,a=0,u=0,f=1;if("string"==typeof s&&(s=document.getElementById(s)),s||(s=document.getElementById("cutjs")||document.getElementById("stage")),!s){h=!0,DEBUG&&console.log("Creating Canvas..."),s=document.createElement("canvas"),s.style.position="absolute";var c=document.body;c.insertBefore(s,c.firstChild)}o=s.getContext("2d",{fastcontext:!0}),o.isFast=!!o.isFast,h=h||o.isFast,DEBUG&&console.log("FastContext: "+o.isFast);var p=window.devicePixelRatio||1,l=o.webkitBackingStorePixelRatio||o.mozBackingStorePixelRatio||o.msBackingStorePixelRatio||o.oBackingStorePixelRatio||o.backingStorePixelRatio||1;f=p/l;var _=window.requestAnimationFrame||window.msRequestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.oRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)};DEBUG&&console.log("Creating stage...");var d=n.root(_,i);d.background=function(t){return o.isFast?o.setBackgroundColor&&o.setBackgroundColor(t):s.style.backgroundColor=t,this},t(d,s),r(),window.addEventListener("resize",r,!1),window.addEventListener("orientationchange",r,!1)}function i(t,e,i){function n(){e(r)}DEBUG&&console.log("Loading image: "+t);var r;FastContext?r=FastContext.createImage(t,n,i):(r=new Image,r.onload=n,r.onerror=i,r.src=t)}"undefined"==typeof DEBUG&&(DEBUG=!0);var n=t("../core"),r=t("../util/once");"undefined"==typeof FastContext&&(FastContext=window.FastContext),window.addEventListener("load",function(){DEBUG&&console.log("On load.");var t=r(function(t){DEBUG&&t&&console.log("Started on "+t),n.start()});document.addEventListener("click",function(){t("click")},!1),document.addEventListener("mousemove",function(){t("mousemove")},!1),document.addEventListener("deviceready",function(){t("deviceready")},!1),document.addEventListener("pause",function(){n.pause()},!1),document.addEventListener("resume",function(){n.resume()},!1)},!1),n.config({"app-loader":e,"image-loader":i})},{"../core":8,"../util/once":27}],14:[function(t){var e=t("./core");t("./pin");var i=t("./util/stats");e.prototype._textures=null,e.prototype._alpha=1,e.prototype.render=function(t){if(this._visible){i.node++;var e=this.matrix();t.setTransform(e.a,e.b,e.c,e.d,e.e,e.f),this._alpha=this._pin._alpha*(this._parent?this._parent._alpha:1);var n=this._pin._textureAlpha*this._alpha;if(t.globalAlpha!=n&&(t.globalAlpha=n),null!==this._textures)for(var r=0,s=this._textures.length;s>r;r++)this._textures[r].draw(t);t.globalAlpha!=this._alpha&&(t.globalAlpha=this._alpha);for(var o,h=this._first;o=h;)h=o._next,o.render(t)}},e.prototype._tickBefore=null,e.prototype._tickAfter=null,e.prototype.MAX_ELAPSE=1/0,e.prototype._tick=function(t,e,n){if(this._visible){t>this.MAX_ELAPSE&&(t=this.MAX_ELAPSE);var r=!1;if(null!==this._tickBefore)for(var s=0,o=this._tickBefore.length;o>s;s++)i.tick++,r=this._tickBefore[s].call(this,t,e,n)===!0||r;for(var h,a=this._first;h=a;)a=h._next,h._flag("_tick")&&(r=h._tick(t,e,n)===!0?!0:r);if(null!==this._tickAfter)for(var s=0,o=this._tickAfter.length;o>s;s++)i.tick++,r=this._tickAfter[s].call(this,t,e,n)===!0||r;return r}},e.prototype.tick=function(t,e){"function"==typeof t&&(e?(null===this._tickBefore&&(this._tickBefore=[]),this._tickBefore.push(t)):(null===this._tickAfter&&(this._tickAfter=[]),this._tickAfter.push(t)),this._flag("_tick",null!==this._tickAfter&&this._tickAfter.length>0||null!==this._tickBefore&&this._tickBefore.length>0))},e.prototype.untick=function(t){if("function"==typeof t){var e;null!==this._tickBefore&&(e=this._tickBefore.indexOf(t))>=0&&this._tickBefore.splice(e,1),null!==this._tickAfter&&(e=this._tickAfter.indexOf(t))>=0&&this._tickAfter.splice(e,1)}},e.prototype.timeout=function(t,e){this.tick(function i(n){return(e-=n)<0?(this.untick(i),void t.call(this)):!0})}},{"./core":8,"./pin":16,"./util/stats":29}],15:[function(t,e){function i(t,e,i,n,r,s){this.reset(t,e,i,n,r,s)}i.prototype.toString=function(){return"["+this.a+", "+this.b+", "+this.c+", "+this.d+", "+this.e+", "+this.f+"]"},i.prototype.clone=function(){return new i(this.a,this.b,this.c,this.d,this.e,this.f)},i.prototype.reset=function(t,e,i,n,r,s){return this._dirty=!0,"object"==typeof t?(this.a=t.a,this.d=t.d,this.b=t.b,this.c=t.c,this.e=t.e,this.f=t.f):(this.a=t||1,this.d=n||1,this.b=e||0,this.c=i||0,this.e=r||0,this.f=s||0),this},i.prototype.identity=function(){return this._dirty=!0,this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this},i.prototype.rotate=function(t){if(!t)return this;this._dirty=!0;var e=t?Math.cos(t):1,i=t?Math.sin(t):0,n=e*this.a-i*this.b,r=e*this.b+i*this.a,s=e*this.c-i*this.d,o=e*this.d+i*this.c,h=e*this.e-i*this.f,a=e*this.f+i*this.e;return this.a=n,this.b=r,this.c=s,this.d=o,this.e=h,this.f=a,this},i.prototype.translate=function(t,e){return t||e?(this._dirty=!0,this.e+=t,this.f+=e,this):this},i.prototype.scale=function(t,e){return t-1||e-1?(this._dirty=!0,this.a*=t,this.b*=e,this.c*=t,this.d*=e,this.e*=t,this.f*=e,this):this},i.prototype.skew=function(t,e){if(!t&&!e)return this;this._dirty=!0;var i=this.a+this.b*t,n=this.b+this.a*e,r=this.c+this.d*t,s=this.d+this.c*e,o=this.e+this.f*t,h=this.f+this.e*e;return this.a=i,this.b=n,this.c=r,this.d=s,this.e=o,this.f=h,this},i.prototype.concat=function(t){this._dirty=!0;var e=this,i=e.a*t.a+e.b*t.c,n=e.b*t.d+e.a*t.b,r=e.c*t.a+e.d*t.c,s=e.d*t.d+e.c*t.b,o=e.e*t.a+t.e+e.f*t.c,h=e.f*t.d+t.f+e.e*t.b;return this.a=i,this.b=n,this.c=r,this.d=s,this.e=o,this.f=h,this},i.prototype.inverse=i.prototype.reverse=function(){if(this._dirty){this._dirty=!1,this.inversed=this.inversed||new i;var t=this.a*this.d-this.b*this.c;this.inversed.a=this.d/t,this.inversed.b=-this.b/t,this.inversed.c=-this.c/t,this.inversed.d=this.a/t,this.inversed.e=(this.c*this.f-this.e*this.d)/t,this.inversed.f=(this.e*this.b-this.a*this.f)/t}return this.inversed},i.prototype.map=function(t,e){return e=e||{},e.x=this.a*t.x+this.c*t.y+this.e,e.y=this.b*t.x+this.d*t.y+this.f,e},i.prototype.mapX=function(t,e){return"object"==typeof t&&(e=t.y,t=t.x),this.a*t+this.c*e+this.e},i.prototype.mapY=function(t,e){return"object"==typeof t&&(e=t.y,t=t.x),this.b*t+this.d*e+this.f},e.exports=i},{}],16:[function(t,e){function i(t){this._owner=t,this._parent=null,this._relativeMatrix=new s,this._absoluteMatrix=new s,this.reset()}function n(t,e,i,n){var r="number"==typeof e,s="number"==typeof i,h="string"==typeof n;t._ts_transform=++o,r&&(t._scaleX=e/t._width_,t._width=t._width_),s&&(t._scaleY=i/t._height_,t._height=t._height_),r&&s&&h&&("out"==n||"out-crop"==n?t._scaleX=t._scaleY=Math.max(t._scaleX,t._scaleY):("in"==n||"in-pad"==n)&&(t._scaleX=t._scaleY=Math.min(t._scaleX,t._scaleY)),("out-crop"==n||"in-pad"==n)&&(t._width=e/t._scaleX,t._height=i/t._scaleY))}var r=t("./core"),s=t("./matrix"),o=0;r._init(function(){this._pin=new i(this)}),r.prototype.matrix=function(t){return t===!0?this._pin.relativeMatrix():this._pin.absoluteMatrix()},r.prototype.pin=function(t,e){return"object"==typeof t?(this._pin.set(t),this):"string"==typeof t?"undefined"==typeof e?this._pin.get(t):(this._pin.set(t,e),this):"undefined"==typeof t?this._pin:void 0},i.prototype.reset=function(){this._textureAlpha=1,this._alpha=1,this._width=0,this._height=0,this._scaleX=1,this._scaleY=1,this._skewX=0,this._skewY=0,this._rotation=0,this._pivoted=!1,this._pivotX=null,this._pivotY=null,this._handled=!1,this._handleX=0,this._handleY=0,this._aligned=!1,this._alignX=0,this._alignY=0,this._offsetX=0,this._offsetY=0,this._boxX=0,this._boxY=0,this._boxWidth=this._width,this._boxHeight=this._height,this._ts_translate=++o,this._ts_transform=++o,this._ts_matrix=++o},i.prototype._update=function(){return this._parent=this._owner._parent&&this._owner._parent._pin,this._handled&&this._mo_handle!=this._ts_transform&&(this._mo_handle=this._ts_transform,this._ts_translate=++o),this._aligned&&this._parent&&this._mo_align!=this._parent._ts_transform&&(this._mo_align=this._parent._ts_transform,this._ts_translate=++o),this},i.prototype.toString=function(){return this._owner+" ("+(this._parent?this._parent._owner:null)+")"},i.prototype.absoluteMatrix=function(){this._update();var t=Math.max(this._ts_transform,this._ts_translate,this._parent?this._parent._ts_matrix:0);if(this._mo_abs==t)return this._absoluteMatrix;this._mo_abs=t;var e=this._absoluteMatrix;return e.reset(this.relativeMatrix()),this._parent&&e.concat(this._parent._absoluteMatrix),this._ts_matrix=++o,e},i.prototype.relativeMatrix=function(){this._update();var t=Math.max(this._ts_transform,this._ts_translate,this._parent?this._parent._ts_transform:0);if(this._mo_rel==t)return this._relativeMatrix;this._mo_rel=t;var e=this._relativeMatrix;if(e.identity(),this._pivoted&&e.translate(-this._pivotX*this._width,-this._pivotY*this._height),e.scale(this._scaleX,this._scaleY),e.skew(this._skewX,this._skewY),e.rotate(this._rotation),this._pivoted&&e.translate(this._pivotX*this._width,this._pivotY*this._height),this._pivoted)this._boxX=0,this._boxY=0,this._boxWidth=this._width,this._boxHeight=this._height;else{var i,n;e.a>0&&e.c>0||e.a<0&&e.c<0?(i=0,n=e.a*this._width+e.c*this._height):(i=e.a*this._width,n=e.c*this._height),i>n?(this._boxX=n,this._boxWidth=i-n):(this._boxX=i,this._boxWidth=n-i),e.b>0&&e.d>0||e.b<0&&e.d<0?(i=0,n=e.b*this._width+e.d*this._height):(i=e.b*this._width,n=e.d*this._height),i>n?(this._boxY=n,this._boxHeight=i-n):(this._boxY=i,this._boxHeight=n-i)}return this._x=this._offsetX,this._y=this._offsetY,this._x-=this._boxX+this._handleX*this._boxWidth,this._y-=this._boxY+this._handleY*this._boxHeight,this._aligned&&this._parent&&(this._parent.relativeMatrix(),this._x+=this._alignX*this._parent._width,this._y+=this._alignY*this._parent._height),e.translate(this._x,this._y),this._relativeMatrix},i.prototype.get=function(t){return"function"==typeof h[t]?h[t](this):void 0},i.prototype.set=function(t,e){if("string"==typeof t)"function"==typeof a[t]&&"undefined"!=typeof e&&a[t](this,e);else if("object"==typeof t)for(e in t)"function"==typeof a[e]&&"undefined"!=typeof t[e]&&a[e](this,t[e],t);return this._owner&&(this._owner._ts_pin=++o,this._owner.touch()),this};var h={alpha:function(t){return t._alpha},textureAlpha:function(t){return t._textureAlpha},width:function(t){return t._width},height:function(t){return t._height},boxWidth:function(t){return t._boxWidth},boxHeight:function(t){return t._boxHeight},scaleX:function(t){return t._scaleX},scaleY:function(t){return t._scaleY},skewX:function(t){return t._skewX},skewY:function(t){return t._skewY},rotation:function(t){return t._rotation},pivotX:function(t){return t._pivotX},pivotY:function(t){return t._pivotY},offsetX:function(t){return t._offsetX},offsetY:function(t){return t._offsetY},alignX:function(t){return t._alignX},alignY:function(t){return t._alignY},handleX:function(t){return t._handleX},handleY:function(t){return t._handleY}},a={alpha:function(t,e){t._alpha=e},textureAlpha:function(t,e){t._textureAlpha=e},width:function(t,e){t._width_=e,t._width=e,t._ts_transform=++o},height:function(t,e){t._height_=e,t._height=e,t._ts_transform=++o},scale:function(t,e){t._scaleX=e,t._scaleY=e,t._ts_transform=++o},scaleX:function(t,e){t._scaleX=e,t._ts_transform=++o},scaleY:function(t,e){t._scaleY=e,t._ts_transform=++o},skew:function(t,e){t._skewX=e,t._skewY=e,t._ts_transform=++o},skewX:function(t,e){t._skewX=e,t._ts_transform=++o},skewY:function(t,e){t._skewY=e,t._ts_transform=++o},rotation:function(t,e){t._rotation=e,t._ts_transform=++o},pivot:function(t,e){t._pivotX=e,t._pivotY=e,t._pivoted=!0,t._ts_transform=++o},pivotX:function(t,e){t._pivotX=e,t._pivoted=!0,t._ts_transform=++o},pivotY:function(t,e){t._pivotY=e,t._pivoted=!0,t._ts_transform=++o},offset:function(t,e){t._offsetX=e,t._offsetY=e,t._ts_translate=++o},offsetX:function(t,e){t._offsetX=e,t._ts_translate=++o},offsetY:function(t,e){t._offsetY=e,t._ts_translate=++o},align:function(t,e){this.alignX(t,e),this.alignY(t,e)},alignX:function(t,e){t._alignX=e,t._aligned=!0,t._ts_translate=++o,this.handleX(t,e)},alignY:function(t,e){t._alignY=e,t._aligned=!0,t._ts_translate=++o,this.handleY(t,e)
+},handle:function(t,e){this.handleX(t,e),this.handleY(t,e)},handleX:function(t,e){t._handleX=e,t._handled=!0,t._ts_translate=++o},handleY:function(t,e){t._handleY=e,t._handled=!0,t._ts_translate=++o},resizeMode:function(t,e,i){i&&("in"==e?e="in-pad":"out"==e&&(e="out-crop"),n(t,i.resizeWidth,i.resizeHeight,e))},resizeWidth:function(t,e,i){i&&i.resizeMode||n(t,e,null)},resizeHeight:function(t,e,i){i&&i.resizeMode||n(t,null,e)},scaleMode:function(t,e,i){i&&n(t,i.scaleWidth,i.scaleHeight,e)},scaleWidth:function(t,e,i){i&&i.scaleMode||n(t,e,null)},scaleHeight:function(t,e,i){i&&i.scaleMode||n(t,null,e)},matrix:function(t,e){this.scaleX(t,e.a),this.skewX(t,e.c/e.d),this.skewY(t,e.b/e.a),this.scaleY(t,e.d),this.offsetX(t,e.e),this.offsetY(t,e.f),this.rotation(t,0)}};r.prototype.scaleTo=function(t,e,i){return"object"==typeof t&&(i=e,e=t.y,t=t.x),n(this._pin,t,e,i),this},i._add_shortcuts=function(t){t.prototype.size=function(t,e){return this.pin("width",t),this.pin("height",e),this},t.prototype.width=function(t){return"undefined"==typeof t?this.pin("width"):(this.pin("width",t),this)},t.prototype.height=function(t){return"undefined"==typeof t?this.pin("height"):(this.pin("height",t),this)},t.prototype.offset=function(t,e){return"object"==typeof t&&(e=t.y,t=t.x),this.pin("offsetX",t),this.pin("offsetY",e),this},t.prototype.rotate=function(t){return this.pin("rotation",t),this},t.prototype.skew=function(t,e){return"object"==typeof t?(e=t.y,t=t.x):"undefined"==typeof e&&(e=t),this.pin("skewX",t),this.pin("skewY",e),this},t.prototype.scale=function(t,e){return"object"==typeof t?(e=t.y,t=t.x):"undefined"==typeof e&&(e=t),this.pin("scaleX",t),this.pin("scaleY",e),this},t.prototype.alpha=function(t,e){return this.pin("alpha",t),"undefined"!=typeof e&&this.pin("textureAlpha",e),this}},i._add_shortcuts(r),e.exports=i},{"./core":8,"./matrix":15}],17:[function(t){function e(t,i){e._super.call(this),this.label("Root");var r=!0,s=this,o=0,h=function(e){if(r!==!0){n.tick=n.node=n.draw=0;var a=o||e,u=e-a;o=e;var f=s._tick(u,e,a);s._mo_touch!=s._ts_touch?(s._mo_touch=s._ts_touch,i(s),t(h)):f?t(h):r=!0,n.fps=u?1e3/u:0}};this.start=function(){return this.resume()},this.resume=function(){return r&&(r=!1,t(h)),this},this.pause=function(){return r=!0,this},this.touch_root=this.touch,this.touch=function(){return this.resume(),this.touch_root()}}var i=t("./core");t("./pin"),t("./loop");var n=t("./util/stats"),r=t("./util/create"),s=t("./util/extend");e._super=i,e.prototype=r(e._super.prototype),i.root=function(t,i){return new e(t,i)},e.prototype.background=function(){return this},e.prototype.viewport=function(t,e,i){if("undefined"==typeof t)return s({},this._viewport);this._viewport={width:t,height:e,ratio:i||1},this.viewbox();var n=s({},this._viewport);return this.visit({start:function(t){return t._flag("viewport")?void t.publish("viewport",[n]):!0}}),this},e.prototype.viewbox=function(t,e,i){"number"==typeof t&&"number"==typeof e&&(this._viewbox={width:t,height:e,mode:/^(in|out|in-pad|out-crop)$/.test(i)?i:"in-pad"});var n=this._viewbox,r=this._viewport;return r&&n?(this.pin({width:n.width,height:n.height}),this.scaleTo(r.width,r.height,n.mode)):r&&this.pin({width:r.width,height:r.height}),this}},{"./core":8,"./loop":14,"./pin":16,"./util/create":22,"./util/extend":24,"./util/stats":29}],18:[function(t){function e(){e._super.call(this),this.label("String"),this._textures=[]}var i=t("./core");t("./pin"),t("./loop");var n=t("./util/create"),r=t("./util/is");i.string=function(t){return(new e).frames(t)},e._super=i,e.prototype=n(e._super.prototype),e.prototype.setFont=function(t,e,i){return this.frames(t,e,i)},e.prototype.frames=function(t){return this._textures=[],"string"==typeof t?(t=i.texture(t),this._item=function(e){return t.one(e)}):"object"==typeof t?this._item=function(e){return t[e]}:"function"==typeof t&&(this._item=t),this},e.prototype.setValue=function(t,e,i){return this.value(t,e,i)},e.prototype.value=function(t){if("undefined"==typeof t)return this._value;if(this._value===t)return this;this._value=t,null===t?t="":"string"==typeof t||r.array(t)||(t=t.toString()),this._spacing=this._spacing||0;for(var e=0,i=0,n=0;n<t.length;n++){var s=this._textures[n]=this._item(t[n]);e+=n>0?this._spacing:0,s.dest(e,0),e+=s.width,i=Math.max(i,s.height)}return this.pin("width",e),this.pin("height",i),this._textures.length=t.length,this}},{"./core":8,"./loop":14,"./pin":16,"./util/create":22,"./util/is":25}],19:[function(t,e){function i(t,e){"object"==typeof t&&this.src(t,e)}var n=t("./util/stats"),r=t("./util/math");i.prototype.pipe=function(){return new i(this)},i.prototype.src=function(t,e,i,n){if("object"==typeof t){var r=t,s=e||1;this._image=r,this._sx=this._dx=0,this._sy=this._dy=0,this._sw=this._dw=r.width/s,this._sh=this._dh=r.height/s,this.width=r.width/s,this.height=r.height/s,this.ratio=s}else"undefined"==typeof i?(i=t,n=e):(this._sx=t,this._sy=e),this._sw=this._dw=i,this._sh=this._dh=n,this.width=i,this.height=n;return this},i.prototype.dest=function(t,e,i,n){return this._dx=t,this._dy=e,this._dx=t,this._dy=e,"undefined"!=typeof i&&(this._dw=i,this._dh=n,this.width=i,this.height=n),this},i.prototype.draw=function(t,e,i,s,o,h,a,u,f){var c=this._image;if(null!==c&&"object"==typeof c){var p=this._sx,l=this._sy,_=this._sw,d=this._sh,g=this._dx,y=this._dy,m=this._dw,v=this._dh;"undefined"!=typeof h?(e=r.limit(e,0,this._sw),s=r.limit(s,0,this._sw-e),i=r.limit(i,0,this._sh),o=r.limit(o,0,this._sh-i),p+=e,l+=i,_=s,d=o,g=h,y=a,m=u,v=f):"undefined"!=typeof s?(g=e,y=i,m=s,v=o):"undefined"!=typeof e&&(m=e,v=i);var x=this.ratio||1;p*=x,l*=x,_*=x,d*=x;try{"function"==typeof c.draw?c.draw(t,p,l,_,d,g,y,m,v):(n.draw++,t.drawImage(c,p,l,_,d,g,y,m,v))}catch(b){c._draw_failed||(console.log("Unable to draw: ",c),console.log(b),c._draw_failed=!0)}}},e.exports=i},{"./util/math":26,"./util/stats":29}],20:[function(t,e){function i(t,e){o(e),o(t),e.remove(),t._last&&(t._last._next=e,e._prev=t._last),e._parent=t,t._last=e,t._first||(t._first=e),e._parent._flag(e,!0),e._ts_parent=++u,t._ts_children=++u,t.touch()}function n(t,e){o(e),o(t),e.remove(),t._first&&(t._first._prev=e,e._next=t._first),e._parent=t,t._first=e,t._last||(t._last=e),e._parent._flag(e,!0),e._ts_parent=++u,t._ts_children=++u,t.touch()}function r(t,e){o(t),o(e),t.remove();var i=e._parent,n=e._prev;e._prev=t,n&&(n._next=t)||i&&(i._first=t),t._parent=i,t._prev=n,t._next=e,t._parent._flag(t,!0),t._ts_parent=++u,t.touch()}function s(t,e){o(t),o(e),t.remove();var i=e._parent,n=e._next;e._next=t,n&&(n._prev=t)||i&&(i._last=t),t._parent=i,t._prev=e,t._next=n,t._parent._flag(t,!0),t._ts_parent=++u,t.touch()}function o(t){if(t&&t instanceof h)return t;throw"Invalid node: "+t}var h=t("./core"),a=t("./util/is"),u=0;h.prototype._label="",h.prototype._visible=!0,h.prototype._parent=null,h.prototype._next=null,h.prototype._prev=null,h.prototype._first=null,h.prototype._last=null,h.prototype._attrs=null,h.prototype._flags=null,h.prototype.toString=function(){return"["+this._label+"]"},h.prototype.id=function(t){return this.label(t)},h.prototype.label=function(t){return"undefined"==typeof t?this._label:(this._label=t,this)},h.prototype.attr=function(t,e){return"undefined"==typeof e?null!==this._attrs?this._attrs[t]:void 0:((null!==this._attrs?this._attrs:this._attrs={})[t]=e,this)},h.prototype.visible=function(t){return"undefined"==typeof t?this._visible:(this._visible=t,this._parent&&(this._parent._ts_children=++u),this._ts_pin=++u,this.touch(),this)},h.prototype.hide=function(){return this.visible(!1)},h.prototype.show=function(){return this.visible(!0)},h.prototype.parent=function(){return this._parent},h.prototype.next=function(t){for(var e=this._next;e&&t&&!e._visible;)e=e._next;return e},h.prototype.prev=function(t){for(var e=this._prev;e&&t&&!e._visible;)e=e._prev;return e},h.prototype.first=function(t){for(var e=this._first;e&&t&&!e._visible;)e=e._next;return e},h.prototype.last=function(t){for(var e=this._last;e&&t&&!e._visible;)e=e._prev;return e},h.prototype.visit=function(t,e){var i=t.reverse,n=t.visible;if(!t.start||!t.start(this,e)){for(var r,s=i?this.last(n):this.first(n);r=s;)if(s=i?r.prev(n):r.next(n),r.visit(t,e))return!0;return t.end&&t.end(this,e)}},h.prototype.append=function(t,e){if(a.array(t))for(var n=0;n<t.length;n++)i(this,t[n]);else if("undefined"!=typeof e)for(var n=0;n<arguments.length;n++)i(this,arguments[n]);else"undefined"!=typeof t&&i(this,t);return this},h.prototype.prepend=function(t,e){if(a.array(t))for(var i=t.length-1;i>=0;i--)n(this,t[i]);else if("undefined"!=typeof e)for(var i=arguments.length-1;i>=0;i--)n(this,arguments[i]);else"undefined"!=typeof t&&n(this,t);return this},h.prototype.appendTo=function(t){return i(t,this),this},h.prototype.prependTo=function(t){return n(t,this),this},h.prototype.insertNext=function(t,e){if(a.array(t))for(var i=0;i<t.length;i++)s(t[i],this);else if("undefined"!=typeof e)for(var i=0;i<arguments.length;i++)s(arguments[i],this);else"undefined"!=typeof t&&s(t,this);return this},h.prototype.insertPrev=function(t,e){if(a.array(t))for(var i=t.length-1;i>=0;i--)r(t[i],this);else if("undefined"!=typeof e)for(var i=arguments.length-1;i>=0;i--)r(arguments[i],this);else"undefined"!=typeof t&&r(t,this);return this},h.prototype.insertAfter=function(t){return s(this,t),this},h.prototype.insertBefore=function(t){return r(this,t),this},h.prototype.remove=function(t,e){if("undefined"!=typeof t){if(a.array(t))for(var i=0;i<t.length;i++)o(t[i]).remove();else if("undefined"!=typeof e)for(var i=0;i<arguments.length;i++)o(arguments[i]).remove();else o(t).remove();return this}return this._prev&&(this._prev._next=this._next),this._next&&(this._next._prev=this._prev),this._parent&&(this._parent._first===this&&(this._parent._first=this._next),this._parent._last===this&&(this._parent._last=this._prev),this._parent._flag(this,!1),this._parent._ts_children=++u,this._parent.touch()),this._prev=this._next=this._parent=null,this._ts_parent=++u,this},h.prototype.empty=function(){for(var t,e=this._first;t=e;)e=t._next,t._prev=t._next=t._parent=null,this._flag(t,!1);return this._first=this._last=null,this._ts_children=++u,this.touch(),this},h.prototype.touch=function(){return this._ts_touch=++u,this._parent&&this._parent.touch(),this},h.prototype._flag=function(t,e){if("undefined"==typeof e)return null!==this._flags&&this._flags[t]||0;if("string"==typeof t&&(e?(this._flags=this._flags||{},!this._flags[t]&&this._parent&&this._parent._flag(t,!0),this._flags[t]=(this._flags[t]||0)+1):this._flags&&this._flags[t]>0&&(1==this._flags[t]&&this._parent&&this._parent._flag(t,!1),this._flags[t]=this._flags[t]-1)),"object"==typeof t&&t._flags)for(var i in t._flags)t._flags[i]>0&&this._flag(i,e);return this},h.prototype.hitTest=function(t){return this.attr("spy")?!0:t.x>=0&&t.x<=this._pin._width&&t.y>=0&&t.y<=this._pin._height},e.exports=h},{"./core":8,"./util/is":25}],21:[function(t,e){e.exports=function(){function t(t,n){return i+=n="number"==typeof n&&n>=1?n:1,function(){t&&t.apply(this,arguments),n>0&&(n--,i--,e())}}function e(){if(0===i)for(;n.length;)setTimeout(n.shift(),0)}var i=0,n=[];return t.then=function(t){0===i?setTimeout(t,0):n.push(t)},t}},{}],22:[function(t,e){function i(){}e.exports="function"==typeof Object.create?function(t,e){return Object.create.call(Object,t,e)}:function(t,e){if(e)throw Error("Second argument is not supported!");if("object"!=typeof t||null===t)throw Error("Invalid prototype!");return i.prototype=t,new i}},{}],23:[function(t,e){e.exports=function(t,e){t._listeners=null,t.on=t.listen=function(t,i){if(!t||!t.length||"function"!=typeof i)return this;null===this._listeners&&(this._listeners={});var n="string"!=typeof t&&"function"==typeof t.join;if(t=(n?t.join(" "):t).match(/\S+/g))for(var r=0;r<t.length;r++){var s=t[r];this._listeners[s]=this._listeners[s]||[],this._listeners[s].push(i),"function"==typeof e&&e(this,s,!0)}return this},t.off=function(t,i){if(!t||!t.length||"function"!=typeof i)return this;if(null===this._listeners)return this;var n="string"!=typeof t&&"function"==typeof t.join;if(t=(n?t.join(" "):t).match(/\S+/g))for(var r=0;r<t.length;r++){var s,o=t[r],h=this._listeners[o];h&&(s=h.indexOf(i))>=0&&(h.splice(s,1),h.length||delete this._listeners[o],"function"==typeof e&&e(this,o,!1))}return this},t.listeners=function(t){return this._listeners&&this._listeners[t]},t.publish=function(t,e){var i=this.listeners(t);if(!i||!i.length)return 0;for(var n=0;n<i.length;n++)i[n].apply(this,e);return i.length},t.trigger=function(t,e){return this.publish(t,e),this}}},{}],24:[function(t,e){e.exports=function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])}return t}},{}],25:[function(t,e){var i=Object.prototype,n=i.hasOwnProperty,r=i.toString,s=/^[A-Fa-f0-9]+$/,o=e.exports={};o.a=o.an=o.type=function(t,e){return typeof t===e},o.defined=function(t){return"undefined"!=typeof t},o.empty=function(t){var e,i=r.call(t);if("[object Array]"===i||"[object Arguments]"===i||"[object String]"===i)return 0===t.length;if("[object Object]"===i){for(e in t)if(n.call(t,e))return!1;return!0}return!t},o.equal=function(t,e){if(t===e)return!0;var i,n=r.call(t);if(n!==r.call(e))return!1;if("[object Object]"===n){for(i in t)if(!(o.equal(t[i],e[i])&&i in e))return!1;for(i in e)if(!(o.equal(t[i],e[i])&&i in t))return!1;return!0}if("[object Array]"===n){if(i=t.length,i!==e.length)return!1;for(;--i;)if(!o.equal(t[i],e[i]))return!1;return!0}return"[object Function]"===n?t.prototype===e.prototype:"[object Date]"===n?t.getTime()===e.getTime():!1},o.instance=function(t,e){return t instanceof e},o.nil=function(t){return null===t},o.undef=function(t){return"undefined"==typeof t},o.array=function(t){return"[object Array]"===r.call(t)},o.emptyarray=function(t){return o.array(t)&&0===t.length},o.arraylike=function(t){return!!t&&!o["boolean"](t)&&n.call(t,"length")&&isFinite(t.length)&&o.number(t.length)&&t.length>=0},o["boolean"]=function(t){return"[object Boolean]"===r.call(t)},o.element=function(t){return void 0!==t&&"undefined"!=typeof HTMLElement&&t instanceof HTMLElement&&1===t.nodeType},o.fn=function(t){return"[object Function]"===r.call(t)},o.number=function(t){return"[object Number]"===r.call(t)},o.nan=function(t){return!o.number(t)||t!==t},o.object=function(t){return"[object Object]"===r.call(t)},o.hash=function(t){return o.object(t)&&t.constructor===Object&&!t.nodeType&&!t.setInterval},o.regexp=function(t){return"[object RegExp]"===r.call(t)},o.string=function(t){return"[object String]"===r.call(t)},o.hex=function(t){return o.string(t)&&(!t.length||s.test(t))}},{}],26:[function(t,e){var i=t("./create"),n=Math;e.exports=i(Math),e.exports.random=function(t,e){return"undefined"==typeof t?(e=1,t=0):"undefined"==typeof e&&(e=t,t=0),t==e?t:n.random()*(e-t)+t},e.exports.rotate=function(t,e,i){return"undefined"==typeof e?(i=1,e=0):"undefined"==typeof i&&(i=e,e=0),i>e?(t=(t-e)%(i-e),t+(0>t?i:e)):(t=(t-i)%(e-i),t+(0>=t?e:i))},e.exports.limit=function(t,e,i){return e>t?e:t>i?i:t},e.exports.length=function(t,e){return n.sqrt(t*t+e*e)}},{"./create":22}],27:[function(t,e){e.exports=function(t,e){var i=!1;return function(){i||(i=!0,t.apply(e,arguments))}}},{}],28:[function(t,e){e.exports=function(t,e,i,n,r,s){var o=t.width,h=t.height,a=t.left,u=t.right,f=t.top,c=t.bottom;a="number"==typeof a&&a===a?a:0,u="number"==typeof u&&u===u?u:0,f="number"==typeof f&&f===f?f:0,c="number"==typeof c&&c===c?c:0,o=o-a-u,h=h-f-c,r||(e=Math.max(e-a-u,0),i=Math.max(i-f-c,0));var p=0;if(f>0&&a>0&&s(p++,0,0,a,f,0,0,a,f),c>0&&a>0&&s(p++,0,h+f,a,c,0,i+f,a,c),f>0&&u>0&&s(p++,o+a,0,u,f,e+a,0,u,f),c>0&&u>0&&s(p++,o+a,h+f,u,c,e+a,i+f,u,c),n)f>0&&s(p++,a,0,o,f,a,0,e,f),c>0&&s(p++,a,h+f,o,c,a,i+f,e,c),a>0&&s(p++,0,f,a,h,0,f,a,i),u>0&&s(p++,o+a,f,u,h,e+a,f,u,i),s(p++,a,f,o,h,a,f,e,i);else for(var l,_=a,d=e;d>0;){l=Math.min(o,d),d-=o;for(var g,y=f,m=i;m>0;)g=Math.min(h,m),m-=h,s(p++,a,f,l,g,_,y,l,g),0>=d&&(a&&s(p++,0,f,a,g,0,y,a,g),u&&s(p++,o+a,f,u,g,_+l,y,u,g)),y+=g;f&&s(p++,a,0,l,f,_,0,l,f),c&&s(p++,a,h+f,l,c,_,y,l,c),_+=l}return p}},{}],29:[function(t,e){e.exports={}},{}],30:[function(t,e){e.exports.startsWith=function(t,e){return"string"==typeof t&&"string"==typeof e&&t.substring(0,e.length)==e}},{}]},{},[1])(1)});
\ No newline at end of file
diff --git a/dist/stage.web.js b/dist/stage.web.js
index 5a99a0a..1b9b164 100644
--- a/dist/stage.web.js
+++ b/dist/stage.web.js
@@ -1,8 +1,8 @@
 /*
- * Stage.js 0.8.1
- * Copyright (c) 2015 Ali Shakiba, Piqnt LLC
- * Available under the MIT license
- * @license
+ * Stage.js 0.8.2
+ * 
+ * @copyright 2015 Ali Shakiba, Piqnt LLC
+ * @license The MIT License
  */
 
 !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Stage=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
@@ -29,7 +29,7 @@ module.exports._extend = require("../lib/util/extend");
 module.exports._create = require("../lib/util/create");
 
 require("../lib/loader/web");
-},{"../lib/":11,"../lib/addon/mouse":3,"../lib/addon/tween":4,"../lib/anim":5,"../lib/canvas":7,"../lib/image":10,"../lib/layout":12,"../lib/loader/web":13,"../lib/str":19,"../lib/util/create":22,"../lib/util/extend":24,"../lib/util/math":26}],2:[function(require,module,exports){
+},{"../lib/":11,"../lib/addon/mouse":3,"../lib/addon/tween":4,"../lib/anim":5,"../lib/canvas":7,"../lib/image":10,"../lib/layout":12,"../lib/loader/web":13,"../lib/str":18,"../lib/util/create":22,"../lib/util/extend":24,"../lib/util/math":26}],2:[function(require,module,exports){
 function _identity(x) {
     return x;
 }
@@ -587,7 +587,7 @@ var Class = require("./core");
 
 require("./pin");
 
-require("./render");
+require("./loop");
 
 var create = require("./util/create");
 
@@ -716,7 +716,7 @@ Anim.prototype.stop = function(frame) {
 };
 
 
-},{"./core":8,"./pin":16,"./render":17,"./util/create":22,"./util/math":26}],6:[function(require,module,exports){
+},{"./core":8,"./loop":14,"./pin":16,"./util/create":22,"./util/math":26}],6:[function(require,module,exports){
 if (typeof DEBUG === "undefined") DEBUG = true;
 
 var Class = require("./core");
@@ -932,7 +932,7 @@ function deprecated(hash, name, msg) {
 module.exports = Atlas;
 
 
-},{"./core":8,"./texture":20,"./util/create":22,"./util/extend":24,"./util/is":25,"./util/string":29}],7:[function(require,module,exports){
+},{"./core":8,"./texture":19,"./util/create":22,"./util/extend":24,"./util/is":25,"./util/string":29}],7:[function(require,module,exports){
 var Class = require("./core");
 
 var Texture = require("./texture");
@@ -980,7 +980,7 @@ Class.canvas = function(type, attributes, callback) {
 };
 
 
-},{"./core":8,"./texture":20}],8:[function(require,module,exports){
+},{"./core":8,"./texture":19}],8:[function(require,module,exports){
 if (typeof DEBUG === "undefined") DEBUG = true;
 
 var stats = require("./util/stats");
@@ -1210,7 +1210,7 @@ var Class = require("./core");
 
 require("./pin");
 
-require("./render");
+require("./loop");
 
 var repeat = require("./util/repeat");
 
@@ -1279,7 +1279,7 @@ Image.prototype._repeat = function(stretch, inner) {
 };
 
 
-},{"./core":8,"./pin":16,"./render":17,"./util/create":22,"./util/repeat":27}],11:[function(require,module,exports){
+},{"./core":8,"./loop":14,"./pin":16,"./util/create":22,"./util/repeat":27}],11:[function(require,module,exports){
 module.exports = require("./core");
 
 module.exports.Matrix = require("./matrix");
@@ -1288,23 +1288,23 @@ module.exports.Texture = require("./texture");
 
 require("./atlas");
 
-require("./node");
+require("./tree");
 
 require("./event");
 
 require("./pin");
 
-require("./render");
+require("./loop");
 
 require("./root");
 
 
-},{"./atlas":6,"./core":8,"./event":9,"./matrix":14,"./node":15,"./pin":16,"./render":17,"./root":18,"./texture":20}],12:[function(require,module,exports){
+},{"./atlas":6,"./core":8,"./event":9,"./loop":14,"./matrix":15,"./pin":16,"./root":17,"./texture":19,"./tree":20}],12:[function(require,module,exports){
 var Class = require("./core");
 
 require("./pin");
 
-require("./render");
+require("./loop");
 
 var create = require("./util/create");
 
@@ -1436,7 +1436,7 @@ Class.prototype.spacing = function(space) {
 };
 
 
-},{"./core":8,"./pin":16,"./render":17,"./util/create":22}],13:[function(require,module,exports){
+},{"./core":8,"./loop":14,"./pin":16,"./util/create":22}],13:[function(require,module,exports){
 /**
  * Default loader for web.
  */
@@ -1530,6 +1530,124 @@ function ImageLoader(src, success, error) {
 
 
 },{"../core":8}],14:[function(require,module,exports){
+var Class = require("./core");
+
+require("./pin");
+
+var stats = require("./util/stats");
+
+Class.prototype._textures = null;
+
+Class.prototype._alpha = 1;
+
+Class.prototype.render = function(context) {
+    if (!this._visible) {
+        return;
+    }
+    stats.node++;
+    var m = this.matrix();
+    context.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
+    // move this elsewhere!
+    this._alpha = this._pin._alpha * (this._parent ? this._parent._alpha : 1);
+    var alpha = this._pin._textureAlpha * this._alpha;
+    if (context.globalAlpha != alpha) {
+        context.globalAlpha = alpha;
+    }
+    if (this._textures !== null) {
+        for (var i = 0, n = this._textures.length; i < n; i++) {
+            this._textures[i].draw(context);
+        }
+    }
+    if (context.globalAlpha != this._alpha) {
+        context.globalAlpha = this._alpha;
+    }
+    var child, next = this._first;
+    while (child = next) {
+        next = child._next;
+        child.render(context);
+    }
+};
+
+Class.prototype._tickBefore = null;
+
+Class.prototype._tickAfter = null;
+
+Class.prototype.MAX_ELAPSE = Infinity;
+
+Class.prototype._tick = function(elapsed, now, last) {
+    if (!this._visible) {
+        return;
+    }
+    if (elapsed > this.MAX_ELAPSE) {
+        elapsed = this.MAX_ELAPSE;
+    }
+    var ticked = false;
+    if (this._tickBefore !== null) {
+        for (var i = 0, n = this._tickBefore.length; i < n; i++) {
+            stats.tick++;
+            ticked = this._tickBefore[i].call(this, elapsed, now, last) === true || ticked;
+        }
+    }
+    var child, next = this._first;
+    while (child = next) {
+        next = child._next;
+        if (child._flag("_tick")) {
+            ticked = child._tick(elapsed, now, last) === true ? true : ticked;
+        }
+    }
+    if (this._tickAfter !== null) {
+        for (var i = 0, n = this._tickAfter.length; i < n; i++) {
+            stats.tick++;
+            ticked = this._tickAfter[i].call(this, elapsed, now, last) === true || ticked;
+        }
+    }
+    return ticked;
+};
+
+Class.prototype.tick = function(ticker, before) {
+    if (typeof ticker !== "function") {
+        return;
+    }
+    if (before) {
+        if (this._tickBefore === null) {
+            this._tickBefore = [];
+        }
+        this._tickBefore.push(ticker);
+    } else {
+        if (this._tickAfter === null) {
+            this._tickAfter = [];
+        }
+        this._tickAfter.push(ticker);
+    }
+    this._flag("_tick", this._tickAfter !== null && this._tickAfter.length > 0 || this._tickBefore !== null && this._tickBefore.length > 0);
+};
+
+Class.prototype.untick = function(ticker) {
+    if (typeof ticker !== "function") {
+        return;
+    }
+    var i;
+    if (this._tickBefore !== null && (i = this._tickBefore.indexOf(ticker)) >= 0) {
+        this._tickBefore.splice(i, 1);
+    }
+    if (this._tickAfter !== null && (i = this._tickAfter.indexOf(ticker)) >= 0) {
+        this._tickAfter.splice(i, 1);
+    }
+};
+
+Class.prototype.timeout = function(fn, time) {
+    this.tick(function timer(t) {
+        if ((time -= t) < 0) {
+            this.untick(timer);
+            fn.call(this);
+        } else {
+            return true;
+        }
+    });
+};
+
+
+},{"./core":8,"./pin":16,"./util/stats":28}],15:[function(require,module,exports){
 function Matrix(a, b, c, d, e, f) {
     this.reset(a, b, c, d, e, f);
 }
@@ -1687,460 +1805,116 @@ Matrix.prototype.mapY = function(x, y) {
 module.exports = Matrix;
 
 
-},{}],15:[function(require,module,exports){
+},{}],16:[function(require,module,exports){
 var Class = require("./core");
 
-var is = require("./util/is");
+var Matrix = require("./matrix");
 
 var iid = 0;
 
-// TODO: do not clear next/prev/parent on remove
-Class.prototype._label = "";
-
-Class.prototype._visible = true;
-
-Class.prototype._parent = null;
-
-Class.prototype._next = null;
-
-Class.prototype._prev = null;
-
-Class.prototype._first = null;
-
-Class.prototype._last = null;
-
-Class.prototype._attrs = null;
-
-Class.prototype._flags = null;
+Class._init(function() {
+    this._pin = new Pin(this);
+});
 
-Class.prototype.toString = function() {
-    return "[" + this._label + "]";
+Class.prototype.matrix = function(relative) {
+    if (relative === true) {
+        return this._pin.relativeMatrix();
+    }
+    return this._pin.absoluteMatrix();
 };
 
-/**
- * @deprecated Use label()
- */
-Class.prototype.id = function(id) {
-    return this.label(id);
+Class.prototype.pin = function(a, b) {
+    if (typeof a === "object") {
+        this._pin.set(a);
+        return this;
+    } else if (typeof a === "string") {
+        if (typeof b === "undefined") {
+            return this._pin.get(a);
+        } else {
+            this._pin.set(a, b);
+            return this;
+        }
+    } else if (typeof a === "undefined") {
+        return this._pin;
+    }
 };
 
-Class.prototype.label = function(label) {
-    if (typeof label === "undefined") {
-        return this._label;
-    }
-    this._label = label;
-    return this;
+function Pin(owner) {
+    this._owner = owner;
+    this._parent = null;
+    // relative to parent
+    this._relativeMatrix = new Matrix();
+    // relative to stage
+    this._absoluteMatrix = new Matrix();
+    this.reset();
+}
+
+Pin.prototype.reset = function() {
+    this._textureAlpha = 1;
+    this._alpha = 1;
+    this._width = 0;
+    this._height = 0;
+    this._scaleX = 1;
+    this._scaleY = 1;
+    this._skewX = 0;
+    this._skewY = 0;
+    this._rotation = 0;
+    // scale/skew/rotate center
+    this._pivoted = false;
+    this._pivotX = null;
+    this._pivotY = null;
+    // self pin point
+    this._handled = false;
+    this._handleX = 0;
+    this._handleY = 0;
+    // parent pin point
+    this._aligned = false;
+    this._alignX = 0;
+    this._alignY = 0;
+    // as seen by parent px
+    this._offsetX = 0;
+    this._offsetY = 0;
+    this._boxX = 0;
+    this._boxY = 0;
+    this._boxWidth = this._width;
+    this._boxHeight = this._height;
+    // TODO: also set for owner
+    this._ts_translate = ++iid;
+    this._ts_transform = ++iid;
+    this._ts_matrix = ++iid;
 };
 
-Class.prototype.attr = function(name, value) {
-    if (typeof value === "undefined") {
-        return this._attrs !== null ? this._attrs[name] : undefined;
+Pin.prototype._update = function() {
+    this._parent = this._owner._parent && this._owner._parent._pin;
+    // if handled and transformed then be translated
+    if (this._handled && this._mo_handle != this._ts_transform) {
+        this._mo_handle = this._ts_transform;
+        this._ts_translate = ++iid;
+    }
+    if (this._aligned && this._parent && this._mo_align != this._parent._ts_transform) {
+        this._mo_align = this._parent._ts_transform;
+        this._ts_translate = ++iid;
     }
-    (this._attrs !== null ? this._attrs : this._attrs = {})[name] = value;
     return this;
 };
 
-Class.prototype.visible = function(visible) {
-    if (typeof visible === "undefined") {
-        return this._visible;
-    }
-    this._visible = visible;
-    this._parent && (this._parent._ts_children = ++iid);
-    this._ts_pin = ++iid;
-    this.touch();
-    return this;
+Pin.prototype.toString = function() {
+    return this._owner + " (" + (this._parent ? this._parent._owner : null) + ")";
 };
 
-Class.prototype.hide = function() {
-    return this.visible(false);
-};
-
-Class.prototype.show = function() {
-    return this.visible(true);
-};
-
-Class.prototype.parent = function() {
-    return this._parent;
-};
-
-Class.prototype.next = function(visible) {
-    var next = this._next;
-    while (next && visible && !next._visible) {
-        next = next._next;
-    }
-    return next;
-};
-
-Class.prototype.prev = function(visible) {
-    var prev = this._prev;
-    while (prev && visible && !prev._visible) {
-        prev = prev._prev;
-    }
-    return prev;
-};
-
-Class.prototype.first = function(visible) {
-    var next = this._first;
-    while (next && visible && !next._visible) {
-        next = next._next;
-    }
-    return next;
-};
-
-Class.prototype.last = function(visible) {
-    var prev = this._last;
-    while (prev && visible && !prev._visible) {
-        prev = prev._prev;
-    }
-    return prev;
-};
-
-Class.prototype.visit = function(visitor, data) {
-    var reverse = visitor.reverse;
-    var visible = visitor.visible;
-    if (visitor.start && visitor.start(this, data)) {
-        return;
-    }
-    var child, next = reverse ? this.last(visible) : this.first(visible);
-    while (child = next) {
-        next = reverse ? child.prev(visible) : child.next(visible);
-        if (child.visit(visitor, data)) {
-            return true;
-        }
-    }
-    return visitor.end && visitor.end(this, data);
-};
-
-Class.prototype.append = function(child, more) {
-    if (is.array(child)) for (var i = 0; i < child.length; i++) append(this, child[i]); else if (typeof more !== "undefined") // deprecated
-    for (var i = 0; i < arguments.length; i++) append(this, arguments[i]); else if (typeof child !== "undefined") append(this, child);
-    return this;
-};
-
-Class.prototype.prepend = function(child, more) {
-    if (is.array(child)) for (var i = child.length - 1; i >= 0; i--) prepend(this, child[i]); else if (typeof more !== "undefined") // deprecated
-    for (var i = arguments.length - 1; i >= 0; i--) prepend(this, arguments[i]); else if (typeof child !== "undefined") prepend(this, child);
-    return this;
-};
-
-Class.prototype.appendTo = function(parent) {
-    append(parent, this);
-    return this;
-};
-
-Class.prototype.prependTo = function(parent) {
-    prepend(parent, this);
-    return this;
-};
-
-Class.prototype.insertNext = function(sibling, more) {
-    if (is.array(sibling)) for (var i = 0; i < sibling.length; i++) insertAfter(sibling[i], this); else if (typeof more !== "undefined") // deprecated
-    for (var i = 0; i < arguments.length; i++) insertAfter(arguments[i], this); else if (typeof sibling !== "undefined") insertAfter(sibling, this);
-    return this;
-};
-
-Class.prototype.insertPrev = function(sibling, more) {
-    if (is.array(sibling)) for (var i = sibling.length - 1; i >= 0; i--) insertBefore(sibling[i], this); else if (typeof more !== "undefined") // deprecated
-    for (var i = arguments.length - 1; i >= 0; i--) insertBefore(arguments[i], this); else if (typeof sibling !== "undefined") insertBefore(sibling, this);
-    return this;
-};
-
-Class.prototype.insertAfter = function(prev) {
-    insertAfter(this, prev);
-    return this;
-};
-
-Class.prototype.insertBefore = function(next) {
-    insertBefore(this, next);
-    return this;
-};
-
-function append(parent, child) {
-    _ensure(child);
-    _ensure(parent);
-    child.remove();
-    if (parent._last) {
-        parent._last._next = child;
-        child._prev = parent._last;
-    }
-    child._parent = parent;
-    parent._last = child;
-    if (!parent._first) {
-        parent._first = child;
-    }
-    child._parent._flag(child, true);
-    child._ts_parent = ++iid;
-    parent._ts_children = ++iid;
-    parent.touch();
-}
-
-function prepend(parent, child) {
-    _ensure(child);
-    _ensure(parent);
-    child.remove();
-    if (parent._first) {
-        parent._first._prev = child;
-        child._next = parent._first;
-    }
-    child._parent = parent;
-    parent._first = child;
-    if (!parent._last) {
-        parent._last = child;
-    }
-    child._parent._flag(child, true);
-    child._ts_parent = ++iid;
-    parent._ts_children = ++iid;
-    parent.touch();
-}
-
-function insertBefore(self, next) {
-    _ensure(self);
-    _ensure(next);
-    self.remove();
-    var parent = next._parent;
-    var prev = next._prev;
-    next._prev = self;
-    prev && (prev._next = self) || parent && (parent._first = self);
-    self._parent = parent;
-    self._prev = prev;
-    self._next = next;
-    self._parent._flag(self, true);
-    self._ts_parent = ++iid;
-    self.touch();
-}
-
-function insertAfter(self, prev) {
-    _ensure(self);
-    _ensure(prev);
-    self.remove();
-    var parent = prev._parent;
-    var next = prev._next;
-    prev._next = self;
-    next && (next._prev = self) || parent && (parent._last = self);
-    self._parent = parent;
-    self._prev = prev;
-    self._next = next;
-    self._parent._flag(self, true);
-    self._ts_parent = ++iid;
-    self.touch();
-}
-
-Class.prototype.remove = function(child, more) {
-    if (typeof child !== "undefined") {
-        if (is.array(child)) {
-            for (var i = 0; i < child.length; i++) _ensure(child[i]).remove();
-        } else if (typeof more !== "undefined") {
-            for (var i = 0; i < arguments.length; i++) _ensure(arguments[i]).remove();
-        } else {
-            _ensure(child).remove();
-        }
-        return this;
-    }
-    if (this._prev) {
-        this._prev._next = this._next;
-    }
-    if (this._next) {
-        this._next._prev = this._prev;
-    }
-    if (this._parent) {
-        if (this._parent._first === this) {
-            this._parent._first = this._next;
-        }
-        if (this._parent._last === this) {
-            this._parent._last = this._prev;
-        }
-        this._parent._flag(this, false);
-        this._parent._ts_children = ++iid;
-        this._parent.touch();
-    }
-    this._prev = this._next = this._parent = null;
-    this._ts_parent = ++iid;
-    // this._parent.touch();
-    return this;
-};
-
-Class.prototype.empty = function() {
-    var child, next = this._first;
-    while (child = next) {
-        next = child._next;
-        child._prev = child._next = child._parent = null;
-        this._flag(child, false);
-    }
-    this._first = this._last = null;
-    this._ts_children = ++iid;
-    this.touch();
-    return this;
-};
-
-Class.prototype.touch = function() {
-    this._ts_touch = ++iid;
-    this._parent && this._parent.touch();
-    return this;
-};
-
-/**
- * Deep flags used for optimizing event distribution.
- */
-Class.prototype._flag = function(obj, name) {
-    if (typeof name === "undefined") {
-        return this._flags !== null && this._flags[obj] || 0;
-    }
-    if (typeof obj === "string") {
-        if (name) {
-            this._flags = this._flags || {};
-            if (!this._flags[obj] && this._parent) {
-                this._parent._flag(obj, true);
-            }
-            this._flags[obj] = (this._flags[obj] || 0) + 1;
-        } else if (this._flags && this._flags[obj] > 0) {
-            if (this._flags[obj] == 1 && this._parent) {
-                this._parent._flag(obj, false);
-            }
-            this._flags[obj] = this._flags[obj] - 1;
-        }
-    }
-    if (typeof obj === "object") {
-        if (obj._flags) {
-            for (var type in obj._flags) {
-                if (obj._flags[type] > 0) {
-                    this._flag(type, name);
-                }
-            }
-        }
-    }
-    return this;
-};
-
-/**
- * @private
- */
-Class.prototype.hitTest = function(hit) {
-    if (this.attr("spy")) {
-        return true;
-    }
-    return hit.x >= 0 && hit.x <= this._pin._width && hit.y >= 0 && hit.y <= this._pin._height;
-};
-
-function _ensure(obj) {
-    if (obj && obj instanceof Class) {
-        return obj;
-    }
-    throw "Invalid node: " + obj;
-}
-
-module.exports = Class;
-
-
-},{"./core":8,"./util/is":25}],16:[function(require,module,exports){
-var Class = require("./core");
-
-var Matrix = require("./matrix");
-
-var iid = 0;
-
-Class._init(function() {
-    this._pin = new Pin(this);
-});
-
-Class.prototype.matrix = function(relative) {
-    if (relative === true) {
-        return this._pin.relativeMatrix();
-    }
-    return this._pin.absoluteMatrix();
-};
-
-Class.prototype.pin = function(a, b) {
-    if (typeof a === "object") {
-        this._pin.set(a);
-        return this;
-    } else if (typeof a === "string") {
-        if (typeof b === "undefined") {
-            return this._pin.get(a);
-        } else {
-            this._pin.set(a, b);
-            return this;
-        }
-    } else if (typeof a === "undefined") {
-        return this._pin;
-    }
-};
-
-function Pin(owner) {
-    this._owner = owner;
-    this._parent = null;
-    // relative to parent
-    this._relativeMatrix = new Matrix();
-    // relative to stage
-    this._absoluteMatrix = new Matrix();
-    this.reset();
-}
-
-Pin.prototype.reset = function() {
-    this._textureAlpha = 1;
-    this._alpha = 1;
-    this._width = 0;
-    this._height = 0;
-    this._scaleX = 1;
-    this._scaleY = 1;
-    this._skewX = 0;
-    this._skewY = 0;
-    this._rotation = 0;
-    // scale/skew/rotate center
-    this._pivoted = false;
-    this._pivotX = null;
-    this._pivotY = null;
-    // self pin point
-    this._handled = false;
-    this._handleX = 0;
-    this._handleY = 0;
-    // parent pin point
-    this._aligned = false;
-    this._alignX = 0;
-    this._alignY = 0;
-    // as seen by parent px
-    this._offsetX = 0;
-    this._offsetY = 0;
-    this._boxX = 0;
-    this._boxY = 0;
-    this._boxWidth = this._width;
-    this._boxHeight = this._height;
-    // TODO: also set for owner
-    this._ts_translate = ++iid;
-    this._ts_transform = ++iid;
-    this._ts_matrix = ++iid;
-};
-
-Pin.prototype._update = function() {
-    this._parent = this._owner._parent && this._owner._parent._pin;
-    // if handled and transformed then be translated
-    if (this._handled && this._mo_handle != this._ts_transform) {
-        this._mo_handle = this._ts_transform;
-        this._ts_translate = ++iid;
-    }
-    if (this._aligned && this._parent && this._mo_align != this._parent._ts_transform) {
-        this._mo_align = this._parent._ts_transform;
-        this._ts_translate = ++iid;
-    }
-    return this;
-};
-
-Pin.prototype.toString = function() {
-    return this._owner + " (" + (this._parent ? this._parent._owner : null) + ")";
-};
-
-// TODO: ts fields require refactoring
-Pin.prototype.absoluteMatrix = function() {
-    this._update();
-    var ts = Math.max(this._ts_transform, this._ts_translate, this._parent ? this._parent._ts_matrix : 0);
-    if (this._mo_abs == ts) {
-        return this._absoluteMatrix;
-    }
-    this._mo_abs = ts;
-    var abs = this._absoluteMatrix;
-    abs.reset(this.relativeMatrix());
-    this._parent && abs.concat(this._parent._absoluteMatrix);
-    this._ts_matrix = ++iid;
-    return abs;
+// TODO: ts fields require refactoring
+Pin.prototype.absoluteMatrix = function() {
+    this._update();
+    var ts = Math.max(this._ts_transform, this._ts_translate, this._parent ? this._parent._ts_matrix : 0);
+    if (this._mo_abs == ts) {
+        return this._absoluteMatrix;
+    }
+    this._mo_abs = ts;
+    var abs = this._absoluteMatrix;
+    abs.reset(this.relativeMatrix());
+    this._parent && abs.concat(this._parent._absoluteMatrix);
+    this._ts_matrix = ++iid;
+    return abs;
 };
 
 Pin.prototype.relativeMatrix = function() {
@@ -2539,437 +2313,663 @@ Pin._add_shortcuts = function(Class) {
         if (typeof ta !== "undefined") {
             this.pin("textureAlpha", ta);
         }
-        return this;
-    };
+        return this;
+    };
+};
+
+Pin._add_shortcuts(Class);
+
+module.exports = Pin;
+
+
+},{"./core":8,"./matrix":15}],17:[function(require,module,exports){
+var Class = require("./core");
+
+require("./pin");
+
+require("./loop");
+
+var stats = require("./util/stats");
+
+var create = require("./util/create");
+
+var extend = require("./util/extend");
+
+Root._super = Class;
+
+Root.prototype = create(Root._super.prototype);
+
+Class.root = function(request, render) {
+    return new Root(request, render);
+};
+
+function Root(request, render) {
+    Root._super.call(this);
+    this.label("Root");
+    var paused = true;
+    var self = this;
+    var lastTime = 0;
+    var loop = function(now) {
+        if (paused === true) {
+            return;
+        }
+        stats.tick = stats.node = stats.draw = 0;
+        var last = lastTime || now;
+        var elapsed = now - last;
+        lastTime = now;
+        var ticked = self._tick(elapsed, now, last);
+        if (self._mo_touch != self._ts_touch) {
+            self._mo_touch = self._ts_touch;
+            render(self);
+            request(loop);
+        } else if (ticked) {
+            request(loop);
+        } else {
+            paused = true;
+        }
+        stats.fps = elapsed ? 1e3 / elapsed : 0;
+    };
+    this.start = function() {
+        return this.resume();
+    };
+    this.resume = function() {
+        if (paused) {
+            paused = false;
+            request(loop);
+        }
+        return this;
+    };
+    this.pause = function() {
+        paused = true;
+        return this;
+    };
+    this.touch_root = this.touch;
+    this.touch = function() {
+        this.resume();
+        return this.touch_root();
+    };
+}
+
+Root.prototype.background = function(color) {
+    // to be implemented by loaders
+    return this;
+};
+
+Root.prototype.viewport = function(width, height, ratio) {
+    if (typeof width === "undefined") {
+        return extend({}, this._viewport);
+    }
+    this._viewport = {
+        width: width,
+        height: height,
+        ratio: ratio || 1
+    };
+    this.viewbox();
+    var data = extend({}, this._viewport);
+    this.visit({
+        start: function(node) {
+            if (!node._flag("viewport")) {
+                return true;
+            }
+            node.publish("viewport", [ data ]);
+        }
+    });
+    return this;
 };
 
-Pin._add_shortcuts(Class);
-
-module.exports = Pin;
+// TODO: static/fixed viewbox
+Root.prototype.viewbox = function(width, height, mode) {
+    if (typeof width === "number" && typeof height === "number") {
+        this._viewbox = {
+            width: width,
+            height: height,
+            mode: /^(in|out|in-pad|out-crop)$/.test(mode) ? mode : "in-pad"
+        };
+    }
+    var box = this._viewbox;
+    var size = this._viewport;
+    if (size && box) {
+        this.pin({
+            width: box.width,
+            height: box.height
+        });
+        this.scaleTo(size.width, size.height, box.mode);
+    } else if (size) {
+        this.pin({
+            width: size.width,
+            height: size.height
+        });
+    }
+    return this;
+};
 
 
-},{"./core":8,"./matrix":14}],17:[function(require,module,exports){
+},{"./core":8,"./loop":14,"./pin":16,"./util/create":22,"./util/extend":24,"./util/stats":28}],18:[function(require,module,exports){
 var Class = require("./core");
 
 require("./pin");
 
-var stats = require("./util/stats");
+require("./loop");
 
-Class.prototype._textures = null;
+var create = require("./util/create");
 
-Class.prototype._alpha = 1;
+var is = require("./util/is");
 
-Class.prototype.render = function(context) {
-    if (!this._visible) {
-        return;
-    }
-    stats.node++;
-    var m = this.matrix();
-    context.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
-    // move this elsewhere!
-    this._alpha = this._pin._alpha * (this._parent ? this._parent._alpha : 1);
-    var alpha = this._pin._textureAlpha * this._alpha;
-    if (context.globalAlpha != alpha) {
-        context.globalAlpha = alpha;
-    }
-    if (this._textures !== null) {
-        for (var i = 0, n = this._textures.length; i < n; i++) {
-            this._textures[i].draw(context);
-        }
-    }
-    if (context.globalAlpha != this._alpha) {
-        context.globalAlpha = this._alpha;
-    }
-    var child, next = this._first;
-    while (child = next) {
-        next = child._next;
-        child.render(context);
-    }
+Class.string = function(frames) {
+    return new Str().frames(frames);
 };
 
-Class.prototype._tickBefore = null;
+Str._super = Class;
 
-Class.prototype._tickAfter = null;
+Str.prototype = create(Str._super.prototype);
 
-Class.prototype.MAX_ELAPSE = Infinity;
+function Str() {
+    Str._super.call(this);
+    this.label("String");
+    this._textures = [];
+}
 
-Class.prototype._tick = function(elapsed, now, last) {
-    if (!this._visible) {
-        return;
+/**
+ * @deprecated Use frames
+ */
+Str.prototype.setFont = function(a, b, c) {
+    return this.frames(a, b, c);
+};
+
+Str.prototype.frames = function(frames) {
+    this._textures = [];
+    if (typeof frames == "string") {
+        frames = Class.texture(frames);
+        this._item = function(value) {
+            return frames.one(value);
+        };
+    } else if (typeof frames === "object") {
+        this._item = function(value) {
+            return frames[value];
+        };
+    } else if (typeof frames === "function") {
+        this._item = frames;
     }
-    if (elapsed > this.MAX_ELAPSE) {
-        elapsed = this.MAX_ELAPSE;
+    return this;
+};
+
+/**
+ * @deprecated Use value
+ */
+Str.prototype.setValue = function(a, b, c) {
+    return this.value(a, b, c);
+};
+
+Str.prototype.value = function(value) {
+    if (typeof value === "undefined") {
+        return this._value;
     }
-    var ticked = false;
-    if (this._tickBefore !== null) {
-        for (var i = 0, n = this._tickBefore.length; i < n; i++) {
-            stats.tick++;
-            ticked = this._tickBefore[i].call(this, elapsed, now, last) === true || ticked;
-        }
+    if (this._value === value) {
+        return this;
     }
-    var child, next = this._first;
-    while (child = next) {
-        next = child._next;
-        if (child._flag("_tick")) {
-            ticked = child._tick(elapsed, now, last) === true ? true : ticked;
-        }
+    this._value = value;
+    if (value === null) {
+        value = "";
+    } else if (typeof value !== "string" && !is.array(value)) {
+        value = value.toString();
     }
-    if (this._tickAfter !== null) {
-        for (var i = 0, n = this._tickAfter.length; i < n; i++) {
-            stats.tick++;
-            ticked = this._tickAfter[i].call(this, elapsed, now, last) === true || ticked;
-        }
+    this._spacing = this._spacing || 0;
+    var width = 0, height = 0;
+    for (var i = 0; i < value.length; i++) {
+        var image = this._textures[i] = this._item(value[i]);
+        width += i > 0 ? this._spacing : 0;
+        image.dest(width, 0);
+        width = width + image.width;
+        height = Math.max(height, image.height);
     }
-    return ticked;
+    this.pin("width", width);
+    this.pin("height", height);
+    this._textures.length = value.length;
+    return this;
 };
 
-Class.prototype.tick = function(ticker, before) {
-    if (typeof ticker !== "function") {
-        return;
+
+},{"./core":8,"./loop":14,"./pin":16,"./util/create":22,"./util/is":25}],19:[function(require,module,exports){
+var stats = require("./util/stats");
+
+var math = require("./util/math");
+
+function Texture(image, ratio) {
+    if (typeof image === "object") {
+        this.src(image, ratio);
     }
-    if (before) {
-        if (this._tickBefore === null) {
-            this._tickBefore = [];
-        }
-        this._tickBefore.push(ticker);
+}
+
+Texture.prototype.pipe = function() {
+    return new Texture(this);
+};
+
+/**
+ * Signatures: (image), (x, y, w, h), (w, h)
+ */
+Texture.prototype.src = function(x, y, w, h) {
+    if (typeof x === "object") {
+        var image = x, ratio = y || 1;
+        this._image = image;
+        this._sx = this._dx = 0;
+        this._sy = this._dy = 0;
+        this._sw = this._dw = image.width / ratio;
+        this._sh = this._dh = image.height / ratio;
+        this.width = image.width / ratio;
+        this.height = image.height / ratio;
+        this.ratio = ratio;
     } else {
-        if (this._tickAfter === null) {
-            this._tickAfter = [];
+        if (typeof w === "undefined") {
+            w = x, h = y;
+        } else {
+            this._sx = x, this._sy = y;
         }
-        this._tickAfter.push(ticker);
+        this._sw = this._dw = w;
+        this._sh = this._dh = h;
+        this.width = w;
+        this.height = h;
     }
-    this._flag("_tick", this._tickAfter !== null && this._tickAfter.length > 0 || this._tickBefore !== null && this._tickBefore.length > 0);
+    return this;
 };
 
-Class.prototype.untick = function(ticker) {
-    if (typeof ticker !== "function") {
-        return;
-    }
-    var i;
-    if (this._tickBefore !== null && (i = this._tickBefore.indexOf(ticker)) >= 0) {
-        this._tickBefore.splice(i, 1);
-    }
-    if (this._tickAfter !== null && (i = this._tickAfter.indexOf(ticker)) >= 0) {
-        this._tickAfter.splice(i, 1);
+/**
+ * Signatures: (x, y, w, h), (x, y)
+ */
+Texture.prototype.dest = function(x, y, w, h) {
+    this._dx = x, this._dy = y;
+    this._dx = x, this._dy = y;
+    if (typeof w !== "undefined") {
+        this._dw = w, this._dh = h;
+        this.width = w, this.height = h;
     }
+    return this;
 };
 
-Class.prototype.timeout = function(fn, time) {
-    this.tick(function timer(t) {
-        if ((time -= t) < 0) {
-            this.untick(timer);
-            fn.call(this);
+Texture.prototype.draw = function(context, x1, y1, x2, y2, x3, y3, x4, y4) {
+    var image = this._image;
+    if (image === null || typeof image !== "object") {
+        return;
+    }
+    var sx = this._sx, sy = this._sy;
+    var sw = this._sw, sh = this._sh;
+    var dx = this._dx, dy = this._dy;
+    var dw = this._dw, dh = this._dh;
+    if (typeof x3 !== "undefined") {
+        x1 = math.limit(x1, 0, this._sw), x2 = math.limit(x2, 0, this._sw - x1);
+        y1 = math.limit(y1, 0, this._sh), y2 = math.limit(y2, 0, this._sh - y1);
+        sx += x1, sy += y1, sw = x2, sh = y2;
+        dx = x3, dy = y3, dw = x4, dh = y4;
+    } else if (typeof x2 !== "undefined") {
+        dx = x1, dy = y1, dw = x2, dh = y2;
+    } else if (typeof x1 !== "undefined") {
+        dw = x1, dh = y1;
+    }
+    var ratio = this.ratio || 1;
+    sx *= ratio, sy *= ratio, sw *= ratio, sh *= ratio;
+    try {
+        if (typeof image.draw === "function") {
+            image.draw(context, sx, sy, sw, sh, dx, dy, dw, dh);
         } else {
-            return true;
+            stats.draw++;
+            context.drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh);
+        }
+    } catch (ex) {
+        if (!image._draw_failed) {
+            console.log("Unable to draw: ", image);
+            console.log(ex);
+            image._draw_failed = true;
         }
-    });
+    }
 };
 
+module.exports = Texture;
+
 
-},{"./core":8,"./pin":16,"./util/stats":28}],18:[function(require,module,exports){
+},{"./util/math":26,"./util/stats":28}],20:[function(require,module,exports){
 var Class = require("./core");
 
-require("./pin");
+var is = require("./util/is");
 
-require("./render");
+var iid = 0;
 
-var stats = require("./util/stats");
+// TODO: do not clear next/prev/parent on remove
+Class.prototype._label = "";
 
-var create = require("./util/create");
+Class.prototype._visible = true;
 
-var extend = require("./util/extend");
+Class.prototype._parent = null;
 
-Root._super = Class;
+Class.prototype._next = null;
 
-Root.prototype = create(Root._super.prototype);
+Class.prototype._prev = null;
 
-Class.root = function(request, render) {
-    return new Root(request, render);
+Class.prototype._first = null;
+
+Class.prototype._last = null;
+
+Class.prototype._attrs = null;
+
+Class.prototype._flags = null;
+
+Class.prototype.toString = function() {
+    return "[" + this._label + "]";
 };
 
-function Root(request, render) {
-    Root._super.call(this);
-    this.label("Root");
-    var paused = true;
-    var self = this;
-    var lastTime = 0;
-    var loop = function(now) {
-        if (paused === true) {
-            return;
-        }
-        stats.tick = stats.node = stats.draw = 0;
-        var last = lastTime || now;
-        var elapsed = now - last;
-        lastTime = now;
-        var ticked = self._tick(elapsed, now, last);
-        if (self._mo_touch != self._ts_touch) {
-            self._mo_touch = self._ts_touch;
-            render(self);
-            request(loop);
-        } else if (ticked) {
-            request(loop);
-        } else {
-            paused = true;
-        }
-        stats.fps = elapsed ? 1e3 / elapsed : 0;
-    };
-    this.start = function() {
-        return this.resume();
-    };
-    this.resume = function() {
-        if (paused) {
-            paused = false;
-            request(loop);
-        }
-        return this;
-    };
-    this.pause = function() {
-        paused = true;
-        return this;
-    };
-    this.touch_root = this.touch;
-    this.touch = function() {
-        this.resume();
-        return this.touch_root();
-    };
-}
+/**
+ * @deprecated Use label()
+ */
+Class.prototype.id = function(id) {
+    return this.label(id);
+};
 
-Root.prototype.background = function(color) {
-    // to be implemented by loaders
+Class.prototype.label = function(label) {
+    if (typeof label === "undefined") {
+        return this._label;
+    }
+    this._label = label;
     return this;
 };
 
-Root.prototype.viewport = function(width, height, ratio) {
-    if (typeof width === "undefined") {
-        return extend({}, this._viewport);
+Class.prototype.attr = function(name, value) {
+    if (typeof value === "undefined") {
+        return this._attrs !== null ? this._attrs[name] : undefined;
     }
-    this._viewport = {
-        width: width,
-        height: height,
-        ratio: ratio || 1
-    };
-    this.viewbox();
-    var data = extend({}, this._viewport);
-    this.visit({
-        start: function(node) {
-            if (!node._flag("viewport")) {
-                return true;
-            }
-            node.publish("viewport", [ data ]);
-        }
-    });
+    (this._attrs !== null ? this._attrs : this._attrs = {})[name] = value;
     return this;
 };
 
-// TODO: static/fixed viewbox
-Root.prototype.viewbox = function(width, height, mode) {
-    if (typeof width === "number" && typeof height === "number") {
-        this._viewbox = {
-            width: width,
-            height: height,
-            mode: /^(in|out|in-pad|out-crop)$/.test(mode) ? mode : "in-pad"
-        };
-    }
-    var box = this._viewbox;
-    var size = this._viewport;
-    if (size && box) {
-        this.pin({
-            width: box.width,
-            height: box.height
-        });
-        this.scaleTo(size.width, size.height, box.mode);
-    } else if (size) {
-        this.pin({
-            width: size.width,
-            height: size.height
-        });
+Class.prototype.visible = function(visible) {
+    if (typeof visible === "undefined") {
+        return this._visible;
     }
+    this._visible = visible;
+    this._parent && (this._parent._ts_children = ++iid);
+    this._ts_pin = ++iid;
+    this.touch();
     return this;
 };
 
+Class.prototype.hide = function() {
+    return this.visible(false);
+};
 
-},{"./core":8,"./pin":16,"./render":17,"./util/create":22,"./util/extend":24,"./util/stats":28}],19:[function(require,module,exports){
-var Class = require("./core");
+Class.prototype.show = function() {
+    return this.visible(true);
+};
 
-require("./pin");
+Class.prototype.parent = function() {
+    return this._parent;
+};
 
-require("./render");
+Class.prototype.next = function(visible) {
+    var next = this._next;
+    while (next && visible && !next._visible) {
+        next = next._next;
+    }
+    return next;
+};
 
-var create = require("./util/create");
+Class.prototype.prev = function(visible) {
+    var prev = this._prev;
+    while (prev && visible && !prev._visible) {
+        prev = prev._prev;
+    }
+    return prev;
+};
 
-var is = require("./util/is");
+Class.prototype.first = function(visible) {
+    var next = this._first;
+    while (next && visible && !next._visible) {
+        next = next._next;
+    }
+    return next;
+};
 
-Class.string = function(frames) {
-    return new Str().frames(frames);
+Class.prototype.last = function(visible) {
+    var prev = this._last;
+    while (prev && visible && !prev._visible) {
+        prev = prev._prev;
+    }
+    return prev;
 };
 
-Str._super = Class;
+Class.prototype.visit = function(visitor, data) {
+    var reverse = visitor.reverse;
+    var visible = visitor.visible;
+    if (visitor.start && visitor.start(this, data)) {
+        return;
+    }
+    var child, next = reverse ? this.last(visible) : this.first(visible);
+    while (child = next) {
+        next = reverse ? child.prev(visible) : child.next(visible);
+        if (child.visit(visitor, data)) {
+            return true;
+        }
+    }
+    return visitor.end && visitor.end(this, data);
+};
 
-Str.prototype = create(Str._super.prototype);
+Class.prototype.append = function(child, more) {
+    if (is.array(child)) for (var i = 0; i < child.length; i++) append(this, child[i]); else if (typeof more !== "undefined") // deprecated
+    for (var i = 0; i < arguments.length; i++) append(this, arguments[i]); else if (typeof child !== "undefined") append(this, child);
+    return this;
+};
 
-function Str() {
-    Str._super.call(this);
-    this.label("String");
-    this._textures = [];
-}
+Class.prototype.prepend = function(child, more) {
+    if (is.array(child)) for (var i = child.length - 1; i >= 0; i--) prepend(this, child[i]); else if (typeof more !== "undefined") // deprecated
+    for (var i = arguments.length - 1; i >= 0; i--) prepend(this, arguments[i]); else if (typeof child !== "undefined") prepend(this, child);
+    return this;
+};
 
-/**
- * @deprecated Use frames
- */
-Str.prototype.setFont = function(a, b, c) {
-    return this.frames(a, b, c);
+Class.prototype.appendTo = function(parent) {
+    append(parent, this);
+    return this;
 };
 
-Str.prototype.frames = function(frames) {
-    this._textures = [];
-    if (typeof frames == "string") {
-        frames = Class.texture(frames);
-        this._item = function(value) {
-            return frames.one(value);
-        };
-    } else if (typeof frames === "object") {
-        this._item = function(value) {
-            return frames[value];
-        };
-    } else if (typeof frames === "function") {
-        this._item = frames;
-    }
+Class.prototype.prependTo = function(parent) {
+    prepend(parent, this);
+    return this;
+};
+
+Class.prototype.insertNext = function(sibling, more) {
+    if (is.array(sibling)) for (var i = 0; i < sibling.length; i++) insertAfter(sibling[i], this); else if (typeof more !== "undefined") // deprecated
+    for (var i = 0; i < arguments.length; i++) insertAfter(arguments[i], this); else if (typeof sibling !== "undefined") insertAfter(sibling, this);
+    return this;
+};
+
+Class.prototype.insertPrev = function(sibling, more) {
+    if (is.array(sibling)) for (var i = sibling.length - 1; i >= 0; i--) insertBefore(sibling[i], this); else if (typeof more !== "undefined") // deprecated
+    for (var i = arguments.length - 1; i >= 0; i--) insertBefore(arguments[i], this); else if (typeof sibling !== "undefined") insertBefore(sibling, this);
+    return this;
+};
+
+Class.prototype.insertAfter = function(prev) {
+    insertAfter(this, prev);
     return this;
 };
 
-/**
- * @deprecated Use value
- */
-Str.prototype.setValue = function(a, b, c) {
-    return this.value(a, b, c);
+Class.prototype.insertBefore = function(next) {
+    insertBefore(this, next);
+    return this;
 };
 
-Str.prototype.value = function(value) {
-    if (typeof value === "undefined") {
-        return this._value;
+function append(parent, child) {
+    _ensure(child);
+    _ensure(parent);
+    child.remove();
+    if (parent._last) {
+        parent._last._next = child;
+        child._prev = parent._last;
     }
-    if (this._value === value) {
-        return this;
+    child._parent = parent;
+    parent._last = child;
+    if (!parent._first) {
+        parent._first = child;
     }
-    this._value = value;
-    if (value === null) {
-        value = "";
-    } else if (typeof value !== "string" && !is.array(value)) {
-        value = value.toString();
+    child._parent._flag(child, true);
+    child._ts_parent = ++iid;
+    parent._ts_children = ++iid;
+    parent.touch();
+}
+
+function prepend(parent, child) {
+    _ensure(child);
+    _ensure(parent);
+    child.remove();
+    if (parent._first) {
+        parent._first._prev = child;
+        child._next = parent._first;
     }
-    this._spacing = this._spacing || 0;
-    var width = 0, height = 0;
-    for (var i = 0; i < value.length; i++) {
-        var image = this._textures[i] = this._item(value[i]);
-        width += i > 0 ? this._spacing : 0;
-        image.dest(width, 0);
-        width = width + image.width;
-        height = Math.max(height, image.height);
+    child._parent = parent;
+    parent._first = child;
+    if (!parent._last) {
+        parent._last = child;
     }
-    this.pin("width", width);
-    this.pin("height", height);
-    this._textures.length = value.length;
-    return this;
-};
+    child._parent._flag(child, true);
+    child._ts_parent = ++iid;
+    parent._ts_children = ++iid;
+    parent.touch();
+}
 
+function insertBefore(self, next) {
+    _ensure(self);
+    _ensure(next);
+    self.remove();
+    var parent = next._parent;
+    var prev = next._prev;
+    next._prev = self;
+    prev && (prev._next = self) || parent && (parent._first = self);
+    self._parent = parent;
+    self._prev = prev;
+    self._next = next;
+    self._parent._flag(self, true);
+    self._ts_parent = ++iid;
+    self.touch();
+}
 
-},{"./core":8,"./pin":16,"./render":17,"./util/create":22,"./util/is":25}],20:[function(require,module,exports){
-var stats = require("./util/stats");
+function insertAfter(self, prev) {
+    _ensure(self);
+    _ensure(prev);
+    self.remove();
+    var parent = prev._parent;
+    var next = prev._next;
+    prev._next = self;
+    next && (next._prev = self) || parent && (parent._last = self);
+    self._parent = parent;
+    self._prev = prev;
+    self._next = next;
+    self._parent._flag(self, true);
+    self._ts_parent = ++iid;
+    self.touch();
+}
 
-var math = require("./util/math");
+Class.prototype.remove = function(child, more) {
+    if (typeof child !== "undefined") {
+        if (is.array(child)) {
+            for (var i = 0; i < child.length; i++) _ensure(child[i]).remove();
+        } else if (typeof more !== "undefined") {
+            for (var i = 0; i < arguments.length; i++) _ensure(arguments[i]).remove();
+        } else {
+            _ensure(child).remove();
+        }
+        return this;
+    }
+    if (this._prev) {
+        this._prev._next = this._next;
+    }
+    if (this._next) {
+        this._next._prev = this._prev;
+    }
+    if (this._parent) {
+        if (this._parent._first === this) {
+            this._parent._first = this._next;
+        }
+        if (this._parent._last === this) {
+            this._parent._last = this._prev;
+        }
+        this._parent._flag(this, false);
+        this._parent._ts_children = ++iid;
+        this._parent.touch();
+    }
+    this._prev = this._next = this._parent = null;
+    this._ts_parent = ++iid;
+    // this._parent.touch();
+    return this;
+};
 
-function Texture(image, ratio) {
-    if (typeof image === "object") {
-        this.src(image, ratio);
+Class.prototype.empty = function() {
+    var child, next = this._first;
+    while (child = next) {
+        next = child._next;
+        child._prev = child._next = child._parent = null;
+        this._flag(child, false);
     }
-}
+    this._first = this._last = null;
+    this._ts_children = ++iid;
+    this.touch();
+    return this;
+};
 
-Texture.prototype.pipe = function() {
-    return new Texture(this);
+Class.prototype.touch = function() {
+    this._ts_touch = ++iid;
+    this._parent && this._parent.touch();
+    return this;
 };
 
 /**
- * Signatures: (image), (x, y, w, h), (w, h)
+ * Deep flags used for optimizing event distribution.
  */
-Texture.prototype.src = function(x, y, w, h) {
-    if (typeof x === "object") {
-        var image = x, ratio = y || 1;
-        this._image = image;
-        this._sx = this._dx = 0;
-        this._sy = this._dy = 0;
-        this._sw = this._dw = image.width / ratio;
-        this._sh = this._dh = image.height / ratio;
-        this.width = image.width / ratio;
-        this.height = image.height / ratio;
-        this.ratio = ratio;
-    } else {
-        if (typeof w === "undefined") {
-            w = x, h = y;
-        } else {
-            this._sx = x, this._sy = y;
+Class.prototype._flag = function(obj, name) {
+    if (typeof name === "undefined") {
+        return this._flags !== null && this._flags[obj] || 0;
+    }
+    if (typeof obj === "string") {
+        if (name) {
+            this._flags = this._flags || {};
+            if (!this._flags[obj] && this._parent) {
+                this._parent._flag(obj, true);
+            }
+            this._flags[obj] = (this._flags[obj] || 0) + 1;
+        } else if (this._flags && this._flags[obj] > 0) {
+            if (this._flags[obj] == 1 && this._parent) {
+                this._parent._flag(obj, false);
+            }
+            this._flags[obj] = this._flags[obj] - 1;
+        }
+    }
+    if (typeof obj === "object") {
+        if (obj._flags) {
+            for (var type in obj._flags) {
+                if (obj._flags[type] > 0) {
+                    this._flag(type, name);
+                }
+            }
         }
-        this._sw = this._dw = w;
-        this._sh = this._dh = h;
-        this.width = w;
-        this.height = h;
     }
     return this;
 };
 
 /**
- * Signatures: (x, y, w, h), (x, y)
+ * @private
  */
-Texture.prototype.dest = function(x, y, w, h) {
-    this._dx = x, this._dy = y;
-    this._dx = x, this._dy = y;
-    if (typeof w !== "undefined") {
-        this._dw = w, this._dh = h;
-        this.width = w, this.height = h;
+Class.prototype.hitTest = function(hit) {
+    if (this.attr("spy")) {
+        return true;
     }
-    return this;
+    return hit.x >= 0 && hit.x <= this._pin._width && hit.y >= 0 && hit.y <= this._pin._height;
 };
 
-Texture.prototype.draw = function(context, x1, y1, x2, y2, x3, y3, x4, y4) {
-    var image = this._image;
-    if (image === null || typeof image !== "object") {
-        return;
-    }
-    var sx = this._sx, sy = this._sy;
-    var sw = this._sw, sh = this._sh;
-    var dx = this._dx, dy = this._dy;
-    var dw = this._dw, dh = this._dh;
-    if (typeof x3 !== "undefined") {
-        x1 = math.limit(x1, 0, this._sw), x2 = math.limit(x2, 0, this._sw - x1);
-        y1 = math.limit(y1, 0, this._sh), y2 = math.limit(y2, 0, this._sh - y1);
-        sx += x1, sy += y1, sw = x2, sh = y2;
-        dx = x3, dy = y3, dw = x4, dh = y4;
-    } else if (typeof x2 !== "undefined") {
-        dx = x1, dy = y1, dw = x2, dh = y2;
-    } else if (typeof x1 !== "undefined") {
-        dw = x1, dh = y1;
-    }
-    var ratio = this.ratio || 1;
-    sx *= ratio, sy *= ratio, sw *= ratio, sh *= ratio;
-    try {
-        if (typeof image.draw === "function") {
-            image.draw(context, sx, sy, sw, sh, dx, dy, dw, dh);
-        } else {
-            stats.draw++;
-            context.drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh);
-        }
-    } catch (ex) {
-        if (!image._draw_failed) {
-            console.log("Unable to draw: ", image);
-            console.log(ex);
-            image._draw_failed = true;
-        }
+function _ensure(obj) {
+    if (obj && obj instanceof Class) {
+        return obj;
     }
-};
+    throw "Invalid node: " + obj;
+}
 
-module.exports = Texture;
+module.exports = Class;
 
 
-},{"./util/math":26,"./util/stats":28}],21:[function(require,module,exports){
+},{"./core":8,"./util/is":25}],21:[function(require,module,exports){
 module.exports = function() {
     var await = 0;
     function fork(fn, n) {
@@ -3251,7 +3251,7 @@ is.hex = function(value) {
 },{}],26:[function(require,module,exports){
 var create = require("./create");
 
-var M = Math;
+var native = Math;
 
 module.exports = create(Math);
 
@@ -3261,7 +3261,7 @@ module.exports.random = function(min, max) {
     } else if (typeof max === "undefined") {
         max = min, min = 0;
     }
-    return min == max ? min : M.random() * (max - min) + min;
+    return min == max ? min : native.random() * (max - min) + min;
 };
 
 module.exports.rotate = function(num, min, max) {
@@ -3290,7 +3290,7 @@ module.exports.limit = function(num, min, max) {
 };
 
 module.exports.length = function(x, y) {
-    return Math.sqrt(x * x + y * y);
+    return native.sqrt(x * x + y * y);
 };
 
 
diff --git a/dist/stage.web.min.js b/dist/stage.web.min.js
index 41870df..be4bba0 100644
--- a/dist/stage.web.min.js
+++ b/dist/stage.web.min.js
@@ -1,8 +1,8 @@
 /*
- * Stage.js 0.8.1
- * Copyright (c) 2015 Ali Shakiba, Piqnt LLC
- * Available under the MIT license
- * @license
+ * Stage.js 0.8.2
+ * 
+ * @copyright 2015 Ali Shakiba, Piqnt LLC
+ * @license The MIT License
  */
-!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Stage=t()}}(function(){return function t(e,i,n){function r(o,h){if(!i[o]){if(!e[o]){var a="function"==typeof require&&require;if(!h&&a)return a(o,!0);if(s)return s(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var f=i[o]={exports:{}};e[o][0].call(f.exports,function(t){var i=e[o][1][t];return r(i?i:t)},f,f.exports,t,e,i,n)}return i[o].exports}for(var s="function"==typeof require&&require,o=0;o<n.length;o++)r(n[o]);return r}({1:[function(t,e){e.exports=t("../lib/"),t("../lib/canvas"),t("../lib/image"),t("../lib/anim"),t("../lib/str"),t("../lib/layout"),t("../lib/addon/tween"),e.exports.Mouse=t("../lib/addon/mouse"),e.exports.Math=t("../lib/util/math"),e.exports._extend=t("../lib/util/extend"),e.exports._create=t("../lib/util/create"),t("../lib/loader/web")},{"../lib/":11,"../lib/addon/mouse":3,"../lib/addon/tween":4,"../lib/anim":5,"../lib/canvas":7,"../lib/image":10,"../lib/layout":12,"../lib/loader/web":13,"../lib/str":19,"../lib/util/create":22,"../lib/util/extend":24,"../lib/util/math":26}],2:[function(t,e){function i(t){return t}function n(t){if("function"==typeof t)return t;if("string"!=typeof t)return i;var e=r[t];if(e)return e;var n=/^(\w+)(-(in|out|in-out|out-in))?(\((.*)\))?$/i.exec(t);return n&&n.length?(easing=o[n[1]],mode=s[n[3]],params=n[5],e=easing&&easing.fn?easing.fn:easing&&easing.fc?easing.fc.apply(easing.fc,params&&params.replace(/\s+/,"").split(",")):i,mode&&(e=mode.fn(e)),r[t]=e,e):i}var r={},s={},o={};n.add=function(t){for(var e=(t.name||t.mode).split(/\s+/),i=0;i<e.length;i++){var n=e[i];n&&((t.name?o:s)[n]=t)}},n.add({mode:"in",fn:function(t){return t}}),n.add({mode:"out",fn:function(t){return function(e){return 1-t(1-e)}}}),n.add({mode:"in-out",fn:function(t){return function(e){return.5>e?t(2*e)/2:1-t(2*(1-e))/2}}}),n.add({mode:"out-in",fn:function(t){return function(e){return.5>e?1-t(2*(1-e))/2:t(2*e)/2}}}),n.add({name:"linear",fn:function(t){return t}}),n.add({name:"quad",fn:function(t){return t*t}}),n.add({name:"cubic",fn:function(t){return t*t*t}}),n.add({name:"quart",fn:function(t){return t*t*t*t}}),n.add({name:"quint",fn:function(t){return t*t*t*t*t}}),n.add({name:"sin sine",fn:function(t){return 1-Math.cos(t*Math.PI/2)}}),n.add({name:"exp expo",fn:function(t){return 0==t?0:Math.pow(2,10*(t-1))}}),n.add({name:"circle circ",fn:function(t){return 1-Math.sqrt(1-t*t)}}),n.add({name:"bounce",fn:function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}}),n.add({name:"poly",fc:function(t){return function(e){return Math.pow(e,t)}}}),n.add({name:"elastic",fc:function(t,e){e=e||.45,t=t||1;var i=e/(2*Math.PI)*Math.asin(1/t);return function(n){return 1+t*Math.pow(2,-10*n)*Math.sin(2*(n-i)*Math.PI/e)}}}),n.add({name:"back",fc:function(t){return t="undefined"!=typeof t?t:1.70158,function(e){return e*e*((t+1)*e-t)}}}),e.exports=n},{}],3:[function(t,e){function i(t,e){if(this instanceof i){var n=t.viewport().ratio||1;t.on("viewport",function(t){n=t.ratio||n}),this.x=0,this.y=0,this.toString=function(){return(0|this.x)+"x"+(0|this.y)},this.locate=function(t){r(e,t,this),this.x*=n,this.y*=n},this.lookup=function(e,i){this.type=e,this.root=t,this.event=null,i.length=0,this.collect=i,this.root.visit(this.visitor,this)},this.publish=function(e,i,n){if(this.type=e,this.root=t,this.event=i,this.collect=!1,this.timeStamp=Date.now(),"mousemove"!==e&&"touchmove"!==e&&DEBUG&&console.log(this.type+" "+this),n){for(;n.length&&!this.visitor.end(n.shift(),this););n.length=0}else this.root.visit(this.visitor,this)},this.visitor={reverse:!0,visible:!0,start:function(t,e){return!t._flag(e.type)},end:function(t,e){s.raw=e.event,s.type=e.type,s.timeStamp=e.timeStamp,s.abs.x=e.x,s.abs.y=e.y;var i=t.listeners(e.type);if(i&&(t.matrix().inverse().map(e,s),(t===e.root||t.hitTest(s))&&(e.collect&&e.collect.push(t),e.event))){for(var n=!1,r=0;r<i.length;r++)n=i[r].call(t,s)?!0:n;return n}}}}}function n(t,e,i){Object.defineProperty(t,e,{value:i})}function r(t,e,i){e.touches&&e.touches.length?(i.x=e.touches[0].clientX,i.y=e.touches[0].clientY):(i.x=e.clientX,i.y=e.clientY);var n=t.getBoundingClientRect();return i.x-=n.left,i.y-=n.top,i.x-=0|t.clientLeft,i.y-=0|t.clientTop,i}"undefined"==typeof DEBUG&&(DEBUG=!0),t("../core")._load(function(t,e){i.subscribe(t,e)}),i.CLICK="click",i.START="touchstart mousedown",i.MOVE="touchmove mousemove",i.END="touchend mouseup",i.CANCEL="touchcancel mousecancel",i.subscribe=function(t,e){function n(e){e.preventDefault(),t.mouse.locate(e),t.mouse.publish(e.type,e),t.mouse.lookup("click",h),t.mouse.lookup("mousecancel",a)}function r(e){e.preventDefault(),t.mouse.locate(e),t.mouse.publish(e.type,e)}function s(e){e.preventDefault(),t.mouse.publish(e.type,e),h.length&&t.mouse.publish("click",e,h),a.length=0}function o(e){a.length&&t.mouse.publish("mousecancel",e,a),h.length=0}if(!t.mouse){t.mouse=new i(t,e),e.addEventListener("touchstart",n),e.addEventListener("touchend",s),e.addEventListener("touchmove",r),e.addEventListener("touchcancel",o),e.addEventListener("mousedown",n),e.addEventListener("mouseup",s),e.addEventListener("mousemove",r),document.addEventListener("mouseup",o),window.addEventListener("blur",o);var h=[],a=[]}};var s={},o={};n(s,"clone",function(t){return t=t||{},t.x=this.x,t.y=this.y,t}),n(s,"toString",function(){return(0|this.x)+"x"+(0|this.y)+" ("+this.abs+")"}),n(s,"abs",o),n(o,"clone",function(t){return t=t||{},t.x=this.x,t.y=this.y,t}),n(o,"toString",function(){return(0|this.x)+"x"+(0|this.y)}),e.exports=i},{"../core":8}],4:[function(t,e){function i(t,e,i){this._end={},this._duration=e||400,this._delay=i||0,this._owner=t,this._time=0}function n(t,e,i,n){"number"==typeof t.pin(i)?e[i]=n:"number"==typeof t.pin(i+"X")&&"number"==typeof t.pin(i+"Y")&&(e[i+"X"]=n,e[i+"Y"]=n)}var r=t("./easing"),s=t("../core"),o=t("../pin");s.prototype.tween=function(t,e,n){if("number"!=typeof t?(n=t,e=0,t=0):"number"!=typeof e&&(n=e,e=0),!this._tweens){this._tweens=[];var r=0;this.tick(function(t,e,i){if(this._tweens.length){var n=r!=i;if(r=e,n)return!0;var s=this._tweens[0].tick(this,t,e,i);return s&&this._tweens.shift(),"object"==typeof s&&this._tweens.unshift(s),!0}},!0)}this.touch(),n||(this._tweens.length=0);var s=new i(this,t,e);return this._tweens.push(s),s},i.prototype.tick=function(t,e){if(this._time+=e,!(this._time<this._delay)){var i=this._time-this._delay;if(!this._start){this._start={};for(var n in this._end)this._start[n]=this._owner.pin(n)}var r,s;i<this._duration?(r=i/this._duration,s=!1):(r=1,s=!0),r="function"==typeof this._easing?this._easing(r):r;var o=1-r;for(var n in this._end)this._owner.pin(n,this._start[n]*o+this._end[n]*r);if(s){try{this._done&&this._done.call(this._owner)}catch(h){console.log(h)}return this._next||!0}}},i.prototype.tween=function(t,e){return this._next=new i(this._owner,t,e)},i.prototype.duration=function(t){return this._duration=t,this},i.prototype.delay=function(t){return this._delay=t,this},i.prototype.ease=function(t){return this._easing=r(t),this},i.prototype.done=function(t){return this._done=t,this},i.prototype.hide=function(){return this.done(function(){this.hide()}),this},i.prototype.remove=function(){return this.done(function(){this.remove()}),this},i.prototype.pin=function(t,e){if("object"==typeof t)for(var i in t)n(this._owner,this._end,i,t[i]);else"undefined"!=typeof e&&n(this._owner,this._end,t,e);return this},o._add_shortcuts(i),i.prototype.then=function(t){return this.done(t),this},i.prototype.then=function(t){return this.done(t),this},i.prototype.clear=function(){return this},e.exports=i},{"../core":8,"../pin":16,"./easing":2}],5:[function(t){function e(){e._super.call(this),this.label("Anim"),this._textures=[],this._fps=i.Anim.FPS,this._ft=1e3/this._fps,this._time=-1,this._repeat=0,this._index=0,this._frames=[];var t=0;this.tick(function(e,i,n){if(!(this._time<0||this._frames.length<=1)){var r=t!=n;if(t=i,r)return!0;if(this._time+=e,this._time<this._ft)return!0;var s=this._time/this._ft|0;return this._time-=s*this._ft,this.moveFrame(s),this._repeat>0&&(this._repeat-=s)<=0?(this.stop(),this._callback&&this._callback(),!1):!0}},!1)}var i=t("./core");t("./pin"),t("./render");var n=t("./util/create"),r=t("./util/math");i.anim=function(t,i){var n=new e;return n.frames(t).gotoFrame(0),i&&n.fps(i),n},e._super=i,e.prototype=n(e._super.prototype),i.Anim={FPS:15},e.prototype.fps=function(t){return"undefined"==typeof t?this._fps:(this._fps=t>0?t:i.Anim.FPS,this._ft=1e3/this._fps,this)},e.prototype.setFrames=function(t,e,i){return this.frames(t,e,i)},e.prototype.frames=function(t){return this._index=0,this._frames=i.texture(t).array(),this.touch(),this},e.prototype.length=function(){return this._frames?this._frames.length:0},e.prototype.gotoFrame=function(t,e){return this._index=0|r.rotate(t,this._frames.length),e=e||!this._textures[0],this._textures[0]=this._frames[this._index],e&&(this.pin("width",this._textures[0].width),this.pin("height",this._textures[0].height)),this.touch(),this},e.prototype.moveFrame=function(t){return this.gotoFrame(this._index+t)},e.prototype.repeat=function(t,e){return this._repeat=t*this._frames.length-1,this._callback=e,this.play(),this},e.prototype.play=function(t){return"undefined"!=typeof t?(this.gotoFrame(t),this._time=0):this._time<0&&(this._time=0),this.touch(),this},e.prototype.stop=function(t){return this._time=-1,"undefined"!=typeof t&&this.gotoFrame(t),this}},{"./core":8,"./pin":16,"./render":17,"./util/create":22,"./util/math":26}],6:[function(t,e){function i(t){function e(t){if(!t||u.fn(t.draw))return t;t=h({},t),u.fn(a)&&(t=a(t)),1!=c&&(t.x*=c,t.y*=c,t.width*=c,t.height*=c,t.top*=c,t.bottom*=c,t.left*=c,t.right*=c),0!=p&&(t.x+=p,t.y+=p,t.width-=2*p,t.height-=2*p,t.top-=p,t.bottom-=p,t.left-=p,t.right-=p);var e=o.pipe();return e.top=t.top,e.bottom=t.bottom,e.left=t.left,e.right=t.right,e.src(t.x,t.y,t.width,t.height),e}function s(t){if(l){if(u.fn(l))return l(t);if(u.hash(l))return l[t]}if(d){for(var e=null,i=0,n=0;n<d.length;n++)f.startsWith(d[n].name,t)&&(0===i?e=d[n]:1===i?e=[e,d[n]]:e.push(d[n]),i++);return 0===i&&u.fn(_)&&(e=function(e){return _(t+(e?e:""))}),e}}i._super.call(this);var o=this;r(t,"filter"),r(t,"cutouts"),r(t,"sprites"),r(t,"factory");var a=t.map||t.filter,c=t.ppu||t.ratio||1,p=t.trim||0,l=t.textures,_=t.factory,d=t.cutouts||t.sprites;this.select=function(t){if(!t)return new n(this.pipe());var i=s(t);return i?new n(i,s,e):void 0}}function n(t,e,i){function n(t,r){return t?u.fn(t.draw)?t:u.hash(t)&&u.number(t.width)&&u.number(t.height)&&u.fn(i)?i(t):u.hash(t)&&u.defined(r)?n(t[r]):u.fn(t)?n(t(r)):u.array(t)?n(t[0]):u.string(t)&&u.fn(e)?n(e(t)):void 0:l}this.one=function(e){return n(t,e)},this.array=function(e){var i=u.array(e)?e:[];if(u.array(t))for(var r=0;r<t.length;r++)i[r]=n(t[r]);else i[0]=n(t);return i}}function r(t,e,i){e in t&&console.log(i?i.replace("%name",e):"'"+e+"' field of texture atlas is deprecated.")}"undefined"==typeof DEBUG&&(DEBUG=!0);var s=t("./core"),o=t("./texture"),h=t("./util/extend"),a=t("./util/create"),u=t("./util/is"),f=t("./util/string"),c={},p=[];s.atlas=function(t){var e=u.fn(t.draw)?t:new i(t);t.name&&(c[t.name]=e),p.push(e),r(t,"imagePath"),r(t,"imageRatio");var n=t.imagePath,o=t.imageRatio||1;return u.string(t.image)?n=t.image:u.hash(t.image)&&(n=t.image.src||t.image.url,o=t.image.ratio||o),n&&s.preload(function(t){n=s.resolve(n),DEBUG&&console.log("Loading atlas: "+n);var i=s.config("image-loader");i(n,function(i){DEBUG&&console.log("Image loaded: "+n),e.src(i,o),t()},function(e){DEBUG&&console.log("Error loading atlas: "+n,e),t()})}),e},i._super=o,i.prototype=a(i._super.prototype);var l=new o;l.x=l.y=l.width=l.height=0,l.pipe=l.src=l.dest=function(){return this},l.draw=function(){};var _=new n(l);s.texture=function(t){if(!u.string(t))return new n(t);var e,i,r=null;for((i=t.indexOf(":"))>0&&t.length>i+1&&(e=c[t.slice(0,i)],r=e&&e.select(t.slice(i+1))),!r&&(e=c[t])&&(r=e.select()),i=0;!r&&i<p.length;i++)r=p[i].select(t);return r||(console.error("Texture not found: "+t),r=_),r},e.exports=i},{"./core":8,"./texture":20,"./util/create":22,"./util/extend":24,"./util/is":25,"./util/string":29}],7:[function(t){var e=t("./core"),i=t("./texture");e.canvas=function(t,e,n){"string"==typeof t?"object"==typeof e||("function"==typeof e&&(n=e),e={}):("function"==typeof t&&(n=t),e={},t="2d");var r=document.createElement("canvas"),s=r.getContext(t,e),o=new i(r);return o.context=function(){return s},o.size=function(t,e,i){return i=i||1,r.width=t*i,r.height=e*i,this.src(r,i),this},o.canvas=function(t){return"function"==typeof t?t.call(this,s):"undefined"==typeof t&&"function"==typeof n&&n.call(this,s),this},"function"==typeof n&&n.call(o,s),o}},{"./core":8,"./texture":20}],8:[function(t,e){function i(t){if(!(this instanceof i))return o.fn(t)?i.app.apply(i,arguments):o.object(t)?i.atlas.apply(i,arguments):t;r.create++;for(var e=0;e<a.length;e++)a[e].call(this)}function n(t,e){var i=document.createElement("script");i.addEventListener("load",function(){e()}),i.addEventListener("error",function(i){e(i||"Error loading script: "+t)}),i.src=t,i.id="preload-"+Date.now(),document.body.appendChild(i)}"undefined"==typeof DEBUG&&(DEBUG=!0);var r=t("./util/stats"),s=t("./util/extend"),o=t("./util/is"),h=t("./util/await");r.create=0;var a=[];i._init=function(t){a.push(t)};var u=[];i._load=function(t){u.push(t)};var f={};i.config=function(){return 1===arguments.length&&o.string(arguments[0])?f[arguments[0]]:(1===arguments.length&&o.object(arguments[0])&&s(f,arguments[0]),void(2===arguments.length&&o.string(arguments[0])&&f[(arguments[0],arguments[1])]))};var c=[],p=[],l=!1,_=!1;i.app=function(t,e){if(!l)return void c.push(arguments);DEBUG&&console.log("Creating app...");var n=i.config("app-loader");n(function(e,i){DEBUG&&console.log("Initing app...");for(var n=0;n<u.length;n++)u[n].call(this,e,i);t(e,i),p.push(e),DEBUG&&console.log("Starting app..."),e.start()},e)};var d=h();i.preload=function(t){if("string"==typeof t){var e=i.resolve(t);/\.js($|\?|\#)/.test(e)&&(DEBUG&&console.log("Loading script: "+e),t=function(t){n(e,t)})}"function"==typeof t&&t(d())},i.start=function(t){DEBUG&&console.log("Starting..."),i.config(t),d.then(function(){for(DEBUG&&console.log("Loading apps..."),l=!0;c.length;){var t=c.shift();i.app.apply(i,t)}})},i.pause=function(){if(!_){_=!0;for(var t=p.length-1;t>=0;t--)p[t].pause()}},i.resume=function(){if(_){_=!1;for(var t=p.length-1;t>=0;t--)p[t].resume()}},i.create=function(){return new i},i.resolve=function(){function t(){if(document.currentScript)return document.currentScript.src;var t;try{var i=new Error;if(!i.stack)throw i;t=i.stack}catch(i){t=i.stack}if("string"==typeof t){t=t.split("\n");for(var n=t.length;n--;){var r=t[n].match(/(\w+\:\/\/[^\/]*?\/.+?)(:\d+)(:\d+)?/);if(r)return r[1]}}if(e.length&&"readyState"in e[0])for(var n=e.length;n--;)if("interactive"===e[n].readyState)return e[n].src;return location.href}if("undefined"==typeof window||"undefined"==typeof document)return function(t){return t};var e=document.getElementsByTagName("script");return function(e){if(/^\.\//.test(e)){var i=t(),n=i.substring(0,i.lastIndexOf("/")+1);e=n+e.substring(2)}return e}}(),e.exports=i},{"./util/await":21,"./util/extend":24,"./util/is":25,"./util/stats":28}],9:[function(t){t("./util/event")(t("./core").prototype,function(t,e,i){t._flag(e,i)})},{"./core":8,"./util/event":23}],10:[function(t){function e(){e._super.call(this),this.label("Image"),this._textures=[],this._image=null}var i=t("./core");t("./pin"),t("./render");var n=t("./util/repeat"),r=t("./util/create");i.image=function(t){var i=new e;return t&&i.image(t),i},e._super=i,e.prototype=r(e._super.prototype),e.prototype.setImage=function(t,e,i){return this.image(t,e,i)},e.prototype.image=function(t){return this._image=i.texture(t).one(),this.pin("width",this._image?this._image.width:0),this.pin("height",this._image?this._image.height:0),this._textures[0]=this._image.pipe(),this._textures.length=1,this},e.prototype.tile=function(t){return this._repeat(!1,t),this},e.prototype.stretch=function(t){return this._repeat(!0,t),this},e.prototype._repeat=function(t,e){function i(t,e,i,n,s,o,h,a,u){var f=r._textures.length>t?r._textures[t]:r._textures[t]=r._image.pipe();f.src(e,i,n,s),f.dest(o,h,a,u)}var r=this;this.untick(this._repeatTicker),this.tick(this._repeatTicker=function(){if(this._mo_stretch!=this._pin._ts_transform){this._mo_stretch=this._pin._ts_transform;var r=this.pin("width"),s=this.pin("height");this._textures.length=n(this._image,r,s,t,e,i)}})}},{"./core":8,"./pin":16,"./render":17,"./util/create":22,"./util/repeat":27}],11:[function(t,e){e.exports=t("./core"),e.exports.Matrix=t("./matrix"),e.exports.Texture=t("./texture"),t("./atlas"),t("./node"),t("./event"),t("./pin"),t("./render"),t("./root")},{"./atlas":6,"./core":8,"./event":9,"./matrix":14,"./node":15,"./pin":16,"./render":17,"./root":18,"./texture":20}],12:[function(t){var e=t("./core");t("./pin"),t("./render");t("./util/create");e.row=function(t){return e.create().row(t).label("Row")},e.prototype.row=function(t){return this.sequence("row",t),this},e.column=function(t){return e.create().column(t).label("Row")},e.prototype.column=function(t){return this.sequence("column",t),this},e.sequence=function(t,i){return e.create().sequence(t,i).label("Sequence")},e.prototype.sequence=function(t,e){return this._padding=this._padding||0,this._spacing=this._spacing||0,this.untick(this._layoutTiker),this.tick(this._layoutTiker=function(){if(this._mo_seq!=this._ts_touch){this._mo_seq=this._ts_touch;var i=this._mo_seqAlign!=this._ts_children;this._mo_seqAlign=this._ts_children;for(var n,r=0,s=0,o=this.first(!0),h=!0;n=o;){o=n.next(!0),n.matrix(!0);var a=n.pin("boxWidth"),u=n.pin("boxHeight");"column"==t?(!h&&(s+=this._spacing),n.pin("offsetY")!=s&&n.pin("offsetY",s),r=Math.max(r,a),s+=u,i&&n.pin("alignX",e)):"row"==t&&(!h&&(r+=this._spacing),n.pin("offsetX")!=r&&n.pin("offsetX",r),r+=a,s=Math.max(s,u),i&&n.pin("alignY",e)),h=!1}r+=2*this._padding,s+=2*this._padding,this.pin("width")!=r&&this.pin("width",r),this.pin("height")!=s&&this.pin("height",s)}}),this},e.box=function(){return e.create().box().label("Box")},e.prototype.box=function(){return this._padding=this._padding||0,this.untick(this._layoutTiker),this.tick(this._layoutTiker=function(){if(this._mo_box!=this._ts_touch){this._mo_box=this._ts_touch;for(var t,e=0,i=0,n=this.first(!0);t=n;){n=t.next(!0),t.matrix(!0);var r=t.pin("boxWidth"),s=t.pin("boxHeight");e=Math.max(e,r),i=Math.max(i,s)}e+=2*this._padding,i+=2*this._padding,this.pin("width")!=e&&this.pin("width",e),this.pin("height")!=i&&this.pin("height",i)}}),this},e.layer=function(){return e.create().layer().label("Layer")},e.prototype.layer=function(){return this.untick(this._layoutTiker),this.tick(this._layoutTiker=function(){var t=this.parent();if(t){var e=t.pin("width");this.pin("width")!=e&&this.pin("width",e);var i=t.pin("height");this.pin("height")!=i&&this.pin("height",i)}},!0),this},e.prototype.padding=function(t){return this._padding=t,this},e.prototype.spacing=function(t){return this._spacing=t,this}},{"./core":8,"./pin":16,"./render":17,"./util/create":22}],13:[function(t){function e(t,e){function i(){o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,a,u),d.render(o)}function r(){h?(a=window.innerWidth>0?window.innerWidth:screen.width,u=window.innerHeight>0?window.innerHeight:screen.height,s.style.width=a+"px",s.style.height=u+"px"):(a=s.clientWidth,u=s.clientHeight),a*=f,u*=f,(s.width!==a||s.height!==u)&&(s.width=a,s.height=u,DEBUG&&console.log("Resize: "+a+" x "+u+" / "+f),d.viewport(a,u,f),i())}e=e||{};var s=e.canvas,o=null,h=!1,a=0,u=0,f=1;if("string"==typeof s&&(s=document.getElementById(s)),s||(s=document.getElementById("cutjs")||document.getElementById("stage")),!s){h=!0,DEBUG&&console.log("Creating Canvas..."),s=document.createElement("canvas"),s.style.position="absolute";var c=document.body;c.insertBefore(s,c.firstChild)}o=s.getContext("2d");var p=window.devicePixelRatio||1,l=o.webkitBackingStorePixelRatio||o.mozBackingStorePixelRatio||o.msBackingStorePixelRatio||o.oBackingStorePixelRatio||o.backingStorePixelRatio||1;f=p/l;var _=window.requestAnimationFrame||window.msRequestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.oRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)};DEBUG&&console.log("Creating stage...");var d=n.root(_,i);d.background=function(t){return s.style.backgroundColor=t,this},t(d,s),r(),window.addEventListener("resize",r,!1),window.addEventListener("orientationchange",r,!1)}function i(t,e,i){DEBUG&&console.log("Loading image: "+t);var n=new Image;n.onload=function(){e(n)},n.onerror=i,n.src=t}"undefined"==typeof DEBUG&&(DEBUG=!0);var n=t("../core");window.addEventListener("load",function(){DEBUG&&console.log("On load."),n.start()},!1),n.config({"app-loader":e,"image-loader":i})},{"../core":8}],14:[function(t,e){function i(t,e,i,n,r,s){this.reset(t,e,i,n,r,s)}i.prototype.toString=function(){return"["+this.a+", "+this.b+", "+this.c+", "+this.d+", "+this.e+", "+this.f+"]"},i.prototype.clone=function(){return new i(this.a,this.b,this.c,this.d,this.e,this.f)},i.prototype.reset=function(t,e,i,n,r,s){return this._dirty=!0,"object"==typeof t?(this.a=t.a,this.d=t.d,this.b=t.b,this.c=t.c,this.e=t.e,this.f=t.f):(this.a=t||1,this.d=n||1,this.b=e||0,this.c=i||0,this.e=r||0,this.f=s||0),this},i.prototype.identity=function(){return this._dirty=!0,this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this},i.prototype.rotate=function(t){if(!t)return this;this._dirty=!0;var e=t?Math.cos(t):1,i=t?Math.sin(t):0,n=e*this.a-i*this.b,r=e*this.b+i*this.a,s=e*this.c-i*this.d,o=e*this.d+i*this.c,h=e*this.e-i*this.f,a=e*this.f+i*this.e;return this.a=n,this.b=r,this.c=s,this.d=o,this.e=h,this.f=a,this},i.prototype.translate=function(t,e){return t||e?(this._dirty=!0,this.e+=t,this.f+=e,this):this},i.prototype.scale=function(t,e){return t-1||e-1?(this._dirty=!0,this.a*=t,this.b*=e,this.c*=t,this.d*=e,this.e*=t,this.f*=e,this):this},i.prototype.skew=function(t,e){if(!t&&!e)return this;this._dirty=!0;var i=this.a+this.b*t,n=this.b+this.a*e,r=this.c+this.d*t,s=this.d+this.c*e,o=this.e+this.f*t,h=this.f+this.e*e;return this.a=i,this.b=n,this.c=r,this.d=s,this.e=o,this.f=h,this},i.prototype.concat=function(t){this._dirty=!0;var e=this,i=e.a*t.a+e.b*t.c,n=e.b*t.d+e.a*t.b,r=e.c*t.a+e.d*t.c,s=e.d*t.d+e.c*t.b,o=e.e*t.a+t.e+e.f*t.c,h=e.f*t.d+t.f+e.e*t.b;return this.a=i,this.b=n,this.c=r,this.d=s,this.e=o,this.f=h,this},i.prototype.inverse=i.prototype.reverse=function(){if(this._dirty){this._dirty=!1,this.inversed=this.inversed||new i;var t=this.a*this.d-this.b*this.c;this.inversed.a=this.d/t,this.inversed.b=-this.b/t,this.inversed.c=-this.c/t,this.inversed.d=this.a/t,this.inversed.e=(this.c*this.f-this.e*this.d)/t,this.inversed.f=(this.e*this.b-this.a*this.f)/t}return this.inversed},i.prototype.map=function(t,e){return e=e||{},e.x=this.a*t.x+this.c*t.y+this.e,e.y=this.b*t.x+this.d*t.y+this.f,e},i.prototype.mapX=function(t,e){return"object"==typeof t&&(e=t.y,t=t.x),this.a*t+this.c*e+this.e},i.prototype.mapY=function(t,e){return"object"==typeof t&&(e=t.y,t=t.x),this.b*t+this.d*e+this.f},e.exports=i},{}],15:[function(t,e){function i(t,e){o(e),o(t),e.remove(),t._last&&(t._last._next=e,e._prev=t._last),e._parent=t,t._last=e,t._first||(t._first=e),e._parent._flag(e,!0),e._ts_parent=++u,t._ts_children=++u,t.touch()}function n(t,e){o(e),o(t),e.remove(),t._first&&(t._first._prev=e,e._next=t._first),e._parent=t,t._first=e,t._last||(t._last=e),e._parent._flag(e,!0),e._ts_parent=++u,t._ts_children=++u,t.touch()}function r(t,e){o(t),o(e),t.remove();var i=e._parent,n=e._prev;e._prev=t,n&&(n._next=t)||i&&(i._first=t),t._parent=i,t._prev=n,t._next=e,t._parent._flag(t,!0),t._ts_parent=++u,t.touch()}function s(t,e){o(t),o(e),t.remove();var i=e._parent,n=e._next;e._next=t,n&&(n._prev=t)||i&&(i._last=t),t._parent=i,t._prev=e,t._next=n,t._parent._flag(t,!0),t._ts_parent=++u,t.touch()}function o(t){if(t&&t instanceof h)return t;throw"Invalid node: "+t}var h=t("./core"),a=t("./util/is"),u=0;h.prototype._label="",h.prototype._visible=!0,h.prototype._parent=null,h.prototype._next=null,h.prototype._prev=null,h.prototype._first=null,h.prototype._last=null,h.prototype._attrs=null,h.prototype._flags=null,h.prototype.toString=function(){return"["+this._label+"]"},h.prototype.id=function(t){return this.label(t)},h.prototype.label=function(t){return"undefined"==typeof t?this._label:(this._label=t,this)},h.prototype.attr=function(t,e){return"undefined"==typeof e?null!==this._attrs?this._attrs[t]:void 0:((null!==this._attrs?this._attrs:this._attrs={})[t]=e,this)},h.prototype.visible=function(t){return"undefined"==typeof t?this._visible:(this._visible=t,this._parent&&(this._parent._ts_children=++u),this._ts_pin=++u,this.touch(),this)},h.prototype.hide=function(){return this.visible(!1)},h.prototype.show=function(){return this.visible(!0)},h.prototype.parent=function(){return this._parent},h.prototype.next=function(t){for(var e=this._next;e&&t&&!e._visible;)e=e._next;return e},h.prototype.prev=function(t){for(var e=this._prev;e&&t&&!e._visible;)e=e._prev;return e},h.prototype.first=function(t){for(var e=this._first;e&&t&&!e._visible;)e=e._next;return e},h.prototype.last=function(t){for(var e=this._last;e&&t&&!e._visible;)e=e._prev;return e},h.prototype.visit=function(t,e){var i=t.reverse,n=t.visible;if(!t.start||!t.start(this,e)){for(var r,s=i?this.last(n):this.first(n);r=s;)if(s=i?r.prev(n):r.next(n),r.visit(t,e))return!0;return t.end&&t.end(this,e)}},h.prototype.append=function(t,e){if(a.array(t))for(var n=0;n<t.length;n++)i(this,t[n]);else if("undefined"!=typeof e)for(var n=0;n<arguments.length;n++)i(this,arguments[n]);else"undefined"!=typeof t&&i(this,t);return this},h.prototype.prepend=function(t,e){if(a.array(t))for(var i=t.length-1;i>=0;i--)n(this,t[i]);else if("undefined"!=typeof e)for(var i=arguments.length-1;i>=0;i--)n(this,arguments[i]);else"undefined"!=typeof t&&n(this,t);return this},h.prototype.appendTo=function(t){return i(t,this),this},h.prototype.prependTo=function(t){return n(t,this),this},h.prototype.insertNext=function(t,e){if(a.array(t))for(var i=0;i<t.length;i++)s(t[i],this);else if("undefined"!=typeof e)for(var i=0;i<arguments.length;i++)s(arguments[i],this);else"undefined"!=typeof t&&s(t,this);return this},h.prototype.insertPrev=function(t,e){if(a.array(t))for(var i=t.length-1;i>=0;i--)r(t[i],this);else if("undefined"!=typeof e)for(var i=arguments.length-1;i>=0;i--)r(arguments[i],this);else"undefined"!=typeof t&&r(t,this);return this},h.prototype.insertAfter=function(t){return s(this,t),this},h.prototype.insertBefore=function(t){return r(this,t),this},h.prototype.remove=function(t,e){if("undefined"!=typeof t){if(a.array(t))for(var i=0;i<t.length;i++)o(t[i]).remove();else if("undefined"!=typeof e)for(var i=0;i<arguments.length;i++)o(arguments[i]).remove();else o(t).remove();return this}return this._prev&&(this._prev._next=this._next),this._next&&(this._next._prev=this._prev),this._parent&&(this._parent._first===this&&(this._parent._first=this._next),this._parent._last===this&&(this._parent._last=this._prev),this._parent._flag(this,!1),this._parent._ts_children=++u,this._parent.touch()),this._prev=this._next=this._parent=null,this._ts_parent=++u,this},h.prototype.empty=function(){for(var t,e=this._first;t=e;)e=t._next,t._prev=t._next=t._parent=null,this._flag(t,!1);return this._first=this._last=null,this._ts_children=++u,this.touch(),this},h.prototype.touch=function(){return this._ts_touch=++u,this._parent&&this._parent.touch(),this},h.prototype._flag=function(t,e){if("undefined"==typeof e)return null!==this._flags&&this._flags[t]||0;if("string"==typeof t&&(e?(this._flags=this._flags||{},!this._flags[t]&&this._parent&&this._parent._flag(t,!0),this._flags[t]=(this._flags[t]||0)+1):this._flags&&this._flags[t]>0&&(1==this._flags[t]&&this._parent&&this._parent._flag(t,!1),this._flags[t]=this._flags[t]-1)),"object"==typeof t&&t._flags)for(var i in t._flags)t._flags[i]>0&&this._flag(i,e);return this},h.prototype.hitTest=function(t){return this.attr("spy")?!0:t.x>=0&&t.x<=this._pin._width&&t.y>=0&&t.y<=this._pin._height},e.exports=h},{"./core":8,"./util/is":25}],16:[function(t,e){function i(t){this._owner=t,this._parent=null,this._relativeMatrix=new s,this._absoluteMatrix=new s,this.reset()}function n(t,e,i,n){var r="number"==typeof e,s="number"==typeof i,h="string"==typeof n;t._ts_transform=++o,r&&(t._scaleX=e/t._width_,t._width=t._width_),s&&(t._scaleY=i/t._height_,t._height=t._height_),r&&s&&h&&("out"==n||"out-crop"==n?t._scaleX=t._scaleY=Math.max(t._scaleX,t._scaleY):("in"==n||"in-pad"==n)&&(t._scaleX=t._scaleY=Math.min(t._scaleX,t._scaleY)),("out-crop"==n||"in-pad"==n)&&(t._width=e/t._scaleX,t._height=i/t._scaleY))}var r=t("./core"),s=t("./matrix"),o=0;r._init(function(){this._pin=new i(this)}),r.prototype.matrix=function(t){return t===!0?this._pin.relativeMatrix():this._pin.absoluteMatrix()},r.prototype.pin=function(t,e){return"object"==typeof t?(this._pin.set(t),this):"string"==typeof t?"undefined"==typeof e?this._pin.get(t):(this._pin.set(t,e),this):"undefined"==typeof t?this._pin:void 0},i.prototype.reset=function(){this._textureAlpha=1,this._alpha=1,this._width=0,this._height=0,this._scaleX=1,this._scaleY=1,this._skewX=0,this._skewY=0,this._rotation=0,this._pivoted=!1,this._pivotX=null,this._pivotY=null,this._handled=!1,this._handleX=0,this._handleY=0,this._aligned=!1,this._alignX=0,this._alignY=0,this._offsetX=0,this._offsetY=0,this._boxX=0,this._boxY=0,this._boxWidth=this._width,this._boxHeight=this._height,this._ts_translate=++o,this._ts_transform=++o,this._ts_matrix=++o},i.prototype._update=function(){return this._parent=this._owner._parent&&this._owner._parent._pin,this._handled&&this._mo_handle!=this._ts_transform&&(this._mo_handle=this._ts_transform,this._ts_translate=++o),this._aligned&&this._parent&&this._mo_align!=this._parent._ts_transform&&(this._mo_align=this._parent._ts_transform,this._ts_translate=++o),this},i.prototype.toString=function(){return this._owner+" ("+(this._parent?this._parent._owner:null)+")"},i.prototype.absoluteMatrix=function(){this._update();var t=Math.max(this._ts_transform,this._ts_translate,this._parent?this._parent._ts_matrix:0);if(this._mo_abs==t)return this._absoluteMatrix;this._mo_abs=t;var e=this._absoluteMatrix;return e.reset(this.relativeMatrix()),this._parent&&e.concat(this._parent._absoluteMatrix),this._ts_matrix=++o,e},i.prototype.relativeMatrix=function(){this._update();var t=Math.max(this._ts_transform,this._ts_translate,this._parent?this._parent._ts_transform:0);if(this._mo_rel==t)return this._relativeMatrix;this._mo_rel=t;var e=this._relativeMatrix;if(e.identity(),this._pivoted&&e.translate(-this._pivotX*this._width,-this._pivotY*this._height),e.scale(this._scaleX,this._scaleY),e.skew(this._skewX,this._skewY),e.rotate(this._rotation),this._pivoted&&e.translate(this._pivotX*this._width,this._pivotY*this._height),this._pivoted)this._boxX=0,this._boxY=0,this._boxWidth=this._width,this._boxHeight=this._height;else{var i,n;e.a>0&&e.c>0||e.a<0&&e.c<0?(i=0,n=e.a*this._width+e.c*this._height):(i=e.a*this._width,n=e.c*this._height),i>n?(this._boxX=n,this._boxWidth=i-n):(this._boxX=i,this._boxWidth=n-i),e.b>0&&e.d>0||e.b<0&&e.d<0?(i=0,n=e.b*this._width+e.d*this._height):(i=e.b*this._width,n=e.d*this._height),i>n?(this._boxY=n,this._boxHeight=i-n):(this._boxY=i,this._boxHeight=n-i)}return this._x=this._offsetX,this._y=this._offsetY,this._x-=this._boxX+this._handleX*this._boxWidth,this._y-=this._boxY+this._handleY*this._boxHeight,this._aligned&&this._parent&&(this._parent.relativeMatrix(),this._x+=this._alignX*this._parent._width,this._y+=this._alignY*this._parent._height),e.translate(this._x,this._y),this._relativeMatrix
-},i.prototype.get=function(t){return"function"==typeof h[t]?h[t](this):void 0},i.prototype.set=function(t,e){if("string"==typeof t)"function"==typeof a[t]&&"undefined"!=typeof e&&a[t](this,e);else if("object"==typeof t)for(e in t)"function"==typeof a[e]&&"undefined"!=typeof t[e]&&a[e](this,t[e],t);return this._owner&&(this._owner._ts_pin=++o,this._owner.touch()),this};var h={alpha:function(t){return t._alpha},textureAlpha:function(t){return t._textureAlpha},width:function(t){return t._width},height:function(t){return t._height},boxWidth:function(t){return t._boxWidth},boxHeight:function(t){return t._boxHeight},scaleX:function(t){return t._scaleX},scaleY:function(t){return t._scaleY},skewX:function(t){return t._skewX},skewY:function(t){return t._skewY},rotation:function(t){return t._rotation},pivotX:function(t){return t._pivotX},pivotY:function(t){return t._pivotY},offsetX:function(t){return t._offsetX},offsetY:function(t){return t._offsetY},alignX:function(t){return t._alignX},alignY:function(t){return t._alignY},handleX:function(t){return t._handleX},handleY:function(t){return t._handleY}},a={alpha:function(t,e){t._alpha=e},textureAlpha:function(t,e){t._textureAlpha=e},width:function(t,e){t._width_=e,t._width=e,t._ts_transform=++o},height:function(t,e){t._height_=e,t._height=e,t._ts_transform=++o},scale:function(t,e){t._scaleX=e,t._scaleY=e,t._ts_transform=++o},scaleX:function(t,e){t._scaleX=e,t._ts_transform=++o},scaleY:function(t,e){t._scaleY=e,t._ts_transform=++o},skew:function(t,e){t._skewX=e,t._skewY=e,t._ts_transform=++o},skewX:function(t,e){t._skewX=e,t._ts_transform=++o},skewY:function(t,e){t._skewY=e,t._ts_transform=++o},rotation:function(t,e){t._rotation=e,t._ts_transform=++o},pivot:function(t,e){t._pivotX=e,t._pivotY=e,t._pivoted=!0,t._ts_transform=++o},pivotX:function(t,e){t._pivotX=e,t._pivoted=!0,t._ts_transform=++o},pivotY:function(t,e){t._pivotY=e,t._pivoted=!0,t._ts_transform=++o},offset:function(t,e){t._offsetX=e,t._offsetY=e,t._ts_translate=++o},offsetX:function(t,e){t._offsetX=e,t._ts_translate=++o},offsetY:function(t,e){t._offsetY=e,t._ts_translate=++o},align:function(t,e){this.alignX(t,e),this.alignY(t,e)},alignX:function(t,e){t._alignX=e,t._aligned=!0,t._ts_translate=++o,this.handleX(t,e)},alignY:function(t,e){t._alignY=e,t._aligned=!0,t._ts_translate=++o,this.handleY(t,e)},handle:function(t,e){this.handleX(t,e),this.handleY(t,e)},handleX:function(t,e){t._handleX=e,t._handled=!0,t._ts_translate=++o},handleY:function(t,e){t._handleY=e,t._handled=!0,t._ts_translate=++o},resizeMode:function(t,e,i){i&&("in"==e?e="in-pad":"out"==e&&(e="out-crop"),n(t,i.resizeWidth,i.resizeHeight,e))},resizeWidth:function(t,e,i){i&&i.resizeMode||n(t,e,null)},resizeHeight:function(t,e,i){i&&i.resizeMode||n(t,null,e)},scaleMode:function(t,e,i){i&&n(t,i.scaleWidth,i.scaleHeight,e)},scaleWidth:function(t,e,i){i&&i.scaleMode||n(t,e,null)},scaleHeight:function(t,e,i){i&&i.scaleMode||n(t,null,e)},matrix:function(t,e){this.scaleX(t,e.a),this.skewX(t,e.c/e.d),this.skewY(t,e.b/e.a),this.scaleY(t,e.d),this.offsetX(t,e.e),this.offsetY(t,e.f),this.rotation(t,0)}};r.prototype.scaleTo=function(t,e,i){return"object"==typeof t&&(i=e,e=t.y,t=t.x),n(this._pin,t,e,i),this},i._add_shortcuts=function(t){t.prototype.size=function(t,e){return this.pin("width",t),this.pin("height",e),this},t.prototype.width=function(t){return"undefined"==typeof t?this.pin("width"):(this.pin("width",t),this)},t.prototype.height=function(t){return"undefined"==typeof t?this.pin("height"):(this.pin("height",t),this)},t.prototype.offset=function(t,e){return"object"==typeof t&&(e=t.y,t=t.x),this.pin("offsetX",t),this.pin("offsetY",e),this},t.prototype.rotate=function(t){return this.pin("rotation",t),this},t.prototype.skew=function(t,e){return"object"==typeof t?(e=t.y,t=t.x):"undefined"==typeof e&&(e=t),this.pin("skewX",t),this.pin("skewY",e),this},t.prototype.scale=function(t,e){return"object"==typeof t?(e=t.y,t=t.x):"undefined"==typeof e&&(e=t),this.pin("scaleX",t),this.pin("scaleY",e),this},t.prototype.alpha=function(t,e){return this.pin("alpha",t),"undefined"!=typeof e&&this.pin("textureAlpha",e),this}},i._add_shortcuts(r),e.exports=i},{"./core":8,"./matrix":14}],17:[function(t){var e=t("./core");t("./pin");var i=t("./util/stats");e.prototype._textures=null,e.prototype._alpha=1,e.prototype.render=function(t){if(this._visible){i.node++;var e=this.matrix();t.setTransform(e.a,e.b,e.c,e.d,e.e,e.f),this._alpha=this._pin._alpha*(this._parent?this._parent._alpha:1);var n=this._pin._textureAlpha*this._alpha;if(t.globalAlpha!=n&&(t.globalAlpha=n),null!==this._textures)for(var r=0,s=this._textures.length;s>r;r++)this._textures[r].draw(t);t.globalAlpha!=this._alpha&&(t.globalAlpha=this._alpha);for(var o,h=this._first;o=h;)h=o._next,o.render(t)}},e.prototype._tickBefore=null,e.prototype._tickAfter=null,e.prototype.MAX_ELAPSE=1/0,e.prototype._tick=function(t,e,n){if(this._visible){t>this.MAX_ELAPSE&&(t=this.MAX_ELAPSE);var r=!1;if(null!==this._tickBefore)for(var s=0,o=this._tickBefore.length;o>s;s++)i.tick++,r=this._tickBefore[s].call(this,t,e,n)===!0||r;for(var h,a=this._first;h=a;)a=h._next,h._flag("_tick")&&(r=h._tick(t,e,n)===!0?!0:r);if(null!==this._tickAfter)for(var s=0,o=this._tickAfter.length;o>s;s++)i.tick++,r=this._tickAfter[s].call(this,t,e,n)===!0||r;return r}},e.prototype.tick=function(t,e){"function"==typeof t&&(e?(null===this._tickBefore&&(this._tickBefore=[]),this._tickBefore.push(t)):(null===this._tickAfter&&(this._tickAfter=[]),this._tickAfter.push(t)),this._flag("_tick",null!==this._tickAfter&&this._tickAfter.length>0||null!==this._tickBefore&&this._tickBefore.length>0))},e.prototype.untick=function(t){if("function"==typeof t){var e;null!==this._tickBefore&&(e=this._tickBefore.indexOf(t))>=0&&this._tickBefore.splice(e,1),null!==this._tickAfter&&(e=this._tickAfter.indexOf(t))>=0&&this._tickAfter.splice(e,1)}},e.prototype.timeout=function(t,e){this.tick(function i(n){return(e-=n)<0?(this.untick(i),void t.call(this)):!0})}},{"./core":8,"./pin":16,"./util/stats":28}],18:[function(t){function e(t,i){e._super.call(this),this.label("Root");var r=!0,s=this,o=0,h=function(e){if(r!==!0){n.tick=n.node=n.draw=0;var a=o||e,u=e-a;o=e;var f=s._tick(u,e,a);s._mo_touch!=s._ts_touch?(s._mo_touch=s._ts_touch,i(s),t(h)):f?t(h):r=!0,n.fps=u?1e3/u:0}};this.start=function(){return this.resume()},this.resume=function(){return r&&(r=!1,t(h)),this},this.pause=function(){return r=!0,this},this.touch_root=this.touch,this.touch=function(){return this.resume(),this.touch_root()}}var i=t("./core");t("./pin"),t("./render");var n=t("./util/stats"),r=t("./util/create"),s=t("./util/extend");e._super=i,e.prototype=r(e._super.prototype),i.root=function(t,i){return new e(t,i)},e.prototype.background=function(){return this},e.prototype.viewport=function(t,e,i){if("undefined"==typeof t)return s({},this._viewport);this._viewport={width:t,height:e,ratio:i||1},this.viewbox();var n=s({},this._viewport);return this.visit({start:function(t){return t._flag("viewport")?void t.publish("viewport",[n]):!0}}),this},e.prototype.viewbox=function(t,e,i){"number"==typeof t&&"number"==typeof e&&(this._viewbox={width:t,height:e,mode:/^(in|out|in-pad|out-crop)$/.test(i)?i:"in-pad"});var n=this._viewbox,r=this._viewport;return r&&n?(this.pin({width:n.width,height:n.height}),this.scaleTo(r.width,r.height,n.mode)):r&&this.pin({width:r.width,height:r.height}),this}},{"./core":8,"./pin":16,"./render":17,"./util/create":22,"./util/extend":24,"./util/stats":28}],19:[function(t){function e(){e._super.call(this),this.label("String"),this._textures=[]}var i=t("./core");t("./pin"),t("./render");var n=t("./util/create"),r=t("./util/is");i.string=function(t){return(new e).frames(t)},e._super=i,e.prototype=n(e._super.prototype),e.prototype.setFont=function(t,e,i){return this.frames(t,e,i)},e.prototype.frames=function(t){return this._textures=[],"string"==typeof t?(t=i.texture(t),this._item=function(e){return t.one(e)}):"object"==typeof t?this._item=function(e){return t[e]}:"function"==typeof t&&(this._item=t),this},e.prototype.setValue=function(t,e,i){return this.value(t,e,i)},e.prototype.value=function(t){if("undefined"==typeof t)return this._value;if(this._value===t)return this;this._value=t,null===t?t="":"string"==typeof t||r.array(t)||(t=t.toString()),this._spacing=this._spacing||0;for(var e=0,i=0,n=0;n<t.length;n++){var s=this._textures[n]=this._item(t[n]);e+=n>0?this._spacing:0,s.dest(e,0),e+=s.width,i=Math.max(i,s.height)}return this.pin("width",e),this.pin("height",i),this._textures.length=t.length,this}},{"./core":8,"./pin":16,"./render":17,"./util/create":22,"./util/is":25}],20:[function(t,e){function i(t,e){"object"==typeof t&&this.src(t,e)}var n=t("./util/stats"),r=t("./util/math");i.prototype.pipe=function(){return new i(this)},i.prototype.src=function(t,e,i,n){if("object"==typeof t){var r=t,s=e||1;this._image=r,this._sx=this._dx=0,this._sy=this._dy=0,this._sw=this._dw=r.width/s,this._sh=this._dh=r.height/s,this.width=r.width/s,this.height=r.height/s,this.ratio=s}else"undefined"==typeof i?(i=t,n=e):(this._sx=t,this._sy=e),this._sw=this._dw=i,this._sh=this._dh=n,this.width=i,this.height=n;return this},i.prototype.dest=function(t,e,i,n){return this._dx=t,this._dy=e,this._dx=t,this._dy=e,"undefined"!=typeof i&&(this._dw=i,this._dh=n,this.width=i,this.height=n),this},i.prototype.draw=function(t,e,i,s,o,h,a,u,f){var c=this._image;if(null!==c&&"object"==typeof c){var p=this._sx,l=this._sy,_=this._sw,d=this._sh,g=this._dx,y=this._dy,m=this._dw,v=this._dh;"undefined"!=typeof h?(e=r.limit(e,0,this._sw),s=r.limit(s,0,this._sw-e),i=r.limit(i,0,this._sh),o=r.limit(o,0,this._sh-i),p+=e,l+=i,_=s,d=o,g=h,y=a,m=u,v=f):"undefined"!=typeof s?(g=e,y=i,m=s,v=o):"undefined"!=typeof e&&(m=e,v=i);var x=this.ratio||1;p*=x,l*=x,_*=x,d*=x;try{"function"==typeof c.draw?c.draw(t,p,l,_,d,g,y,m,v):(n.draw++,t.drawImage(c,p,l,_,d,g,y,m,v))}catch(b){c._draw_failed||(console.log("Unable to draw: ",c),console.log(b),c._draw_failed=!0)}}},e.exports=i},{"./util/math":26,"./util/stats":28}],21:[function(t,e){e.exports=function(){function t(t,n){return i+=n="number"==typeof n&&n>=1?n:1,function(){t&&t.apply(this,arguments),n>0&&(n--,i--,e())}}function e(){if(0===i)for(;n.length;)setTimeout(n.shift(),0)}var i=0,n=[];return t.then=function(t){0===i?setTimeout(t,0):n.push(t)},t}},{}],22:[function(t,e){function i(){}e.exports="function"==typeof Object.create?function(t,e){return Object.create.call(Object,t,e)}:function(t,e){if(e)throw Error("Second argument is not supported!");if("object"!=typeof t||null===t)throw Error("Invalid prototype!");return i.prototype=t,new i}},{}],23:[function(t,e){e.exports=function(t,e){t._listeners=null,t.on=t.listen=function(t,i){if(!t||!t.length||"function"!=typeof i)return this;null===this._listeners&&(this._listeners={});var n="string"!=typeof t&&"function"==typeof t.join;if(t=(n?t.join(" "):t).match(/\S+/g))for(var r=0;r<t.length;r++){var s=t[r];this._listeners[s]=this._listeners[s]||[],this._listeners[s].push(i),"function"==typeof e&&e(this,s,!0)}return this},t.off=function(t,i){if(!t||!t.length||"function"!=typeof i)return this;if(null===this._listeners)return this;var n="string"!=typeof t&&"function"==typeof t.join;if(t=(n?t.join(" "):t).match(/\S+/g))for(var r=0;r<t.length;r++){var s,o=t[r],h=this._listeners[o];h&&(s=h.indexOf(i))>=0&&(h.splice(s,1),h.length||delete this._listeners[o],"function"==typeof e&&e(this,o,!1))}return this},t.listeners=function(t){return this._listeners&&this._listeners[t]},t.publish=function(t,e){var i=this.listeners(t);if(!i||!i.length)return 0;for(var n=0;n<i.length;n++)i[n].apply(this,e);return i.length},t.trigger=function(t,e){return this.publish(t,e),this}}},{}],24:[function(t,e){e.exports=function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])}return t}},{}],25:[function(t,e){var i=Object.prototype,n=i.hasOwnProperty,r=i.toString,s=/^[A-Fa-f0-9]+$/,o=e.exports={};o.a=o.an=o.type=function(t,e){return typeof t===e},o.defined=function(t){return"undefined"!=typeof t},o.empty=function(t){var e,i=r.call(t);if("[object Array]"===i||"[object Arguments]"===i||"[object String]"===i)return 0===t.length;if("[object Object]"===i){for(e in t)if(n.call(t,e))return!1;return!0}return!t},o.equal=function(t,e){if(t===e)return!0;var i,n=r.call(t);if(n!==r.call(e))return!1;if("[object Object]"===n){for(i in t)if(!(o.equal(t[i],e[i])&&i in e))return!1;for(i in e)if(!(o.equal(t[i],e[i])&&i in t))return!1;return!0}if("[object Array]"===n){if(i=t.length,i!==e.length)return!1;for(;--i;)if(!o.equal(t[i],e[i]))return!1;return!0}return"[object Function]"===n?t.prototype===e.prototype:"[object Date]"===n?t.getTime()===e.getTime():!1},o.instance=function(t,e){return t instanceof e},o.nil=function(t){return null===t},o.undef=function(t){return"undefined"==typeof t},o.array=function(t){return"[object Array]"===r.call(t)},o.emptyarray=function(t){return o.array(t)&&0===t.length},o.arraylike=function(t){return!!t&&!o["boolean"](t)&&n.call(t,"length")&&isFinite(t.length)&&o.number(t.length)&&t.length>=0},o["boolean"]=function(t){return"[object Boolean]"===r.call(t)},o.element=function(t){return void 0!==t&&"undefined"!=typeof HTMLElement&&t instanceof HTMLElement&&1===t.nodeType},o.fn=function(t){return"[object Function]"===r.call(t)},o.number=function(t){return"[object Number]"===r.call(t)},o.nan=function(t){return!o.number(t)||t!==t},o.object=function(t){return"[object Object]"===r.call(t)},o.hash=function(t){return o.object(t)&&t.constructor===Object&&!t.nodeType&&!t.setInterval},o.regexp=function(t){return"[object RegExp]"===r.call(t)},o.string=function(t){return"[object String]"===r.call(t)},o.hex=function(t){return o.string(t)&&(!t.length||s.test(t))}},{}],26:[function(t,e){var i=t("./create"),n=Math;e.exports=i(Math),e.exports.random=function(t,e){return"undefined"==typeof t?(e=1,t=0):"undefined"==typeof e&&(e=t,t=0),t==e?t:n.random()*(e-t)+t},e.exports.rotate=function(t,e,i){return"undefined"==typeof e?(i=1,e=0):"undefined"==typeof i&&(i=e,e=0),i>e?(t=(t-e)%(i-e),t+(0>t?i:e)):(t=(t-i)%(e-i),t+(0>=t?e:i))},e.exports.limit=function(t,e,i){return e>t?e:t>i?i:t},e.exports.length=function(t,e){return Math.sqrt(t*t+e*e)}},{"./create":22}],27:[function(t,e){e.exports=function(t,e,i,n,r,s){var o=t.width,h=t.height,a=t.left,u=t.right,f=t.top,c=t.bottom;a="number"==typeof a&&a===a?a:0,u="number"==typeof u&&u===u?u:0,f="number"==typeof f&&f===f?f:0,c="number"==typeof c&&c===c?c:0,o=o-a-u,h=h-f-c,r||(e=Math.max(e-a-u,0),i=Math.max(i-f-c,0));var p=0;if(f>0&&a>0&&s(p++,0,0,a,f,0,0,a,f),c>0&&a>0&&s(p++,0,h+f,a,c,0,i+f,a,c),f>0&&u>0&&s(p++,o+a,0,u,f,e+a,0,u,f),c>0&&u>0&&s(p++,o+a,h+f,u,c,e+a,i+f,u,c),n)f>0&&s(p++,a,0,o,f,a,0,e,f),c>0&&s(p++,a,h+f,o,c,a,i+f,e,c),a>0&&s(p++,0,f,a,h,0,f,a,i),u>0&&s(p++,o+a,f,u,h,e+a,f,u,i),s(p++,a,f,o,h,a,f,e,i);else for(var l,_=a,d=e;d>0;){l=Math.min(o,d),d-=o;for(var g,y=f,m=i;m>0;)g=Math.min(h,m),m-=h,s(p++,a,f,l,g,_,y,l,g),0>=d&&(a&&s(p++,0,f,a,g,0,y,a,g),u&&s(p++,o+a,f,u,g,_+l,y,u,g)),y+=g;f&&s(p++,a,0,l,f,_,0,l,f),c&&s(p++,a,h+f,l,c,_,y,l,c),_+=l}return p}},{}],28:[function(t,e){e.exports={}},{}],29:[function(t,e){e.exports.startsWith=function(t,e){return"string"==typeof t&&"string"==typeof e&&t.substring(0,e.length)==e}},{}]},{},[1])(1)});
\ No newline at end of file
+!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var i;"undefined"!=typeof window?i=window:"undefined"!=typeof global?i=global:"undefined"!=typeof self&&(i=self),i.Stage=t()}}(function(){return function t(i,e,n){function r(o,h){if(!e[o]){if(!i[o]){var a="function"==typeof require&&require;if(!h&&a)return a(o,!0);if(s)return s(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var f=e[o]={exports:{}};i[o][0].call(f.exports,function(t){var e=i[o][1][t];return r(e?e:t)},f,f.exports,t,i,e,n)}return e[o].exports}for(var s="function"==typeof require&&require,o=0;o<n.length;o++)r(n[o]);return r}({1:[function(t,i){i.exports=t("../lib/"),t("../lib/canvas"),t("../lib/image"),t("../lib/anim"),t("../lib/str"),t("../lib/layout"),t("../lib/addon/tween"),i.exports.Mouse=t("../lib/addon/mouse"),i.exports.Math=t("../lib/util/math"),i.exports._extend=t("../lib/util/extend"),i.exports._create=t("../lib/util/create"),t("../lib/loader/web")},{"../lib/":11,"../lib/addon/mouse":3,"../lib/addon/tween":4,"../lib/anim":5,"../lib/canvas":7,"../lib/image":10,"../lib/layout":12,"../lib/loader/web":13,"../lib/str":18,"../lib/util/create":22,"../lib/util/extend":24,"../lib/util/math":26}],2:[function(t,i){function e(t){return t}function n(t){if("function"==typeof t)return t;if("string"!=typeof t)return e;var i=r[t];if(i)return i;var n=/^(\w+)(-(in|out|in-out|out-in))?(\((.*)\))?$/i.exec(t);return n&&n.length?(easing=o[n[1]],mode=s[n[3]],params=n[5],i=easing&&easing.fn?easing.fn:easing&&easing.fc?easing.fc.apply(easing.fc,params&&params.replace(/\s+/,"").split(",")):e,mode&&(i=mode.fn(i)),r[t]=i,i):e}var r={},s={},o={};n.add=function(t){for(var i=(t.name||t.mode).split(/\s+/),e=0;e<i.length;e++){var n=i[e];n&&((t.name?o:s)[n]=t)}},n.add({mode:"in",fn:function(t){return t}}),n.add({mode:"out",fn:function(t){return function(i){return 1-t(1-i)}}}),n.add({mode:"in-out",fn:function(t){return function(i){return.5>i?t(2*i)/2:1-t(2*(1-i))/2}}}),n.add({mode:"out-in",fn:function(t){return function(i){return.5>i?1-t(2*(1-i))/2:t(2*i)/2}}}),n.add({name:"linear",fn:function(t){return t}}),n.add({name:"quad",fn:function(t){return t*t}}),n.add({name:"cubic",fn:function(t){return t*t*t}}),n.add({name:"quart",fn:function(t){return t*t*t*t}}),n.add({name:"quint",fn:function(t){return t*t*t*t*t}}),n.add({name:"sin sine",fn:function(t){return 1-Math.cos(t*Math.PI/2)}}),n.add({name:"exp expo",fn:function(t){return 0==t?0:Math.pow(2,10*(t-1))}}),n.add({name:"circle circ",fn:function(t){return 1-Math.sqrt(1-t*t)}}),n.add({name:"bounce",fn:function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}}),n.add({name:"poly",fc:function(t){return function(i){return Math.pow(i,t)}}}),n.add({name:"elastic",fc:function(t,i){i=i||.45,t=t||1;var e=i/(2*Math.PI)*Math.asin(1/t);return function(n){return 1+t*Math.pow(2,-10*n)*Math.sin(2*(n-e)*Math.PI/i)}}}),n.add({name:"back",fc:function(t){return t="undefined"!=typeof t?t:1.70158,function(i){return i*i*((t+1)*i-t)}}}),i.exports=n},{}],3:[function(t,i){function e(t,i){if(this instanceof e){var n=t.viewport().ratio||1;t.on("viewport",function(t){n=t.ratio||n}),this.x=0,this.y=0,this.toString=function(){return(0|this.x)+"x"+(0|this.y)},this.locate=function(t){r(i,t,this),this.x*=n,this.y*=n},this.lookup=function(i,e){this.type=i,this.root=t,this.event=null,e.length=0,this.collect=e,this.root.visit(this.visitor,this)},this.publish=function(i,e,n){if(this.type=i,this.root=t,this.event=e,this.collect=!1,this.timeStamp=Date.now(),"mousemove"!==i&&"touchmove"!==i&&DEBUG&&console.log(this.type+" "+this),n){for(;n.length&&!this.visitor.end(n.shift(),this););n.length=0}else this.root.visit(this.visitor,this)},this.visitor={reverse:!0,visible:!0,start:function(t,i){return!t._flag(i.type)},end:function(t,i){s.raw=i.event,s.type=i.type,s.timeStamp=i.timeStamp,s.abs.x=i.x,s.abs.y=i.y;var e=t.listeners(i.type);if(e&&(t.matrix().inverse().map(i,s),(t===i.root||t.hitTest(s))&&(i.collect&&i.collect.push(t),i.event))){for(var n=!1,r=0;r<e.length;r++)n=e[r].call(t,s)?!0:n;return n}}}}}function n(t,i,e){Object.defineProperty(t,i,{value:e})}function r(t,i,e){i.touches&&i.touches.length?(e.x=i.touches[0].clientX,e.y=i.touches[0].clientY):(e.x=i.clientX,e.y=i.clientY);var n=t.getBoundingClientRect();return e.x-=n.left,e.y-=n.top,e.x-=0|t.clientLeft,e.y-=0|t.clientTop,e}"undefined"==typeof DEBUG&&(DEBUG=!0),t("../core")._load(function(t,i){e.subscribe(t,i)}),e.CLICK="click",e.START="touchstart mousedown",e.MOVE="touchmove mousemove",e.END="touchend mouseup",e.CANCEL="touchcancel mousecancel",e.subscribe=function(t,i){function n(i){i.preventDefault(),t.mouse.locate(i),t.mouse.publish(i.type,i),t.mouse.lookup("click",h),t.mouse.lookup("mousecancel",a)}function r(i){i.preventDefault(),t.mouse.locate(i),t.mouse.publish(i.type,i)}function s(i){i.preventDefault(),t.mouse.publish(i.type,i),h.length&&t.mouse.publish("click",i,h),a.length=0}function o(i){a.length&&t.mouse.publish("mousecancel",i,a),h.length=0}if(!t.mouse){t.mouse=new e(t,i),i.addEventListener("touchstart",n),i.addEventListener("touchend",s),i.addEventListener("touchmove",r),i.addEventListener("touchcancel",o),i.addEventListener("mousedown",n),i.addEventListener("mouseup",s),i.addEventListener("mousemove",r),document.addEventListener("mouseup",o),window.addEventListener("blur",o);var h=[],a=[]}};var s={},o={};n(s,"clone",function(t){return t=t||{},t.x=this.x,t.y=this.y,t}),n(s,"toString",function(){return(0|this.x)+"x"+(0|this.y)+" ("+this.abs+")"}),n(s,"abs",o),n(o,"clone",function(t){return t=t||{},t.x=this.x,t.y=this.y,t}),n(o,"toString",function(){return(0|this.x)+"x"+(0|this.y)}),i.exports=e},{"../core":8}],4:[function(t,i){function e(t,i,e){this._end={},this._duration=i||400,this._delay=e||0,this._owner=t,this._time=0}function n(t,i,e,n){"number"==typeof t.pin(e)?i[e]=n:"number"==typeof t.pin(e+"X")&&"number"==typeof t.pin(e+"Y")&&(i[e+"X"]=n,i[e+"Y"]=n)}var r=t("./easing"),s=t("../core"),o=t("../pin");s.prototype.tween=function(t,i,n){if("number"!=typeof t?(n=t,i=0,t=0):"number"!=typeof i&&(n=i,i=0),!this._tweens){this._tweens=[];var r=0;this.tick(function(t,i,e){if(this._tweens.length){var n=r!=e;if(r=i,n)return!0;var s=this._tweens[0].tick(this,t,i,e);return s&&this._tweens.shift(),"object"==typeof s&&this._tweens.unshift(s),!0}},!0)}this.touch(),n||(this._tweens.length=0);var s=new e(this,t,i);return this._tweens.push(s),s},e.prototype.tick=function(t,i){if(this._time+=i,!(this._time<this._delay)){var e=this._time-this._delay;if(!this._start){this._start={};for(var n in this._end)this._start[n]=this._owner.pin(n)}var r,s;e<this._duration?(r=e/this._duration,s=!1):(r=1,s=!0),r="function"==typeof this._easing?this._easing(r):r;var o=1-r;for(var n in this._end)this._owner.pin(n,this._start[n]*o+this._end[n]*r);if(s){try{this._done&&this._done.call(this._owner)}catch(h){console.log(h)}return this._next||!0}}},e.prototype.tween=function(t,i){return this._next=new e(this._owner,t,i)},e.prototype.duration=function(t){return this._duration=t,this},e.prototype.delay=function(t){return this._delay=t,this},e.prototype.ease=function(t){return this._easing=r(t),this},e.prototype.done=function(t){return this._done=t,this},e.prototype.hide=function(){return this.done(function(){this.hide()}),this},e.prototype.remove=function(){return this.done(function(){this.remove()}),this},e.prototype.pin=function(t,i){if("object"==typeof t)for(var e in t)n(this._owner,this._end,e,t[e]);else"undefined"!=typeof i&&n(this._owner,this._end,t,i);return this},o._add_shortcuts(e),e.prototype.then=function(t){return this.done(t),this},e.prototype.then=function(t){return this.done(t),this},e.prototype.clear=function(){return this},i.exports=e},{"../core":8,"../pin":16,"./easing":2}],5:[function(t){function i(){i._super.call(this),this.label("Anim"),this._textures=[],this._fps=e.Anim.FPS,this._ft=1e3/this._fps,this._time=-1,this._repeat=0,this._index=0,this._frames=[];var t=0;this.tick(function(i,e,n){if(!(this._time<0||this._frames.length<=1)){var r=t!=n;if(t=e,r)return!0;if(this._time+=i,this._time<this._ft)return!0;var s=this._time/this._ft|0;return this._time-=s*this._ft,this.moveFrame(s),this._repeat>0&&(this._repeat-=s)<=0?(this.stop(),this._callback&&this._callback(),!1):!0}},!1)}var e=t("./core");t("./pin"),t("./loop");var n=t("./util/create"),r=t("./util/math");e.anim=function(t,e){var n=new i;return n.frames(t).gotoFrame(0),e&&n.fps(e),n},i._super=e,i.prototype=n(i._super.prototype),e.Anim={FPS:15},i.prototype.fps=function(t){return"undefined"==typeof t?this._fps:(this._fps=t>0?t:e.Anim.FPS,this._ft=1e3/this._fps,this)},i.prototype.setFrames=function(t,i,e){return this.frames(t,i,e)},i.prototype.frames=function(t){return this._index=0,this._frames=e.texture(t).array(),this.touch(),this},i.prototype.length=function(){return this._frames?this._frames.length:0},i.prototype.gotoFrame=function(t,i){return this._index=0|r.rotate(t,this._frames.length),i=i||!this._textures[0],this._textures[0]=this._frames[this._index],i&&(this.pin("width",this._textures[0].width),this.pin("height",this._textures[0].height)),this.touch(),this},i.prototype.moveFrame=function(t){return this.gotoFrame(this._index+t)},i.prototype.repeat=function(t,i){return this._repeat=t*this._frames.length-1,this._callback=i,this.play(),this},i.prototype.play=function(t){return"undefined"!=typeof t?(this.gotoFrame(t),this._time=0):this._time<0&&(this._time=0),this.touch(),this},i.prototype.stop=function(t){return this._time=-1,"undefined"!=typeof t&&this.gotoFrame(t),this}},{"./core":8,"./loop":14,"./pin":16,"./util/create":22,"./util/math":26}],6:[function(t,i){function e(t){function i(t){if(!t||u.fn(t.draw))return t;t=h({},t),u.fn(a)&&(t=a(t)),1!=c&&(t.x*=c,t.y*=c,t.width*=c,t.height*=c,t.top*=c,t.bottom*=c,t.left*=c,t.right*=c),0!=p&&(t.x+=p,t.y+=p,t.width-=2*p,t.height-=2*p,t.top-=p,t.bottom-=p,t.left-=p,t.right-=p);var i=o.pipe();return i.top=t.top,i.bottom=t.bottom,i.left=t.left,i.right=t.right,i.src(t.x,t.y,t.width,t.height),i}function s(t){if(l){if(u.fn(l))return l(t);if(u.hash(l))return l[t]}if(d){for(var i=null,e=0,n=0;n<d.length;n++)f.startsWith(d[n].name,t)&&(0===e?i=d[n]:1===e?i=[i,d[n]]:i.push(d[n]),e++);return 0===e&&u.fn(_)&&(i=function(i){return _(t+(i?i:""))}),i}}e._super.call(this);var o=this;r(t,"filter"),r(t,"cutouts"),r(t,"sprites"),r(t,"factory");var a=t.map||t.filter,c=t.ppu||t.ratio||1,p=t.trim||0,l=t.textures,_=t.factory,d=t.cutouts||t.sprites;this.select=function(t){if(!t)return new n(this.pipe());var e=s(t);return e?new n(e,s,i):void 0}}function n(t,i,e){function n(t,r){return t?u.fn(t.draw)?t:u.hash(t)&&u.number(t.width)&&u.number(t.height)&&u.fn(e)?e(t):u.hash(t)&&u.defined(r)?n(t[r]):u.fn(t)?n(t(r)):u.array(t)?n(t[0]):u.string(t)&&u.fn(i)?n(i(t)):void 0:l}this.one=function(i){return n(t,i)},this.array=function(i){var e=u.array(i)?i:[];if(u.array(t))for(var r=0;r<t.length;r++)e[r]=n(t[r]);else e[0]=n(t);return e}}function r(t,i,e){i in t&&console.log(e?e.replace("%name",i):"'"+i+"' field of texture atlas is deprecated.")}"undefined"==typeof DEBUG&&(DEBUG=!0);var s=t("./core"),o=t("./texture"),h=t("./util/extend"),a=t("./util/create"),u=t("./util/is"),f=t("./util/string"),c={},p=[];s.atlas=function(t){var i=u.fn(t.draw)?t:new e(t);t.name&&(c[t.name]=i),p.push(i),r(t,"imagePath"),r(t,"imageRatio");var n=t.imagePath,o=t.imageRatio||1;return u.string(t.image)?n=t.image:u.hash(t.image)&&(n=t.image.src||t.image.url,o=t.image.ratio||o),n&&s.preload(function(t){n=s.resolve(n),DEBUG&&console.log("Loading atlas: "+n);var e=s.config("image-loader");e(n,function(e){DEBUG&&console.log("Image loaded: "+n),i.src(e,o),t()},function(i){DEBUG&&console.log("Error loading atlas: "+n,i),t()})}),i},e._super=o,e.prototype=a(e._super.prototype);var l=new o;l.x=l.y=l.width=l.height=0,l.pipe=l.src=l.dest=function(){return this},l.draw=function(){};var _=new n(l);s.texture=function(t){if(!u.string(t))return new n(t);var i,e,r=null;for((e=t.indexOf(":"))>0&&t.length>e+1&&(i=c[t.slice(0,e)],r=i&&i.select(t.slice(e+1))),!r&&(i=c[t])&&(r=i.select()),e=0;!r&&e<p.length;e++)r=p[e].select(t);return r||(console.error("Texture not found: "+t),r=_),r},i.exports=e},{"./core":8,"./texture":19,"./util/create":22,"./util/extend":24,"./util/is":25,"./util/string":29}],7:[function(t){var i=t("./core"),e=t("./texture");i.canvas=function(t,i,n){"string"==typeof t?"object"==typeof i||("function"==typeof i&&(n=i),i={}):("function"==typeof t&&(n=t),i={},t="2d");var r=document.createElement("canvas"),s=r.getContext(t,i),o=new e(r);return o.context=function(){return s},o.size=function(t,i,e){return e=e||1,r.width=t*e,r.height=i*e,this.src(r,e),this},o.canvas=function(t){return"function"==typeof t?t.call(this,s):"undefined"==typeof t&&"function"==typeof n&&n.call(this,s),this},"function"==typeof n&&n.call(o,s),o}},{"./core":8,"./texture":19}],8:[function(t,i){function e(t){if(!(this instanceof e))return o.fn(t)?e.app.apply(e,arguments):o.object(t)?e.atlas.apply(e,arguments):t;r.create++;for(var i=0;i<a.length;i++)a[i].call(this)}function n(t,i){var e=document.createElement("script");e.addEventListener("load",function(){i()}),e.addEventListener("error",function(e){i(e||"Error loading script: "+t)}),e.src=t,e.id="preload-"+Date.now(),document.body.appendChild(e)}"undefined"==typeof DEBUG&&(DEBUG=!0);var r=t("./util/stats"),s=t("./util/extend"),o=t("./util/is"),h=t("./util/await");r.create=0;var a=[];e._init=function(t){a.push(t)};var u=[];e._load=function(t){u.push(t)};var f={};e.config=function(){return 1===arguments.length&&o.string(arguments[0])?f[arguments[0]]:(1===arguments.length&&o.object(arguments[0])&&s(f,arguments[0]),void(2===arguments.length&&o.string(arguments[0])&&f[(arguments[0],arguments[1])]))};var c=[],p=[],l=!1,_=!1;e.app=function(t,i){if(!l)return void c.push(arguments);DEBUG&&console.log("Creating app...");var n=e.config("app-loader");n(function(i,e){DEBUG&&console.log("Initing app...");for(var n=0;n<u.length;n++)u[n].call(this,i,e);t(i,e),p.push(i),DEBUG&&console.log("Starting app..."),i.start()},i)};var d=h();e.preload=function(t){if("string"==typeof t){var i=e.resolve(t);/\.js($|\?|\#)/.test(i)&&(DEBUG&&console.log("Loading script: "+i),t=function(t){n(i,t)})}"function"==typeof t&&t(d())},e.start=function(t){DEBUG&&console.log("Starting..."),e.config(t),d.then(function(){for(DEBUG&&console.log("Loading apps..."),l=!0;c.length;){var t=c.shift();e.app.apply(e,t)}})},e.pause=function(){if(!_){_=!0;for(var t=p.length-1;t>=0;t--)p[t].pause()}},e.resume=function(){if(_){_=!1;for(var t=p.length-1;t>=0;t--)p[t].resume()}},e.create=function(){return new e},e.resolve=function(){function t(){if(document.currentScript)return document.currentScript.src;var t;try{var e=new Error;if(!e.stack)throw e;t=e.stack}catch(e){t=e.stack}if("string"==typeof t){t=t.split("\n");for(var n=t.length;n--;){var r=t[n].match(/(\w+\:\/\/[^\/]*?\/.+?)(:\d+)(:\d+)?/);if(r)return r[1]}}if(i.length&&"readyState"in i[0])for(var n=i.length;n--;)if("interactive"===i[n].readyState)return i[n].src;return location.href}if("undefined"==typeof window||"undefined"==typeof document)return function(t){return t};var i=document.getElementsByTagName("script");return function(i){if(/^\.\//.test(i)){var e=t(),n=e.substring(0,e.lastIndexOf("/")+1);i=n+i.substring(2)}return i}}(),i.exports=e},{"./util/await":21,"./util/extend":24,"./util/is":25,"./util/stats":28}],9:[function(t){t("./util/event")(t("./core").prototype,function(t,i,e){t._flag(i,e)})},{"./core":8,"./util/event":23}],10:[function(t){function i(){i._super.call(this),this.label("Image"),this._textures=[],this._image=null}var e=t("./core");t("./pin"),t("./loop");var n=t("./util/repeat"),r=t("./util/create");e.image=function(t){var e=new i;return t&&e.image(t),e},i._super=e,i.prototype=r(i._super.prototype),i.prototype.setImage=function(t,i,e){return this.image(t,i,e)},i.prototype.image=function(t){return this._image=e.texture(t).one(),this.pin("width",this._image?this._image.width:0),this.pin("height",this._image?this._image.height:0),this._textures[0]=this._image.pipe(),this._textures.length=1,this},i.prototype.tile=function(t){return this._repeat(!1,t),this},i.prototype.stretch=function(t){return this._repeat(!0,t),this},i.prototype._repeat=function(t,i){function e(t,i,e,n,s,o,h,a,u){var f=r._textures.length>t?r._textures[t]:r._textures[t]=r._image.pipe();f.src(i,e,n,s),f.dest(o,h,a,u)}var r=this;this.untick(this._repeatTicker),this.tick(this._repeatTicker=function(){if(this._mo_stretch!=this._pin._ts_transform){this._mo_stretch=this._pin._ts_transform;var r=this.pin("width"),s=this.pin("height");this._textures.length=n(this._image,r,s,t,i,e)}})}},{"./core":8,"./loop":14,"./pin":16,"./util/create":22,"./util/repeat":27}],11:[function(t,i){i.exports=t("./core"),i.exports.Matrix=t("./matrix"),i.exports.Texture=t("./texture"),t("./atlas"),t("./tree"),t("./event"),t("./pin"),t("./loop"),t("./root")},{"./atlas":6,"./core":8,"./event":9,"./loop":14,"./matrix":15,"./pin":16,"./root":17,"./texture":19,"./tree":20}],12:[function(t){var i=t("./core");t("./pin"),t("./loop");t("./util/create");i.row=function(t){return i.create().row(t).label("Row")},i.prototype.row=function(t){return this.sequence("row",t),this},i.column=function(t){return i.create().column(t).label("Row")},i.prototype.column=function(t){return this.sequence("column",t),this},i.sequence=function(t,e){return i.create().sequence(t,e).label("Sequence")},i.prototype.sequence=function(t,i){return this._padding=this._padding||0,this._spacing=this._spacing||0,this.untick(this._layoutTiker),this.tick(this._layoutTiker=function(){if(this._mo_seq!=this._ts_touch){this._mo_seq=this._ts_touch;var e=this._mo_seqAlign!=this._ts_children;this._mo_seqAlign=this._ts_children;for(var n,r=0,s=0,o=this.first(!0),h=!0;n=o;){o=n.next(!0),n.matrix(!0);var a=n.pin("boxWidth"),u=n.pin("boxHeight");"column"==t?(!h&&(s+=this._spacing),n.pin("offsetY")!=s&&n.pin("offsetY",s),r=Math.max(r,a),s+=u,e&&n.pin("alignX",i)):"row"==t&&(!h&&(r+=this._spacing),n.pin("offsetX")!=r&&n.pin("offsetX",r),r+=a,s=Math.max(s,u),e&&n.pin("alignY",i)),h=!1}r+=2*this._padding,s+=2*this._padding,this.pin("width")!=r&&this.pin("width",r),this.pin("height")!=s&&this.pin("height",s)}}),this},i.box=function(){return i.create().box().label("Box")},i.prototype.box=function(){return this._padding=this._padding||0,this.untick(this._layoutTiker),this.tick(this._layoutTiker=function(){if(this._mo_box!=this._ts_touch){this._mo_box=this._ts_touch;for(var t,i=0,e=0,n=this.first(!0);t=n;){n=t.next(!0),t.matrix(!0);var r=t.pin("boxWidth"),s=t.pin("boxHeight");i=Math.max(i,r),e=Math.max(e,s)}i+=2*this._padding,e+=2*this._padding,this.pin("width")!=i&&this.pin("width",i),this.pin("height")!=e&&this.pin("height",e)}}),this},i.layer=function(){return i.create().layer().label("Layer")},i.prototype.layer=function(){return this.untick(this._layoutTiker),this.tick(this._layoutTiker=function(){var t=this.parent();if(t){var i=t.pin("width");this.pin("width")!=i&&this.pin("width",i);var e=t.pin("height");this.pin("height")!=e&&this.pin("height",e)}},!0),this},i.prototype.padding=function(t){return this._padding=t,this},i.prototype.spacing=function(t){return this._spacing=t,this}},{"./core":8,"./loop":14,"./pin":16,"./util/create":22}],13:[function(t){function i(t,i){function e(){o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,a,u),d.render(o)}function r(){h?(a=window.innerWidth>0?window.innerWidth:screen.width,u=window.innerHeight>0?window.innerHeight:screen.height,s.style.width=a+"px",s.style.height=u+"px"):(a=s.clientWidth,u=s.clientHeight),a*=f,u*=f,(s.width!==a||s.height!==u)&&(s.width=a,s.height=u,DEBUG&&console.log("Resize: "+a+" x "+u+" / "+f),d.viewport(a,u,f),e())}i=i||{};var s=i.canvas,o=null,h=!1,a=0,u=0,f=1;if("string"==typeof s&&(s=document.getElementById(s)),s||(s=document.getElementById("cutjs")||document.getElementById("stage")),!s){h=!0,DEBUG&&console.log("Creating Canvas..."),s=document.createElement("canvas"),s.style.position="absolute";var c=document.body;c.insertBefore(s,c.firstChild)}o=s.getContext("2d");var p=window.devicePixelRatio||1,l=o.webkitBackingStorePixelRatio||o.mozBackingStorePixelRatio||o.msBackingStorePixelRatio||o.oBackingStorePixelRatio||o.backingStorePixelRatio||1;f=p/l;var _=window.requestAnimationFrame||window.msRequestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.oRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)};DEBUG&&console.log("Creating stage...");var d=n.root(_,e);d.background=function(t){return s.style.backgroundColor=t,this},t(d,s),r(),window.addEventListener("resize",r,!1),window.addEventListener("orientationchange",r,!1)}function e(t,i,e){DEBUG&&console.log("Loading image: "+t);var n=new Image;n.onload=function(){i(n)},n.onerror=e,n.src=t}"undefined"==typeof DEBUG&&(DEBUG=!0);var n=t("../core");window.addEventListener("load",function(){DEBUG&&console.log("On load."),n.start()},!1),n.config({"app-loader":i,"image-loader":e})},{"../core":8}],14:[function(t){var i=t("./core");t("./pin");var e=t("./util/stats");i.prototype._textures=null,i.prototype._alpha=1,i.prototype.render=function(t){if(this._visible){e.node++;var i=this.matrix();t.setTransform(i.a,i.b,i.c,i.d,i.e,i.f),this._alpha=this._pin._alpha*(this._parent?this._parent._alpha:1);var n=this._pin._textureAlpha*this._alpha;if(t.globalAlpha!=n&&(t.globalAlpha=n),null!==this._textures)for(var r=0,s=this._textures.length;s>r;r++)this._textures[r].draw(t);t.globalAlpha!=this._alpha&&(t.globalAlpha=this._alpha);for(var o,h=this._first;o=h;)h=o._next,o.render(t)}},i.prototype._tickBefore=null,i.prototype._tickAfter=null,i.prototype.MAX_ELAPSE=1/0,i.prototype._tick=function(t,i,n){if(this._visible){t>this.MAX_ELAPSE&&(t=this.MAX_ELAPSE);var r=!1;if(null!==this._tickBefore)for(var s=0,o=this._tickBefore.length;o>s;s++)e.tick++,r=this._tickBefore[s].call(this,t,i,n)===!0||r;for(var h,a=this._first;h=a;)a=h._next,h._flag("_tick")&&(r=h._tick(t,i,n)===!0?!0:r);if(null!==this._tickAfter)for(var s=0,o=this._tickAfter.length;o>s;s++)e.tick++,r=this._tickAfter[s].call(this,t,i,n)===!0||r;return r}},i.prototype.tick=function(t,i){"function"==typeof t&&(i?(null===this._tickBefore&&(this._tickBefore=[]),this._tickBefore.push(t)):(null===this._tickAfter&&(this._tickAfter=[]),this._tickAfter.push(t)),this._flag("_tick",null!==this._tickAfter&&this._tickAfter.length>0||null!==this._tickBefore&&this._tickBefore.length>0))},i.prototype.untick=function(t){if("function"==typeof t){var i;null!==this._tickBefore&&(i=this._tickBefore.indexOf(t))>=0&&this._tickBefore.splice(i,1),null!==this._tickAfter&&(i=this._tickAfter.indexOf(t))>=0&&this._tickAfter.splice(i,1)}},i.prototype.timeout=function(t,i){this.tick(function e(n){return(i-=n)<0?(this.untick(e),void t.call(this)):!0})}},{"./core":8,"./pin":16,"./util/stats":28}],15:[function(t,i){function e(t,i,e,n,r,s){this.reset(t,i,e,n,r,s)}e.prototype.toString=function(){return"["+this.a+", "+this.b+", "+this.c+", "+this.d+", "+this.e+", "+this.f+"]"},e.prototype.clone=function(){return new e(this.a,this.b,this.c,this.d,this.e,this.f)},e.prototype.reset=function(t,i,e,n,r,s){return this._dirty=!0,"object"==typeof t?(this.a=t.a,this.d=t.d,this.b=t.b,this.c=t.c,this.e=t.e,this.f=t.f):(this.a=t||1,this.d=n||1,this.b=i||0,this.c=e||0,this.e=r||0,this.f=s||0),this},e.prototype.identity=function(){return this._dirty=!0,this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this},e.prototype.rotate=function(t){if(!t)return this;this._dirty=!0;var i=t?Math.cos(t):1,e=t?Math.sin(t):0,n=i*this.a-e*this.b,r=i*this.b+e*this.a,s=i*this.c-e*this.d,o=i*this.d+e*this.c,h=i*this.e-e*this.f,a=i*this.f+e*this.e;return this.a=n,this.b=r,this.c=s,this.d=o,this.e=h,this.f=a,this},e.prototype.translate=function(t,i){return t||i?(this._dirty=!0,this.e+=t,this.f+=i,this):this},e.prototype.scale=function(t,i){return t-1||i-1?(this._dirty=!0,this.a*=t,this.b*=i,this.c*=t,this.d*=i,this.e*=t,this.f*=i,this):this},e.prototype.skew=function(t,i){if(!t&&!i)return this;this._dirty=!0;var e=this.a+this.b*t,n=this.b+this.a*i,r=this.c+this.d*t,s=this.d+this.c*i,o=this.e+this.f*t,h=this.f+this.e*i;return this.a=e,this.b=n,this.c=r,this.d=s,this.e=o,this.f=h,this},e.prototype.concat=function(t){this._dirty=!0;var i=this,e=i.a*t.a+i.b*t.c,n=i.b*t.d+i.a*t.b,r=i.c*t.a+i.d*t.c,s=i.d*t.d+i.c*t.b,o=i.e*t.a+t.e+i.f*t.c,h=i.f*t.d+t.f+i.e*t.b;return this.a=e,this.b=n,this.c=r,this.d=s,this.e=o,this.f=h,this},e.prototype.inverse=e.prototype.reverse=function(){if(this._dirty){this._dirty=!1,this.inversed=this.inversed||new e;var t=this.a*this.d-this.b*this.c;this.inversed.a=this.d/t,this.inversed.b=-this.b/t,this.inversed.c=-this.c/t,this.inversed.d=this.a/t,this.inversed.e=(this.c*this.f-this.e*this.d)/t,this.inversed.f=(this.e*this.b-this.a*this.f)/t}return this.inversed},e.prototype.map=function(t,i){return i=i||{},i.x=this.a*t.x+this.c*t.y+this.e,i.y=this.b*t.x+this.d*t.y+this.f,i},e.prototype.mapX=function(t,i){return"object"==typeof t&&(i=t.y,t=t.x),this.a*t+this.c*i+this.e},e.prototype.mapY=function(t,i){return"object"==typeof t&&(i=t.y,t=t.x),this.b*t+this.d*i+this.f},i.exports=e},{}],16:[function(t,i){function e(t){this._owner=t,this._parent=null,this._relativeMatrix=new s,this._absoluteMatrix=new s,this.reset()}function n(t,i,e,n){var r="number"==typeof i,s="number"==typeof e,h="string"==typeof n;t._ts_transform=++o,r&&(t._scaleX=i/t._width_,t._width=t._width_),s&&(t._scaleY=e/t._height_,t._height=t._height_),r&&s&&h&&("out"==n||"out-crop"==n?t._scaleX=t._scaleY=Math.max(t._scaleX,t._scaleY):("in"==n||"in-pad"==n)&&(t._scaleX=t._scaleY=Math.min(t._scaleX,t._scaleY)),("out-crop"==n||"in-pad"==n)&&(t._width=i/t._scaleX,t._height=e/t._scaleY))}var r=t("./core"),s=t("./matrix"),o=0;r._init(function(){this._pin=new e(this)}),r.prototype.matrix=function(t){return t===!0?this._pin.relativeMatrix():this._pin.absoluteMatrix()},r.prototype.pin=function(t,i){return"object"==typeof t?(this._pin.set(t),this):"string"==typeof t?"undefined"==typeof i?this._pin.get(t):(this._pin.set(t,i),this):"undefined"==typeof t?this._pin:void 0},e.prototype.reset=function(){this._textureAlpha=1,this._alpha=1,this._width=0,this._height=0,this._scaleX=1,this._scaleY=1,this._skewX=0,this._skewY=0,this._rotation=0,this._pivoted=!1,this._pivotX=null,this._pivotY=null,this._handled=!1,this._handleX=0,this._handleY=0,this._aligned=!1,this._alignX=0,this._alignY=0,this._offsetX=0,this._offsetY=0,this._boxX=0,this._boxY=0,this._boxWidth=this._width,this._boxHeight=this._height,this._ts_translate=++o,this._ts_transform=++o,this._ts_matrix=++o},e.prototype._update=function(){return this._parent=this._owner._parent&&this._owner._parent._pin,this._handled&&this._mo_handle!=this._ts_transform&&(this._mo_handle=this._ts_transform,this._ts_translate=++o),this._aligned&&this._parent&&this._mo_align!=this._parent._ts_transform&&(this._mo_align=this._parent._ts_transform,this._ts_translate=++o),this},e.prototype.toString=function(){return this._owner+" ("+(this._parent?this._parent._owner:null)+")"},e.prototype.absoluteMatrix=function(){this._update();var t=Math.max(this._ts_transform,this._ts_translate,this._parent?this._parent._ts_matrix:0);if(this._mo_abs==t)return this._absoluteMatrix;this._mo_abs=t;var i=this._absoluteMatrix;return i.reset(this.relativeMatrix()),this._parent&&i.concat(this._parent._absoluteMatrix),this._ts_matrix=++o,i},e.prototype.relativeMatrix=function(){this._update();var t=Math.max(this._ts_transform,this._ts_translate,this._parent?this._parent._ts_transform:0);if(this._mo_rel==t)return this._relativeMatrix;this._mo_rel=t;var i=this._relativeMatrix;if(i.identity(),this._pivoted&&i.translate(-this._pivotX*this._width,-this._pivotY*this._height),i.scale(this._scaleX,this._scaleY),i.skew(this._skewX,this._skewY),i.rotate(this._rotation),this._pivoted&&i.translate(this._pivotX*this._width,this._pivotY*this._height),this._pivoted)this._boxX=0,this._boxY=0,this._boxWidth=this._width,this._boxHeight=this._height;else{var e,n;i.a>0&&i.c>0||i.a<0&&i.c<0?(e=0,n=i.a*this._width+i.c*this._height):(e=i.a*this._width,n=i.c*this._height),e>n?(this._boxX=n,this._boxWidth=e-n):(this._boxX=e,this._boxWidth=n-e),i.b>0&&i.d>0||i.b<0&&i.d<0?(e=0,n=i.b*this._width+i.d*this._height):(e=i.b*this._width,n=i.d*this._height),e>n?(this._boxY=n,this._boxHeight=e-n):(this._boxY=e,this._boxHeight=n-e)}return this._x=this._offsetX,this._y=this._offsetY,this._x-=this._boxX+this._handleX*this._boxWidth,this._y-=this._boxY+this._handleY*this._boxHeight,this._aligned&&this._parent&&(this._parent.relativeMatrix(),this._x+=this._alignX*this._parent._width,this._y+=this._alignY*this._parent._height),i.translate(this._x,this._y),this._relativeMatrix},e.prototype.get=function(t){return"function"==typeof h[t]?h[t](this):void 0},e.prototype.set=function(t,i){if("string"==typeof t)"function"==typeof a[t]&&"undefined"!=typeof i&&a[t](this,i);else if("object"==typeof t)for(i in t)"function"==typeof a[i]&&"undefined"!=typeof t[i]&&a[i](this,t[i],t);return this._owner&&(this._owner._ts_pin=++o,this._owner.touch()),this};var h={alpha:function(t){return t._alpha},textureAlpha:function(t){return t._textureAlpha},width:function(t){return t._width},height:function(t){return t._height},boxWidth:function(t){return t._boxWidth},boxHeight:function(t){return t._boxHeight},scaleX:function(t){return t._scaleX},scaleY:function(t){return t._scaleY},skewX:function(t){return t._skewX},skewY:function(t){return t._skewY},rotation:function(t){return t._rotation},pivotX:function(t){return t._pivotX},pivotY:function(t){return t._pivotY},offsetX:function(t){return t._offsetX},offsetY:function(t){return t._offsetY},alignX:function(t){return t._alignX},alignY:function(t){return t._alignY},handleX:function(t){return t._handleX},handleY:function(t){return t._handleY}},a={alpha:function(t,i){t._alpha=i},textureAlpha:function(t,i){t._textureAlpha=i},width:function(t,i){t._width_=i,t._width=i,t._ts_transform=++o},height:function(t,i){t._height_=i,t._height=i,t._ts_transform=++o},scale:function(t,i){t._scaleX=i,t._scaleY=i,t._ts_transform=++o},scaleX:function(t,i){t._scaleX=i,t._ts_transform=++o},scaleY:function(t,i){t._scaleY=i,t._ts_transform=++o},skew:function(t,i){t._skewX=i,t._skewY=i,t._ts_transform=++o},skewX:function(t,i){t._skewX=i,t._ts_transform=++o},skewY:function(t,i){t._skewY=i,t._ts_transform=++o},rotation:function(t,i){t._rotation=i,t._ts_transform=++o},pivot:function(t,i){t._pivotX=i,t._pivotY=i,t._pivoted=!0,t._ts_transform=++o},pivotX:function(t,i){t._pivotX=i,t._pivoted=!0,t._ts_transform=++o},pivotY:function(t,i){t._pivotY=i,t._pivoted=!0,t._ts_transform=++o},offset:function(t,i){t._offsetX=i,t._offsetY=i,t._ts_translate=++o},offsetX:function(t,i){t._offsetX=i,t._ts_translate=++o},offsetY:function(t,i){t._offsetY=i,t._ts_translate=++o},align:function(t,i){this.alignX(t,i),this.alignY(t,i)},alignX:function(t,i){t._alignX=i,t._aligned=!0,t._ts_translate=++o,this.handleX(t,i)},alignY:function(t,i){t._alignY=i,t._aligned=!0,t._ts_translate=++o,this.handleY(t,i)},handle:function(t,i){this.handleX(t,i),this.handleY(t,i)},handleX:function(t,i){t._handleX=i,t._handled=!0,t._ts_translate=++o},handleY:function(t,i){t._handleY=i,t._handled=!0,t._ts_translate=++o},resizeMode:function(t,i,e){e&&("in"==i?i="in-pad":"out"==i&&(i="out-crop"),n(t,e.resizeWidth,e.resizeHeight,i))},resizeWidth:function(t,i,e){e&&e.resizeMode||n(t,i,null)},resizeHeight:function(t,i,e){e&&e.resizeMode||n(t,null,i)},scaleMode:function(t,i,e){e&&n(t,e.scaleWidth,e.scaleHeight,i)},scaleWidth:function(t,i,e){e&&e.scaleMode||n(t,i,null)},scaleHeight:function(t,i,e){e&&e.scaleMode||n(t,null,i)},matrix:function(t,i){this.scaleX(t,i.a),this.skewX(t,i.c/i.d),this.skewY(t,i.b/i.a),this.scaleY(t,i.d),this.offsetX(t,i.e),this.offsetY(t,i.f),this.rotation(t,0)
+}};r.prototype.scaleTo=function(t,i,e){return"object"==typeof t&&(e=i,i=t.y,t=t.x),n(this._pin,t,i,e),this},e._add_shortcuts=function(t){t.prototype.size=function(t,i){return this.pin("width",t),this.pin("height",i),this},t.prototype.width=function(t){return"undefined"==typeof t?this.pin("width"):(this.pin("width",t),this)},t.prototype.height=function(t){return"undefined"==typeof t?this.pin("height"):(this.pin("height",t),this)},t.prototype.offset=function(t,i){return"object"==typeof t&&(i=t.y,t=t.x),this.pin("offsetX",t),this.pin("offsetY",i),this},t.prototype.rotate=function(t){return this.pin("rotation",t),this},t.prototype.skew=function(t,i){return"object"==typeof t?(i=t.y,t=t.x):"undefined"==typeof i&&(i=t),this.pin("skewX",t),this.pin("skewY",i),this},t.prototype.scale=function(t,i){return"object"==typeof t?(i=t.y,t=t.x):"undefined"==typeof i&&(i=t),this.pin("scaleX",t),this.pin("scaleY",i),this},t.prototype.alpha=function(t,i){return this.pin("alpha",t),"undefined"!=typeof i&&this.pin("textureAlpha",i),this}},e._add_shortcuts(r),i.exports=e},{"./core":8,"./matrix":15}],17:[function(t){function i(t,e){i._super.call(this),this.label("Root");var r=!0,s=this,o=0,h=function(i){if(r!==!0){n.tick=n.node=n.draw=0;var a=o||i,u=i-a;o=i;var f=s._tick(u,i,a);s._mo_touch!=s._ts_touch?(s._mo_touch=s._ts_touch,e(s),t(h)):f?t(h):r=!0,n.fps=u?1e3/u:0}};this.start=function(){return this.resume()},this.resume=function(){return r&&(r=!1,t(h)),this},this.pause=function(){return r=!0,this},this.touch_root=this.touch,this.touch=function(){return this.resume(),this.touch_root()}}var e=t("./core");t("./pin"),t("./loop");var n=t("./util/stats"),r=t("./util/create"),s=t("./util/extend");i._super=e,i.prototype=r(i._super.prototype),e.root=function(t,e){return new i(t,e)},i.prototype.background=function(){return this},i.prototype.viewport=function(t,i,e){if("undefined"==typeof t)return s({},this._viewport);this._viewport={width:t,height:i,ratio:e||1},this.viewbox();var n=s({},this._viewport);return this.visit({start:function(t){return t._flag("viewport")?void t.publish("viewport",[n]):!0}}),this},i.prototype.viewbox=function(t,i,e){"number"==typeof t&&"number"==typeof i&&(this._viewbox={width:t,height:i,mode:/^(in|out|in-pad|out-crop)$/.test(e)?e:"in-pad"});var n=this._viewbox,r=this._viewport;return r&&n?(this.pin({width:n.width,height:n.height}),this.scaleTo(r.width,r.height,n.mode)):r&&this.pin({width:r.width,height:r.height}),this}},{"./core":8,"./loop":14,"./pin":16,"./util/create":22,"./util/extend":24,"./util/stats":28}],18:[function(t){function i(){i._super.call(this),this.label("String"),this._textures=[]}var e=t("./core");t("./pin"),t("./loop");var n=t("./util/create"),r=t("./util/is");e.string=function(t){return(new i).frames(t)},i._super=e,i.prototype=n(i._super.prototype),i.prototype.setFont=function(t,i,e){return this.frames(t,i,e)},i.prototype.frames=function(t){return this._textures=[],"string"==typeof t?(t=e.texture(t),this._item=function(i){return t.one(i)}):"object"==typeof t?this._item=function(i){return t[i]}:"function"==typeof t&&(this._item=t),this},i.prototype.setValue=function(t,i,e){return this.value(t,i,e)},i.prototype.value=function(t){if("undefined"==typeof t)return this._value;if(this._value===t)return this;this._value=t,null===t?t="":"string"==typeof t||r.array(t)||(t=t.toString()),this._spacing=this._spacing||0;for(var i=0,e=0,n=0;n<t.length;n++){var s=this._textures[n]=this._item(t[n]);i+=n>0?this._spacing:0,s.dest(i,0),i+=s.width,e=Math.max(e,s.height)}return this.pin("width",i),this.pin("height",e),this._textures.length=t.length,this}},{"./core":8,"./loop":14,"./pin":16,"./util/create":22,"./util/is":25}],19:[function(t,i){function e(t,i){"object"==typeof t&&this.src(t,i)}var n=t("./util/stats"),r=t("./util/math");e.prototype.pipe=function(){return new e(this)},e.prototype.src=function(t,i,e,n){if("object"==typeof t){var r=t,s=i||1;this._image=r,this._sx=this._dx=0,this._sy=this._dy=0,this._sw=this._dw=r.width/s,this._sh=this._dh=r.height/s,this.width=r.width/s,this.height=r.height/s,this.ratio=s}else"undefined"==typeof e?(e=t,n=i):(this._sx=t,this._sy=i),this._sw=this._dw=e,this._sh=this._dh=n,this.width=e,this.height=n;return this},e.prototype.dest=function(t,i,e,n){return this._dx=t,this._dy=i,this._dx=t,this._dy=i,"undefined"!=typeof e&&(this._dw=e,this._dh=n,this.width=e,this.height=n),this},e.prototype.draw=function(t,i,e,s,o,h,a,u,f){var c=this._image;if(null!==c&&"object"==typeof c){var p=this._sx,l=this._sy,_=this._sw,d=this._sh,g=this._dx,y=this._dy,m=this._dw,v=this._dh;"undefined"!=typeof h?(i=r.limit(i,0,this._sw),s=r.limit(s,0,this._sw-i),e=r.limit(e,0,this._sh),o=r.limit(o,0,this._sh-e),p+=i,l+=e,_=s,d=o,g=h,y=a,m=u,v=f):"undefined"!=typeof s?(g=i,y=e,m=s,v=o):"undefined"!=typeof i&&(m=i,v=e);var x=this.ratio||1;p*=x,l*=x,_*=x,d*=x;try{"function"==typeof c.draw?c.draw(t,p,l,_,d,g,y,m,v):(n.draw++,t.drawImage(c,p,l,_,d,g,y,m,v))}catch(b){c._draw_failed||(console.log("Unable to draw: ",c),console.log(b),c._draw_failed=!0)}}},i.exports=e},{"./util/math":26,"./util/stats":28}],20:[function(t,i){function e(t,i){o(i),o(t),i.remove(),t._last&&(t._last._next=i,i._prev=t._last),i._parent=t,t._last=i,t._first||(t._first=i),i._parent._flag(i,!0),i._ts_parent=++u,t._ts_children=++u,t.touch()}function n(t,i){o(i),o(t),i.remove(),t._first&&(t._first._prev=i,i._next=t._first),i._parent=t,t._first=i,t._last||(t._last=i),i._parent._flag(i,!0),i._ts_parent=++u,t._ts_children=++u,t.touch()}function r(t,i){o(t),o(i),t.remove();var e=i._parent,n=i._prev;i._prev=t,n&&(n._next=t)||e&&(e._first=t),t._parent=e,t._prev=n,t._next=i,t._parent._flag(t,!0),t._ts_parent=++u,t.touch()}function s(t,i){o(t),o(i),t.remove();var e=i._parent,n=i._next;i._next=t,n&&(n._prev=t)||e&&(e._last=t),t._parent=e,t._prev=i,t._next=n,t._parent._flag(t,!0),t._ts_parent=++u,t.touch()}function o(t){if(t&&t instanceof h)return t;throw"Invalid node: "+t}var h=t("./core"),a=t("./util/is"),u=0;h.prototype._label="",h.prototype._visible=!0,h.prototype._parent=null,h.prototype._next=null,h.prototype._prev=null,h.prototype._first=null,h.prototype._last=null,h.prototype._attrs=null,h.prototype._flags=null,h.prototype.toString=function(){return"["+this._label+"]"},h.prototype.id=function(t){return this.label(t)},h.prototype.label=function(t){return"undefined"==typeof t?this._label:(this._label=t,this)},h.prototype.attr=function(t,i){return"undefined"==typeof i?null!==this._attrs?this._attrs[t]:void 0:((null!==this._attrs?this._attrs:this._attrs={})[t]=i,this)},h.prototype.visible=function(t){return"undefined"==typeof t?this._visible:(this._visible=t,this._parent&&(this._parent._ts_children=++u),this._ts_pin=++u,this.touch(),this)},h.prototype.hide=function(){return this.visible(!1)},h.prototype.show=function(){return this.visible(!0)},h.prototype.parent=function(){return this._parent},h.prototype.next=function(t){for(var i=this._next;i&&t&&!i._visible;)i=i._next;return i},h.prototype.prev=function(t){for(var i=this._prev;i&&t&&!i._visible;)i=i._prev;return i},h.prototype.first=function(t){for(var i=this._first;i&&t&&!i._visible;)i=i._next;return i},h.prototype.last=function(t){for(var i=this._last;i&&t&&!i._visible;)i=i._prev;return i},h.prototype.visit=function(t,i){var e=t.reverse,n=t.visible;if(!t.start||!t.start(this,i)){for(var r,s=e?this.last(n):this.first(n);r=s;)if(s=e?r.prev(n):r.next(n),r.visit(t,i))return!0;return t.end&&t.end(this,i)}},h.prototype.append=function(t,i){if(a.array(t))for(var n=0;n<t.length;n++)e(this,t[n]);else if("undefined"!=typeof i)for(var n=0;n<arguments.length;n++)e(this,arguments[n]);else"undefined"!=typeof t&&e(this,t);return this},h.prototype.prepend=function(t,i){if(a.array(t))for(var e=t.length-1;e>=0;e--)n(this,t[e]);else if("undefined"!=typeof i)for(var e=arguments.length-1;e>=0;e--)n(this,arguments[e]);else"undefined"!=typeof t&&n(this,t);return this},h.prototype.appendTo=function(t){return e(t,this),this},h.prototype.prependTo=function(t){return n(t,this),this},h.prototype.insertNext=function(t,i){if(a.array(t))for(var e=0;e<t.length;e++)s(t[e],this);else if("undefined"!=typeof i)for(var e=0;e<arguments.length;e++)s(arguments[e],this);else"undefined"!=typeof t&&s(t,this);return this},h.prototype.insertPrev=function(t,i){if(a.array(t))for(var e=t.length-1;e>=0;e--)r(t[e],this);else if("undefined"!=typeof i)for(var e=arguments.length-1;e>=0;e--)r(arguments[e],this);else"undefined"!=typeof t&&r(t,this);return this},h.prototype.insertAfter=function(t){return s(this,t),this},h.prototype.insertBefore=function(t){return r(this,t),this},h.prototype.remove=function(t,i){if("undefined"!=typeof t){if(a.array(t))for(var e=0;e<t.length;e++)o(t[e]).remove();else if("undefined"!=typeof i)for(var e=0;e<arguments.length;e++)o(arguments[e]).remove();else o(t).remove();return this}return this._prev&&(this._prev._next=this._next),this._next&&(this._next._prev=this._prev),this._parent&&(this._parent._first===this&&(this._parent._first=this._next),this._parent._last===this&&(this._parent._last=this._prev),this._parent._flag(this,!1),this._parent._ts_children=++u,this._parent.touch()),this._prev=this._next=this._parent=null,this._ts_parent=++u,this},h.prototype.empty=function(){for(var t,i=this._first;t=i;)i=t._next,t._prev=t._next=t._parent=null,this._flag(t,!1);return this._first=this._last=null,this._ts_children=++u,this.touch(),this},h.prototype.touch=function(){return this._ts_touch=++u,this._parent&&this._parent.touch(),this},h.prototype._flag=function(t,i){if("undefined"==typeof i)return null!==this._flags&&this._flags[t]||0;if("string"==typeof t&&(i?(this._flags=this._flags||{},!this._flags[t]&&this._parent&&this._parent._flag(t,!0),this._flags[t]=(this._flags[t]||0)+1):this._flags&&this._flags[t]>0&&(1==this._flags[t]&&this._parent&&this._parent._flag(t,!1),this._flags[t]=this._flags[t]-1)),"object"==typeof t&&t._flags)for(var e in t._flags)t._flags[e]>0&&this._flag(e,i);return this},h.prototype.hitTest=function(t){return this.attr("spy")?!0:t.x>=0&&t.x<=this._pin._width&&t.y>=0&&t.y<=this._pin._height},i.exports=h},{"./core":8,"./util/is":25}],21:[function(t,i){i.exports=function(){function t(t,n){return e+=n="number"==typeof n&&n>=1?n:1,function(){t&&t.apply(this,arguments),n>0&&(n--,e--,i())}}function i(){if(0===e)for(;n.length;)setTimeout(n.shift(),0)}var e=0,n=[];return t.then=function(t){0===e?setTimeout(t,0):n.push(t)},t}},{}],22:[function(t,i){function e(){}i.exports="function"==typeof Object.create?function(t,i){return Object.create.call(Object,t,i)}:function(t,i){if(i)throw Error("Second argument is not supported!");if("object"!=typeof t||null===t)throw Error("Invalid prototype!");return e.prototype=t,new e}},{}],23:[function(t,i){i.exports=function(t,i){t._listeners=null,t.on=t.listen=function(t,e){if(!t||!t.length||"function"!=typeof e)return this;null===this._listeners&&(this._listeners={});var n="string"!=typeof t&&"function"==typeof t.join;if(t=(n?t.join(" "):t).match(/\S+/g))for(var r=0;r<t.length;r++){var s=t[r];this._listeners[s]=this._listeners[s]||[],this._listeners[s].push(e),"function"==typeof i&&i(this,s,!0)}return this},t.off=function(t,e){if(!t||!t.length||"function"!=typeof e)return this;if(null===this._listeners)return this;var n="string"!=typeof t&&"function"==typeof t.join;if(t=(n?t.join(" "):t).match(/\S+/g))for(var r=0;r<t.length;r++){var s,o=t[r],h=this._listeners[o];h&&(s=h.indexOf(e))>=0&&(h.splice(s,1),h.length||delete this._listeners[o],"function"==typeof i&&i(this,o,!1))}return this},t.listeners=function(t){return this._listeners&&this._listeners[t]},t.publish=function(t,i){var e=this.listeners(t);if(!e||!e.length)return 0;for(var n=0;n<e.length;n++)e[n].apply(this,i);return e.length},t.trigger=function(t,i){return this.publish(t,i),this}}},{}],24:[function(t,i){i.exports=function(t){for(var i=1;i<arguments.length;i++){var e=arguments[i];for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])}return t}},{}],25:[function(t,i){var e=Object.prototype,n=e.hasOwnProperty,r=e.toString,s=/^[A-Fa-f0-9]+$/,o=i.exports={};o.a=o.an=o.type=function(t,i){return typeof t===i},o.defined=function(t){return"undefined"!=typeof t},o.empty=function(t){var i,e=r.call(t);if("[object Array]"===e||"[object Arguments]"===e||"[object String]"===e)return 0===t.length;if("[object Object]"===e){for(i in t)if(n.call(t,i))return!1;return!0}return!t},o.equal=function(t,i){if(t===i)return!0;var e,n=r.call(t);if(n!==r.call(i))return!1;if("[object Object]"===n){for(e in t)if(!(o.equal(t[e],i[e])&&e in i))return!1;for(e in i)if(!(o.equal(t[e],i[e])&&e in t))return!1;return!0}if("[object Array]"===n){if(e=t.length,e!==i.length)return!1;for(;--e;)if(!o.equal(t[e],i[e]))return!1;return!0}return"[object Function]"===n?t.prototype===i.prototype:"[object Date]"===n?t.getTime()===i.getTime():!1},o.instance=function(t,i){return t instanceof i},o.nil=function(t){return null===t},o.undef=function(t){return"undefined"==typeof t},o.array=function(t){return"[object Array]"===r.call(t)},o.emptyarray=function(t){return o.array(t)&&0===t.length},o.arraylike=function(t){return!!t&&!o["boolean"](t)&&n.call(t,"length")&&isFinite(t.length)&&o.number(t.length)&&t.length>=0},o["boolean"]=function(t){return"[object Boolean]"===r.call(t)},o.element=function(t){return void 0!==t&&"undefined"!=typeof HTMLElement&&t instanceof HTMLElement&&1===t.nodeType},o.fn=function(t){return"[object Function]"===r.call(t)},o.number=function(t){return"[object Number]"===r.call(t)},o.nan=function(t){return!o.number(t)||t!==t},o.object=function(t){return"[object Object]"===r.call(t)},o.hash=function(t){return o.object(t)&&t.constructor===Object&&!t.nodeType&&!t.setInterval},o.regexp=function(t){return"[object RegExp]"===r.call(t)},o.string=function(t){return"[object String]"===r.call(t)},o.hex=function(t){return o.string(t)&&(!t.length||s.test(t))}},{}],26:[function(t,i){var e=t("./create"),n=Math;i.exports=e(Math),i.exports.random=function(t,i){return"undefined"==typeof t?(i=1,t=0):"undefined"==typeof i&&(i=t,t=0),t==i?t:n.random()*(i-t)+t},i.exports.rotate=function(t,i,e){return"undefined"==typeof i?(e=1,i=0):"undefined"==typeof e&&(e=i,i=0),e>i?(t=(t-i)%(e-i),t+(0>t?e:i)):(t=(t-e)%(i-e),t+(0>=t?i:e))},i.exports.limit=function(t,i,e){return i>t?i:t>e?e:t},i.exports.length=function(t,i){return n.sqrt(t*t+i*i)}},{"./create":22}],27:[function(t,i){i.exports=function(t,i,e,n,r,s){var o=t.width,h=t.height,a=t.left,u=t.right,f=t.top,c=t.bottom;a="number"==typeof a&&a===a?a:0,u="number"==typeof u&&u===u?u:0,f="number"==typeof f&&f===f?f:0,c="number"==typeof c&&c===c?c:0,o=o-a-u,h=h-f-c,r||(i=Math.max(i-a-u,0),e=Math.max(e-f-c,0));var p=0;if(f>0&&a>0&&s(p++,0,0,a,f,0,0,a,f),c>0&&a>0&&s(p++,0,h+f,a,c,0,e+f,a,c),f>0&&u>0&&s(p++,o+a,0,u,f,i+a,0,u,f),c>0&&u>0&&s(p++,o+a,h+f,u,c,i+a,e+f,u,c),n)f>0&&s(p++,a,0,o,f,a,0,i,f),c>0&&s(p++,a,h+f,o,c,a,e+f,i,c),a>0&&s(p++,0,f,a,h,0,f,a,e),u>0&&s(p++,o+a,f,u,h,i+a,f,u,e),s(p++,a,f,o,h,a,f,i,e);else for(var l,_=a,d=i;d>0;){l=Math.min(o,d),d-=o;for(var g,y=f,m=e;m>0;)g=Math.min(h,m),m-=h,s(p++,a,f,l,g,_,y,l,g),0>=d&&(a&&s(p++,0,f,a,g,0,y,a,g),u&&s(p++,o+a,f,u,g,_+l,y,u,g)),y+=g;f&&s(p++,a,0,l,f,_,0,l,f),c&&s(p++,a,h+f,l,c,_,y,l,c),_+=l}return p}},{}],28:[function(t,i){i.exports={}},{}],29:[function(t,i){i.exports.startsWith=function(t,i){return"string"==typeof t&&"string"==typeof i&&t.substring(0,i.length)==i}},{}]},{},[1])(1)});
\ No newline at end of file
diff --git a/package.json b/package.json
index ec73a63..964cc49 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "stage-js",
-  "version": "0.8.1",
+  "version": "0.8.2",
   "description": "2D HTML5 JavaScript library for cross-platform game development",
   "homepage": "http://piqnt.com/stage.js/",
   "keywords": [
diff --git a/template/dist.js b/template/dist.js
index 569da4f..8587c2a 100644
--- a/template/dist.js
+++ b/template/dist.js
@@ -1,8 +1,8 @@
 /*
  * Stage.js ${version}
- * Copyright (c) 2015 Ali Shakiba, Piqnt LLC
- * Available under the MIT license
- * @license
+ * 
+ * @copyright 2015 Ali Shakiba, Piqnt LLC
+ * @license The MIT License
  */
 
 ${contents}
\ No newline at end of file
