Created
May 6, 2013 02:25
-
-
Save coodoo/5523055 to your computer and use it in GitHub Desktop.
Starling.js source code, slightly annotated. Starling.js is a canvas based drawing framework, ported from iOS to AS3 to Javascript. Demo: http://gamua.com/area-51/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
RequireJS 2.1.4 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. | |
Available via the MIT or new BSD license. | |
see: http://github.com/jrburke/requirejs for details | |
*/ | |
/*! jQuery v1.9.1 | (c) 2005, 2012 jQuery Foundation, Inc. | jquery.org/license | |
//@ sourceMappingURL=jquery.min.map | |
*/ | |
/** | |
* PreloadJS | |
* Visit http://createjs.com/ for documentation, updates and examples. | |
* | |
* Copyright (c) 2011 gskinner.com, inc. | |
* | |
* Distributed under the terms of the MIT license. | |
* http://www.opensource.org/licenses/mit-license.html | |
* | |
* This notice shall be included in all copies or substantial portions of the Software. | |
**/ | |
/** | |
* minified: 250kb | |
* gzipped: 72kb | |
* | |
* jx. | |
*/ | |
(function() { | |
var requirejs, require, define; | |
(function(Y) { | |
function I(t) { | |
return "[object Function]" === L.call(t) | |
} | |
function J(t) { | |
return "[object Array]" === L.call(t) | |
} | |
function x(t, e) { | |
if (t) { | |
var n; | |
for (n = 0; t.length > n && (!t[n] || !e(t[n], n, t)); n += 1); | |
} | |
} | |
function M(t, e) { | |
if (t) { | |
var n; | |
for (n = t.length - 1; n > -1 && (!t[n] || !e(t[n], n, t)); n -= 1); | |
} | |
} | |
function r(t, e) { | |
return da.call(t, e) | |
} | |
function i(t, e) { | |
return r(t, e) && t[e] | |
} | |
function E(t, e) { | |
for (var n in t) if (r(t, n) && e(t[n], n)) break | |
} | |
function Q(t, e, n, i) { | |
return e && E(e, function(e, o) { | |
(n || !r(t, o)) && (i && "string" != typeof e ? (t[o] || (t[o] = {}), Q(t[o], e, n, i)) : t[o] = e) | |
}), t | |
} | |
function t(t, e) { | |
return function() { | |
return e.apply(t, arguments) | |
} | |
} | |
function Z(t) { | |
if (!t) return t; | |
var e = Y; | |
return x(t.split("."), function(t) { | |
e = e[t] | |
}), e | |
} | |
function F(t, e, n, r) { | |
return e = Error(e + "\nhttp://requirejs.org/docs/errors.html#" + t), e.requireType = t, e.requireModules = r, n && (e.originalError = n), e | |
} | |
function ea(e) { | |
function n(t, e, n) { | |
var r, o, s, a, u, h, l, c = e && e.split("/"); | |
r = c; | |
var p = S.map, | |
f = p && p["*"]; | |
if (t && "." === t.charAt(0)) if (e) { | |
for (r = i(S.pkgs, e) ? c = [e] : c.slice(0, c.length - 1), e = t = r.concat(t.split("/")), r = 0; e[r]; r += 1) if (o = e[r], "." === o) e.splice(r, 1), r -= 1; | |
else if (".." === o) { | |
if (1 === r && (".." === e[2] || ".." === e[0])) break; | |
r > 0 && (e.splice(r - 1, 2), r -= 2) | |
} | |
r = i(S.pkgs, e = t[0]), t = t.join("/"), r && t === e + "/" + r.main && (t = e) | |
} else 0 === t.indexOf("./") && (t = t.substring(2)); | |
if (n && (c || f) && p) { | |
for (e = t.split("/"), r = e.length; r > 0; r -= 1) { | |
if (s = e.slice(0, r).join("/"), c) for (o = c.length; o > 0; o -= 1) if ((n = i(p, c.slice(0, o).join("/"))) && (n = i(n, s))) { | |
a = n, u = r; | |
break | |
} | |
if (a) break; | |
!h && f && i(f, s) && (h = i(f, s), l = r) | |
}!a && h && (a = h, u = l), a && (e.splice(0, u, a), t = e.join("/")) | |
} | |
return t | |
} | |
function o(t) { | |
z && x(document.getElementsByTagName("script"), function(e) { | |
return e.getAttribute("data-requiremodule") === t && e.getAttribute("data-requirecontext") === w.contextName ? (e.parentNode.removeChild(e), !0) : void 0 | |
}) | |
} | |
function s(t) { | |
var e = i(S.paths, t); | |
return e && J(e) && e.length > 1 ? (o(t), e.shift(), w.require.undef(t), w.require([t]), !0) : void 0 | |
} | |
function a(t) { | |
var e, n = t ? t.indexOf("!") : -1; | |
return n > -1 && (e = t.substring(0, n), t = t.substring(n + 1, t.length)), [e, t] | |
} | |
function u(t, e, r, o) { | |
var s, u, h = null, | |
l = e ? e.name : null, | |
c = t, | |
p = !0, | |
f = ""; | |
return t || (p = !1, t = "_@r" + (D += 1)), t = a(t), h = t[0], t = t[1], h && (h = n(h, l, o), u = i(j, h)), t && (h ? f = u && u.normalize ? u.normalize(t, function(t) { | |
return n(t, l, o) | |
}) : n(t, l, o) : (f = n(t, l, o), t = a(f), h = t[0], f = t[1], r = !0, s = w.nameToUrl(f))), r = !h || u || r ? "" : "_unnormalized" + (k += 1), { | |
prefix: h, | |
name: f, | |
parentMap: e, | |
unnormalized: !! r, | |
url: s, | |
originalName: c, | |
isDefine: p, | |
id: (h ? h + "!" + f : f) + r | |
} | |
} | |
function h(t) { | |
var e = t.id, | |
n = i(M, e); | |
return n || (n = M[e] = new w.Module(t)), n | |
} | |
function c(t, e, n) { | |
var o = t.id, | |
s = i(M, o); | |
!r(j, o) || s && !s.defineEmitComplete ? h(t).on(e, n) : "defined" === e && n(j[o]) | |
} | |
function p(t, e) { | |
var n = t.requireModules, | |
r = !1; | |
e ? e(t) : (x(n, function(e) { | |
(e = i(M, e)) && (e.error = t, e.events.error && (r = !0, e.emit("error", t))) | |
}), r || l.onError(t)) | |
} | |
function f() { | |
R.length && (fa.apply(L, [L.length - 1, 0].concat(R)), R = []) | |
} | |
function m(t, e, n) { | |
var r = t.map.id; | |
t.error ? t.emit("error", t.error) : (e[r] = !0, x(t.depMaps, function(r, o) { | |
var s = r.id, | |
a = i(M, s); | |
a && !t.depMatched[o] && !n[s] && (i(e, s) ? (t.defineDep(o, j[s]), t.check()) : m(a, e, n)) | |
}), n[r] = !0) | |
} | |
function d() { | |
var t, e, n, r, i = (n = 1e3 * S.waitSeconds) && w.startTime + n < (new Date).getTime(), | |
a = [], | |
u = [], | |
h = !1, | |
l = !0; | |
if (!b) { | |
if (b = !0, E(M, function(n) { | |
if (t = n.map, e = t.id, n.enabled && (t.isDefine || u.push(n), !n.error)) if (!n.inited && i) s(e) ? h = r = !0 : (a.push(e), o(e)); | |
else if (!n.inited && n.fetched && t.isDefine && (h = !0, !t.prefix)) return l = !1 | |
}), i && a.length) return n = F("timeout", "Load timeout for modules: " + a, null, a), n.contextName = w.contextName, p(n); | |
l && x(u, function(t) { | |
m(t, {}, {}) | |
}), i && !r || !h || !z && !$ || C || (C = setTimeout(function() { | |
C = 0, d() | |
}, 50)), b = !1 | |
} | |
} | |
function g(t) { | |
r(j, t[0]) || h(u(t[0], null, !0)).init(t[1], t[2]) | |
} | |
function y(t) { | |
var t = t.currentTarget || t.srcElement, | |
e = w.onScriptLoad; | |
return t.detachEvent && !V ? t.detachEvent("onreadystatechange", e) : t.removeEventListener("load", e, !1), e = w.onScriptError, (!t.detachEvent || V) && t.removeEventListener("error", e, !1), { | |
node: t, | |
id: t && t.getAttribute("data-requiremodule") | |
} | |
} | |
function v() { | |
var t; | |
for (f(); L.length;) { | |
if (t = L.shift(), null === t[0]) return p(F("mismatch", "Mismatched anonymous define() module: " + t[t.length - 1])); | |
g(t) | |
} | |
} | |
var b, T, w, _, C, S = { | |
waitSeconds: 7, | |
baseUrl: "./", | |
paths: {}, | |
pkgs: {}, | |
shim: {}, | |
map: {}, | |
config: {} | |
}, M = {}, A = {}, L = [], | |
j = {}, N = {}, D = 1, | |
k = 1; | |
return _ = { | |
require: function(t) { | |
return t.require ? t.require : t.require = w.makeRequire(t.map) | |
}, | |
exports: function(t) { | |
return t.usingExports = !0, t.map.isDefine ? t.exports ? t.exports : t.exports = j[t.map.id] = {} : void 0 | |
}, | |
module: function(t) { | |
return t.module ? t.module : t.module = { | |
id: t.map.id, | |
uri: t.map.url, | |
config: function() { | |
return S.config && i(S.config, t.map.id) || {} | |
}, | |
exports: j[t.map.id] | |
} | |
} | |
}, T = function(t) { | |
this.events = i(A, t.id) || {}, this.map = t, this.shim = i(S.shim, t.id), this.depExports = [], this.depMaps = [], this.depMatched = [], this.pluginMaps = {}, this.depCount = 0 | |
}, T.prototype = { | |
init: function(e, n, r, i) { | |
i = i || {}, this.inited || (this.factory = n, r ? this.on("error", r) : this.events.error && (r = t(this, function(t) { | |
this.emit("error", t) | |
})), this.depMaps = e && e.slice(0), this.errback = r, this.inited = !0, this.ignore = i.ignore, i.enabled || this.enabled ? this.enable() : this.check()) | |
}, | |
defineDep: function(t, e) { | |
this.depMatched[t] || (this.depMatched[t] = !0, this.depCount -= 1, this.depExports[t] = e) | |
}, | |
fetch: function() { | |
if (!this.fetched) { | |
this.fetched = !0, w.startTime = (new Date).getTime(); | |
var e = this.map; | |
if (!this.shim) return e.prefix ? this.callPlugin() : this.load(); | |
w.makeRequire(this.map, { | |
enableBuildCallback: !0 | |
})(this.shim.deps || [], t(this, function() { | |
return e.prefix ? this.callPlugin() : this.load() | |
})) | |
} | |
}, | |
load: function() { | |
var t = this.map.url; | |
N[t] || (N[t] = !0, w.load(this.map.id, t)) | |
}, | |
check: function() { | |
if (this.enabled && !this.enabling) { | |
var t, e, n = this.map.id; | |
e = this.depExports; | |
var r = this.exports, | |
i = this.factory; | |
if (this.inited) { | |
if (this.error) this.emit("error", this.error); | |
else if (!this.defining) { | |
if (this.defining = !0, 1 > this.depCount && !this.defined) { | |
if (I(i)) { | |
if (this.events.error) try { | |
r = w.execCb(n, i, e, r) | |
} catch (o) { | |
t = o | |
} else r = w.execCb(n, i, e, r); | |
if (this.map.isDefine && ((e = this.module) && void 0 !== e.exports && e.exports !== this.exports ? r = e.exports : void 0 === r && this.usingExports && (r = this.exports)), t) return t.requireMap = this.map, t.requireModules = [this.map.id], t.requireType = "define", p(this.error = t) | |
} else r = i; | |
this.exports = r, this.map.isDefine && !this.ignore && (j[n] = r, l.onResourceLoad) && l.onResourceLoad(w, this.map, this.depMaps), delete M[n], this.defined = !0 | |
} | |
this.defining = !1, this.defined && !this.defineEmitted && (this.defineEmitted = !0, this.emit("defined", this.exports), this.defineEmitComplete = !0) | |
} | |
} else this.fetch() | |
} | |
}, | |
callPlugin: function() { | |
var e = this.map, | |
o = e.id, | |
s = u(e.prefix); | |
this.depMaps.push(s), c(s, "defined", t(this, function(s) { | |
var a, f; | |
f = this.map.name; | |
var m = this.map.parentMap ? this.map.parentMap.name : null, | |
d = w.makeRequire(e.parentMap, { | |
enableBuildCallback: !0 | |
}); | |
this.map.unnormalized ? (s.normalize && (f = s.normalize(f, function(t) { | |
return n(t, m, !0) | |
}) || ""), s = u(e.prefix + "!" + f, this.map.parentMap), c(s, "defined", t(this, function(t) { | |
this.init([], function() { | |
return t | |
}, null, { | |
enabled: !0, | |
ignore: !0 | |
}) | |
})), (f = i(M, s.id)) && (this.depMaps.push(s), this.events.error && f.on("error", t(this, function(t) { | |
this.emit("error", t) | |
})), f.enable())) : (a = t(this, function(t) { | |
this.init([], function() { | |
return t | |
}, null, { | |
enabled: !0 | |
}) | |
}), a.error = t(this, function(t) { | |
this.inited = !0, this.error = t, t.requireModules = [o], E(M, function(t) { | |
0 === t.map.id.indexOf(o + "_unnormalized") && delete M[t.map.id] | |
}), p(t) | |
}), a.fromText = t(this, function(t, n) { | |
var i = e.name, | |
s = u(i), | |
c = O; | |
n && (t = n), c && (O = !1), h(s), r(S.config, o) && (S.config[i] = S.config[o]); | |
try { | |
l.exec(t) | |
} catch (f) { | |
return p(F("fromtexteval", "fromText eval for " + o + " failed: " + f, f, [o])) | |
} | |
c && (O = !0), this.depMaps.push(s), w.completeLoad(i), d([i], a) | |
}), s.load(e.name, d, a, S)) | |
})), w.enable(s, this), this.pluginMaps[s.id] = s | |
}, | |
enable: function() { | |
this.enabling = this.enabled = !0, x(this.depMaps, t(this, function(e, n) { | |
var o, s; | |
if ("string" == typeof e) { | |
if (e = u(e, this.map.isDefine ? this.map : this.map.parentMap, !1, !this.skipMap), this.depMaps[n] = e, o = i(_, e.id)) return this.depExports[n] = o(this), void 0; | |
this.depCount += 1, c(e, "defined", t(this, function(t) { | |
this.defineDep(n, t), this.check() | |
})), this.errback && c(e, "error", this.errback) | |
} | |
o = e.id, s = M[o], !r(_, o) && s && !s.enabled && w.enable(e, this) | |
})), E(this.pluginMaps, t(this, function(t) { | |
var e = i(M, t.id); | |
e && !e.enabled && w.enable(t, this) | |
})), this.enabling = !1, this.check() | |
}, | |
on: function(t, e) { | |
var n = this.events[t]; | |
n || (n = this.events[t] = []), n.push(e) | |
}, | |
emit: function(t, e) { | |
x(this.events[t], function(t) { | |
t(e) | |
}), "error" === t && delete this.events[t] | |
} | |
}, w = { | |
config: S, | |
contextName: e, | |
registry: M, | |
defined: j, | |
urlFetched: N, | |
defQueue: L, | |
Module: T, | |
makeModuleMap: u, | |
nextTick: l.nextTick, | |
configure: function(t) { | |
t.baseUrl && "/" !== t.baseUrl.charAt(t.baseUrl.length - 1) && (t.baseUrl += "/"); | |
var e = S.pkgs, | |
n = S.shim, | |
r = { | |
paths: !0, | |
config: !0, | |
map: !0 | |
}; | |
E(t, function(t, e) { | |
r[e] ? "map" === e ? Q(S[e], t, !0, !0) : Q(S[e], t, !0) : S[e] = t | |
}), t.shim && (E(t.shim, function(t, e) { | |
J(t) && (t = { | |
deps: t | |
}), !t.exports && !t.init || t.exportsFn || (t.exportsFn = w.makeShimExports(t)), n[e] = t | |
}), S.shim = n), t.packages && (x(t.packages, function(t) { | |
t = "string" == typeof t ? { | |
name: t | |
} : t, e[t.name] = { | |
name: t.name, | |
location: t.location || t.name, | |
main: (t.main || "main").replace(ga, "").replace(aa, "") | |
} | |
}), S.pkgs = e), E(M, function(t, e) { | |
!t.inited && !t.map.unnormalized && (t.map = u(e)) | |
}), (t.deps || t.callback) && w.require(t.deps || [], t.callback) | |
}, | |
makeShimExports: function(t) { | |
return function() { | |
var e; | |
return t.init && (e = t.init.apply(Y, arguments)), e || t.exports && Z(t.exports) | |
} | |
}, | |
makeRequire: function(t, o) { | |
function s(n, i, a) { | |
var c, f; | |
return o.enableBuildCallback && i && I(i) && (i.__requireJsBuild = !0), "string" == typeof n ? I(i) ? p(F("requireargs", "Invalid require call"), a) : t && r(_, n) ? _[n](M[t.id]) : l.get ? l.get(w, n, t) : (c = u(n, t, !1, !0), c = c.id, r(j, c) ? j[c] : p(F("notloaded", 'Module name "' + c + '" has not been loaded yet for context: ' + e + (t ? "" : ". Use require([])")))) : (v(), w.nextTick(function() { | |
v(), f = h(u(null, t)), f.skipMap = o.skipMap, f.init(n, i, a, { | |
enabled: !0 | |
}), d() | |
}), s) | |
} | |
return o = o || {}, Q(s, { | |
isBrowser: z, | |
toUrl: function(e) { | |
var r, i = e.lastIndexOf("."), | |
o = e.split("/")[0]; | |
return -1 !== i && ("." !== o && ".." !== o || i > 1) && (r = e.substring(i, e.length), e = e.substring(0, i)), e = w.nameToUrl(n(e, t && t.id, !0), r || ".fake"), r ? e : e.substring(0, e.length - 5) | |
}, | |
defined: function(e) { | |
return r(j, u(e, t, !1, !0).id) | |
}, | |
specified: function(e) { | |
return e = u(e, t, !1, !0).id, r(j, e) || r(M, e) | |
} | |
}), t || (s.undef = function(e) { | |
f(); | |
var n = u(e, t, !0), | |
r = i(M, e); | |
delete j[e], delete N[n.url], delete A[e], r && (r.events.defined && (A[e] = r.events), delete M[e]) | |
}), s | |
}, | |
enable: function(t) { | |
i(M, t.id) && h(t).enable() | |
}, | |
completeLoad: function(t) { | |
var e, n, o = i(S.shim, t) || {}, a = o.exports; | |
for (f(); L.length;) { | |
if (n = L.shift(), null === n[0]) { | |
if (n[0] = t, e) break; | |
e = !0 | |
} else n[0] === t && (e = !0); | |
g(n) | |
} | |
if (n = i(M, t), !e && !r(j, t) && n && !n.inited) { | |
if (S.enforceDefine && (!a || !Z(a))) return s(t) ? void 0 : p(F("nodefine", "No define call for " + t, null, [t])); | |
g([t, o.deps || [], o.exportsFn]) | |
} | |
d() | |
}, | |
nameToUrl: function(t, e) { | |
var n, r, o, s, a, u; | |
if (l.jsExtRegExp.test(t)) s = t + (e || ""); | |
else { | |
for (n = S.paths, r = S.pkgs, s = t.split("/"), a = s.length; a > 0; a -= 1) { | |
if (u = s.slice(0, a).join("/"), o = i(r, u), u = i(n, u)) { | |
J(u) && (u = u[0]), s.splice(0, a, u); | |
break | |
} | |
if (o) { | |
n = t === o.name ? o.location + "/" + o.main : o.location, s.splice(0, a, n); | |
break | |
} | |
} | |
s = s.join("/"), s += e || (/\?/.test(s) ? "" : ".js"), s = ("/" === s.charAt(0) || s.match(/^[\w\+\.\-]+:/) ? "" : S.baseUrl) + s | |
} | |
return S.urlArgs ? s + ((-1 === s.indexOf("?") ? "?" : "&") + S.urlArgs) : s | |
}, | |
load: function(t, e) { | |
l.load(w, t, e) | |
}, | |
execCb: function(t, e, n, r) { | |
return e.apply(r, n) | |
}, | |
onScriptLoad: function(t) { | |
("load" === t.type || ha.test((t.currentTarget || t.srcElement).readyState)) && (P = null, t = y(t), w.completeLoad(t.id)) | |
}, | |
onScriptError: function(t) { | |
var e = y(t); | |
return s(e.id) ? void 0 : p(F("scripterror", "Script error", t, [e.id])) | |
} | |
}, w.require = w.makeRequire(), w | |
} | |
var l, w, B, D, s, H, P, K, ba, ca, ia = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/gm, | |
ja = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, | |
aa = /\.js$/, | |
ga = /^\.\//; | |
w = Object.prototype; | |
var L = w.toString, | |
da = w.hasOwnProperty, | |
fa = Array.prototype.splice, | |
z = !("undefined" == typeof window || !navigator || !document), | |
$ = !z && "undefined" != typeof importScripts, | |
ha = z && "PLAYSTATION 3" === navigator.platform ? /^complete$/ : /^(complete|loaded)$/, | |
V = "undefined" != typeof opera && "[object Opera]" == "" + opera, | |
C = {}, q = {}, R = [], | |
O = !1; | |
if (define === void 0) { | |
if (requirejs !== void 0) { | |
if (I(requirejs)) return; | |
q = requirejs, requirejs = void 0 | |
} | |
require !== void 0 && !I(require) && (q = require, require = void 0), l = requirejs = function(t, e, n, r) { | |
var o, s = "_"; | |
return !J(t) && "string" != typeof t && (o = t, J(e) ? (t = e, e = n, n = r) : t = []), o && o.context && (s = o.context), (r = i(C, s)) || (r = C[s] = l.s.newContext(s)), o && r.configure(o), r.require(t, e, n) | |
}, l.config = function(t) { | |
return l(t) | |
}, l.nextTick = "undefined" != typeof setTimeout ? function(t) { | |
setTimeout(t, 4) | |
} : function(t) { | |
t() | |
}, require || (require = l), l.version = "2.1.4", l.jsExtRegExp = /^\/|:|\?|\.js$/, l.isBrowser = z, w = l.s = { | |
contexts: C, | |
newContext: ea | |
}, l({}), x(["toUrl", "undef", "defined", "specified"], function(t) { | |
l[t] = function() { | |
var e = C._; | |
return e.require[t].apply(e, arguments) | |
} | |
}), z && (B = w.head = document.getElementsByTagName("head")[0], D = document.getElementsByTagName("base")[0]) && (B = w.head = D.parentNode), l.onError = function(t) { | |
throw t | |
}, l.load = function(t, e, n) { | |
var r, i = t && t.config || {}; | |
return z ? (r = i.xhtml ? document.createElementNS("http://www.w3.org/1999/xhtml", "html:script") : document.createElement("script"), r.type = i.scriptType || "text/javascript", r.charset = "utf-8", r.async = !0, r.setAttribute("data-requirecontext", t.contextName), r.setAttribute("data-requiremodule", e), !r.attachEvent || r.attachEvent.toString && 0 > ("" + r.attachEvent).indexOf("[native code") || V ? (r.addEventListener("load", t.onScriptLoad, !1), r.addEventListener("error", t.onScriptError, !1)) : (O = !0, r.attachEvent("onreadystatechange", t.onScriptLoad)), r.src = n, K = r, D ? B.insertBefore(r, D) : B.appendChild(r), K = null, r) : ($ && (importScripts(n), t.completeLoad(e)), void 0) | |
}, z && M(document.getElementsByTagName("script"), function(t) { | |
return B || (B = t.parentNode), (s = t.getAttribute("data-main")) ? (q.baseUrl || (H = s.split("/"), ba = H.pop(), ca = H.length ? H.join("/") + "/" : "./", q.baseUrl = ca, s = ba), s = s.replace(aa, ""), q.deps = q.deps ? q.deps.concat(s) : [s], !0) : void 0 | |
}), define = function(t, e, n) { | |
var r, i; | |
"string" != typeof t && (n = e, e = t, t = null), J(e) || (n = e, e = []), !e.length && I(n) && n.length && (("" + n).replace(ia, "").replace(ja, function(t, n) { | |
e.push(n) | |
}), e = (1 === n.length ? ["require"] : ["require", "exports", "module"]).concat(e)), O && ((r = K) || (P && "interactive" === P.readyState || M(document.getElementsByTagName("script"), function(t) { | |
return "interactive" === t.readyState ? P = t : void 0 | |
}), r = P), r && (t || (t = r.getAttribute("data-requiremodule")), i = C[r.getAttribute("data-requirecontext")])), (i ? i.defQueue : R).push([t, e, n]) | |
}, define.amd = { | |
jQuery: !0 | |
}, l.exec = function(b) { | |
return eval(b) | |
}, l(q) | |
} | |
})(this), define("lib/require.min.js", function() {}); | |
//Matrix | |
var geom; | |
(function(t) { | |
var e = function() { | |
function e(t, e, n, r, i, o) { | |
e === void 0 && (e = 0), n === void 0 && (n = 0), r === void 0 && (r = 0), i === void 0 && (i = 0), o === void 0 && (o = 0), t === void 0 && (t = 1, e = 0, n = 0, r = 1, i = 0, o = 0), this.a = t, this.b = e, this.c = n, this.d = r, this.tx = i, this.ty = o | |
} | |
return e.prototype.setTo = function(t, e, n, r, i, o) { | |
this.a = t, this.b = e, this.c = n, this.d = r, this.tx = i, this.ty = o | |
}, e.prototype.identity = function() { | |
this.a = 1, this.b = 0, this.c = 0, this.d = 1, this.tx = 0, this.ty = 0 | |
}, e.prototype.transformPoint = function(e) { | |
var n = new t.Point(e.x * this.a + e.y * this.c + this.tx, e.x * this.b + e.y * this.d + this.ty); | |
return n | |
}, e.prototype.translate = function(t, e) { | |
this.tx += t, this.ty += e | |
}, e.prototype.rotate = function(t) { | |
var n = Math.cos(t), | |
r = Math.sin(t), | |
i = new e(n, r, - r, n, 0, 0); | |
this.concat(i) | |
}, e.prototype.scale = function(t, n) { | |
var r = new e(t, 0, 0, n, 0, 0); | |
this.concat(r) | |
}, e.prototype.concat = function(t) { | |
this.copyFrom(new e(this.a * t.a + this.b * t.c, this.a * t.b + this.b * t.d, this.c * t.a + this.d * t.c, this.c * t.b + this.d * t.d, this.tx * t.a + this.ty * t.c + t.tx, this.tx * t.b + this.ty * t.d + t.ty)) | |
}, e.prototype.invert = function() { | |
var t = this.a * this.d - this.b * this.c; | |
this.copyFrom(new e(this.d / t, - this.b / t, - this.c / t, this.a / t, (this.c * this.ty - this.d * this.tx) / t, - ((this.a * this.ty - this.b * this.tx) / t))) | |
}, e.prototype.clone = function() { | |
var t = new e(this.a, this.b, this.c, this.d, this.tx, this.ty); | |
return t | |
}, e.prototype.copyFrom = function(t) { | |
this.a = t.a, this.b = t.b, this.c = t.c, this.d = t.d, this.tx = t.tx, this.ty = t.ty | |
}, e | |
}(); | |
t.Matrix = e | |
})(geom || (geom = {})); | |
//Point | |
var geom; | |
(function(t) { | |
var e = function() { | |
function t(t, e) { | |
t === void 0 && (t = 0), e === void 0 && (e = 0), this.x = t, this.y = e | |
} | |
return t.prototype.add = function(e) { | |
return new t(this.x + e.x, this.y + e.y) | |
}, t.prototype.subtract = function(e) { | |
return new t(this.x - e.x, this.y - e.y) | |
}, t.prototype.dot = function(t) { | |
return this.x * t.x + this.y * t.y | |
}, t.prototype.cross = function(t) { | |
return this.x * t.y - this.y * t.x | |
}, t.prototype.clone = function() { | |
return new t(this.x, this.y) | |
}, t.prototype.setTo = function(t, e) { | |
this.x = t, this.y = e | |
}, t.distance = function(t, e) { | |
return Math.sqrt((e.x - t.x) * (e.x - t.x) + (e.y - t.y) * (e.y - t.y)) | |
}, t | |
}(); | |
t.Point = e | |
})(geom || (geom = {})); | |
//Rectangle | |
var geom; | |
(function(t) { | |
var e = function() { | |
function e(t, e, n, r) { | |
t === void 0 && (t = 0), e === void 0 && (e = 0), n === void 0 && (n = 0), r === void 0 && (r = 0), this.setTo(t, e, n, r) | |
} | |
return e.prototype.setTo = function(t, e, n, r) { | |
t === void 0 && (t = 0), e === void 0 && (e = 0), n === void 0 && (n = 0), r === void 0 && (r = 0), this.x = t, this.y = e, this.width = n, this.height = r | |
}, Object.defineProperty(e.prototype, "bottom", { | |
get: function() { | |
return this.y + this.height | |
}, | |
set: function(t) { | |
null !== t && t !== void 0 && (this.height = t - this.y) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "bottomright", { | |
get: function() { | |
return new t.Point(this.right, this.bottom) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "left", { | |
set: function(t) { | |
null !== t && t !== void 0 && (this.width += this.x - t, this.x = t) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "right", { | |
get: function() { | |
return this.x + this.width | |
}, | |
set: function(t) { | |
null !== t && t !== void 0 && (this.width = t - this.x) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "size", { | |
get: function() { | |
return new t.Point(this.width, this.height) | |
}, | |
set: function() { | |
throw new errors.IllegalOperationError("Not yet implemented") | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "top", { | |
set: function(t) { | |
null !== t && t !== void 0 && (this.height += this.y - t, this.y = t) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "topLeft", { | |
get: function() { | |
return new t.Point(this.x, this.y) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e.prototype.clone = function() { | |
return new e(this.x, this.y, this.width, this.height) | |
}, e.prototype.contains = function(t, e) { | |
var n = t >= this.x && e >= this.y && this.right >= t && this.bottom >= e; | |
return n | |
}, e.prototype.containsPoint = function(t) { | |
return this.contains(t.x, t.y) | |
}, e.prototype.containsRect = function(t) { | |
var e = t.x >= this.x && t.y >= this.y && t.right <= this.right && t.bottom <= this.bottom; | |
return e | |
}, e.prototype.equals = function(t) { | |
var e = t.x === this.x && t.y === this.y && t.width === this.width && t.height === this.height; | |
return e | |
}, e.prototype.inflate = function(t, e) { | |
this.x -= t, this.y -= e, this.width += 2 * t, this.height += 2 * e | |
}, e.prototype.inflatePoint = function(t) { | |
this.inflate(t.x, t.y) | |
}, e.prototype.inclusiveRangeContains = function(t, e, n) { | |
var r = t >= e && n >= t; | |
return r | |
}, e.prototype.intersectRange = function(t, e, n, r) { | |
var i = Math.max(t, n); | |
if (!this.inclusiveRangeContains(i, t, e) || !this.inclusiveRangeContains(i, n, r)) return null; | |
var o = Math.min(e, r); | |
return this.inclusiveRangeContains(o, t, e) && this.inclusiveRangeContains(o, n, r) ? { | |
min: i, | |
max: o | |
} : null | |
}, e.prototype.intersection = function(t) { | |
var n = this.intersectRange(this.x, this.right, t.x, t.right); | |
if (!n) return null; | |
var r = this.intersectRange(this.y, this.bottom, t.y, t.bottom); | |
if (!r) return null; | |
var i = new e(n.min, r.min, n.max - n.min, r.max - r.min); | |
return i | |
}, e.prototype.intersects = function(t) { | |
var e = this.intersection(t); | |
return null !== e | |
}, e.prototype.isEmpty = function() { | |
return 0 >= this.width || 0 >= this.height | |
}, e.prototype.offset = function(t, e) { | |
this.x += t, this.y += e | |
}, e.prototype.offsetPoint = function(t) { | |
this.offset(t.x, t.y) | |
}, e.prototype.setEmpty = function() { | |
this.x = 0, this.y = 0, this.width = 0, this.height = 0 | |
}, e.prototype.toString = function() { | |
var t = "{"; | |
return t += '"x":' + this.x + ",", t += '"y":' + this.y + ",", t += '"width":' + this.width + ",", t += '"height":' + this.height + "}" | |
}, e.prototype.union = function(t) { | |
var n = Math.min(t.x, this.x), | |
r = Math.max(t.right, this.right), | |
i = Math.min(t.y, this.y), | |
o = Math.max(t.bottom, this.bottom), | |
s = new e(n, i, r - n, o - i); | |
return s | |
}, e | |
}(); | |
t.Rectangle = e | |
})(geom || (geom = {})); | |
//Matrix3D - TBD | |
var geom; | |
(function(t) { | |
var e = function() { | |
function t() {} | |
return t | |
}(); | |
t.Matrix3D = e | |
})(geom || (geom = {})); | |
//Events | |
var events; | |
(function(t) { | |
var e = function() { | |
function t(t, e, n) { | |
e === void 0 && (e = !1), n === void 0 && (n = null), this.mType = t, this.mBubbles = e, this.mData = n | |
} | |
return t.ADDED = "added", t.ADDED_TO_STAGE = "addedToStage", t.ENTER_FRAME = "enterFrame", t.REMOVED = "removed", t.REMOVED_FROM_STAGE = "removedFromStage", t.TRIGGERED = "triggered", t.FLATTEN = "flatten", t.RESIZE = "resize", t.COMPLETE = "complete", t.CONTEXT3D_CREATE = "context3DCreate", t.ROOT_CREATED = "rootCreated", t.REMOVE_FROM_JUGGLER = "removeFromJuggler", t.CHANGE = "change", t.CANCEL = "cancel", t.SCROLL = "scroll", t.OPEN = "open", t.CLOSE = "close", t.SELECT = "select", t.sEventPool = [], t.prototype.stopPropagation = function() { | |
this.mStopsPropagation = !0 | |
}, t.prototype.stopImmediatePropagation = function() { | |
this.mStopsPropagation = this.mStopsImmediatePropagation = !0 | |
}, t.prototype.toString = function() { | |
var t = utils.ClassUtil.getQualifiedClassName(this).split("::").pop(); | |
return utils.StringUtil.format('[{0} type="{1}" bubbles={2}]', t, this.mType, this.mBubbles) | |
}, Object.defineProperty(t.prototype, "bubbles", { | |
get: function() { | |
return this.mBubbles | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "target", { | |
get: function() { | |
return this.mTarget | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "currentTarget", { | |
get: function() { | |
return this.mCurrentTarget | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "type", { | |
get: function() { | |
return this.mType | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "data", { | |
get: function() { | |
return this.mData | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), t.prototype.setTarget = function(t) { | |
this.mTarget = t | |
}, t.prototype.setCurrentTarget = function(t) { | |
this.mCurrentTarget = t | |
}, t.prototype.setData = function(t) { | |
this.mData = t | |
}, Object.defineProperty(t.prototype, "stopsPropagation", { | |
get: function() { | |
return this.mStopsPropagation | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "stopsImmediatePropagation", { | |
get: function() { | |
return this.mStopsImmediatePropagation | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), t.fromPool = function(e, n, r) { | |
return n === void 0 && (n = !1), r === void 0 && (r = null), t.sEventPool.length ? t.sEventPool.pop().reset(e, n, r) : new t(e, n, r) | |
}, t.toPool = function(e) { | |
e.mData = e.mTarget = e.mCurrentTarget = null, t.sEventPool.push(e) | |
}, t.prototype.reset = function(t, e, n) { | |
return e === void 0 && (e = !1), n === void 0 && (n = null), this.mType = t, this.mBubbles = e, this.mData = n, this.mTarget = this.mCurrentTarget = null, this.mStopsPropagation = this.mStopsImmediatePropagation = !1, this | |
}, t | |
}(); | |
t.Event = e | |
})(events || (events = {})); | |
//Touch Events | |
var events; | |
(function(t) { | |
var e = function() { | |
function t(t, e, n, r, i) { | |
this.mID = t, this.mGlobalX = this.mPreviousGlobalX = e, this.mGlobalY = this.mPreviousGlobalY = n, this.mTapCount = 0, this.mPhase = r, this.mTarget = i, this.mPressure = this.mWidth = this.mHeight = 1, this.mBubbleChain = [], this.updateBubbleChain() | |
} | |
return t.sHelperMatrix = new geom.Matrix, t.prototype.getLocation = function(e, n) { | |
return n === void 0 && (n = null), null == n && (n = new geom.Point), e.base.getTransformationMatrix(e, t.sHelperMatrix), utils.MatrixUtil.transformCoords(t.sHelperMatrix, this.mGlobalX, this.mGlobalY, n) | |
}, t.prototype.getPreviousLocation = function(e, n) { | |
return n === void 0 && (n = null), null == n && (n = new geom.Point), e.base.getTransformationMatrix(e, t.sHelperMatrix), utils.MatrixUtil.transformCoords(t.sHelperMatrix, this.mPreviousGlobalX, this.mPreviousGlobalY, n) | |
}, t.prototype.getMovement = function(t, e) { | |
e === void 0 && (e = null), null == e && (e = new geom.Point), this.getLocation(t, e); | |
var n = e.x, | |
r = e.y; | |
return this.getPreviousLocation(t, e), e.setTo(n - e.x, r - e.y), e | |
}, t.prototype.isTouching = function(t) { | |
return -1 != this.mBubbleChain.indexOf(t) | |
}, t.prototype.toString = function() { | |
return utils.StringUtil.format("Touch {0}: globalX={1}, globalY={2}, phase={3}", this.mID, this.mGlobalX, this.mGlobalY, this.mPhase) | |
}, t.prototype.clone = function() { | |
var e = new t(this.mID, this.mGlobalX, this.mGlobalY, this.mPhase, this.mTarget); | |
return e.mPreviousGlobalX = this.mPreviousGlobalX, e.mPreviousGlobalY = this.mPreviousGlobalY, e.mTapCount = this.mTapCount, e.mTimestamp = this.mTimestamp, e.mPressure = this.mPressure, e.mWidth = this.mWidth, e.mHeight = this.mHeight, e | |
}, t.prototype.updateBubbleChain = function() { | |
if (this.mTarget) { | |
var t = 1, | |
e = this.mTarget; | |
for (this.mBubbleChain.length = 1, this.mBubbleChain[0] = e; null != (e = e.parent);) this.mBubbleChain[t++] = e | |
} else this.mBubbleChain.length = 0 | |
}, Object.defineProperty(t.prototype, "id", { | |
get: function() { | |
return this.mID | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "globalX", { | |
get: function() { | |
return this.mGlobalX | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "globalY", { | |
get: function() { | |
return this.mGlobalY | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "previousGlobalX", { | |
get: function() { | |
return this.mPreviousGlobalX | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "previousGlobalY", { | |
get: function() { | |
return this.mPreviousGlobalY | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "tapCount", { | |
get: function() { | |
return this.mTapCount | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "phase", { | |
get: function() { | |
return this.mPhase | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "target", { | |
get: function() { | |
return this.mTarget | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "timestamp", { | |
get: function() { | |
return this.mTimestamp | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "pressure", { | |
get: function() { | |
return this.mPressure | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "width", { | |
get: function() { | |
return this.mWidth | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "height", { | |
get: function() { | |
return this.mHeight | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), t.prototype.dispatchEvent = function(t) { | |
this.mTarget && t.dispatch(this.mBubbleChain) | |
}, Object.defineProperty(t.prototype, "bubbleChain", { | |
get: function() { | |
return this.mBubbleChain.concat() | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), t.prototype.setTarget = function(t) { | |
this.mTarget = t, this.updateBubbleChain() | |
}, t.prototype.setPosition = function(t, e) { | |
this.mPreviousGlobalX = this.mGlobalX, this.mPreviousGlobalY = this.mGlobalY, this.mGlobalX = t, this.mGlobalY = e | |
}, t.prototype.setSize = function(t, e) { | |
this.mWidth = t, this.mHeight = e | |
}, t.prototype.setPhase = function(t) { | |
this.mPhase = t | |
}, t.prototype.setTapCount = function(t) { | |
this.mTapCount = t | |
}, t.prototype.setTimestamp = function(t) { | |
this.mTimestamp = t | |
}, t.prototype.setPressure = function(t) { | |
this.mPressure = t | |
}, t | |
}(); | |
t.Touch = e | |
})(events || (events = {})); | |
// | |
var __extends = this.__extends || function(t, e) { | |
function n() { | |
this.constructor = t | |
} | |
n.prototype = e.prototype, t.prototype = new n | |
}, events; | |
//Touch Events | |
(function(t) { | |
var e = function(e) { | |
function n(t, n, r, i, o) { | |
r === void 0 && (r = !1), i === void 0 && (i = !1), o === void 0 && (o = !0), e.call(this, t, o, n), this.mShiftKey = r, this.mCtrlKey = i, this.mTimestamp = -1, this.mVisitedObjects = []; | |
for (var s = n.length, a = 0; s > a; ++a) n[a].timestamp > this.mTimestamp && (this.mTimestamp = n[a].timestamp) | |
} | |
return __extends(n, e), n.TOUCH = "touch", n.sTouches = [], n.prototype.getTouches = function(t, e, n) { | |
e === void 0 && (e = null), n === void 0 && (n = null), null == n && (n = []); | |
for (var r = this.data, i = r.length, o = 0; i > o; ++o) { | |
var s = r[o], | |
a = s.isTouching(t), | |
u = null == e || e == s.phase; | |
a && u && n.push(s) | |
} | |
return n | |
}, n.prototype.getTouch = function(t, e) { | |
if (e === void 0 && (e = null), this.getTouches(t, e, n.sTouches), n.sTouches.length) { | |
var r = n.sTouches[0]; | |
return n.sTouches.length = 0, r | |
} | |
return null | |
}, n.prototype.interactsWith = function(e) { | |
if (null == this.getTouch(e)) return !1; | |
for (var n = this.getTouches(e), r = n.length - 1; r >= 0; --r) if (n[r].phase != t.TouchPhase.ENDED) return !0; | |
return !1 | |
}, n.prototype.dispatch = function(t) { | |
if (t && t.length) { | |
var e = this.bubbles ? t.length : 1, | |
n = this.target; | |
this.setTarget(t[0]); | |
for (var r = 0; e > r; ++r) { | |
var i = t[r]; | |
if (-1 == this.mVisitedObjects.indexOf(i)) { | |
var o = i.invokeEvent(this); | |
if (this.mVisitedObjects.push(i), o) break | |
} | |
} | |
this.setTarget(n) | |
} | |
}, Object.defineProperty(n.prototype, "timestamp", { | |
get: function() { | |
return this.mTimestamp | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "touches", { | |
get: function() { | |
return this.data.concat() | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "shiftKey", { | |
get: function() { | |
return this.mShiftKey | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "ctrlKey", { | |
get: function() { | |
return this.mCtrlKey | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), n | |
}(t.Event); | |
t.TouchEvent = e | |
})(events || (events = {})); | |
//Touch Phase | |
var events; | |
(function(t) { | |
var e = function() { | |
function t() { | |
throw new errors.AbstractClassError | |
} | |
return t.HOVER = "hover", t.BEGAN = "began", t.MOVED = "moved", t.STATIONARY = "stationary", t.ENDED = "ended", t | |
}(); | |
t.TouchPhase = e | |
})(events || (events = {})); | |
//Keyboard Events | |
var events; | |
(function(t) { | |
var e = function(t) { | |
function e(e, n, r, i, o, s, a) { | |
n === void 0 && (n = 0), r === void 0 && (r = 0), i === void 0 && (i = 0), o === void 0 && (o = !1), s === void 0 && (s = !1), a === void 0 && (a = !1), t.call(this, e, !1, r), this.mCharCode = n, this.mKeyCode = r, this.mKeyLocation = i, this.mCtrlKey = o, this.mAltKey = s, this.mShiftKey = a | |
} | |
return __extends(e, t), e.KEY_UP = "keyup", e.KEY_DOWN = "keydown", Object.defineProperty(e.prototype, "charCode", { | |
get: function() { | |
return this.mCharCode | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "keyCode", { | |
get: function() { | |
return this.mKeyCode | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "keyLocation", { | |
get: function() { | |
return this.mKeyLocation | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "altKey", { | |
get: function() { | |
return this.mAltKey | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "ctrlKey", { | |
get: function() { | |
return this.mCtrlKey | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "shiftKey", { | |
get: function() { | |
return this.mShiftKey | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e | |
}(t.Event); | |
t.KeyboardEvent = e | |
})(events || (events = {})); | |
//EnterFrame Event | |
var events; | |
(function(t) { | |
var e = function(t) { | |
function e(e, n, r) { | |
r === void 0 && (r = !1), t.call(this, e, r, n) | |
} | |
return __extends(e, t), e.ENTER_FRAME = "enterFrame", Object.defineProperty(e.prototype, "passedTime", { | |
get: function() { | |
return this.data | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e | |
}(t.Event); | |
t.EnterFrameEvent = e | |
})(events || (events = {})); | |
//Event Dispatcher | |
var events; | |
(function(t) { | |
var e = function() { | |
function t(t, e) { | |
this.context = e, this.fn = t | |
} | |
return t | |
}(); | |
t.EventListener = e; | |
var n = function() { | |
function e() {} | |
return e.sBubbleChains = [], e.prototype.addEventListener = function(e, n, r) { | |
r === void 0 && (r = null), null == this.mEventListeners && (this.mEventListeners = {}); | |
var i = this.mEventListeners[e], | |
o = new t.EventListener(n, r || this); | |
null == i ? this.mEventListeners[e] = [o] : -1 === this.findEventListener(e, n, r || this) && i.push(o) | |
}, e.prototype.removeEventListener = function(t, e, n) { | |
if (n === void 0 && (n = null), this.mEventListeners) { | |
var r = this.mEventListeners[t]; | |
if (r) { | |
for (var i = r.length, o = [], s = 0; i > s; ++s) { | |
var a = r[s]; | |
(a.context !== (n || this) || a.fn !== e) && o.push(a) | |
} | |
this.mEventListeners[t] = o | |
} | |
} | |
}, e.prototype.findEventListener = function(t, e, n) { | |
n === void 0 && (n = null); | |
var r = this.mEventListeners[t]; | |
if (null != r) for (var i = 0; r.length > i; i++) { | |
var o = r[i]; | |
if (o.context === n && o.fn === e) return i | |
} | |
return -1 | |
}, e.prototype.removeEventListeners = function(t) { | |
t === void 0 && (t = null), t && this.mEventListeners ? delete this.mEventListeners[t] : this.mEventListeners = null | |
}, e.prototype.dispatchEvent = function(t) { | |
var e = t.bubbles; | |
if (e || null != this.mEventListeners && t.type in this.mEventListeners) { | |
var n = t.target; | |
t.setTarget(this), e && this instanceof display.DisplayObject ? this.bubbleEvent(t) : this.invokeEvent(t), n && t.setTarget(n) | |
} | |
}, e.prototype.invokeEvent = function(t) { | |
var e = this.mEventListeners ? this.mEventListeners[t.type] : null, | |
n = null == e ? 0 : e.length; | |
if (n) { | |
t.setCurrentTarget(this); | |
for (var r = 0; n > r; ++r) { | |
var i = e[r], | |
o = i.fn, | |
s = i.context; | |
if (o.apply(s, [t, t.data]), t.stopsImmediatePropagation) return !0 | |
} | |
return t.stopsPropagation | |
} | |
return !1 | |
}, e.prototype.bubbleEvent = function(t) { | |
var n, r = this, | |
i = 1; | |
for (e.sBubbleChains.length > 0 ? (n = e.sBubbleChains.pop(), n[0] = r) : n = [r]; null != (r = r.parent);) n[i++] = r; | |
for (var o = 0; i > o; ++o) { | |
var s = n[o].invokeEvent(t); | |
if (s) break | |
} | |
n.length = 0, e.sBubbleChains.push(n) | |
}, e.prototype.dispatchEventWith = function(e, n, r) { | |
if (n === void 0 && (n = !1), r === void 0 && (r = null), n || this.hasEventListener(e)) { | |
var i = t.Event.fromPool(e, n, r); | |
this.dispatchEvent(i), t.Event.toPool(i) | |
} | |
}, e.prototype.hasEventListener = function(t) { | |
var e = this.mEventListeners ? this.mEventListeners[t] : null; | |
return e ? 0 != e.length : !1 | |
}, e | |
}(); | |
t.EventDispatcher = n | |
})(events || (events = {})); | |
//DisplayObject | |
var display; | |
(function(t) { | |
var e = function(e) { | |
function n() { | |
e.call(this), this.mX = this.mY = this.mPivotX = this.mPivotY = this.mRotation = this.mSkewX = this.mSkewY = 0, this.mScaleX = this.mScaleY = this.mAlpha = 1, this.mVisible = this.mTouchable = !0, this.mBlendMode = t.BlendMode.AUTO, this.mTransformationMatrix = new geom.Matrix, this.mOrientationChanged = this.mUseHandCursor = !1 | |
} | |
return __extends(n, e), n.sAncestors = [], n.sHelperRect = new geom.Rectangle, n.sHelperMatrix = new geom.Matrix, n.prototype.dispose = function() { | |
this.mFilter && this.mFilter.dispose(), this.removeEventListeners(null) | |
}, n.prototype.removeFromParent = function(t) { | |
t === void 0 && (t = !1), this.mParent && this.mParent.removeChild(this, t) | |
}, n.prototype.getTransformationMatrix = function(t, e) { | |
e === void 0 && (e = null); | |
var r, i; | |
if (e ? e.identity() : e = new geom.Matrix, t === this) return e; | |
if (t === this.mParent || null == t && null == this.mParent) return e.copyFrom(this.transformationMatrix), e; | |
if (null == t || t === this.base) { | |
for (i = this; i != t;) e.concat(i.transformationMatrix), i = i.mParent; | |
return e | |
} | |
if (t.mParent === this) return t.getTransformationMatrix(this, e), e.invert(), e; | |
for (r = null, i = this; i;) n.sAncestors.push(i), i = i.mParent; | |
for (i = t; i && -1 === n.sAncestors.indexOf(i);) i = i.mParent; | |
if (n.sAncestors.length = 0, !i) throw new errors.ArgumentError("Object not connected to target"); | |
for (r = i, i = this; i != r;) e.concat(i.transformationMatrix), i = i.mParent; | |
if (r === t) return e; | |
for (n.sHelperMatrix.identity(), i = t; i != r;) n.sHelperMatrix.concat(i.transformationMatrix), i = i.mParent; | |
return n.sHelperMatrix.invert(), e.concat(n.sHelperMatrix), e | |
}, n.prototype.getBounds = function(t, e) { | |
throw e === void 0 && (e = null), new errors.AbstractMethodError("Method needs to be implemented in subclass") | |
}, n.prototype.hitTest = function(t, e) { | |
return e === void 0 && (e = !1), !e || this.mVisible && this.mTouchable ? this.getBounds(this, n.sHelperRect).containsPoint(t) ? this : null : null | |
}, n.prototype.localToGlobal = function(t, e) { | |
e === void 0 && (e = null), this.getTransformationMatrix(this.base, n.sHelperMatrix); | |
var r = utils.MatrixUtil.transformCoords(n.sHelperMatrix, t.x, t.y, e); | |
return r | |
}, n.prototype.globalToLocal = function(t, e) { | |
return e === void 0 && (e = null), this.getTransformationMatrix(this.base, n.sHelperMatrix), n.sHelperMatrix.invert(), utils.MatrixUtil.transformCoords(n.sHelperMatrix, t.x, t.y, e) | |
}, n.prototype.render = function() { | |
throw new errors.AbstractMethodError("Method needs to be implemented in subclass") | |
}, Object.defineProperty(n.prototype, "hasVisibleArea", { | |
get: function() { | |
return 0 != this.mAlpha && this.mVisible && 0 != this.mScaleX && 0 != this.mScaleY | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), n.prototype.setParent = function(t) { | |
for (var e = t; e != this && null != e;) e = e.mParent; | |
if (e === this) throw new errors.ArgumentError("An object cannot be <a>added child to itself or one of its children (or children's children, etc.)"); | |
this.mParent = t | |
}, n.isEquivalent = function(t, e, n) { | |
return n === void 0 && (n = 1e-4), e > t - n && t + n > e | |
}, n.normalizeAngle = function(t) { | |
for (; - Math.PI > t;) t += 2 * Math.PI; | |
for (; t > Math.PI;) t -= 2 * Math.PI; | |
return t | |
}, Object.defineProperty(n.prototype, "transformationMatrix", { | |
get: function() { | |
return this.mOrientationChanged && (this.mOrientationChanged = !1, this.mTransformationMatrix.identity(), (1 != this.mScaleX || 1 != this.mScaleY) && this.mTransformationMatrix.scale(this.mScaleX, this.mScaleY), (0 != this.mSkewX || 0 != this.mSkewY) && utils.MatrixUtil.skew(this.mTransformationMatrix, this.mSkewX, this.mSkewY), 0 != this.mRotation && this.mTransformationMatrix.rotate(this.mRotation), (0 != this.mX || 0 != this.mY) && this.mTransformationMatrix.translate(this.mX, this.mY), (0 != this.mPivotX || 0 != this.mPivotY) && (this.mTransformationMatrix.tx = this.mX - this.mTransformationMatrix.a * this.mPivotX - this.mTransformationMatrix.c * this.mPivotY, this.mTransformationMatrix.ty = this.mY - this.mTransformationMatrix.b * this.mPivotX - this.mTransformationMatrix.d * this.mPivotY)), this.mTransformationMatrix | |
}, | |
set: function(t) { | |
this.mOrientationChanged = !1, this.mTransformationMatrix.copyFrom(t), this.mX = t.tx, this.mY = t.ty, this.mScaleX = Math.sqrt(t.a * t.a + t.b * t.b), this.mSkewY = Math.acos(t.a / this.mScaleX), n.isEquivalent(t.b, this.mScaleX * Math.sin(this.mSkewY)) || (this.mScaleX *= -1, this.mSkewY = Math.acos(t.a / this.mScaleX)), this.mScaleY = Math.sqrt(t.c * t.c + t.d * t.d), this.mSkewX = Math.acos(t.d / this.mScaleY), n.isEquivalent(t.c, - this.mScaleY * Math.sin(this.mSkewX)) || (this.mScaleY *= -1, this.mSkewX = Math.acos(t.d / this.mScaleY)), n.isEquivalent(this.mSkewX, this.mSkewY) ? (this.mRotation = this.mSkewX, this.mSkewX = this.mSkewY = 0) : this.mRotation = 0 | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "useHandCursor", { | |
get: function() { | |
return this.mUseHandCursor | |
}, | |
set: function(t) { | |
t !== this.mUseHandCursor && (this.mUseHandCursor = t) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), n.prototype.onTouch = function() {}, Object.defineProperty(n.prototype, "bounds", { | |
get: function() { | |
return this.getBounds(this.mParent) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "width", { | |
get: function() { | |
return this.getBounds(this.mParent, n.sHelperRect).width | |
}, | |
set: function(t) { | |
this.scaleX = 1; | |
var e = this.width; | |
0 != e && (this.scaleX = t / e) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "height", { | |
get: function() { | |
return this.getBounds(this.mParent, n.sHelperRect).height | |
}, | |
set: function(t) { | |
this.scaleY = 1; | |
var e = this.height; | |
0 != e && (this.scaleY = t / e) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "x", { | |
get: function() { | |
return this.mX | |
}, | |
set: function(t) { | |
this.mX != t && (this.mX = t, this.mOrientationChanged = !0) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "y", { | |
get: function() { | |
return this.mY | |
}, | |
set: function(t) { | |
this.mY != t && (this.mY = t, this.mOrientationChanged = !0) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "pivotX", { | |
get: function() { | |
return this.mPivotX | |
}, | |
set: function(t) { | |
this.mPivotX != t && (this.mPivotX = t, this.mOrientationChanged = !0) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "pivotY", { | |
get: function() { | |
return this.mPivotY | |
}, | |
set: function(t) { | |
this.mPivotY != t && (this.mPivotY = t, this.mOrientationChanged = !0) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "scaleX", { | |
get: function() { | |
return this.mScaleX | |
}, | |
set: function(t) { | |
this.mScaleX != t && (this.mScaleX = t, this.mOrientationChanged = !0) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "scaleY", { | |
get: function() { | |
return this.mScaleY | |
}, | |
set: function(t) { | |
this.mScaleY != t && (this.mScaleY = t, this.mOrientationChanged = !0) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "skewX", { | |
get: function() { | |
return this.mSkewX | |
}, | |
set: function(t) { | |
t = n.normalizeAngle(t), this.mSkewX != t && (this.mSkewX = t, this.mOrientationChanged = !0) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "skewY", { | |
get: function() { | |
return this.mSkewY | |
}, | |
set: function(t) { | |
t = n.normalizeAngle(t), this.mSkewY != t && (this.mSkewY = t, this.mOrientationChanged = !0) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "rotation", { | |
get: function() { | |
return this.mRotation | |
}, | |
set: function(t) { | |
t = n.normalizeAngle(t), this.mRotation != t && (this.mRotation = t, this.mOrientationChanged = !0) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "alpha", { | |
get: function() { | |
return this.mAlpha | |
}, | |
set: function(t) { | |
this.mAlpha = 0 > t ? 0 : t > 1 ? 1 : t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "visible", { | |
get: function() { | |
return this.mVisible | |
}, | |
set: function(t) { | |
this.mVisible = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "touchable", { | |
get: function() { | |
return this.mTouchable | |
}, | |
set: function(t) { | |
this.mTouchable = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "blendMode", { | |
get: function() { | |
return this.mBlendMode | |
}, | |
set: function(t) { | |
this.mBlendMode = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "name", { | |
get: function() { | |
return this.mName | |
}, | |
set: function(t) { | |
this.mName = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "filter", { | |
get: function() { | |
return this.mFilter | |
}, | |
set: function(t) { | |
this.mFilter = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "parent", { | |
get: function() { | |
return this.mParent | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "base", { | |
get: function() { | |
for (var t = this; t.mParent;) t = t.mParent; | |
return t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "root", { | |
get: function() { | |
for (var e = this; e.mParent;) { | |
if (e.mParent instanceof t.Stage) return e; | |
e = e.parent | |
} | |
return null | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "stage", { | |
get: function() { | |
var e = this.base; | |
return e instanceof t.Stage ? e : null | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), n | |
}(events.EventDispatcher); | |
t.DisplayObject = e | |
})(display || (display = {})); | |
//DisplayObjectContainer | |
var display; | |
(function(t) { | |
var e = function(t) { | |
function e() { | |
t.call(this), this.mChildren = [] | |
} | |
return __extends(e, t), e.sHelperMatrix = new geom.Matrix, e.sHelperPoint = new geom.Point, e.sBroadcastListeners = [], e.prototype.dispose = function() { | |
for (var e = this.mChildren.length - 1; e >= 0; --e) this.mChildren[e].dispose(); | |
t.prototype.dispose.call(this) | |
}, e.prototype.addChild = function(t) { | |
return this.addChildAt(t, this.numChildren), t | |
}, e.prototype.addChildAt = function(t, n) { | |
var r = this.mChildren.length; | |
if (n >= 0 && r >= n) { | |
if (t.removeFromParent(), n == r ? this.mChildren.push(t) : this.mChildren.splice(n, 0, t), t.setParent(this), t.dispatchEventWith(events.Event.ADDED, !0), this.stage) { | |
var i = t; | |
t instanceof e ? i.broadcastEventWith(events.Event.ADDED_TO_STAGE) : t.dispatchEventWith(events.Event.ADDED_TO_STAGE) | |
} | |
return t | |
} | |
throw new RangeError("Invalid child index") | |
}, e.prototype.removeChild = function(t, e) { | |
e === void 0 && (e = !1); | |
var n = this.getChildIndex(t); | |
return -1 != n && this.removeChildAt(n, e), t | |
}, e.prototype.removeChildAt = function(t, n) { | |
if (n === void 0 && (n = !1), t >= 0 && this.numChildren > t) { | |
var r = this.mChildren[t]; | |
if (r.dispatchEventWith(events.Event.REMOVED, !0), this.stage) { | |
var i = r; | |
r instanceof e ? i.broadcastEventWith(events.Event.REMOVED_FROM_STAGE) : r.dispatchEventWith(events.Event.REMOVED_FROM_STAGE) | |
} | |
return r.setParent(null), t = this.mChildren.indexOf(r), t >= 0 && this.mChildren.splice(t, 1), n && r.dispose(), r | |
} | |
throw new RangeError("Invalid child index") | |
}, e.prototype.removeChildren = function(t, e, n) { | |
t === void 0 && (t = 0), e === void 0 && (e = -1), n === void 0 && (n = !1), (0 > e || e >= this.numChildren) && (e = this.numChildren - 1); | |
for (var r = t; e >= r; ++r) this.removeChildAt(t, n) | |
}, e.prototype.getChildAt = function(t) { | |
if (t >= 0 && this.numChildren > t) return this.mChildren[t]; | |
throw new RangeError("Invalid child index") | |
}, e.prototype.getChildByName = function(t) { | |
for (var e = this.mChildren.length, n = 0; e > n; ++n) if (this.mChildren[n].name == t) return this.mChildren[n]; | |
return null | |
}, e.prototype.getChildIndex = function(t) { | |
return this.mChildren.indexOf(t) | |
}, e.prototype.setChildIndex = function(t, e) { | |
var n = this.getChildIndex(t); | |
if (-1 == n) throw new errors.ArgumentError("Not a child of this container"); | |
this.mChildren.splice(n, 1), this.mChildren.splice(e, 0, t) | |
}, e.prototype.swapChildren = function(t, e) { | |
var n = this.getChildIndex(t), | |
r = this.getChildIndex(e); | |
if (-1 == n || -1 == r) throw new errors.ArgumentError("Not a child of this container"); | |
this.swapChildrenAt(n, r) | |
}, e.prototype.swapChildrenAt = function(t, e) { | |
var n = this.getChildAt(t), | |
r = this.getChildAt(e); | |
this.mChildren[t] = r, this.mChildren[e] = n | |
}, e.prototype.sortChildren = function(t) { | |
this.mChildren.sort(t) | |
}, e.prototype.contains = function(t) { | |
for (; t;) { | |
if (t == this) return !0; | |
t = t.parent | |
} | |
return !1 | |
}, e.prototype.getBounds = function(t, n) { | |
n === void 0 && (n = null), null == n && (n = new geom.Rectangle); | |
var r = this.mChildren.length; | |
if (0 == r) return this.getTransformationMatrix(t, e.sHelperMatrix), utils.MatrixUtil.transformCoords(e.sHelperMatrix, 0, 0, e.sHelperPoint), n.setTo(e.sHelperPoint.x, e.sHelperPoint.y, 0, 0), n; | |
if (1 == r) return this.mChildren[0].getBounds(t, n); | |
for (var i = Number.MAX_VALUE, o = -Number.MAX_VALUE, s = Number.MAX_VALUE, a = -Number.MAX_VALUE, u = 0; r > u; ++u) this.mChildren[u].getBounds(t, n), i = n.x > i ? i : n.x, o = o > n.right ? o : n.right, s = n.y > s ? s : n.y, a = a > n.bottom ? a : n.bottom; | |
return n.setTo(i, s, o - i, a - s), n | |
}, e.prototype.hitTest = function(t, n) { | |
if (n === void 0 && (n = !1), n && (!this.visible || !this.touchable)) return null; | |
for (var r = t.x, i = t.y, o = this.mChildren.length, s = o - 1; s >= 0; --s) { | |
var a = this.mChildren[s]; | |
this.getTransformationMatrix(a, e.sHelperMatrix), utils.MatrixUtil.transformCoords(e.sHelperMatrix, r, i, e.sHelperPoint); | |
var u = a.hitTest(e.sHelperPoint, n); | |
if (u) return u | |
} | |
return null | |
}, e.prototype.render = function(t, e) { | |
for (var n = e * this.alpha, r = this.mChildren.length, i = t.blendMode, o = 0; r > o; ++o) { | |
var s = this.mChildren[o]; | |
if (s.hasVisibleArea) { | |
var a = s.filter; | |
t.pushMatrix(), t.transformMatrix(s), t.blendMode = s.blendMode, a ? a.render(s, t, n) : s.render(t, n), t.blendMode = i, t.popMatrix() | |
} | |
} | |
}, e.prototype.broadcastEvent = function(t) { | |
if (t.bubbles) throw new errors.ArgumentError("Broadcast of bubbling events is prohibited"); | |
e.sBroadcastListeners; | |
var n = e.sBroadcastListeners.length; | |
this.getChildEventListeners(this, t.type, e.sBroadcastListeners); | |
for (var r = e.sBroadcastListeners.length, i = n; r > i; ++i) e.sBroadcastListeners[i].dispatchEvent(t); | |
e.sBroadcastListeners.length = n | |
}, e.prototype.broadcastEventWith = function(t, e) { | |
e === void 0 && (e = null); | |
var n = events.Event.fromPool(t, !1, e); | |
this.broadcastEvent(n), events.Event.toPool(n) | |
}, e.prototype.getChildEventListeners = function(t, e, n) { | |
var r = t; | |
if (t.hasEventListener(e) && n.push(t), r && r.mChildren) for (var i = r.mChildren, o = i.length, s = 0; o > s; ++s) this.getChildEventListeners(i[s], e, n) | |
}, Object.defineProperty(e.prototype, "numChildren", { | |
get: function() { | |
return this.mChildren.length | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e | |
}(t.DisplayObject); | |
t.DisplayObjectContainer = e | |
})(display || (display = {})); | |
//Quad | |
var display; | |
(function(t) { | |
var e = function(t) { | |
function e(e, n, r, i) { | |
if (r === void 0 && (r = 16777215), i === void 0 && (i = !0), t.call(this), null == e || null == n) throw new errors.ArgumentError('Either "width" or "height" is undefined: ' + e + ", " + n); | |
this.mTinted = 16777215 != r, this.mWidth = e, this.mHeight = n, this.mColor = r | |
} | |
return __extends(e, t), e.sHelperPoint = new geom.Point, e.sHelperMatrix = new geom.Matrix, e.prototype.getBounds = function(t, n) { | |
return n === void 0 && (n = null), null == n && (n = new geom.Rectangle), t === this ? n.setTo(0, 0, this.mWidth, this.mHeight) : (this.getTransformationMatrix(t, e.sHelperMatrix), this.getTransformedBounds(e.sHelperMatrix, n)), n | |
}, e.prototype.getTransformedBounds = function(t, n) { | |
t === void 0 && (t = null), n === void 0 && (n = null), null == n && (n = new geom.Rectangle); | |
var r, i, o, s, a = Number.MAX_VALUE, | |
u = -Number.MAX_VALUE, | |
h = Number.MAX_VALUE, | |
l = -Number.MAX_VALUE; | |
if (null == t && 0 === this.rotation) a = this.x, h = this.y, u = this.x + this.mWidth, l = this.y + this.mHeight; | |
else { | |
var c = this.mWidth, | |
p = this.mHeight, | |
r = 0, | |
i = 0, | |
f = e.sHelperPoint, | |
m = [r, i, r + c, i, r + c, i + p, r, i + p]; | |
for (o = 0, s = 0; 4 > o; o++) r = m[s], i = m[s + 1], s += 2, utils.MatrixUtil.transformCoords(t, r, i, f), a = f.x > a ? a : f.x, u = u > f.x ? u : f.x, h = f.y > h ? h : f.y, l = l > f.y ? l : f.y | |
} | |
return n.setTo(a, h, u - a, l - h), n | |
}, Object.defineProperty(e.prototype, "color", { | |
get: function() { | |
return this.mColor | |
}, | |
set: function(t) { | |
this.mColor = t, (16777215 != t || 1 != this.alpha) && (this.mTinted = !0) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "alpha", { | |
get: function() { | |
return Object.getOwnPropertyDescriptor(t.prototype, "alpha").get.call(this) | |
}, | |
set: function(e) { | |
Object.getOwnPropertyDescriptor(t.prototype, "alpha").set.call(this, e), 1 > e && (this.mTinted = !0) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e.prototype.render = function(t) { | |
var e = core.Starling.context; | |
e.save(); | |
var n = t.mvpMatrix; | |
e.setTransform(n.a, n.b, n.c, n.d, n.tx, n.ty), e.fillStyle = "#" + Number(this.mColor).toString(16), this.renderTransformed(t, e), e.restore() | |
}, e.prototype.renderTransformed = function(t, e) { | |
e.fillRect(0, 0, this.mWidth, this.mHeight) | |
}, Object.defineProperty(e.prototype, "tinted", { | |
get: function() { | |
return this.mTinted | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e | |
}(t.DisplayObject); | |
t.Quad = e | |
})(display || (display = {})); | |
//SimpleImage | |
var display; | |
(function(t) { | |
var e = function(t) { | |
function e(e) { | |
t.call(this, e.width, e.height, 16777215, !1), this.mSourceReady = !1, this.mSource = e | |
} | |
return __extends(e, t), e.prototype.renderTransformed = function(t, e) { | |
return this.mSourceReady || (this.mSourceReady = this.mSource.isComplete()), this.mSourceReady ? (e.drawImage(this.mSource.image, 0, 0), void 0) : (this.mSource || console.log("[WARN] Cannot render because image source is not available yet."), void 0) | |
}, e.prototype.readjustSize = function() { | |
var t = this.mSource; | |
if (null == t.width || null == t.height) throw new errors.IllegalOperationError('Cannot readjust size when texture has no "width" or "height"'); | |
this.width = t.width, this.height = t.height | |
}, Object.defineProperty(e.prototype, "texture", { | |
get: function() { | |
return this.mSource | |
}, | |
set: function(t) { | |
if (null == t) throw new errors.ArgumentError("Texture cannot be null"); | |
t != this.mSource && (this.mSource = t, this.readjustSize()) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e | |
}(t.Quad); | |
t.SimpleImage = e | |
})(display || (display = {})); | |
//MovieClip | |
var display; | |
(function(t) { | |
var e = function(t) { | |
function e(e, n) { | |
if (n === void 0 && (n = 12), !(e.length > 0)) throw new errors.ArgumentError("Empty texture array"); | |
t.call(this, e[0]), this.init(e, n) | |
} | |
return __extends(e, t), e.prototype.init = function(t, e) { | |
if (0 >= e) throw new errors.ArgumentError("Invalid fps: " + e); | |
var n = t.length; | |
this.mDefaultFrameDuration = 1 / e, this.mLoop = !0, this.mPlaying = !0, this.mCurrentTime = 0, this.mCurrentFrame = 0, this.mTotalTime = this.mDefaultFrameDuration * n, this.mTextures = t.concat(), this.mSounds = Array(n), this.mDurations = Array(n), this.mStartTimes = Array(n); | |
for (var r = 0; n > r; ++r) this.mDurations[r] = this.mDefaultFrameDuration, this.mStartTimes[r] = r * this.mDefaultFrameDuration | |
}, e.prototype.addFrame = function(t, e, n) { | |
e === void 0 && (e = null), n === void 0 && (n = -1), this.addFrameAt(this.numFrames, t, e, n) | |
}, e.prototype.addFrameAt = function(t, e, n, r) { | |
if (n === void 0 && (n = null), r === void 0 && (r = -1), 0 > t || t > this.numFrames) throw new errors.ArgumentError("Invalid frame id"); | |
0 > r && (r = this.mDefaultFrameDuration), this.mTextures.splice(t, 0, e), this.mSounds.splice(t, 0, n), this.mDurations.splice(t, 0, r), this.mTotalTime += r, t > 0 && t == this.numFrames ? this.mStartTimes[t] = this.mStartTimes[t - 1] + this.mDurations[t - 1] : this.updateStartTimes() | |
}, e.prototype.removeFrameAt = function(t) { | |
if (0 > t || t >= this.numFrames) throw new errors.ArgumentError("Invalid frame id"); | |
if (1 == this.numFrames) throw new errors.IllegalOperationError("Movie clip must not be empty"); | |
this.mTotalTime -= this.getFrameDuration(t), this.mTextures.splice(t, 1), this.mSounds.splice(t, 1), this.mDurations.splice(t, 1), this.updateStartTimes() | |
}, e.prototype.getFrameTexture = function(t) { | |
if (0 > t || t >= this.numFrames) throw new errors.ArgumentError("Invalid frame id"); | |
return this.mTextures[t] | |
}, e.prototype.setFrameTexture = function(t, e) { | |
if (0 > t || t >= this.numFrames) throw new errors.ArgumentError("Invalid frame id"); | |
this.mTextures[t] = e | |
}, e.prototype.getFrameSound = function(t) { | |
if (0 > t || t >= this.numFrames) throw new errors.ArgumentError("Invalid frame id"); | |
return this.mSounds[t] | |
}, e.prototype.setFrameSound = function(t, e) { | |
if (0 > t || t >= this.numFrames) throw new errors.ArgumentError("Invalid frame id"); | |
this.mSounds[t] = e | |
}, e.prototype.getFrameDuration = function(t) { | |
if (0 > t || t >= this.numFrames) throw new errors.ArgumentError("Invalid frame id"); | |
return this.mDurations[t] | |
}, e.prototype.setFrameDuration = function(t, e) { | |
if (0 > t || t >= this.numFrames) throw new errors.ArgumentError("Invalid frame id"); | |
this.mTotalTime -= this.getFrameDuration(t), this.mTotalTime += e, this.mDurations[t] = e, this.updateStartTimes() | |
}, e.prototype.play = function() { | |
this.mPlaying = !0 | |
}, e.prototype.pause = function() { | |
this.mPlaying = !1 | |
}, e.prototype.stop = function() { | |
this.mPlaying = !1, this.currentFrame = 0 | |
}, e.prototype.updateStartTimes = function() { | |
var t = this.numFrames; | |
this.mStartTimes.length = 0, this.mStartTimes[0] = 0; | |
for (var e = 1; t > e; ++e) this.mStartTimes[e] = this.mStartTimes[e - 1] + this.mDurations[e - 1] | |
}, e.prototype.advanceTime = function(t) { | |
var e, n = this.mCurrentFrame, | |
r = 0, | |
i = !1; | |
if (this.mLoop && this.mCurrentTime == this.mTotalTime && (this.mCurrentTime = 0, this.mCurrentFrame = 0), this.mPlaying && t > 0 && this.mCurrentTime < this.mTotalTime) for (this.mCurrentTime += t, e = this.mTextures.length - 1; this.mCurrentTime >= this.mStartTimes[this.mCurrentFrame] + this.mDurations[this.mCurrentFrame];) { | |
this.mCurrentFrame == e ? (this.hasEventListener(events.Event.COMPLETE) && (this.mCurrentFrame != n && (this.texture = this.mTextures[this.mCurrentFrame]), r = this.mCurrentTime - this.mTotalTime, this.mCurrentTime = this.mTotalTime, this.dispatchEventWith(events.Event.COMPLETE), i = !0), this.mLoop ? (this.mCurrentTime -= this.mTotalTime, this.mCurrentFrame = 0) : (this.mCurrentTime = this.mTotalTime, i = !0)) : this.mCurrentFrame++; | |
var o = this.mSounds[this.mCurrentFrame]; | |
if (o && o.play(), i) break | |
} | |
this.mCurrentFrame != n && (this.texture = this.mTextures[this.mCurrentFrame]), r && this.advanceTime(r) | |
}, Object.defineProperty(e.prototype, "isComplete", { | |
get: function() { | |
return !this.mLoop && this.mCurrentTime >= this.mTotalTime | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "totalTime", { | |
get: function() { | |
return this.mTotalTime | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "numFrames", { | |
get: function() { | |
return this.mTextures.length | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "loop", { | |
get: function() { | |
return this.mLoop | |
}, | |
set: function(t) { | |
this.mLoop = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "currentFrame", { | |
get: function() { | |
return this.mCurrentFrame | |
}, | |
set: function(t) { | |
this.mCurrentFrame = t, this.mCurrentTime = 0; | |
for (var e = 0; t > e; ++e) this.mCurrentTime += this.getFrameDuration(e); | |
this.texture = this.mTextures[this.mCurrentFrame], this.mSounds[this.mCurrentFrame] && this.mSounds[this.mCurrentFrame].play() | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "fps", { | |
get: function() { | |
return 1 / this.mDefaultFrameDuration | |
}, | |
set: function(t) { | |
if (0 >= t) throw new errors.ArgumentError("Invalid fps: " + t); | |
var e = 1 / t, | |
n = e / this.mDefaultFrameDuration; | |
this.mCurrentTime *= n, this.mDefaultFrameDuration = e; | |
for (var r = 0; this.numFrames > r; ++r) { | |
var i = this.mDurations[r] * n; | |
this.mTotalTime = this.mTotalTime - this.mDurations[r] + i, this.mDurations[r] = i | |
} | |
this.updateStartTimes() | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "isPlaying", { | |
get: function() { | |
return this.mPlaying ? this.mLoop || this.mCurrentTime < this.mTotalTime : !1 | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e | |
}(t.SimpleImage); | |
t.MovieClip = e | |
})(display || (display = {})); | |
//Sprite | |
var display; | |
(function(t) { | |
var e = function(t) { | |
function e() { | |
t.call(this) | |
} | |
return __extends(e, t), e.prototype.dispose = function() { | |
this.disposeFlattenedContents(), t.prototype.dispose.call(this) | |
}, e.prototype.disposeFlattenedContents = function() { | |
if (this.mFlattenedContents, this.mFlattenedContents) { | |
for (var t = 0, e = this.mFlattenedContents.length; e > t; ++t) this.mFlattenedContents[t].dispose(); | |
this.mFlattenedContents = null | |
} | |
}, e.prototype.flatten = function() { | |
this.mFlattenRequested = !0, this.broadcastEventWith(events.Event.FLATTEN) | |
}, e.prototype.unflatten = function() { | |
this.mFlattenRequested = !1, this.disposeFlattenedContents() | |
}, Object.defineProperty(e.prototype, "isFlattened", { | |
get: function() { | |
return null != this.mFlattenedContents || this.mFlattenRequested | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e.prototype.render = function(e, n) { | |
this.mFlattenedContents, this.mFlattenRequested, this.mFlattenedContents || this.mFlattenRequested ? (null == this.mFlattenedContents && (this.mFlattenedContents = []), this.mFlattenRequested && (this.mFlattenRequested = !1), n * this.alpha, e.mvpMatrix) : t.prototype.render.call(this, e, n) | |
}, e | |
}(t.DisplayObjectContainer); | |
t.Sprite = e | |
})(display || (display = {})); | |
//Stage | |
var display; | |
(function(t) { | |
var e = function(t) { | |
function e(e, n, r) { | |
r === void 0 && (r = 0), t.call(this), this.mEnterFrameEvent = new events.EnterFrameEvent(events.Event.ENTER_FRAME, 0), this.mWidth = e, this.mHeight = n, this.mColor = r | |
} | |
return __extends(e, t), e.prototype.advanceTime = function(t) { | |
this.mEnterFrameEvent.reset(events.Event.ENTER_FRAME, !1, t), this.broadcastEvent(this.mEnterFrameEvent) | |
}, e.prototype.hitTest = function(e, n) { | |
if (n === void 0 && (n = !1), n && (!this.visible || !this.touchable)) return null; | |
if (0 > e.x || e.x > this.mWidth || 0 > e.y || e.y > this.mHeight) return null; | |
var r = t.prototype.hitTest.call(this, e, n); | |
return null == r && (r = this), r | |
}, Object.defineProperty(e.prototype, "width", { | |
set: function() { | |
throw new errors.IllegalOperationError("Cannot set width of stage") | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "height", { | |
set: function() { | |
throw new errors.IllegalOperationError("Cannot set height of stage") | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "x", { | |
set: function() { | |
throw new errors.IllegalOperationError("Cannot set x-coordinate of stage") | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "y", { | |
set: function() { | |
throw new errors.IllegalOperationError("Cannot set y-coordinate of stage") | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "scaleX", { | |
set: function() { | |
throw new errors.IllegalOperationError("Cannot scale stage") | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "scaleY", { | |
set: function() { | |
throw new errors.IllegalOperationError("Cannot scale stage") | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "rotation", { | |
set: function() { | |
throw new errors.IllegalOperationError("Cannot rotate stage") | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "color", { | |
get: function() { | |
return this.mColor | |
}, | |
set: function(t) { | |
this.mColor = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "stageWidth", { | |
get: function() { | |
return this.mWidth | |
}, | |
set: function(t) { | |
this.mWidth = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "stageHeight", { | |
get: function() { | |
return this.mHeight | |
}, | |
set: function(t) { | |
this.mHeight = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e | |
}(t.DisplayObjectContainer); | |
t.Stage = e | |
})(display || (display = {})); | |
//BlendMode - TBD | |
var display; | |
(function(t) { | |
var e = function() { | |
function t() {} | |
return t.AUTO = "auto", t.getBlendFactors = function() { | |
return null | |
}, t | |
}(); | |
t.BlendMode = e | |
})(display || (display = {})); | |
//ClassUtil | |
var utils; | |
(function(t) { | |
var e = function() { | |
function t() {} | |
return t.getQualifiedClassName = function(t) { | |
var e = /function (.{1,})\(/, | |
n = e.exec("" + t.constructor); | |
return n && n.length > 1 ? n[1] : "" | |
}, t | |
}(); | |
t.ClassUtil = e | |
})(utils || (utils = {})); | |
//StringUtil | |
var utils; | |
(function(t) { | |
var e = function() { | |
function t() {} | |
return t.format = function(t) { | |
for (var e = [], n = 0; arguments.length - 1 > n; n++) e[n] = arguments[n + 1]; | |
var r, i = t; | |
for (r = 0; e.length > r; r++) i = i.replace("{" + r + "}", e[r]); | |
return i | |
}, t | |
}(); | |
t.StringUtil = e | |
})(utils || (utils = {})); | |
//MatrixUtil | |
var utils; | |
(function(t) { | |
var e = function() { | |
function t() { | |
throw new errors.AbstractClassError | |
} | |
return t.sRawData = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], t.convertTo3D = function(t, e) { | |
return e === void 0 && (e = null), null | |
}, t.transformCoords = function(t, e, n, r) { | |
return r === void 0 && (r = null), null == r && (r = new geom.Point), r.x = t.a * e + t.c * n + t.tx, r.y = t.d * n + t.b * e + t.ty, r | |
}, t.skew = function(t, e, n) { | |
var r = Math.sin(e), | |
i = Math.cos(e), | |
o = Math.sin(n), | |
s = Math.cos(n); | |
t.setTo(t.a * s - t.b * r, t.a * o + t.b * i, t.c * s - t.d * r, t.c * o + t.d * i, t.tx * s - t.ty * r, t.tx * o + t.ty * i) | |
}, t.prependMatrix = function(t, e) { | |
t.setTo(t.a * e.a + t.c * e.b, t.b * e.a + t.d * e.b, t.a * e.c + t.c * e.d, t.b * e.c + t.d * e.d, t.tx + t.a * e.tx + t.c * e.ty, t.ty + t.b * e.tx + t.d * e.ty) | |
}, t.prependTranslation = function(t, e, n) { | |
t.tx += t.a * e + t.c * n, t.ty += t.b * e + t.d * n | |
}, t.prependScale = function(t, e, n) { | |
t.setTo(t.a * e, t.b * e, t.c * n, t.d * n, t.tx, t.ty) | |
}, t.prependRotation = function(t, e) { | |
var n = Math.sin(e), | |
r = Math.cos(e); | |
t.setTo(t.a * r + t.c * n, t.b * r + t.d * n, t.c * r - t.a * n, t.d * r - t.b * n, t.tx, t.ty) | |
}, t.prependSkew = function(t, e, n) { | |
var r = Math.sin(e), | |
i = Math.cos(e), | |
o = Math.sin(n), | |
s = Math.cos(n); | |
t.setTo(t.a * s + t.c * o, t.b * s + t.d * o, t.c * i - t.a * r, t.d * i - t.b * r, t.tx, t.ty) | |
}, t | |
}(); | |
t.MatrixUtil = e | |
})(utils || (utils = {})); | |
//VertexData | |
var utils; | |
(function(t) { | |
var e = function() { | |
function e(t, e) { | |
e === void 0 && (e = !1), this.mRawData = [], this.mPremultipliedAlpha = e, this.numVertices = t | |
} | |
return e.ELEMENTS_PER_VERTEX = 8, e.POSITION_OFFSET = 0, e.COLOR_OFFSET = 2, e.TEXCOORD_OFFSET = 6, e.sHelperPoint = new geom.Point, e.prototype.clone = function(t, n) { | |
t === void 0 && (t = 0), n === void 0 && (n = -1), (0 > n || t + n > this.mNumVertices) && (n = this.mNumVertices - t); | |
var r = new e(0, this.mPremultipliedAlpha); | |
return r.mNumVertices = n, r.mRawData = this.mRawData.slice(t * e.ELEMENTS_PER_VERTEX, n * e.ELEMENTS_PER_VERTEX), r | |
}, e.prototype.copyTo = function(t, n, r, i) { | |
n === void 0 && (n = 0), r === void 0 && (r = 0), i === void 0 && (i = -1), (0 > i || r + i > this.mNumVertices) && (i = this.mNumVertices - r); | |
for (var o = t.mRawData, s = n * e.ELEMENTS_PER_VERTEX, a = r * e.ELEMENTS_PER_VERTEX, u = i * e.ELEMENTS_PER_VERTEX, h = a; u > h; ++h) o[Number(s++)] = this.mRawData[h] | |
}, e.prototype.append = function(t) { | |
for (var e = this.mRawData.length, n = t.mRawData, r = n.length, i = 0; r > i; ++i) this.mRawData[Number(e++)] = n[i]; | |
this.mNumVertices += t.numVertices | |
}, e.prototype.setPosition = function(t, n, r) { | |
var i = this.getOffset(t) + e.POSITION_OFFSET; | |
this.mRawData[i] = n, this.mRawData[Number(i + 1)] = r | |
}, e.prototype.getPosition = function(t, n) { | |
var r = this.getOffset(t) + e.POSITION_OFFSET; | |
n.x = this.mRawData[r], n.y = this.mRawData[Number(r + 1)] | |
}, e.prototype.setColor = function(t, n) { | |
var r = this.getOffset(t) + e.COLOR_OFFSET, | |
i = this.mPremultipliedAlpha ? this.mRawData[Number(r + 3)] : 1; | |
this.mRawData[r] = (255 & n >> 16) / 255 * i, this.mRawData[Number(r + 1)] = (255 & n >> 8) / 255 * i, this.mRawData[Number(r + 2)] = (255 & n) / 255 * i | |
}, e.prototype.getColor = function(t) { | |
var n = this.getOffset(t) + e.COLOR_OFFSET, | |
r = this.mPremultipliedAlpha ? this.mRawData[Number(n + 3)] : 1; | |
if (0 == r) return 0; | |
var i = this.mRawData[n] / r, | |
o = this.mRawData[Number(n + 1)] / r, | |
s = this.mRawData[Number(n + 2)] / r; | |
return Number(255 * i) << 16 | Number(255 * o) << 8 | Number(255 * s) | |
}, e.prototype.setAlpha = function(t, n) { | |
var r = this.getOffset(t) + e.COLOR_OFFSET + 3; | |
if (this.mPremultipliedAlpha) {.001 > n && (n = .001); | |
var i = this.getColor(t); | |
this.mRawData[r] = n, this.setColor(t, i) | |
} else this.mRawData[r] = n | |
}, e.prototype.getAlpha = function(t) { | |
var n = this.getOffset(t) + e.COLOR_OFFSET + 3; | |
return this.mRawData[n] | |
}, e.prototype.setTexCoords = function(t, n, r) { | |
var i = this.getOffset(t) + e.TEXCOORD_OFFSET; | |
this.mRawData[i] = n, this.mRawData[Number(i + 1)] = r | |
}, e.prototype.getTexCoords = function(t, n) { | |
var r = this.getOffset(t) + e.TEXCOORD_OFFSET; | |
n.x = this.mRawData[r], n.y = this.mRawData[Number(r + 1)] | |
}, e.prototype.translateVertex = function(t, n, r) { | |
var i = this.getOffset(t) + e.POSITION_OFFSET; | |
this.mRawData[i] += n, this.mRawData[Number(i + 1)] += r | |
}, e.prototype.transformVertex = function(t, n, r) { | |
r === void 0 && (r = 1); | |
for (var i = this.getOffset(t) + e.POSITION_OFFSET, o = 0; r > o; ++o) { | |
var s = this.mRawData[i], | |
a = this.mRawData[Number(i + 1)]; | |
this.mRawData[i] = n.a * s + n.c * a + n.tx, this.mRawData[Number(i + 1)] = n.d * a + n.b * s + n.ty, i += e.ELEMENTS_PER_VERTEX | |
} | |
}, e.prototype.setUniformColor = function(t) { | |
for (var e = 0; this.mNumVertices > e; ++e) this.setColor(e, t) | |
}, e.prototype.setUniformAlpha = function(t) { | |
for (var e = 0; this.mNumVertices > e; ++e) this.setAlpha(e, t) | |
}, e.prototype.scaleAlpha = function(t, n, r) { | |
if (r === void 0 && (r = 1), 1 != n) { | |
(0 > r || t + r > this.mNumVertices) && (r = this.mNumVertices - t); | |
var i; | |
if (this.mPremultipliedAlpha) for (i = 0; r > i; ++i) this.setAlpha(t + i, this.getAlpha(t + i) * n); | |
else { | |
var o = this.getOffset(t) + e.COLOR_OFFSET + 3; | |
for (i = 0; r > i; ++i) this.mRawData[Number(o + i * e.ELEMENTS_PER_VERTEX)] *= n | |
} | |
} | |
}, e.prototype.getOffset = function(t) { | |
return t * e.ELEMENTS_PER_VERTEX | |
}, e.prototype.getBounds = function(n, r, i, o) { | |
n === void 0 && (n = null), r === void 0 && (r = 0), i === void 0 && (i = -1), o === void 0 && (o = null), null == o && (o = new geom.Rectangle), (0 > i || r + i > this.mNumVertices) && (i = this.mNumVertices - r); | |
var s, a, u, h = Number.MAX_VALUE, | |
l = -Number.MAX_VALUE, | |
c = Number.MAX_VALUE, | |
p = -Number.MAX_VALUE, | |
f = this.getOffset(r) + e.POSITION_OFFSET; | |
if (null == n) for (u = r; i > u; ++u) s = this.mRawData[f], a = this.mRawData[Number(f + 1)], f += e.ELEMENTS_PER_VERTEX, h = s > h ? h : s, l = l > s ? l : s, c = a > c ? c : a, p = p > a ? p : a; | |
else for (u = r; i > u; ++u) s = this.mRawData[f], a = this.mRawData[Number(f + 1)], f += e.ELEMENTS_PER_VERTEX, t.MatrixUtil.transformCoords(n, s, a, e.sHelperPoint), h = e.sHelperPoint.x > h ? h : e.sHelperPoint.x, l = l > e.sHelperPoint.x ? l : e.sHelperPoint.x, c = e.sHelperPoint.y > c ? c : e.sHelperPoint.y, p = p > e.sHelperPoint.y ? p : e.sHelperPoint.y; | |
return o.setTo(h, c, l - h, p - c), o | |
}, Object.defineProperty(e.prototype, "tinted", { | |
get: function() { | |
for (var t = e.COLOR_OFFSET, n = 0; this.mNumVertices > n; ++n) { | |
for (var r = 0; 4 > r; ++r) if (1 != this.mRawData[Number(t + r)]) return !0; | |
t += e.ELEMENTS_PER_VERTEX | |
} | |
return !1 | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e.prototype.setPremultipliedAlpha = function(t, n) { | |
if (n === void 0 && (n = !0), t != this.mPremultipliedAlpha) { | |
if (n) for (var r = this.mNumVertices * e.ELEMENTS_PER_VERTEX, i = e.COLOR_OFFSET; r > i; i += e.ELEMENTS_PER_VERTEX) { | |
var o = this.mRawData[Number(i + 3)], | |
s = this.mPremultipliedAlpha ? o : 1, | |
a = t ? o : 1; | |
0 != s && (this.mRawData[i] = this.mRawData[i] / s * a, this.mRawData[Number(i + 1)] = this.mRawData[Number(i + 1)] / s * a, this.mRawData[Number(i + 2)] = this.mRawData[Number(i + 2)] / s * a) | |
} | |
this.mPremultipliedAlpha = t | |
} | |
}, Object.defineProperty(e.prototype, "premultipliedAlpha", { | |
get: function() { | |
return this.mPremultipliedAlpha | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "numVertices", { | |
get: function() { | |
return this.mNumVertices | |
}, | |
set: function(t) { | |
var n, r = t - this.mNumVertices; | |
for (n = 0; r > n; ++n) this.mRawData.push(0, 0, 0, 0, 0, 1, 0, 0); | |
for (n = 0; - (r * e.ELEMENTS_PER_VERTEX) > n; ++n) this.mRawData.pop(); | |
this.mNumVertices = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "rawData", { | |
get: function() { | |
return this.mRawData | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e | |
}(); | |
t.VertexData = e | |
})(utils || (utils = {})); | |
//RectangleUtil | |
var utils; | |
(function(t) { | |
var e = function() { | |
function e() { | |
throw new errors.AbstractClassError | |
} | |
return e.intersect = function(t, e, n) { | |
n === void 0 && (n = null), null == n && (n = new geom.Rectangle); | |
var r = Math.max(t.x, e.x), | |
i = Math.min(t.x + t.width, e.x + e.width), | |
o = Math.max(t.y, e.y), | |
s = Math.min(t.y + t.height, e.y + e.height); | |
return r > i || o > s ? n.setEmpty() : n.setTo(r, o, i - r, s - o), n | |
}, e.fit = function(n, r, i, o, s) { | |
if (i === void 0 && (i = "showAll"), o === void 0 && (o = !1), s === void 0 && (s = null), !t.ScaleMode.isValid(i)) throw new errors.ArgumentError("Invalid scaleMode: " + i); | |
null == s && (s = new geom.Rectangle); | |
var a = n.width, | |
u = n.height, | |
h = r.width / a, | |
l = r.height / u, | |
c = 1; | |
return i == t.ScaleMode.SHOW_ALL ? (c = l > h ? h : l, o && (c = e.nextSuitableScaleFactor(c, !1))) : i == t.ScaleMode.NO_BORDER && (c = h > l ? h : l, o && (c = e.nextSuitableScaleFactor(c, !0))), a *= c, u *= c, s.setTo(r.x + (r.width - a) / 2, r.y + (r.height - u) / 2, a, u), s | |
}, e.nextSuitableScaleFactor = function(t, e) { | |
var n = 1; | |
if (e) { | |
if (t >= .5) return Math.ceil(t); | |
for (; 1 / (n + 1) > t;)++n | |
} else { | |
if (t >= 1) return Math.floor(t); | |
for (; 1 / n > t;)++n | |
} | |
return 1 / n | |
}, e | |
}(); | |
t.RectangleUtil = e | |
})(utils || (utils = {})); | |
//ScaleMode | |
var utils; | |
(function(t) { | |
var e = function() { | |
function t() { | |
throw new errors.AbstractClassError | |
} | |
return t.NONE = "none", t.NO_BORDER = "noBorder", t.SHOW_ALL = "showAll", t.isValid = function(e) { | |
return e == t.NONE || e == t.NO_BORDER || e == t.SHOW_ALL | |
}, t | |
}(); | |
t.ScaleMode = e | |
})(utils || (utils = {})); | |
//MathUtil | |
var utils; | |
(function(t) { | |
var e = function() { | |
function t() {} | |
return t.rad2deg = function(t) { | |
return 180 * (t / Math.PI) | |
}, t.deg2rad = function(t) { | |
return t / 180 * Math.PI | |
}, t.getNextPowerOfTwo = function(t) { | |
if (t > 0 && 0 == (t & t - 1)) return t; | |
for (var e = 1; t > e;) e <<= 1; | |
return e | |
}, t | |
}(); | |
t.MathUtil = e | |
})(utils || (utils = {})), | |
//TinyColor | |
function(t) { | |
function e(t, r) { | |
if (t = t ? t : "", r = r || {}, "object" == typeof t && t.hasOwnProperty("_tc_id")) return t; | |
var o = n(t), | |
a = o.r, | |
h = o.g, | |
c = o.b, | |
p = o.a, | |
f = E(100 * p) / 100, | |
d = r.format || o.format; | |
return 1 > a && (a = E(a)), 1 > h && (h = E(h)), 1 > c && (c = E(c)), { | |
ok: o.ok, | |
format: d, | |
_tc_id: b++, | |
alpha: p, | |
red: a, | |
green: h, | |
blue: c, | |
toHsv: function() { | |
var t = s(a, h, c); | |
return { | |
h: 360 * t.h, | |
s: t.s, | |
v: t.v, | |
a: p | |
} | |
}, | |
toHsvString: function() { | |
var t = s(a, h, c), | |
e = E(360 * t.h), | |
n = E(100 * t.s), | |
r = E(100 * t.v); | |
return 1 == p ? "hsv(" + e + ", " + n + "%, " + r + "%)" : "hsva(" + e + ", " + n + "%, " + r + "%, " + f + ")" | |
}, | |
toHsl: function() { | |
var t = i(a, h, c); | |
return { | |
h: 360 * t.h, | |
s: t.s, | |
l: t.l, | |
a: p | |
} | |
}, | |
toHslString: function() { | |
var t = i(a, h, c), | |
e = E(360 * t.h), | |
n = E(100 * t.s), | |
r = E(100 * t.l); | |
return 1 == p ? "hsl(" + e + ", " + n + "%, " + r + "%)" : "hsla(" + e + ", " + n + "%, " + r + "%, " + f + ")" | |
}, | |
toHex: function(t) { | |
return u(a, h, c, t) | |
}, | |
toHexString: function(t) { | |
return "#" + u(a, h, c, t) | |
}, | |
toRgb: function() { | |
return { | |
r: E(a), | |
g: E(h), | |
b: E(c), | |
a: p | |
} | |
}, | |
toRgbString: function() { | |
return 1 == p ? "rgb(" + E(a) + ", " + E(h) + ", " + E(c) + ")" : "rgba(" + E(a) + ", " + E(h) + ", " + E(c) + ", " + f + ")" | |
}, | |
toPercentageRgb: function() { | |
return { | |
r: E(100 * l(a, 255)) + "%", | |
g: E(100 * l(h, 255)) + "%", | |
b: E(100 * l(c, 255)) + "%", | |
a: p | |
} | |
}, | |
toPercentageRgbString: function() { | |
return 1 == p ? "rgb(" + E(100 * l(a, 255)) + "%, " + E(100 * l(h, 255)) + "%, " + E(100 * l(c, 255)) + "%)" : "rgba(" + E(100 * l(a, 255)) + "%, " + E(100 * l(h, 255)) + "%, " + E(100 * l(c, 255)) + "%, " + f + ")" | |
}, | |
toName: function() { | |
return 0 === p ? "transparent" : C[u(a, h, c, !0)] || !1 | |
}, | |
toFilter: function(t) { | |
var n = u(a, h, c, !1), | |
i = n, | |
o = Math.round(255 * parseFloat(p)).toString(16), | |
s = o, | |
l = r && r.gradientType ? "GradientType = 1, " : ""; | |
if (t) { | |
var f = e(t, !1); | |
i = f.toHex(), s = Math.round(255 * parseFloat(f.alpha)).toString(16) | |
} | |
return "progid:DXImageTransform.Microsoft.gradient(" + l + "startColorstr=#" + m(o) + n + ",endColorstr=#" + m(s) + i + ")" | |
}, | |
toString: function(t) { | |
t = t || this.format; | |
var e = !1; | |
return "rgb" === t && (e = this.toRgbString()), "prgb" === t && (e = this.toPercentageRgbString()), ("hex" === t || "hex6" === t) && (e = this.toHexString()), "hex3" === t && (e = this.toHexString(!0)), "name" === t && (e = this.toName()), "hsl" === t && (e = this.toHslString()), "hsv" === t && (e = this.toHsvString()), e || this.toHexString() | |
} | |
} | |
} | |
function n(t) { | |
var e = { | |
r: 0, | |
g: 0, | |
b: 0 | |
}, n = 1, | |
i = !1, | |
s = !1; | |
return "string" == typeof t && (t = g(t)), "object" == typeof t && (t.hasOwnProperty("r") && t.hasOwnProperty("g") && t.hasOwnProperty("b") ? (e = r(t.r, t.g, t.b), i = !0, s = "%" === (t.r + "").substr(-1) ? "prgb" : "rgb") : t.hasOwnProperty("h") && t.hasOwnProperty("s") && t.hasOwnProperty("v") ? (t.s = d(t.s), t.v = d(t.v), e = a(t.h, t.s, t.v), i = !0, s = "hsv") : t.hasOwnProperty("h") && t.hasOwnProperty("s") && t.hasOwnProperty("l") && (t.s = d(t.s), t.l = d(t.l), e = o(t.h, t.s, t.l), i = !0, s = "hsl"), t.hasOwnProperty("a") && (n = t.a)), n = parseFloat(n), (isNaN(n) || 0 > n || n > 1) && (n = 1), { | |
ok: i, | |
format: t.format || s, | |
r: w(255, x(e.r, 0)), | |
g: w(255, x(e.g, 0)), | |
b: w(255, x(e.b, 0)), | |
a: n | |
} | |
} | |
function r(t, e, n) { | |
return { | |
r: 255 * l(t, 255), | |
g: 255 * l(e, 255), | |
b: 255 * l(n, 255) | |
} | |
} | |
function i(t, e, n) { | |
t = l(t, 255), e = l(e, 255), n = l(n, 255); | |
var r, i, o = x(t, e, n), | |
s = w(t, e, n), | |
a = (o + s) / 2; | |
if (o == s) r = i = 0; | |
else { | |
var u = o - s; | |
switch (i = a > .5 ? u / (2 - o - s) : u / (o + s), o) { | |
case t: | |
r = (e - n) / u + (n > e ? 6 : 0); | |
break; | |
case e: | |
r = (n - t) / u + 2; | |
break; | |
case n: | |
r = (t - e) / u + 4 | |
} | |
r /= 6 | |
} | |
return { | |
h: r, | |
s: i, | |
l: a | |
} | |
} | |
function o(t, e, n) { | |
function r(t, e, n) { | |
return 0 > n && (n += 1), n > 1 && (n -= 1), 1 / 6 > n ? t + 6 * (e - t) * n : .5 > n ? e : 2 / 3 > n ? t + 6 * (e - t) * (2 / 3 - n) : t | |
} | |
var i, o, s; | |
if (t = l(t, 360), e = l(e, 100), n = l(n, 100), 0 === e) i = o = s = n; | |
else { | |
var a = .5 > n ? n * (1 + e) : n + e - n * e, | |
u = 2 * n - a; | |
i = r(u, a, t + 1 / 3), o = r(u, a, t), s = r(u, a, t - 1 / 3) | |
} | |
return { | |
r: 255 * i, | |
g: 255 * o, | |
b: 255 * s | |
} | |
} | |
function s(t, e, n) { | |
t = l(t, 255), e = l(e, 255), n = l(n, 255); | |
var r, i, o = x(t, e, n), | |
s = w(t, e, n), | |
a = o, | |
u = o - s; | |
if (i = 0 === o ? 0 : u / o, o == s) r = 0; | |
else { | |
switch (o) { | |
case t: | |
r = (e - n) / u + (n > e ? 6 : 0); | |
break; | |
case e: | |
r = (n - t) / u + 2; | |
break; | |
case n: | |
r = (t - e) / u + 4 | |
} | |
r /= 6 | |
} | |
return { | |
h: r, | |
s: i, | |
v: a | |
} | |
} | |
function a(t, e, n) { | |
t = 6 * l(t, 360), e = l(e, 100), n = l(n, 100); | |
var r = T.floor(t), | |
i = t - r, | |
o = n * (1 - e), | |
s = n * (1 - i * e), | |
a = n * (1 - (1 - i) * e), | |
u = r % 6, | |
h = [n, s, o, o, a, n][u], | |
c = [a, n, n, s, o, o][u], | |
p = [o, o, a, n, n, s][u]; | |
return { | |
r: 255 * h, | |
g: 255 * c, | |
b: 255 * p | |
} | |
} | |
function u(t, e, n, r) { | |
var i = [m(E(t).toString(16)), m(E(e).toString(16)), m(E(n).toString(16))]; | |
return r && i[0].charAt(0) == i[0].charAt(1) && i[1].charAt(0) == i[1].charAt(1) && i[2].charAt(0) == i[2].charAt(1) ? i[0].charAt(0) + i[1].charAt(0) + i[2].charAt(0) : i.join("") | |
} | |
function h(t) { | |
var e = {}; | |
for (var n in t) t.hasOwnProperty(n) && (e[t[n]] = n); | |
return e | |
} | |
function l(t, e) { | |
p(t) && (t = "100%"); | |
var n = f(t); | |
return t = w(e, x(0, parseFloat(t))), n && (t = parseInt(t * e, 10) / 100), 1e-6 > T.abs(t - e) ? 1 : t % e / parseFloat(e) | |
} | |
function c(t) { | |
return parseInt(t, 16) | |
} | |
function p(t) { | |
return "string" == typeof t && -1 != t.indexOf(".") && 1 === parseFloat(t) | |
} | |
function f(t) { | |
return "string" == typeof t && -1 != t.indexOf("%") | |
} | |
function m(t) { | |
return 1 == t.length ? "0" + t : "" + t | |
} | |
function d(t) { | |
return 1 >= t && (t = 100 * t + "%"), t | |
} | |
function g(t) { | |
t = t.replace(y, "").replace(v, "").toLowerCase(); | |
var e = !1; | |
if (_[t]) t = _[t], e = !0; | |
else if ("transparent" == t) return { | |
r: 0, | |
g: 0, | |
b: 0, | |
a: 0, | |
format: "name" | |
}; | |
var n; | |
return (n = P.rgb.exec(t)) ? { | |
r: n[1], | |
g: n[2], | |
b: n[3] | |
} : (n = P.rgba.exec(t)) ? { | |
r: n[1], | |
g: n[2], | |
b: n[3], | |
a: n[4] | |
} : (n = P.hsl.exec(t)) ? { | |
h: n[1], | |
s: n[2], | |
l: n[3] | |
} : (n = P.hsla.exec(t)) ? { | |
h: n[1], | |
s: n[2], | |
l: n[3], | |
a: n[4] | |
} : (n = P.hsv.exec(t)) ? { | |
h: n[1], | |
s: n[2], | |
v: n[3] | |
} : (n = P.hex6.exec(t)) ? { | |
r: c(n[1]), | |
g: c(n[2]), | |
b: c(n[3]), | |
format: e ? "name" : "hex" | |
} : (n = P.hex3.exec(t)) ? { | |
r: c(n[1] + "" + n[1]), | |
g: c(n[2] + "" + n[2]), | |
b: c(n[3] + "" + n[3]), | |
format: e ? "name" : "hex" | |
} : !1 | |
} | |
var y = /^[\s,#]+/, | |
v = /\s+$/, | |
b = 0, | |
T = Math, | |
E = T.round, | |
w = T.min, | |
x = T.max; | |
T.random, e.equals = function(t, n) { | |
return t && n ? e(t, !1).toRgbString() == e(n, !1).toRgbString() : !1 | |
}; | |
var _ = e.names = { | |
aliceblue: "f0f8ff", | |
antiquewhite: "faebd7", | |
aqua: "0ff", | |
aquamarine: "7fffd4", | |
azure: "f0ffff", | |
beige: "f5f5dc", | |
bisque: "ffe4c4", | |
black: "000", | |
blanchedalmond: "ffebcd", | |
blue: "00f", | |
blueviolet: "8a2be2", | |
brown: "a52a2a", | |
burlywood: "deb887", | |
burntsienna: "ea7e5d", | |
cadetblue: "5f9ea0", | |
chartreuse: "7fff00", | |
chocolate: "d2691e", | |
coral: "ff7f50", | |
cornflowerblue: "6495ed", | |
cornsilk: "fff8dc", | |
crimson: "dc143c", | |
cyan: "0ff", | |
darkblue: "00008b", | |
darkcyan: "008b8b", | |
darkgoldenrod: "b8860b", | |
darkgray: "a9a9a9", | |
darkgreen: "006400", | |
darkgrey: "a9a9a9", | |
darkkhaki: "bdb76b", | |
darkmagenta: "8b008b", | |
darkolivegreen: "556b2f", | |
darkorange: "ff8c00", | |
darkorchid: "9932cc", | |
darkred: "8b0000", | |
darksalmon: "e9967a", | |
darkseagreen: "8fbc8f", | |
darkslateblue: "483d8b", | |
darkslategray: "2f4f4f", | |
darkslategrey: "2f4f4f", | |
darkturquoise: "00ced1", | |
darkviolet: "9400d3", | |
deeppink: "ff1493", | |
deepskyblue: "00bfff", | |
dimgray: "696969", | |
dimgrey: "696969", | |
dodgerblue: "1e90ff", | |
firebrick: "b22222", | |
floralwhite: "fffaf0", | |
forestgreen: "228b22", | |
fuchsia: "f0f", | |
gainsboro: "dcdcdc", | |
ghostwhite: "f8f8ff", | |
gold: "ffd700", | |
goldenrod: "daa520", | |
gray: "808080", | |
green: "008000", | |
greenyellow: "adff2f", | |
grey: "808080", | |
honeydew: "f0fff0", | |
hotpink: "ff69b4", | |
indianred: "cd5c5c", | |
indigo: "4b0082", | |
ivory: "fffff0", | |
khaki: "f0e68c", | |
lavender: "e6e6fa", | |
lavenderblush: "fff0f5", | |
lawngreen: "7cfc00", | |
lemonchiffon: "fffacd", | |
lightblue: "add8e6", | |
lightcoral: "f08080", | |
lightcyan: "e0ffff", | |
lightgoldenrodyellow: "fafad2", | |
lightgray: "d3d3d3", | |
lightgreen: "90ee90", | |
lightgrey: "d3d3d3", | |
lightpink: "ffb6c1", | |
lightsalmon: "ffa07a", | |
lightseagreen: "20b2aa", | |
lightskyblue: "87cefa", | |
lightslategray: "789", | |
lightslategrey: "789", | |
lightsteelblue: "b0c4de", | |
lightyellow: "ffffe0", | |
lime: "0f0", | |
limegreen: "32cd32", | |
linen: "faf0e6", | |
magenta: "f0f", | |
maroon: "800000", | |
mediumaquamarine: "66cdaa", | |
mediumblue: "0000cd", | |
mediumorchid: "ba55d3", | |
mediumpurple: "9370db", | |
mediumseagreen: "3cb371", | |
mediumslateblue: "7b68ee", | |
mediumspringgreen: "00fa9a", | |
mediumturquoise: "48d1cc", | |
mediumvioletred: "c71585", | |
midnightblue: "191970", | |
mintcream: "f5fffa", | |
mistyrose: "ffe4e1", | |
moccasin: "ffe4b5", | |
navajowhite: "ffdead", | |
navy: "000080", | |
oldlace: "fdf5e6", | |
olive: "808000", | |
olivedrab: "6b8e23", | |
orange: "ffa500", | |
orangered: "ff4500", | |
orchid: "da70d6", | |
palegoldenrod: "eee8aa", | |
palegreen: "98fb98", | |
paleturquoise: "afeeee", | |
palevioletred: "db7093", | |
papayawhip: "ffefd5", | |
peachpuff: "ffdab9", | |
peru: "cd853f", | |
pink: "ffc0cb", | |
plum: "dda0dd", | |
powderblue: "b0e0e6", | |
purple: "800080", | |
red: "f00", | |
rosybrown: "bc8f8f", | |
royalblue: "4169e1", | |
saddlebrown: "8b4513", | |
salmon: "fa8072", | |
sandybrown: "f4a460", | |
seagreen: "2e8b57", | |
seashell: "fff5ee", | |
sienna: "a0522d", | |
silver: "c0c0c0", | |
skyblue: "87ceeb", | |
slateblue: "6a5acd", | |
slategray: "708090", | |
slategrey: "708090", | |
snow: "fffafa", | |
springgreen: "00ff7f", | |
steelblue: "4682b4", | |
tan: "d2b48c", | |
teal: "008080", | |
thistle: "d8bfd8", | |
tomato: "ff6347", | |
turquoise: "40e0d0", | |
violet: "ee82ee", | |
wheat: "f5deb3", | |
white: "fff", | |
whitesmoke: "f5f5f5", | |
yellow: "ff0", | |
yellowgreen: "9acd32" | |
}, C = e.hexNames = h(_), | |
P = function() { | |
var t = "[-\\+]?\\d+%?", | |
e = "[-\\+]?\\d*\\.\\d+%?", | |
n = "(?:" + e + ")|(?:" + t + ")", | |
r = "[\\s|\\(]+(" + n + ")[,|\\s]+(" + n + ")[,|\\s]+(" + n + ")\\s*\\)?", | |
i = "[\\s|\\(]+(" + n + ")[,|\\s]+(" + n + ")[,|\\s]+(" + n + ")[,|\\s]+(" + n + ")\\s*\\)?"; | |
return { | |
rgb: RegExp("rgb" + r), | |
rgba: RegExp("rgba" + i), | |
hsl: RegExp("hsl" + r), | |
hsla: RegExp("hsla" + i), | |
hsv: RegExp("hsv" + r), | |
hex3: /^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, | |
hex6: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/ | |
} | |
}(); | |
t.TinyColor = e | |
}(utils); | |
//Color | |
var utils; | |
(function(t) { | |
var e = function() { | |
function e() { | |
throw new errors.AbstractClassError | |
} | |
return e.WHITE = 16777215, e.SILVER = 12632256, e.GRAY = 8421504, e.BLACK = 0, e.RED = 16711680, e.MAROON = 8388608, e.YELLOW = 16776960, e.OLIVE = 8421376, e.LIME = 65280, e.GREEN = 32768, e.AQUA = 65535, e.TEAL = 32896, e.BLUE = 255, e.NAVY = 128, e.FUCHSIA = 16711935, e.PURPLE = 8388736, e.getAlpha = function(t) { | |
return 255 & t >> 24 | |
}, e.getRed = function(t) { | |
return 255 & t >> 16 | |
}, e.getGreen = function(t) { | |
return 255 & t >> 8 | |
}, e.getBlue = function(t) { | |
return 255 & t | |
}, e.rgb = function(t, e, n) { | |
return t << 16 | e << 8 | n | |
}, e.argb = function(t, e, n, r) { | |
return t << 24 | e << 16 | n << 8 | r | |
}, e.fromString = function(n) { | |
var r = t.TinyColor(n); | |
if (!r.ok) throw new errors.ArgumentError("Color format mismatch: " + n); | |
return 1 === r.alpha ? e.rgb(r.red, r.green, r.blue) : e.argb(r.alpha, r.red, r.green, r.blue) | |
}, e | |
}(); | |
t.Color = e | |
})(utils || (utils = {})); | |
//RenderSupport | |
var core; | |
(function(t) { | |
var e = function() { | |
function e() { | |
this.mProjectionMatrix = new geom.Matrix, this.mModelViewMatrix = new geom.Matrix, this.mMvpMatrix = new geom.Matrix, this.mMvpMatrix3D = new geom.Matrix3D, this.mMatrixStack = [], this.mMatrixStackSize = 0, this.mDrawCount = 0, this.mRenderTarget = null, this.mBlendMode = display.BlendMode.NORMAL, this.mScissorRectangle = new geom.Rectangle, this.loadIdentity(), this.setOrthographicProjection(0, 0, 400, 300) | |
} | |
return e.sPoint = new geom.Point, e.sRectangle = new geom.Rectangle, e.prototype.dispose = function() {}, e.prototype.setOrthographicProjection = function(t, e, n, r) { | |
this.mProjectionMatrix.setTo(2 / n, 0, 0, - 2 / r, - (2 * t + n) / n, (2 * e + r) / r) | |
}, e.prototype.loadIdentity = function() { | |
this.mModelViewMatrix.identity() | |
}, e.prototype.translateMatrix = function(t, e) { | |
utils.MatrixUtil.prependTranslation(this.mModelViewMatrix, t, e) | |
}, e.prototype.rotateMatrix = function(t) { | |
utils.MatrixUtil.prependRotation(this.mModelViewMatrix, t) | |
}, e.prototype.scaleMatrix = function(t, e) { | |
utils.MatrixUtil.prependScale(this.mModelViewMatrix, t, e) | |
}, e.prototype.prependMatrix = function(t) { | |
utils.MatrixUtil.prependMatrix(this.mModelViewMatrix, t) | |
}, e.prototype.transformMatrix = function(t) { | |
utils.MatrixUtil.prependMatrix(this.mModelViewMatrix, t.transformationMatrix) | |
}, e.prototype.pushMatrix = function() { | |
this.mMatrixStack.length < this.mMatrixStackSize + 1 && this.mMatrixStack.push(new geom.Matrix), this.mMatrixStack[this.mMatrixStackSize++].copyFrom(this.mModelViewMatrix) | |
}, e.prototype.popMatrix = function() { | |
this.mModelViewMatrix.copyFrom(this.mMatrixStack[--this.mMatrixStackSize]) | |
}, e.prototype.resetMatrix = function() { | |
this.mMatrixStackSize = 0, this.loadIdentity() | |
}, e.transformMatrixForObject = function(t, e) { | |
utils.MatrixUtil.prependMatrix(t, e.transformationMatrix) | |
}, Object.defineProperty(e.prototype, "mvpMatrix", { | |
get: function() { | |
return this.mMvpMatrix.copyFrom(this.mModelViewMatrix), this.mMvpMatrix | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "mvpMatrix3D", { | |
get: function() { | |
return utils.MatrixUtil.convertTo3D(this.mvpMatrix, this.mMvpMatrix3D) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "modelViewMatrix", { | |
get: function() { | |
return this.mModelViewMatrix | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "projectionMatrix", { | |
get: function() { | |
return this.mProjectionMatrix | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e.prototype.applyBlendMode = function() {}, Object.defineProperty(e.prototype, "blendMode", { | |
get: function() { | |
return this.mBlendMode | |
}, | |
set: function(t) { | |
t != display.BlendMode.AUTO && (this.mBlendMode = t) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "renderTarget", { | |
get: function() { | |
return this.mRenderTarget | |
}, | |
set: function(t) { | |
this.mRenderTarget = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e.prototype.configureBackBuffer = function(t, e) { | |
this.mBackBufferWidth = t, this.mBackBufferHeight = e | |
}, Object.defineProperty(e.prototype, "backBufferWidth", { | |
get: function() { | |
return this.mBackBufferWidth | |
}, | |
set: function(t) { | |
this.mBackBufferWidth = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "backBufferHeight", { | |
get: function() { | |
return this.mBackBufferHeight | |
}, | |
set: function(t) { | |
this.mBackBufferHeight = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "scissorRectangle", { | |
get: function() { | |
return this.mScissorRectangle.isEmpty() ? null : this.mScissorRectangle | |
}, | |
set: function(t) { | |
if (t) { | |
this.mScissorRectangle.setTo(t.x, t.y, t.width, t.height); | |
var n = this.mRenderTarget ? this.mRenderTarget.root.nativeWidth : this.mBackBufferWidth, | |
r = this.mRenderTarget ? this.mRenderTarget.root.nativeHeight : this.mBackBufferHeight; | |
utils.MatrixUtil.transformCoords(this.mProjectionMatrix, t.x, t.y, e.sPoint), e.sRectangle.x = Math.max(0, (e.sPoint.x + 1) / 2) * n, e.sRectangle.y = Math.max(0, (-e.sPoint.y + 1) / 2) * r, utils.MatrixUtil.transformCoords(this.mProjectionMatrix, t.right, t.bottom, e.sPoint), e.sRectangle.right = Math.min(1, (e.sPoint.x + 1) / 2) * n, e.sRectangle.bottom = Math.min(1, (-e.sPoint.y + 1) / 2) * r | |
} else this.mScissorRectangle.setEmpty() | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e.prototype.nextFrame = function() { | |
this.resetMatrix(), this.mBlendMode = display.BlendMode.NORMAL, this.mDrawCount = 0 | |
}, e.setDefaultBlendFactors = function(t) { | |
e.setBlendFactors(t) | |
}, e.setBlendFactors = function(t, e) { | |
e === void 0 && (e = "normal"), display.BlendMode.getBlendFactors(e, t) | |
}, e.clear = function(e, n) { | |
e === void 0 && (e = 0), n === void 0 && (n = 0); | |
var r = t.Starling.current, | |
i = r.canvas, | |
o = r.context; | |
o.save(), o.setTransform(1, 0, 0, 1, 0, 0), o.clearRect(0, 0, i.width, i.height), o.restore() | |
}, e.prototype.clear = function(t, n) { | |
t === void 0 && (t = 0), n === void 0 && (n = 0), e.clear(t, n) | |
}, e.assembleAgal = function(t, e, n) { | |
return n === void 0 && (n = null), null | |
}, e.prototype.raiseDrawCount = function(t) { | |
t === void 0 && (t = 1), this.mDrawCount += t | |
}, Object.defineProperty(e.prototype, "drawCount", { | |
get: function() { | |
return this.mDrawCount | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e | |
}(); | |
t.RenderSupport = e | |
})(core || (core = {})); | |
//Starling | |
var core; | |
(function(t) { | |
var e = function(e) { | |
function n(r, i, o) { | |
if (i === void 0 && (i = "stage"), o === void 0 && (o = null), e.call(this), this.mBufferedRender = !1, this.mShareContext = !1, null == i && (i = "stage"), null == r) throw new errors.ArgumentError("Root class must not be null"); | |
n.configured || n.configure(), this.initializeCanvasProvider(); | |
var s = this.initializeCanvas(i), | |
a = this.mCanvasProvider.getBackgroundColor(s); | |
null == o && (o = new geom.Rectangle(0, 0, s.width, s.height)), this.buffered = n.sBuffered, this.buffered && this.initializeBufferCanvas(), this.makeCurrent(), null != this.mLoader && this.load({ | |
id: "touchMarker", | |
src: "assets/touchmarker.png", | |
width: 32, | |
height: 32 | |
}), this.mRootClass = r, this.mViewPort = o, this.mPreviousViewPort = new geom.Rectangle, this.mStage = new display.Stage(o.width, o.height, a), this.mTouchProcessor = new t.TouchProcessor(this.mStage), this.mJuggler = new animation.Juggler, this.mSimulateMultitouch = !1, this.mLastFrameTimestamp = this.getTimer() / 1e3, this.mSupport = new t.RenderSupport; | |
var u = this.touchEventTypes, | |
h = u.length; | |
for (this.$onTouch = this.onTouch.bind(this); h-- > -1;) s.addEventListener(u[h], this.$onTouch, !1); | |
this.$onKey = this.onKey.bind(this), this.$onResize = this.onResize.bind(this), this.$onMouseLeave = this.onMouseLeave.bind(this), s.addEventListener("keydown", this.$onKey, !1), s.addEventListener("keyup", this.$onKey, !1), s.addEventListener("resize", this.$onResize, !1), s.addEventListener("mouseleave", this.$onMouseLeave, !1), this.makeCurrent(), this.initializeLoader(), this.initializeRoot(), this.updateViewPort(), this.mTouchProcessor.simulateMultitouch = this.mSimulateMultitouch, this.mLastFrameTimestamp = this.getTimer() / 1e3 | |
} | |
return __extends(n, e), n.sBuffered = !0, n.use = function(e) { | |
if (null == e) throw new errors.ArgumentError('Parameter "obj:0" is null or undefined!'); | |
if (e.LoadQueue) n.use(new t.PreloadJsImageLoaderFactory(e, !1)); | |
else if (e.isImageLoaderFactory) n.sLoaderFactory = e; | |
else if (e.isCanvasProviderFactory) n.sCanvasProviderFactory = e; | |
else { | |
if ("function" != typeof e) throw new errors.ArgumentError("Don't know how to use the given object: " + e); | |
n.use(new e) | |
} | |
return n | |
}, n.reset = function() { | |
n.sLoaderFactory = null, n.sCanvasProviderFactory = null, n.sBuffered = !0 | |
}, n.configure = function() { | |
return null == n.sLoaderFactory && "undefined" != typeof createjs && createjs.LoadQueue && (console.log("[INFO] Auto-detected PreloadJS. We will make good use of it (as ImageLoader)!"), n.use(createjs)), null == n.sCanvasProviderFactory && n.use(t.HTMLCanvasProviderFactory), n.configured = !0, n | |
}, Object.defineProperty(n, "buffered", { | |
get: function() { | |
return n.sBuffered | |
}, | |
set: function(t) { | |
n.sBuffered = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n, "configured", { | |
get: function() { | |
return n.sConfigured | |
}, | |
set: function(t) { | |
n.sConfigured = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), n.create = function(t, e) { | |
return n.configured || n.configure(), new n(t, e) | |
}, n.prototype.initializeCanvas = function(t) { | |
var e = this.mCanvasProvider, | |
n = e.getCanvasById(t); | |
null == n && (n = e.createCanvas(t, 400, 300)), n.setAttribute("tabIndex", 0), n.focus(); | |
var r = e.getContextFor(n); | |
return this.mCanvas = n, this.mContext = r, n | |
}, n.prototype.initializeBufferCanvas = function() { | |
var t, e = this.mCanvasProvider, | |
n = this.mCanvas; | |
return t = e.createCanvasWith(function(t) { | |
t.style.cssText = "position:absolute; top:-10000px; left:-10000px", t.id = n.id + "-buffer", t.width = n.width, t.height = n.height | |
}), this.mBufferCanvas = t, this.mBuffer = e.getContextFor(t), t | |
}, n.prototype.initializeCanvasProvider = function() { | |
if (!n.sCanvasProviderFactory) throw new errors.IllegalSystemStateError("No CanvasProviderFactory configured!"); | |
this.mCanvasProvider = n.sCanvasProviderFactory.create() | |
}, n.prototype.initializeLoader = function() { | |
n.sLoaderFactory && (this.mLoader = n.sLoaderFactory.create()) | |
}, n.prototype.initializeRoot = function() { | |
var t = this.mRootClass; | |
if (null == this.mRoot) { | |
if (this.mRoot = new t, !(this.mRoot instanceof display.DisplayObject)) throw Error("Invalid root class: " + this.mRootClass); | |
this.mStage.addChildAt(this.mRoot, 0), this.dispatchEventWith(events.Event.ROOT_CREATED, !1, this.mRoot) | |
} | |
}, n.prototype.updateViewPort = function(t) { | |
t === void 0 && (t = !1), (t || this.mPreviousViewPort.width != this.mViewPort.width || this.mPreviousViewPort.height != this.mViewPort.height || this.mPreviousViewPort.x != this.mViewPort.x || this.mPreviousViewPort.y != this.mViewPort.y) && (this.mPreviousViewPort.setTo(this.mViewPort.x, this.mViewPort.y, this.mViewPort.width, this.mViewPort.height), this.mClippedViewPort = this.mViewPort.intersection(new geom.Rectangle(0, 0, this.canvas.width, this.canvas.height)), this.mShareContext && (this.mSupport.backBufferWidth = this.mClippedViewPort.width, this.mSupport.backBufferHeight = this.mClippedViewPort.height)) | |
}, n.prototype.nextFrame = function() { | |
var t = this.getTimer() / 1e3, | |
e = t - this.mLastFrameTimestamp; | |
this.mLastFrameTimestamp = t, this.advanceTime(e), this.render() | |
}, n.prototype.advanceTime = function(t) { | |
this.makeCurrent(), this.mTouchProcessor.advanceTime(t), this.mStage.advanceTime(t), this.mJuggler.advanceTime(t) | |
}, n.prototype.render = function() { | |
this.makeCurrent(), this.mSupport.nextFrame(), this.mShareContext || t.RenderSupport.clear(this.mStage.color, 1); | |
var e = this.mViewPort.width / this.mStage.stageWidth, | |
n = this.mViewPort.height / this.mStage.stageHeight; | |
this.mSupport.renderTarget = null, this.mSupport.setOrthographicProjection(0 > this.mViewPort.x ? -this.mViewPort.x / e : 0, 0 > this.mViewPort.y ? -this.mViewPort.y / n : 0, this.mClippedViewPort.width / e, this.mClippedViewPort.height / n), this.mStage.render(this.mSupport, 1), this.mBufferedRender && this.flushBuffer() | |
}, n.prototype.flushBuffer = function() { | |
var t = this.mContext; | |
t.clearRect(0, 0, this.mCanvas.width, this.mCanvas.height), t.drawImage(this.mBufferCanvas, 0, 0) | |
}, n.prototype.makeCurrent = function() { | |
return n.current = this, this | |
}, n.prototype.load = function(t) { | |
if (!t) throw new errors.ArgumentError('Parameter "manifest" is null or undefined. Expected an ImageSource descriptor ({ id, src, width, height}) or an array of descriptors'); | |
return Array.isArray(t) || (t = [t]), this.mLoader.loadManifest(t), this | |
}, n.prototype.getImageSource = function(t) { | |
return this.mLoader.getImageSource(t) | |
}, n.prototype.start = function() { | |
return this.mStarted = !0, this.mLastFrameTimestamp = this.getTimer() / 1e3, this.$onEnterFrame = this.onEnterFrame.bind(this), this.mAfHandle = window.requestAnimationFrame(this.$onEnterFrame), this | |
}, n.prototype.startOnReady = function() { | |
var t = this, | |
e = $(function() { | |
t.start() | |
}), | |
n = this.mLoader; | |
return n && n.isRunning() ? n.onReady(e) : e(), this | |
}, n.prototype.stop = function() { | |
this.mStarted = !1, window.cancelAnimationFrame(this.mAfHandle), this.mAfHandle = null | |
}, n.prototype.onEnterFrame = function() { | |
this.mAfHandle = window.requestAnimationFrame(this.$onEnterFrame), this.mStarted ? this.nextFrame() : this.render() | |
}, n.prototype.onKey = function(t) { | |
this.mStarted && (this.makeCurrent(), this.mStage.dispatchEvent(new events.KeyboardEvent(t.type, t.charCode, t.keyCode, t.location, t.ctrlKey, t.altKey, t.shiftKey))) | |
}, n.prototype.onResize = function() {}, n.prototype.onMouseLeave = function() { | |
this.mTouchProcessor.enqueueMouseLeftStage() | |
}, n.prototype.onTouch = function(t) { | |
if (this.mStarted) { | |
var e, n, r, i, o = 1, | |
s = 1, | |
a = 1; | |
if (!(t instanceof MouseEvent)) throw new errors.IllegalOperationError("Processing of native touch events not yet supported"); | |
var u = t, | |
h = u.target || u.srcElement, | |
l = h.getBoundingClientRect(), | |
c = window.getComputedStyle(this.mCanvas, null), | |
p = parseInt(c.getPropertyValue("padding-left"), 10), | |
f = parseInt(c.getPropertyValue("padding-top"), 10); | |
switch (e = u.clientX - l.left - p, n = u.clientY - l.top - f, r = 0, "mousedown" == t.type ? this.mLeftMouseDown = !0 : "mouseup" == t.type && (this.mLeftMouseDown = !1), t.type) { | |
case "touchstart": | |
i = events.TouchPhase.BEGAN; | |
break; | |
case "touchmove": | |
i = events.TouchPhase.MOVED; | |
break; | |
case "touchend": | |
i = events.TouchPhase.ENDED; | |
break; | |
case "mousedown": | |
i = events.TouchPhase.BEGAN; | |
break; | |
case "mouseup": | |
i = events.TouchPhase.ENDED; | |
break; | |
case "mousemove": | |
i = this.mLeftMouseDown ? events.TouchPhase.MOVED : events.TouchPhase.HOVER | |
} | |
e = this.mStage.stageWidth * (e - this.mViewPort.x) / this.mViewPort.width, n = this.mStage.stageHeight * (n - this.mViewPort.y) / this.mViewPort.height, this.mTouchProcessor.enqueue(r, i, e, n, o, s, a) | |
} | |
}, Object.defineProperty(n.prototype, "touchEventTypes", { | |
get: function() { | |
return ["mousedown", "mousemove", "mouseup"] | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), n.prototype.getTimer = function() { | |
return (new Date).getTime() | |
}, Object.defineProperty(n.prototype, "stage", { | |
get: function() { | |
return this.mStage | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "juggler", { | |
get: function() { | |
return this.mJuggler | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "viewPort", { | |
get: function() { | |
return this.mViewPort | |
}, | |
set: function(t) { | |
this.mViewPort = t.clone() | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "root", { | |
get: function() { | |
return this.mRoot | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "canvas", { | |
get: function() { | |
return this.mCanvas | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "context", { | |
get: function() { | |
return this.mBufferedRender ? this.mBuffer : this.mContext | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "isLoaderRunning", { | |
get: function() { | |
return this.mLoader ? this.mLoader.isRunning() : !1 | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "buffered", { | |
get: function() { | |
return this.mBufferedRender | |
}, | |
set: function(t) { | |
this.mBufferedRender = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n, "current", { | |
get: function() { | |
return n.sCurrent | |
}, | |
set: function(t) { | |
n.sCurrent = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n, "context", { | |
get: function() { | |
return n.current.context | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), n.prototype.dispose = function() { | |
this.mStarted && this.stop(), "undefined" != typeof window && window.cancelAnimationFrame(this.mAfHandle), n.sCurrent === this && (n.sCurrent = null) | |
}, n | |
}(events.EventDispatcher); | |
t.Starling = e | |
})(core || (core = {})); | |
//PreloadJsAsyncImageSource | |
var core; | |
(function(t) { | |
var e = function() { | |
function e(e, n) { | |
if (n === void 0 && (n = !0), null == e || !e.LoadQueue) throw Error('Missing required dependency "preloadjs"'); | |
this.preloadjs = e, n && t.Starling.use(this) | |
} | |
return e.initialize = function(t) { | |
new e(t, !0) | |
}, e.prototype.create = function() { | |
var t = new this.preloadjs.LoadQueue; | |
return new n(t) | |
}, Object.defineProperty(e.prototype, "isImageLoaderFactory", { | |
get: function() { | |
return !0 | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e | |
}(); | |
t.PreloadJsImageLoaderFactory = e; | |
var n = function() { | |
function t(t) { | |
var e = this; | |
this.mRunning = !1, this.mQueue = t, this.mImageSources = [], t.addEventListener("complete", function() { | |
e.mRunning = !1, console.log("complete", arguments), e.onComplete() | |
}), t.addEventListener("fileload", function(t) { | |
var n = t.item, | |
r = t.result, | |
i = e.mImageSources[n.id]; | |
null != i && (i.setComplete(r), delete e.mImageSources[n.id]) | |
}) | |
} | |
return Object.defineProperty(t.prototype, "queue", { | |
get: function() { | |
return this.mQueue | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), t.prototype.loadManifest = function(t) { | |
t && t.length > 0 && (this.mRunning = !0, this.mQueue.loadManifest(t)) | |
}, t.prototype.isRunning = function() { | |
return this.mRunning | |
}, t.prototype.onComplete = function() { | |
this.mRunning = !1 | |
}, t.prototype.onReady = function(t) { | |
this.mQueue.addEventListener("complete", t) | |
}, t.prototype.getImage = function(t) { | |
return this.mQueue.getResult(t) | |
}, t.prototype.getImageSource = function(t) { | |
var e, n, i = this.mQueue; | |
if (e = this.mImageSources[t]) return e; | |
if (n = i.getResult(t), null != n) e = new r(i, n, !0); | |
else { | |
if (n = i.getItem(t), null == n) throw new errors.ArgumentError('Resource with id "' + t + '" not found in queue'); | |
e = new r(i, n, !1) | |
} | |
return this.mImageSources[t] = e, e | |
}, t | |
}(); | |
t.PreloadJsImageLoader = n; | |
var r = function() { | |
function t(t, e, n) { | |
this.mComplete = !1, this.mItem = e, this.mComplete = n | |
} | |
return t.prototype.isComplete = function() { | |
return this.mComplete | |
}, t.prototype.setComplete = function(t) { | |
this.mComplete = !0, this.mImage = t | |
}, Object.defineProperty(t.prototype, "width", { | |
get: function() { | |
return this.mItem.width | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "height", { | |
get: function() { | |
return this.mItem.height | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "src", { | |
get: function() { | |
return this.mItem.src | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "image", { | |
get: function() { | |
return this.mImage | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), t.prototype.dispose = function() {}, t | |
}(); | |
t.PreloadJsAsyncImageSource = r | |
})(core || (core = {})); | |
//TouchMarker | |
var core; | |
(function(t) { | |
var e = function(e) { | |
function n() { | |
e.call(this), this.mCenter = new geom.Point, this.mTexture = this.createTexture(); | |
for (var t = 0; 2 > t; ++t) { | |
var n = new display.SimpleImage(this.mTexture); | |
n.pivotX = this.mTexture.width / 2, n.pivotY = this.mTexture.height / 2, n.touchable = !1, this.addChild(n) | |
} | |
} | |
return __extends(n, e), n.prototype.dispose = function() { | |
this.mTexture.dispose(), e.prototype.dispose.call(this) | |
}, n.prototype.moveMarker = function(t, e, n) { | |
n === void 0 && (n = !1), n && (this.mCenter.x += t - this.realMarker.x, this.mCenter.y += e - this.realMarker.y), this.realMarker.x = t, this.realMarker.y = e, this.mockMarker.x = 2 * this.mCenter.x - t, this.mockMarker.y = 2 * this.mCenter.y - e | |
}, n.prototype.moveCenter = function(t, e) { | |
this.mCenter.x = t, this.mCenter.y = e, this.moveMarker(this.realX, this.realY) | |
}, n.prototype.createTexture = function() { | |
return t.Starling.current.getImageSource("touchmarker") | |
}, Object.defineProperty(n.prototype, "realMarker", { | |
get: function() { | |
return this.getChildAt(0) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "mockMarker", { | |
get: function() { | |
return this.getChildAt(1) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "realX", { | |
get: function() { | |
return this.realMarker.x | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "realY", { | |
get: function() { | |
return this.realMarker.y | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "mockX", { | |
get: function() { | |
return this.mockMarker.x | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "mockY", { | |
get: function() { | |
return this.mockMarker.y | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), n | |
}(display.Sprite); | |
t.TouchMarker = e | |
})(core || (core = {})); | |
//TouchProcessor | |
var core; | |
(function(t) { | |
var e = function() { | |
function e(t) { | |
this.mShiftDown = !1, this.mCtrlDown = !1, this.mStage = t, this.mElapsedTime = 0, this.mCurrentTouches = [], this.mQueue = [], this.mLastTaps = [], this.mStage.addEventListener(events.KeyboardEvent.KEY_DOWN, this.onKey), this.mStage.addEventListener(events.KeyboardEvent.KEY_UP, this.onKey), this.monitorInterruptions(!0) | |
} | |
return e.MULTITAP_TIME = .3, e.MULTITAP_DISTANCE = 25, e.sProcessedTouchIDs = [], e.sHoveringTouchData = [], e.prototype.dispose = function() { | |
this.monitorInterruptions(!1), this.mStage.removeEventListener(events.KeyboardEvent.KEY_DOWN, this.onKey), this.mStage.removeEventListener(events.KeyboardEvent.KEY_UP, this.onKey), this.mTouchMarker && this.mTouchMarker.dispose() | |
}, e.prototype.advanceTime = function(t) { | |
var n, r, i, o, s; | |
this.mElapsedTime += t; | |
var a = this.mLastTaps, | |
u = this.mElapsedTime; | |
if (r = a.length, r > 0) for (n = r - 1; n >= 0; --n) u - a[n].timestamp > e.MULTITAP_TIME && a.splice(n, 1); | |
for (; this.mQueue.length > 0;) { | |
e.sProcessedTouchIDs.length = e.sHoveringTouchData.length = 0; | |
var h = this.mCurrentTouches, | |
r = h.length; | |
for (n = 0, o = h[n]; r > n; n++)(o.phase == events.TouchPhase.BEGAN || o.phase == events.TouchPhase.MOVED) && o.setPhase(events.TouchPhase.STATIONARY); | |
for (; this.mQueue.length > 0 && -1 == e.sProcessedTouchIDs.indexOf(this.mQueue[this.mQueue.length - 1][0]);) { | |
var l = this.mQueue.pop(); | |
i = l[0], o = this.getCurrentTouch(i), o && o.phase == events.TouchPhase.HOVER && o.target && e.sHoveringTouchData.push({ | |
touch: o, | |
target: o.target, | |
bubbleChain: o.bubbleChain | |
}), this.processTouch.apply(this, l), e.sProcessedTouchIDs.push(i) | |
} | |
var c = new events.TouchEvent(events.TouchEvent.TOUCH, this.mCurrentTouches, this.mShiftDown, this.mCtrlDown), | |
p = e.sHoveringTouchData; | |
for (r = p.length, n = 0, s = p[n]; r > n; n++) s.touch.target != s.target && c.dispatch(s.bubbleChain); | |
var f = e.sProcessedTouchIDs; | |
for (n = 0; f.length > n; n++) this.getCurrentTouch(f[n]).dispatchEvent(c); | |
var m = this.mCurrentTouches; | |
for (n = m.length - 1; n >= 0; --n) m[n].phase == events.TouchPhase.ENDED && m.splice(n, 1) | |
} | |
}, e.prototype.enqueue = function(t, e, n, r, i, o, s) { | |
i === void 0 && (i = 1), o === void 0 && (o = 1), s === void 0 && (s = 1), this.mQueue.unshift(arguments), this.mCtrlDown && this.simulateMultitouch && 0 == t && (this.mTouchMarker.moveMarker(n, r, this.mShiftDown), this.mQueue.unshift([1, e, this.mTouchMarker.mockX, this.mTouchMarker.mockY])) | |
}, e.prototype.enqueueMouseLeftStage = function() { | |
var t = this.getCurrentTouch(0); | |
if (null != t && t.phase == events.TouchPhase.HOVER) { | |
var e = 1, | |
n = t.globalX, | |
r = t.globalY, | |
i = t.globalX, | |
o = this.mStage.stageWidth - i, | |
s = t.globalY, | |
a = this.mStage.stageHeight - s, | |
u = Math.min(i, o, s, a); | |
u == i ? n = -e : u == o ? n = this.mStage.stageWidth + e : r = u == s ? -e : this.mStage.stageHeight + e, this.enqueue(0, events.TouchPhase.HOVER, n, r) | |
} | |
}, e.prototype.processTouch = function(t, e, n, r, i, o, s) { | |
i === void 0 && (i = 1), o === void 0 && (o = 1), s === void 0 && (s = 1); | |
var a = new geom.Point(n, r), | |
u = this.getCurrentTouch(t); | |
null == u && (u = new events.Touch(t, n, r, e, null), this.addCurrentTouch(u)), u.setPosition(n, r), u.setPhase(e), u.setTimestamp(this.mElapsedTime), u.setPressure(i), u.setSize(o, s), (e == events.TouchPhase.HOVER || e == events.TouchPhase.BEGAN) && u.setTarget(this.mStage.hitTest(a, !0)), e == events.TouchPhase.BEGAN && this.processTap(u) | |
}, e.prototype.onKey = function(t) { | |
if (17 == t.keyCode || 15 == t.keyCode) { | |
var e = this.mCtrlDown; | |
if (this.mCtrlDown = t.type == events.KeyboardEvent.KEY_DOWN, this.simulateMultitouch && e != this.mCtrlDown) { | |
this.mTouchMarker.visible = this.mCtrlDown, this.mTouchMarker.moveCenter(this.mStage.stageWidth / 2, this.mStage.stageHeight / 2); | |
var n = this.getCurrentTouch(0), | |
r = this.getCurrentTouch(1); | |
n && this.mTouchMarker.moveMarker(n.globalX, n.globalY), e && r && r.phase != events.TouchPhase.ENDED ? this.mQueue.unshift([1, events.TouchPhase.ENDED, r.globalX, r.globalY]) : this.mCtrlDown && n && (n.phase == events.TouchPhase.HOVER || n.phase == events.TouchPhase.ENDED ? this.mQueue.unshift([1, events.TouchPhase.HOVER, this.mTouchMarker.mockX, this.mTouchMarker.mockY]) : this.mQueue.unshift([1, events.TouchPhase.BEGAN, this.mTouchMarker.mockX, this.mTouchMarker.mockY])) | |
} | |
} else 16 == t.keyCode && (this.mShiftDown = t.type == events.KeyboardEvent.KEY_DOWN) | |
}, e.prototype.processTap = function(t) { | |
var n, r, i = null, | |
o = e.MULTITAP_DISTANCE * e.MULTITAP_DISTANCE, | |
s = this.mLastTaps, | |
a = s.length; | |
for (n = 0, r = s[n]; a > n; n++) { | |
var u = Math.pow(r.globalX - t.globalX, 2) + Math.pow(r.globalY - t.globalY, 2); | |
if (o >= u) { | |
i = r; | |
break | |
} | |
} | |
i ? (t.setTapCount(i.tapCount + 1), this.mLastTaps.splice(this.mLastTaps.indexOf(i), 1)) : t.setTapCount(1), this.mLastTaps.push(t.clone()) | |
}, e.prototype.addCurrentTouch = function(t) { | |
for (var e = this.mCurrentTouches, n = e.length - 1; n >= 0; --n) e[n].id == t.id && e.splice(n, 1); | |
e.push(t) | |
}, e.prototype.getCurrentTouch = function(t) { | |
for (var e = this.mCurrentTouches, n = e.length, r = 0, i = e[r]; n > r; r++) if (i.id == t) return i; | |
return null | |
}, Object.defineProperty(e.prototype, "simulateMultitouch", { | |
get: function() { | |
return null != this.mTouchMarker | |
}, | |
set: function(e) { | |
if (this.simulateMultitouch != e) { | |
var n = this.mTouchMarker; | |
e ? (n = new t.TouchMarker, n.visible = !1, this.mStage.addChild(n)) : (n.removeFromParent(!0), this.mTouchMarker = null) | |
} | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e.prototype.monitorInterruptions = function() {}, e.prototype.onInterruption = function() { | |
var t, e, n = this.mCurrentTouches, | |
r = n.length; | |
for (e = 0, t = n[e]; r > e; e++)(t.phase == events.TouchPhase.BEGAN || t.phase == events.TouchPhase.MOVED || t.phase == events.TouchPhase.STATIONARY) && t.setPhase(events.TouchPhase.ENDED); | |
var i = new events.TouchEvent(events.TouchEvent.TOUCH, this.mCurrentTouches, this.mShiftDown, this.mCtrlDown); | |
for (e = 0, t = n[e]; r > e; e++) t.dispatchEvent(i); | |
this.mCurrentTouches.length = 0 | |
}, e | |
}(); | |
t.TouchProcessor = e | |
})(core || (core = {})); | |
//HTMLCanvasProvider | |
var core; | |
(function(t) { | |
var e = function() { | |
function t() {} | |
return t.prototype.getElementById = function() { | |
throw new errors.AbstractMethodError | |
}, t.prototype.createCanvasWith = function() { | |
throw new errors.AbstractMethodError | |
}, t.prototype.getContextFor = function() { | |
throw new errors.AbstractMethodError | |
}, t.prototype.getCanvasById = function(t) { | |
var e = this.getElementById(t); | |
if (null != e && !(e instanceof HTMLCanvasElement)) throw new TypeError('The DOM element with id "' + t + '" is not a HTMLCanvasElement!'); | |
return e | |
}, t.prototype.createCanvas = function(t, e, n) { | |
if (e === void 0 && (e = null), n === void 0 && (n = null), null != this.getElementById(t)) throw Error('Cannot create canvas with id "' + t + '" - the DOM already contains an element with that id.'); | |
return this.createCanvasWith(function(r) { | |
r.id = t, r.width = e, r.height = n | |
}) | |
}, t.prototype.getBackgroundColor = function(t) { | |
var e = t.style.backgroundColor; | |
return null != e && "" != e ? utils.Color.fromString(e) : 0 | |
}, t | |
}(); | |
t.AbstractCanvasProvider = e; | |
var n = function() { | |
function t() {} | |
return Object.defineProperty(t.prototype, "isCanvasProviderFactory", { | |
get: function() { | |
return !0 | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), t.prototype.create = function() { | |
return new r(document) | |
}, t | |
}(); | |
t.HTMLCanvasProviderFactory = n; | |
var r = function(t) { | |
function e(e) { | |
t.call(this), this.mDocument = null != e ? e : document | |
} | |
return __extends(e, t), e.prototype.getElementById = function(t) { | |
return document.getElementById(t) | |
}, e.prototype.createCanvasWith = function(t) { | |
var e = document.createElement("canvas"); | |
t.call(this, e); | |
var n = document.body; | |
return n.appendChild(e), e | |
}, e.prototype.getContextFor = function(t) { | |
if ("canvas" !== t.nodeName.toLowerCase()) throw Error("Given HTMLElement is not a CANVAS element: " + t); | |
var e = t.getContext && t.getContext("2d"); | |
if (!e) throw Error("Your Browser does not support the Canvas API"); | |
return e | |
}, e | |
}(e); | |
t.HTMLCanvasProvider = r | |
})(core || (core = {})); | |
//DelayedCall | |
var animation; | |
(function(t) { | |
var e = function(t) { | |
function e(e, n, r) { | |
r === void 0 && (r = null), t.call(this), this.reset(e, n, r) | |
} | |
return __extends(e, t), e.prototype.reset = function(t, e, n) { | |
return n === void 0 && (n = null), this.mCurrentTime = 0, this.mTotalTime = Math.max(e, 1e-4), this.mCall = t, this.mArgs = n, this.mRepeatCount = 1, this | |
}, e.prototype.advanceTime = function(t) { | |
var e = this.mCurrentTime; | |
this.mCurrentTime = Math.min(this.mTotalTime, this.mCurrentTime + t), this.mTotalTime > e && this.mCurrentTime >= this.mTotalTime && (this.mCall.apply(null, this.mArgs), 0 == this.mRepeatCount || this.mRepeatCount > 1 ? (this.mRepeatCount > 0 && (this.mRepeatCount -= 1), this.mCurrentTime = 0, this.advanceTime(e + t - this.mTotalTime)) : this.dispatchEventWith(events.Event.REMOVE_FROM_JUGGLER)) | |
}, Object.defineProperty(e.prototype, "isComplete", { | |
get: function() { | |
return 1 == this.mRepeatCount && this.mCurrentTime >= this.mTotalTime | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "totalTime", { | |
get: function() { | |
return this.mTotalTime | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "currentTime", { | |
get: function() { | |
return this.mCurrentTime | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "repeatCount", { | |
get: function() { | |
return this.mRepeatCount | |
}, | |
set: function(t) { | |
this.mRepeatCount = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e | |
}(events.EventDispatcher); | |
t.DelayedCall = e | |
})(animation || (animation = {})); | |
//Juggler | |
var animation; | |
(function(t) { | |
var e = function() { | |
function e() { | |
this.mElapsedTime = 0, this.mObjects = [] | |
} | |
return e.prototype.add = function(t) { | |
t && -1 == this.mObjects.indexOf(t) && (this.mObjects.push(t), t instanceof events.EventDispatcher && t.addEventListener(events.Event.REMOVE_FROM_JUGGLER, this.onRemove, this)) | |
}, e.prototype.contains = function(t) { | |
return -1 != this.mObjects.indexOf(t) | |
}, e.prototype.remove = function(t) { | |
if (null != t) { | |
t instanceof events.EventDispatcher && t.removeEventListener(events.Event.REMOVE_FROM_JUGGLER, this.onRemove, this); | |
var e = this.mObjects.indexOf(t); - 1 != e && (this.mObjects[e] = null) | |
} | |
}, e.prototype.removeTweens = function(t) { | |
if (null != t) for (var e = this.mObjects, n = e.length - 1; n >= 0; --n) { | |
var r = e[n]; | |
r && r.target == t && (r.removeEventListener(events.Event.REMOVE_FROM_JUGGLER, this.onRemove, this), e[n] = null) | |
} | |
}, e.prototype.purge = function() { | |
for (var t = this.mObjects, e = t.length - 1; e >= 0; --e) { | |
var n = t[e]; | |
n && n instanceof events.EventDispatcher && n.removeEventListener(events.Event.REMOVE_FROM_JUGGLER, this.onRemove, this), t[e] = null | |
} | |
}, e.prototype.delayCall = function(e, n) { | |
for (var r = [], i = 0; arguments.length - 2 > i; i++) r[i] = arguments[i + 2]; | |
if (null == e) return null; | |
var o = new t.DelayedCall(e, n, r); | |
return this.add(o), o | |
}, e.prototype.tween = function(e, n, r) { | |
var i = t.Tween.fromPool(e, n); | |
for (var o in r) { | |
var s = r[o]; | |
if (i[o] !== void 0) i[o] = s; | |
else { | |
if (void 0 === e[o]) throw new errors.ArgumentError("Invalid property: " + o); | |
i.animate(o, s) | |
} | |
} | |
i.addEventListener(events.Event.REMOVE_FROM_JUGGLER, this.onPooledTweenComplete), this.add(i) | |
}, e.prototype.onPooledTweenComplete = function(e) { | |
t.Tween.toPool(e.target) | |
}, e.prototype.advanceTime = function(t) { | |
var e, n = this.mObjects, | |
r = n.length, | |
i = 0; | |
if (this.mElapsedTime += t, 0 != r) { | |
for (e = 0; r > e; ++e) { | |
var o = n[e]; | |
o && (i != e && (n[i] = o, n[e] = null), o.advanceTime(t), ++i) | |
} | |
if (i != e) { | |
for (r = n.length; r > e;) n[i++] = n[e++]; | |
n.length = i | |
} | |
} | |
}, e.prototype.onRemove = function(e) { | |
var n = e.target; | |
this.remove(n), n instanceof t.Tween && n.isComplete && this.add(n.nextTween) | |
}, Object.defineProperty(e.prototype, "elapsedTime", { | |
get: function() { | |
return this.mElapsedTime | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e | |
}(); | |
t.Juggler = e | |
})(animation || (animation = {})); | |
//Juggler | |
var animation; | |
(function(t) { | |
var e = function() { | |
function t() { | |
throw new errors.AbstractClassError | |
} | |
return t.LINEAR = "linear", t.EASE_IN = "easeIn", t.EASE_OUT = "easeOut", t.EASE_IN_OUT = "easeInOut", t.EASE_OUT_IN = "easeOutIn", t.EASE_IN_BACK = "easeInBack", t.EASE_OUT_BACK = "easeOutBack", t.EASE_IN_OUT_BACK = "easeInOutBack", t.EASE_OUT_IN_BACK = "easeOutInBack", t.EASE_IN_ELASTIC = "easeInElastic", t.EASE_OUT_ELASTIC = "easeOutElastic", t.EASE_IN_OUT_ELASTIC = "easeInOutElastic", t.EASE_OUT_IN_ELASTIC = "easeOutInElastic", t.EASE_IN_BOUNCE = "easeInBounce", t.EASE_OUT_BOUNCE = "easeOutBounce", t.EASE_IN_OUT_BOUNCE = "easeInOutBounce", t.EASE_OUT_IN_BOUNCE = "easeOutInBounce", t.getTransition = function(e) { | |
return null == t.sTransitions && t.registerDefaults(), t.sTransitions[e] | |
}, t.register = function(e, n) { | |
null == t.sTransitions && t.registerDefaults(), t.sTransitions[e] = n | |
}, t.registerDefaults = function() { | |
t.sTransitions = {}, t.register(t.LINEAR, t.linear), t.register(t.EASE_IN, t.easeIn), t.register(t.EASE_OUT, t.easeOut), t.register(t.EASE_IN_OUT, t.easeInOut), t.register(t.EASE_OUT_IN, t.easeOutIn), t.register(t.EASE_IN_BACK, t.easeInBack), t.register(t.EASE_OUT_BACK, t.easeOutBack), t.register(t.EASE_IN_OUT_BACK, t.easeInOutBack), t.register(t.EASE_OUT_IN_BACK, t.easeOutInBack), t.register(t.EASE_IN_ELASTIC, t.easeInElastic), t.register(t.EASE_OUT_ELASTIC, t.easeOutElastic), t.register(t.EASE_IN_OUT_ELASTIC, t.easeInOutElastic), t.register(t.EASE_OUT_IN_ELASTIC, t.easeOutInElastic), t.register(t.EASE_IN_BOUNCE, t.easeInBounce), t.register(t.EASE_OUT_BOUNCE, t.easeOutBounce), t.register(t.EASE_IN_OUT_BOUNCE, t.easeInOutBounce), t.register(t.EASE_OUT_IN_BOUNCE, t.easeOutInBounce) | |
}, t.linear = function(t) { | |
return t | |
}, t.easeIn = function(t) { | |
return t * t * t | |
}, t.easeOut = function(t) { | |
var e = t - 1; | |
return e * e * e + 1 | |
}, t.easeInOut = function(e) { | |
return t.easeCombined(t.easeIn, t.easeOut, e) | |
}, t.easeOutIn = function(e) { | |
return t.easeCombined(t.easeOut, t.easeIn, e) | |
}, t.easeInBack = function(t) { | |
var e = 1.70158; | |
return Math.pow(t, 2) * ((e + 1) * t - e) | |
}, t.easeOutBack = function(t) { | |
var e = t - 1, | |
n = 1.70158; | |
return Math.pow(e, 2) * ((n + 1) * e + n) + 1 | |
}, t.easeInOutBack = function(e) { | |
return t.easeCombined(t.easeInBack, t.easeOutBack, e) | |
}, t.easeOutInBack = function(e) { | |
return t.easeCombined(t.easeOutBack, t.easeInBack, e) | |
}, t.easeInElastic = function(t) { | |
if (0 == t || 1 == t) return t; | |
var e = .3, | |
n = e / 4, | |
r = t - 1; | |
return -1 * Math.pow(2, 10 * r) * Math.sin((r - n) * 2 * Math.PI / e) | |
}, t.easeOutElastic = function(t) { | |
if (0 == t || 1 == t) return t; | |
var e = .3, | |
n = e / 4; | |
return Math.pow(2, - 10 * t) * Math.sin((t - n) * 2 * Math.PI / e) + 1 | |
}, t.easeInOutElastic = function(e) { | |
return t.easeCombined(t.easeInElastic, t.easeOutElastic, e) | |
}, t.easeOutInElastic = function(e) { | |
return t.easeCombined(t.easeOutElastic, t.easeInElastic, e) | |
}, t.easeInBounce = function(e) { | |
return 1 - t.easeOutBounce(1 - e) | |
}, t.easeOutBounce = function(t) { | |
var e, n = 7.5625, | |
r = 2.75; | |
return 1 / r > t ? e = n * Math.pow(t, 2) : 2 / r > t ? (t -= 1.5 / r, e = n * Math.pow(t, 2) + .75) : 2.5 / r > t ? (t -= 2.25 / r, e = n * Math.pow(t, 2) + .9375) : (t -= 2.625 / r, e = n * Math.pow(t, 2) + .984375), e | |
}, t.easeInOutBounce = function(e) { | |
return t.easeCombined(t.easeInBounce, t.easeOutBounce, e) | |
}, t.easeOutInBounce = function(e) { | |
return t.easeCombined(t.easeOutBounce, t.easeInBounce, e) | |
}, t.easeCombined = function(t, e, n) { | |
return .5 > n ? .5 * t(2 * n) : .5 * e(2 * (n - .5)) + .5 | |
}, t | |
}(); | |
t.Transitions = e | |
})(animation || (animation = {})); | |
//Tween | |
var animation; | |
(function(t) { | |
var e = function(e) { | |
function n(t, n, r) { | |
r === void 0 && (r = "linear"), e.call(this), this.reset(t, n, r) | |
} | |
return __extends(n, e), n.prototype.reset = function(t, e, n) { | |
if (n === void 0 && (n = "linear"), this.mTarget = t, this.mCurrentTime = 0, this.mTotalTime = Math.max(1e-4, e), this.mDelay = this.mRepeatDelay = 0, this.mOnStart = this.mOnUpdate = this.mOnComplete = null, this.mOnStartArgs = this.mOnUpdateArgs = this.mOnCompleteArgs = null, this.mRoundToInt = this.mReverse = !1, this.mRepeatCount = 1, this.mCurrentCycle = -1, "string" == typeof n) this.transition = n; | |
else { | |
if ("function" != typeof n) throw new errors.ArgumentError("Transition must be either a string or a Function"); | |
this.transitionFunc = n | |
} | |
return this.mProperties ? this.mProperties.length = 0 : this.mProperties = [], this.mStartValues ? this.mStartValues.length = 0 : this.mStartValues = [], this.mEndValues ? this.mEndValues.length = 0 : this.mEndValues = [], this | |
}, n.prototype.animate = function(t, e) { | |
null != this.mTarget && (this.mProperties.push(t), this.mStartValues.push(Number.NaN), this.mEndValues.push(e)) | |
}, n.prototype.scaleTo = function(t) { | |
this.animate("scaleX", t), this.animate("scaleY", t) | |
}, n.prototype.moveTo = function(t, e) { | |
this.animate("x", t), this.animate("y", e) | |
}, n.prototype.fadeTo = function(t) { | |
this.animate("alpha", t) | |
}, n.prototype.advanceTime = function(t) { | |
if (0 != t && (1 != this.mRepeatCount || this.mCurrentTime != this.mTotalTime)) { | |
var e, n = this.mCurrentTime, | |
r = this.mTotalTime - this.mCurrentTime, | |
i = t > r ? t - r : 0; | |
if (this.mCurrentTime = Math.min(this.mTotalTime, this.mCurrentTime + t), !(0 >= this.mCurrentTime)) { | |
0 > this.mCurrentCycle && 0 >= n && this.mCurrentTime > 0 && (this.mCurrentCycle++, null != this.mOnStart && this.mOnStart.apply(null, this.mOnStartArgs)); | |
var o = this.mCurrentTime / this.mTotalTime, | |
s = this.mReverse && 1 == this.mCurrentCycle % 2, | |
a = this.mStartValues.length; | |
for (e = 0; a > e; ++e) { | |
isNaN(this.mStartValues[e]) && (this.mStartValues[e] = this.mTarget[this.mProperties[e]]); | |
var u = this.mStartValues[e], | |
h = this.mEndValues[e], | |
l = h - u, | |
c = s ? this.mTransitionFunc(1 - o) : this.mTransitionFunc(o), | |
p = u + c * l; | |
this.mRoundToInt && (p = Math.round(p)), this.mTarget[this.mProperties[e]] = p | |
} | |
if (null != this.mOnUpdate && this.mOnUpdate.apply(null, this.mOnUpdateArgs), this.mTotalTime > n && this.mCurrentTime >= this.mTotalTime) if (0 == this.mRepeatCount || this.mRepeatCount > 1) this.mCurrentTime = -this.mRepeatDelay, this.mCurrentCycle++, this.mRepeatCount > 1 && this.mRepeatCount--, null != this.mOnRepeat && this.mOnRepeat.apply(null, this.mOnRepeatArgs); | |
else { | |
var f = this.mOnComplete, | |
m = this.mOnCompleteArgs; | |
this.dispatchEventWith(events.Event.REMOVE_FROM_JUGGLER), null != f && f.apply(null, m) | |
} | |
i && this.advanceTime(i) | |
} | |
} | |
}, Object.defineProperty(n.prototype, "isComplete", { | |
get: function() { | |
return this.mCurrentTime >= this.mTotalTime && 1 == this.mRepeatCount | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "target", { | |
get: function() { | |
return this.mTarget | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "transition", { | |
get: function() { | |
return this.mTransitionName | |
}, | |
set: function(e) { | |
if (this.mTransitionName = e, this.mTransitionFunc = t.Transitions.getTransition(e), null == this.mTransitionFunc) throw new errors.ArgumentError("Invalid transiton: " + e) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "transitionFunc", { | |
get: function() { | |
return this.mTransitionFunc | |
}, | |
set: function(t) { | |
this.mTransitionName = "custom", this.mTransitionFunc = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "totalTime", { | |
get: function() { | |
return this.mTotalTime | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "currentTime", { | |
get: function() { | |
return this.mCurrentTime | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "delay", { | |
get: function() { | |
return this.mDelay | |
}, | |
set: function(t) { | |
this.mCurrentTime = this.mCurrentTime + this.mDelay - t, this.mDelay = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "repeatCount", { | |
get: function() { | |
return this.mRepeatCount | |
}, | |
set: function(t) { | |
this.mRepeatCount = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "repeatDelay", { | |
get: function() { | |
return this.mRepeatDelay | |
}, | |
set: function(t) { | |
this.mRepeatDelay = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "reverse", { | |
get: function() { | |
return this.mReverse | |
}, | |
set: function(t) { | |
this.mReverse = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "roundToInt", { | |
get: function() { | |
return this.mRoundToInt | |
}, | |
set: function(t) { | |
this.mRoundToInt = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "onStart", { | |
get: function() { | |
return this.mOnStart | |
}, | |
set: function(t) { | |
this.mOnStart = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "onUpdate", { | |
get: function() { | |
return this.mOnUpdate | |
}, | |
set: function(t) { | |
this.mOnUpdate = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "onRepeat", { | |
get: function() { | |
return this.mOnRepeat | |
}, | |
set: function(t) { | |
this.mOnRepeat = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "onComplete", { | |
get: function() { | |
return this.mOnComplete | |
}, | |
set: function(t) { | |
this.mOnComplete = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "onStartArgs", { | |
get: function() { | |
return this.mOnStartArgs | |
}, | |
set: function(t) { | |
this.mOnStartArgs = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "onUpdateArgs", { | |
get: function() { | |
return this.mOnUpdateArgs | |
}, | |
set: function(t) { | |
this.mOnUpdateArgs = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "onRepeatArgs", { | |
get: function() { | |
return this.mOnRepeatArgs | |
}, | |
set: function(t) { | |
this.mOnRepeatArgs = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "onCompleteArgs", { | |
get: function() { | |
return this.mOnCompleteArgs | |
}, | |
set: function(t) { | |
this.mOnCompleteArgs = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "nextTween", { | |
get: function() { | |
return this.mNextTween | |
}, | |
set: function(t) { | |
this.mNextTween = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), n.sTweenPool = [], n.fromPool = function(t, e, r) { | |
return r === void 0 && (r = "linear"), n.sTweenPool.length ? n.sTweenPool.pop().reset(t, e, r) : new n(t, e, r) | |
}, n.toPool = function(t) { | |
t.mOnStart = t.mOnUpdate = t.mOnRepeat = t.mOnComplete = null, t.mOnStartArgs = t.mOnUpdateArgs = t.mOnRepeatArgs = t.mOnCompleteArgs = null, t.mTarget = null, t.mTransitionFunc = null, t.removeEventListeners(), n.sTweenPool.push(t) | |
}, n | |
}(events.EventDispatcher); | |
t.Tween = e | |
})(animation || (animation = {})); | |
//DefaultError | |
var ErrorImpl = Error, | |
errors; | |
(function(t) { | |
var e = function(t) { | |
function e(e) { | |
t.call(this, e), this.name = "DefaultError", this.message = e, this.stack = Error().stack | |
} | |
return __extends(e, t), e | |
}(ErrorImpl); | |
t.DefaultError = e | |
})(errors || (errors = {})); | |
//AbstractClassError | |
var errors; | |
(function(t) { | |
var e = function(t) { | |
function e(e) { | |
e === void 0 && (e = null), t.call(this, e) | |
} | |
return __extends(e, t), e | |
}(t.DefaultError); | |
t.AbstractClassError = e | |
})(errors || (errors = {})); | |
//AbstractMethodError | |
var errors; | |
(function(t) { | |
var e = function(t) { | |
function e(e) { | |
t.call(this, e || "ABSTRACT METHOD ERROR: Method must be implemented in a sub-class.") | |
} | |
return __extends(e, t), e | |
}(t.DefaultError); | |
t.AbstractMethodError = e | |
})(errors || (errors = {})); | |
//ArgumentError | |
var errors; | |
(function(t) { | |
var e = function(t) { | |
function e(e) { | |
t.call(this, e), this.name = "ArgumentError" | |
} | |
return __extends(e, t), e | |
}(t.DefaultError); | |
t.ArgumentError = e | |
})(errors || (errors = {})); | |
//IllegalOperationError | |
var errors; | |
(function(t) { | |
var e = function(t) { | |
function e(e) { | |
t.call(this, e) | |
} | |
return __extends(e, t), e | |
}(t.DefaultError); | |
t.IllegalOperationError = e | |
})(errors || (errors = {})); | |
//IllegalSystemStateError | |
var errors; | |
(function(t) { | |
var e = function(t) { | |
function e(e) { | |
t.call(this, e) | |
} | |
return __extends(e, t), e | |
}(t.DefaultError); | |
t.IllegalSystemStateError = e | |
})(errors || (errors = {})); | |
//MissingContextError | |
var errors; | |
(function(t) { | |
var e = function(t) { | |
function e(e) { | |
e === void 0 && (e = null), t.call(this, e) | |
} | |
return __extends(e, t), e | |
}(t.DefaultError); | |
t.MissingContextError = e | |
})(errors || (errors = {})); | |
//FragmentFilterMode | |
var filters; | |
(function(t) { | |
var e = function() { | |
function t() { | |
throw new errors.AbstractClassError | |
} | |
return t.BELOW = "below", t.REPLACE = "replace", t.ABOVE = "above", t | |
}(); | |
t.FragmentFilterMode = e | |
})(filters || (filters = {})); | |
//FragmentFilter | |
var filters; | |
(function(t) { | |
var e = function() { | |
function t(t, e) { | |
t === void 0 && (t = 1), e === void 0 && (e = 1), this.PMA = !0, this.STD_VERTEX_SHADER = "m44 op, va0, vc0 \nmov v0, va1 \n", this.STD_FRAGMENT_SHADER = "tex oc, v0, fs0 <2d, clamp, linear, mipnone>", this.mVertexPosAtID = 0, this.mTexCoordsAtID = 1, this.mBaseTextureID = 0, this.mMvpConstantID = 0, this.mProjMatrix = new geom.Matrix | |
} | |
return t.sBounds = new geom.Rectangle, t.sStageBounds = new geom.Rectangle, t.sTransformationMatrix = new geom.Matrix, t.prototype.dispose = function() {}, t.prototype.onContextCreated = function() {}, t.prototype.render = function() {}, t.prototype.renderPasses = function(t, e, n, r) { | |
return r === void 0 && (r = !1), null | |
}, t.prototype.updateBuffers = function() {}, t.prototype.updatePassTextures = function() {}, t.prototype.getPassTexture = function() { | |
return null | |
}, t.prototype.calculateBounds = function() {}, t.prototype.disposePassTextures = function() {}, t.prototype.disposeCache = function() {}, t.prototype.createPrograms = function() {}, t.prototype.activate = function() {}, t.prototype.deactivate = function() {}, t.prototype.assembleAgal = function(t, e) { | |
return t === void 0 && (t = null), e === void 0 && (e = null), null | |
}, t.prototype.cache = function() {}, t.prototype.clearCache = function() {}, t.prototype.compile = function() { | |
return null | |
}, Object.defineProperty(t.prototype, "isCached", { | |
get: function() { | |
return null != this.mCache || this.mCacheRequested | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "resolution", { | |
get: function() { | |
return this.mResolution | |
}, | |
set: function(t) { | |
if (0 >= t) throw new errors.ArgumentError("Resolution must be > 0"); | |
this.mResolution = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "mode", { | |
get: function() { | |
return this.mMode | |
}, | |
set: function(t) { | |
this.mMode = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "offsetX", { | |
get: function() { | |
return this.mOffsetX | |
}, | |
set: function(t) { | |
this.mOffsetX = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "offsetY", { | |
get: function() { | |
return this.mOffsetY | |
}, | |
set: function(t) { | |
this.mOffsetY = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "marginX", { | |
get: function() { | |
return this.mMarginX | |
}, | |
set: function(t) { | |
this.mMarginX = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "marginY", { | |
get: function() { | |
return this.mMarginY | |
}, | |
set: function(t) { | |
this.mMarginY = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "numPasses", { | |
get: function() { | |
return this.mNumPasses | |
}, | |
set: function(t) { | |
this.mNumPasses = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "vertexPosAtID", { | |
get: function() { | |
return this.mVertexPosAtID | |
}, | |
set: function(t) { | |
this.mVertexPosAtID = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "texCoordsAtID", { | |
get: function() { | |
return this.mTexCoordsAtID | |
}, | |
set: function(t) { | |
this.mTexCoordsAtID = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "baseTextureID", { | |
get: function() { | |
return this.mBaseTextureID | |
}, | |
set: function(t) { | |
this.mBaseTextureID = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(t.prototype, "mvpConstantID", { | |
get: function() { | |
return this.mMvpConstantID | |
}, | |
set: function(t) { | |
this.mMvpConstantID = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), t | |
}(); | |
t.FragmentFilter = e | |
})(filters || (filters = {})); | |
//TextureSmoothing | |
var textures; | |
(function(t) { | |
var e = function() { | |
function t() { | |
throw new errors.AbstractClassError | |
} | |
return t.NONE = "none", t.BILINEAR = "bilinear", t.TRILINEAR = "trilinear", t.isValid = function(e) { | |
return e == t.NONE || e == t.BILINEAR || e == t.TRILINEAR | |
}, t | |
}(); | |
t.TextureSmoothing = e | |
})(textures || (textures = {})); | |
//Defaults | |
var starling = { | |
core: core, | |
animation: animation, | |
display: display, | |
errors: errors, | |
events: events, | |
filters: filters, | |
geom: geom, | |
textures: textures, | |
utils: utils | |
}; | |
// | |
(function(t, e) { | |
if ("object" == typeof exports) for (var n in e) exports[n] = e[n]; | |
else "function" == typeof define && define.amd ? define("starling", e) : t.returnExports = e | |
})(this, starling), | |
//App code begin | |
var __extends = this.__extends || function(t, e) { | |
function n() { | |
this.constructor = t | |
} | |
n.prototype = e.prototype, t.prototype = new n | |
}, game; | |
(function(t) { | |
var e = function(t) { | |
function e(e, n) { | |
t.call(this), this._lastElementID = -1, this._visibleArea = new geom.Rectangle(0, 0, 900, 100), this._textures = [], this._y = n, this._z = 0, this._contents = null; | |
var r = core.Starling.current; | |
for (var i in e) this._textures.push(r.getImageSource(e[i])) | |
} | |
return __extends(e, t), e.prototype.updateVisibleArea = function() { | |
if (0 != this._textures.length) if (null == this._contents) this.createInitialContents(); | |
else { | |
for (var t; this._contents.getChildAt(0).bounds.right <= this._visibleArea.x;) this._contents.removeChildAt(0); | |
for (; this._contents.getChildAt(this._contents.numChildren - 1).x >= this._visibleArea.right;) this._contents.removeChildAt(this._contents.numChildren - 1); | |
for (; this._contents.getChildAt(0).x > this._visibleArea.x;) t = this.createNewElement(), t.x = this._contents.getChildAt(0).x - t.width, this._contents.addChildAt(t, 0); | |
for (; this._contents.getChildAt(this._contents.numChildren - 1).bounds.right < this._visibleArea.right;) t = this.createNewElement(), t.x = this._contents.getChildAt(this._contents.numChildren - 1).bounds.right, this._contents.addChild(t) | |
} | |
}, e.prototype.createNewElement = function() { | |
var t = 0; | |
this._textures.length > 0 && (t = (this._lastElementID + 1) % this._textures.length); | |
var e = this._textures[t], | |
n = new display.SimpleImage(e); | |
return n.y = this._y - n.height, this._lastElementID = t, n | |
}, e.prototype.createInitialContents = function() { | |
this._contents = new display.Sprite, this.addChildAt(this._contents, 0); | |
for (var t = 0 | this._visibleArea.x; this._visibleArea.right > t;) { | |
var e = this.createNewElement(); | |
e.x = t, this._contents.addChild(e), t += e.width | |
} | |
}, Object.defineProperty(e.prototype, "visibleArea", { | |
get: function() { | |
return this._visibleArea | |
}, | |
set: function(t) { | |
this._visibleArea.setTo(t.x, t.y, t.width, t.height), this.updateVisibleArea() | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "z", { | |
get: function() { | |
return this._z | |
}, | |
set: function(t) { | |
this._z = t | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e | |
}(display.Sprite); | |
t.ParallaxLayer = e | |
})(game || (game = {})); | |
//Hero figure | |
var game; | |
(function(t) { | |
var e = function(t) { | |
function e() { | |
t.call(this); | |
var e = new display.SimpleImage(core.Starling.current.getImageSource("shadow")); | |
e.pivotX = 0 | e.width / 2, e.pivotY = 0 | e.height / 2, e.x = -23, this.addChild(e), this._wait = this.createMovieClip("wait", 1), this._wait.pivotX = 0 | this._wait.width / 2, this._wait.pivotY = this._wait.height, this._run = this.createMovieClip("run", 15), this._run.pivotX = 0 | this._run.width / 2, this._run.pivotY = this._run.height, this._runWithPig = this.createMovieClip("run-with-pig", 15), this._runWithPig.pivotX = 150, this._runWithPig.pivotY = this._runWithPig.height, this._throw = this.createMovieClip("throw", 7), this._throw.pivotX = 0 | this._throw.width / 2, this._throw.pivotY = 0 | this._throw.height, this._throw.addEventListener(events.Event.COMPLETE, this.catchUp, this), this._roll = this.createMovieClip("roll", 10), this._roll.pivotX = 70, this._roll.pivotY = 160, this._roll.loop = !1, this._roll.addEventListener(events.Event.COMPLETE, this.fly, this), this._airborne = this.createMovieClip("airborne", 11), this._airborne.pivotX = 0 | this._airborne.width / 2, this._airborne.pivotY = this._airborne.height, this._land = this.createMovieClip("landing", 7), this._land.pivotX = this._run.pivotX, this._land.pivotY = 148, this._land.loop = !1, this._land.addEventListener(events.Event.COMPLETE, this.catchUp, this), this._velocity = 0, this._juggler = new animation.Juggler, this.wait() | |
} | |
return __extends(e, t), e.STATE_WAIT = "wait", e.STATE_RUN = "run", e.STATE_JUMP = "jump", e.STATE_RUN_WITH_PIG = "runWithPig", e.STATE_THROW_PIG = "throwPig", e.RUN_VELOCITY = 200, e.FPS = 20, e.prototype.createMovieClip = function(t, n) { | |
for (var r = function(t) { | |
for (var e = t + ""; 2 > e.length;) e = "0" + e; | |
return e | |
}, i = core.Starling.current, o = [], s = 1; n >= s; ++s) { | |
var a = t + "_" + r(s); | |
o.push(i.getImageSource(a)) | |
} | |
return new display.MovieClip(o, e.FPS) | |
}, e.prototype.advanceTime = function(t) { | |
this._juggler.advanceTime(t), this._activeMovie.advanceTime(t) | |
}, e.prototype.wait = function() { | |
this._state = e.STATE_WAIT, this._velocity = 0, this.activeMovie = this._wait, this.activeMovie.y = 0 | |
}, e.prototype.run = function() { | |
this._state = e.STATE_RUN, this.cruise(), this.activeMovie = this._run, this.activeMovie.y = 0 | |
}, e.prototype.runWithPig = function() { | |
this._state = e.STATE_RUN_WITH_PIG, this.cruise(), this.activeMovie = this._runWithPig, this.activeMovie.y = 0 | |
}, e.prototype.throwPig = function() { | |
this._state = e.STATE_THROW_PIG, this._velocity = 0, this.activeMovie = this._throw | |
}, e.prototype.jump = function() { | |
this._state == e.STATE_RUN && (this._state = e.STATE_JUMP, this.activeMovie = this._roll) | |
}, e.prototype.fly = function() { | |
var t = .9, | |
e = this._activeMovie.y; | |
this.activeMovie = this._airborne, this.activeMovie.y = 0, this._juggler.tween(this._activeMovie, t / 2, { | |
transition: animation.Transitions.EASE_OUT, | |
y: -200 | |
}), this._juggler.tween(this._activeMovie, t / 2, { | |
delay: t / 2, | |
transition: animation.Transitions.EASE_IN, | |
y: e - 40, | |
onComplete: this.land.bind(this) | |
}) | |
}, e.prototype.land = function() { | |
this._velocity = 0, this.activeMovie = this._land | |
}, e.prototype.catchUp = function() { | |
var t = .75, | |
n = 1.875; | |
this.activeMovie = this._run, this.activeMovie.fps = 50, this._velocity = e.RUN_VELOCITY * n, this._juggler.tween(this, t, { | |
_velocity: e.RUN_VELOCITY | |
}), this._juggler.tween(this._activeMovie, t, { | |
fps: e.FPS, | |
onComplete: this.run.bind(this) | |
}) | |
}, Object.defineProperty(e.prototype, "activeMovie", { | |
get: function() { | |
return this._activeMovie | |
}, | |
set: function(t) { | |
t != this._activeMovie && (this._activeMovie && this._activeMovie.removeFromParent(), this._activeMovie = t, this._activeMovie.currentFrame = 0, this.addChild(t)) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "state", { | |
get: function() { | |
return this._state | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(e.prototype, "velocity", { | |
get: function() { | |
return this._velocity | |
}, | |
set: function(t) { | |
(this._state == e.STATE_RUN || this._state == e.STATE_RUN_WITH_PIG) && (this._velocity = t) | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), e.prototype.accelerate = function() { | |
(this._state == e.STATE_RUN || this._state == e.STATE_RUN_WITH_PIG) && (this._velocity = 1.7 * e.RUN_VELOCITY) | |
}, e.prototype.slowdown = function() { | |
(this._state == e.STATE_RUN || this._state == e.STATE_RUN_WITH_PIG) && (this._velocity = .3 * e.RUN_VELOCITY) | |
}, e.prototype.cruise = function() { | |
(this._state == e.STATE_RUN || this._state == e.STATE_RUN_WITH_PIG) && (this._velocity = e.RUN_VELOCITY) | |
}, e | |
}(display.Sprite); | |
t.Hero = e | |
})(game || (game = {})); | |
//Master layer | |
var game; | |
(function(t) { | |
var e = function(e) { | |
function n() { | |
e.call(this, ["grass_0", "grass_1", "grass_2", "grass_3"], 400), this._juggler = new animation.Juggler, this._pigFalling = !1, this._pig = new display.SimpleImage(core.Starling.current.getImageSource("pig")), this._pig.pivotX = 150, this._pig.pivotY = 0 | this._pig.height / 2, this._pig.visible = !1, this.addChild(this._pig), this._hero = new t.Hero, this._hero.x = 150, this._hero.y = 375, this.addChild(this._hero), this.addEventListener(events.Event.ADDED_TO_STAGE, this.onAddedToStage), this.addEventListener(events.Event.REMOVED_FROM_STAGE, this.onRemovedFromStage) | |
} | |
return __extends(n, e), n.prototype.onAddedToStage = function() { | |
console.log("Master layer added to stage"), this.stage.addEventListener(events.KeyboardEvent.KEY_UP, this.onKeyUp, this), this.stage.addEventListener(events.KeyboardEvent.KEY_DOWN, this.onKeyDown, this), this.stage.addEventListener(events.TouchEvent.TOUCH, this.onTouch, this) | |
}, n.prototype.onRemovedFromStage = function() { | |
this.stage.removeEventListener(events.KeyboardEvent.KEY_UP, this.onKeyUp), this.stage.removeEventListener(events.KeyboardEvent.KEY_DOWN, this.onKeyDown), this.stage.removeEventListener(events.TouchEvent.TOUCH, this.onTouch) | |
}, n.prototype.onKeyUp = function(t) { | |
var e = t.keyCode; | |
(37 == e || 39 == e) && this._hero.cruise() | |
}, n.prototype.onKeyDown = function(e) { | |
var n = e.keyCode; | |
38 == n || 32 == n ? this._hero.state == t.Hero.STATE_RUN ? this._hero.jump() : this._hero.state == t.Hero.STATE_RUN_WITH_PIG && this.throwPig() : 13 == n ? this._hero.state == t.Hero.STATE_RUN_WITH_PIG ? this.throwPig() : this.dropPig() : 39 == n ? this._hero.accelerate() : 37 == n && this._hero.slowdown() | |
}, n.prototype.onTouch = function(e) { | |
var n = e.getTouch(this.stage, events.TouchPhase.BEGAN); | |
n && (this._hero.state == t.Hero.STATE_RUN_WITH_PIG ? this.throwPig() : this._hero.state != t.Hero.STATE_RUN || this._pigFalling || (n.globalY < this.stage.stageHeight / 2 ? this.dropPig() : this._hero.jump())), this._juggler.delayCall(this._hero.cruise.bind(this._hero), 1) | |
}, n.prototype.start = function() { | |
this._hero.run() | |
}, n.prototype.dropPig = function() { | |
this._hero.state != t.Hero.STATE_RUN || this._pig.visible || (this._pigFalling = !0, this._pig.x = this._hero.x, this._pig.y = -50, this._pig.visible = !0, this._pig.rotation = 0, this._juggler.tween(this._pig, .3, { | |
y: this._hero.y - 140, | |
onComplete: this.catchPig.bind(this) | |
})) | |
}, n.prototype.catchPig = function() { | |
this._pigFalling = !1, this._pig.visible = !1, this._hero.runWithPig() | |
}, n.prototype.throwPig = function() { | |
var t = this; | |
if (!this._pig.visible) { | |
var e = .8; | |
this._hero.throwPig(), this._pig.x = this._hero.x, this._pig.visible = !0, this._pig.rotation = -.2, this._juggler.tween(this._pig, e / 2, { | |
transition: animation.Transitions.EASE_OUT, | |
y: this._pig.y - 100, | |
reverse: !0, | |
repeatCount: 2 | |
}), this._juggler.tween(this._pig, e, { | |
x: this.visibleArea.right + this._hero.velocity * e + 400, | |
rotation: Math.random() + .5, | |
onComplete: function() { | |
t._pig.visible = !1 | |
} | |
}) | |
} | |
}, n.prototype.advanceTime = function(t) { | |
this._juggler.advanceTime(t), this._hero.advanceTime(t), this._hero.x += this._hero.velocity * t, this._pigFalling && (this._pig.x = this._hero.x) | |
}, n | |
}(t.ParallaxLayer); | |
t.MasterLayer = e | |
})(game || (game = {})); | |
//world | |
var game; | |
(function(t) { | |
var e = function(e) { | |
function n(n, r) { | |
e.call(this), this._currentTime = 0, this._visibleArea = new geom.Rectangle(0, 0, n, r), this._scrollVelocity = 0; | |
var i = new t.ParallaxLayer(["clouds_0", "clouds_1"], 250); | |
i.z = 980, this.addChild(i); | |
var o = new t.ParallaxLayer(["clouds_1", "clouds_0"], 360); | |
o.z = 900, this.addChild(o); | |
var s = new t.ParallaxLayer(["trees_0", "trees_1"], 400); | |
s.z = 500, this.addChild(s); | |
var a = new t.MasterLayer; | |
this.addChild(a), this._layers = [i, o, s, a], this.updateVisibleArea() | |
} | |
return __extends(n, e), n.STD_SCROLL_VELOCITY = 200, n.MAX_DIST = 1e3, n.sRect = new geom.Rectangle, n.prototype.start = function() { | |
core.Starling.current.juggler.tween(this, 2, { | |
_scrollVelocity: n.STD_SCROLL_VELOCITY | |
}), this.masterLayer.start() | |
}, n.prototype.advanceTime = function(t) { | |
this._visibleArea.x += t * this._scrollVelocity, this.masterLayer.advanceTime(t), this.updateVisibleArea() | |
}, n.prototype.updateVisibleArea = function() { | |
for (var t in this._layers) { | |
var e = this._layers[t], | |
r = 1 - e.z / n.MAX_DIST, | |
i = n.sRect; | |
i.setTo(this._visibleArea.x, this._visibleArea.y, this._visibleArea.width, this._visibleArea.height), i.x *= r, i.y *= r, e.visibleArea = i, e.x = 0 | -i.x | |
} | |
}, Object.defineProperty(n.prototype, "visibleArea", { | |
get: function() { | |
return this._visibleArea | |
}, | |
set: function(t) { | |
this._visibleArea.setTo(t.x, t.y, t.width, t.height), this.updateVisibleArea() | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "numLayers", { | |
get: function() { | |
return this._layers.length | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), Object.defineProperty(n.prototype, "masterLayer", { | |
get: function() { | |
return this._layers[this.numLayers - 1] | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), n | |
}(display.DisplayObjectContainer); | |
t.World = e | |
})(game || (game = {})); | |
//game - entry point | |
var game; | |
(function(t) { | |
var e = function(e) { | |
function n() { | |
e.call(this); | |
var n = core.Starling.current, | |
r = n.stage; | |
this._currentTime = 0, this._isStarted = !1, this.loadTextures(), this.addEventListener(events.Event.ENTER_FRAME, this.onEnterFrame), this._world = new t.World(r.stageWidth, r.stageHeight), this.addChild(this._world), this.showLoadingBubble() | |
} | |
return __extends(n, e), n.prototype.loadTextures = function() { | |
var t = [{ | |
id: "loading", | |
src: "assets/loading.png", | |
width: 414, | |
height: 244 | |
}, { | |
id: "clouds_0", | |
src: "assets/clouds_0.png", | |
width: 338, | |
height: 223 | |
}, { | |
id: "clouds_1", | |
src: "assets/clouds_1.png", | |
width: 468, | |
height: 209 | |
}, { | |
id: "grass_0", | |
src: "assets/grass_0.png", | |
width: 176, | |
height: 68 | |
}, { | |
id: "grass_1", | |
src: "assets/grass_1.png", | |
width: 425, | |
height: 68 | |
}, { | |
id: "grass_2", | |
src: "assets/grass_2.png", | |
width: 244, | |
height: 68 | |
}, { | |
id: "grass_3", | |
src: "assets/grass_3.png", | |
width: 192, | |
height: 68 | |
}, { | |
id: "trees_0", | |
src: "assets/trees_0.png", | |
width: 619, | |
height: 181 | |
}, { | |
id: "trees_1", | |
src: "assets/trees_1.png", | |
width: 480, | |
height: 254 | |
}, { | |
id: "shadow", | |
src: "assets/shadow.png", | |
width: 110, | |
height: 28 | |
}, { | |
id: "pig", | |
src: "assets/pig.png", | |
width: 191, | |
height: 182 | |
}], | |
e = function(t) { | |
for (var e = t + ""; 2 > e.length;) e = "0" + e; | |
return e | |
}, n = function(n, r, i, o) { | |
for (var s = 1; r >= s; ++s) t.push({ | |
id: n + "_" + e(s), | |
src: "assets/" + n + "_" + e(s) + ".png", | |
width: i, | |
height: o | |
}) | |
}; | |
n("wait", 1, 133, 132), n("run", 15, 165, 131), n("roll", 10, 500, 415), n("airborne", 11, 137, 140), n("landing", 7, 175, 151), n("run-with-pig", 15, 239, 213), n("throw", 7, 164, 166), core.Starling.current.load(t) | |
}, n.prototype.showLoadingBubble = function() { | |
this._loadingBubble = new display.SimpleImage(core.Starling.current.getImageSource("loading")), this._loadingBubble.pivotY = 244, this.addChild(this._loadingBubble) | |
}, n.prototype.removeLoadingBubble = function() { | |
var t = this; | |
core.Starling.current.juggler.tween(this._loadingBubble, .3, { | |
transition: animation.Transitions.EASE_IN, | |
x: 300, | |
scaleX: 0, | |
scaleY: 0, | |
onComplete: function() { | |
t._loadingBubble.removeFromParent() | |
} | |
}) | |
}, n.prototype.onEnterFrame = function(t) { | |
var e = Math.min(.2, t.passedTime); | |
this._currentTime += e, this._isStarted || core.Starling.current.isLoaderRunning || (this.removeLoadingBubble(), this._world.start(), this._isStarted = !0), this._isStarted ? (this._world.advanceTime(e), this._world.updateVisibleArea()) : (this._loadingBubble.x = 230 + 10 * Math.sin(1.5 * this._currentTime), this._loadingBubble.y = 275 + 15 * Math.sin(2 * this._currentTime)) | |
}, Object.defineProperty(n.prototype, "isStarted", { | |
get: function() { | |
return null != this._world | |
}, | |
enumerable: !0, | |
configurable: !0 | |
}), n | |
}(display.DisplayObjectContainer); | |
t.Game = e | |
})(game || (game = {})), define("game", ["jquery", "raf", "preloadjs", "starling"], function(t) { | |
return function() { | |
var e, n; | |
return n = function() { | |
return game | |
}, e = n.apply(t, arguments), e || t.game | |
} | |
}(this)), requirejs(["starling", "game"], function(t, e) { | |
t.core.Starling.create(e.Game, "stage").startOnReady() | |
}), define("run", function() {}) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment