www.gusucode.com > monkey 游戏微信朋友圈小游戏源码程序 > monkey/js/quark.base-1.0.0.alpha.min.js

    (function(c){var b=c.Quark=c.Quark||{version:"1.0.0",global:c},a=function(){};b.inherit=function(b,g){a.prototype=g.prototype;b.superClass=g.prototype;b.prototype=new a;b.prototype.constructor=b};b.merge=function(a,b,c){for(var e in b)if(!c||a.hasOwnProperty(e))a[e]=b[e];return a};b.delegate=function(a,b){var d=b||c;if(arguments.length>2){var e=Array.prototype.slice.call(arguments,2);return function(){var b=Array.prototype.concat.apply(e,arguments);return a.apply(d,b)}}else return function(){return a.apply(d,
arguments)}};b.getDOM=function(a){return document.getElementById(a)};b.createDOM=function(a,b){var c=document.createElement(a),e;for(e in b){var h=b[e];if(e=="style")for(var i in h)c.style[i]=h[i];else c[e]=h}return c};b.use=function(a){for(var a=a.split("."),b=c,d=0;d<a.length;d++)var e=a[d],b=b[e]||(b[e]={});return b};(function(a){var b=a.ua=navigator.userAgent;a.isWebKit=/webkit/i.test(b);a.isMozilla=/mozilla/i.test(b);a.isIE=/msie/i.test(b);a.isFirefox=/firefox/i.test(b);a.isChrome=/chrome/i.test(b);
a.isSafari=/safari/i.test(b)&&!this.isChrome;a.isMobile=/mobile/i.test(b);a.isOpera=/opera/i.test(b);a.isIOS=/ios/i.test(b);a.isIpad=/ipad/i.test(b);a.isIpod=/ipod/i.test(b);a.isIphone=/iphone/i.test(b)&&!this.isIpod;a.isAndroid=/android/i.test(b);a.supportStorage="localStorage"in c;a.supportOrientation="orientation"in c;a.supportDeviceMotion="ondevicemotion"in c;a.supportTouch="ontouchstart"in c;a.cssPrefix=a.isWebKit?"webkit":a.isFirefox?"Moz":a.isOpera?"O":a.isIE?"ms":""})(b);b.getElementOffset=
function(a){for(var b=a.offsetLeft,c=a.offsetTop;(a=a.offsetParent)&&a!=document.body&&a!=document;)b+=a.offsetLeft,c+=a.offsetTop;return{left:b,top:c}};b.createDOMDrawable=function(a,c){var d=a.tagName||"div",e=c.image,h=a.width||e&&e.width,i=a.height||e&&e.height,j=b.createDOM(d);if(a.id)j.id=a.id;j.style.position="absolute";j.style.left=(a.left||0)+"px";j.style.top=(a.top||0)+"px";j.style.width=h+"px";j.style.height=i+"px";if(d=="canvas")j.width=h,j.height=i,e&&(d=j.getContext("2d"),h=c.rect||
[0,0,h,i],d.drawImage(e,h[0],h[1],h[2],h[3],a.x||0,a.y||0,a.width||h[2],a.height||h[3]));else if(j.style.opacity=a.alpha!=void 0?a.alpha:1,j.style.overflow="hidden",e&&e.src)j.style.backgroundImage="url("+e.src+")",j.style.backgroundPosition=-(a.rectX||0)+"px "+-(a.rectY||0)+"px";return j};b.toString=function(){return"Quark"};b.trace=function(){var a=Array.prototype.slice.call(arguments);typeof console!="undefined"&&typeof console.log!="undefined"&&console.log(a.join(" "))};if(c.Q==void 0)c.Q=b;if(c.trace==
void 0)c.trace=b.trace})(window);(function(){var c=Quark.Matrix=function(b,a,f,c,d,e){this.a=b;this.b=a;this.c=f;this.d=c;this.tx=d;this.ty=e};c.prototype.concat=function(b){var a=this.a,f=this.c,c=this.tx;this.a=a*b.a+this.b*b.c;this.b=a*b.b+this.b*b.d;this.c=f*b.a+this.d*b.c;this.d=f*b.b+this.d*b.d;this.tx=c*b.a+this.ty*b.c+b.tx;this.ty=c*b.b+this.ty*b.d+b.ty;return this};c.prototype.rotate=function(b){var a=Math.cos(b),b=Math.sin(b),f=this.a,c=this.c,d=this.tx;this.a=f*a-this.b*b;this.b=f*b+this.b*a;this.c=c*a-this.d*b;this.d=
c*b+this.d*a;this.tx=d*a-this.ty*b;this.ty=d*b+this.ty*a;return this};c.prototype.scale=function(b,a){this.a*=b;this.d*=a;this.tx*=b;this.ty*=a;return this};c.prototype.translate=function(b,a){this.tx+=b;this.ty+=a;return this};c.prototype.identity=function(){this.a=this.d=1;this.b=this.c=this.tx=this.ty=0;return this};c.prototype.invert=function(){var b=this.a,a=this.b,f=this.c,c=this.d,d=this.tx,e=b*c-a*f;this.a=c/e;this.b=-a/e;this.c=-f/e;this.d=b/e;this.tx=(f*this.ty-c*d)/e;this.ty=-(b*this.ty-
a*d)/e;return this};c.prototype.clone=function(){return new c(this.a,this.b,this.c,this.d,this.tx,this.ty)};c.prototype.toString=function(){return"(a="+this.a+", b="+this.b+", c="+this.c+", d="+this.d+", tx="+this.tx+", ty="+this.ty+")"}})();(function(){var c=Quark.Rectangle=function(b,a,f,c){this.x=b;this.y=a;this.width=f;this.height=c};c.prototype.intersects=function(b){return this.x<=b.x+b.width&&b.x<=this.x+this.width&&this.y<=b.y+b.height&&b.y<=this.y+this.height};c.prototype.intersection=function(b){var a=Math.max(this.x,b.x),f=Math.min(this.x+this.width,b.x+b.width);if(a<=f){var g=Math.max(this.y,b.y),b=Math.min(this.y+this.height,b.y+b.height);if(g<=b)return new c(a,g,f-a,b-g)}return null};c.prototype.union=function(b,a){var f=
Math.min(this.x,b.x),g=Math.min(this.y,b.y),d=Math.max(this.x+this.width,b.x+b.width)-f,e=Math.max(this.y+this.height,b.y+b.height)-g;if(a)return new c(f,g,d,e);else this.x=f,this.y=g,this.width=d,this.height=e};c.prototype.containsPoint=function(b,a){return this.x<=b&&b<=this.x+this.width&&this.y<=a&&a<=this.y+this.height};c.prototype.clone=function(){return new c(this.x,this.y,this.width,this.height)};c.prototype.toString=function(){return"(x="+this.x+", y="+this.y+", width="+this.width+", height="+
this.height+")"}})();(function(){Quark.KEY={MOUSE_LEFT:1,MOUSE_MID:2,MOUSE_RIGHT:3,BACKSPACE:8,TAB:9,NUM_CENTER:12,ENTER:13,RETURN:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,ESCAPE:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:44,INSERT:45,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,
CONTEXT_MENU:93,NUM_ZERO:96,NUM_ONE:97,NUM_TWO:98,NUM_THREE:99,NUM_FOUR:100,NUM_FIVE:101,NUM_SIX:102,NUM_SEVEN:103,NUM_EIGHT:104,NUM_NINE:105,NUM_MULTIPLY:106,NUM_PLUS:107,NUM_MINUS:109,NUM_PERIOD:110,NUM_DIVISION:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123}})();(function(){var c=Quark.EventManager=function(){this.keyState={}};c.prototype.registerStage=function(b,a,f,c){this.register(b.context.canvas,a,function(a){b.onEvent(a)},f,c)};c.prototype.register=function(b,a,f,c,d){for(var e={prevent:c,stop:d},h=this,c=function(a){h._onEvent(a,e,f)},d=0;d<a.length;d++)b.addEventListener(a[d],c,!1)};c.prototype._onEvent=function(b,a,f){var c=b.type;if(c=="keydown"||c=="keyup"||c=="keypress")this.keyState[b.keyCode]=c;f!=null&&f(b);a.prevent&&b.preventDefault();a.stop&&
(b.stopPropagation(),b.stopImmediatePropagation&&b.stopImmediatePropagation())};c.stop=function(b,a,f){a||b.preventDefault();f||b.stopPropagation()}})();(function(){var c=Quark.EventDispatcher=function(){this._eventMap={}};c.prototype.addEventListener=function(b,a){var f=this._eventMap[b];f==null&&(f=this._eventMap[b]=[]);return f.indexOf(a)==-1?(f.push(a),!0):!1};c.prototype.removeEventListener=function(b,a){var f=this._eventMap[b];if(f==null)return!1;for(var c=0;c<f.length;c++)if(f[c]===a)return f.splice(c,1),f.length==0&&delete this._eventMap[b],!0;return!1};c.prototype.removeEventListenerByType=function(b){return this._eventMap[b]!=null?(delete this._eventMap[b],
!0):!1};c.prototype.removeAllEventListeners=function(){this._eventMap={}};c.prototype.dispatchEvent=function(b){var a=this._eventMap[b.type];if(a==null)return!1;if(!b.target)b.target=this;for(var f=0;f<a.length;f++){var c=a[f];typeof c=="function"&&c.call(this,b)}return!0};c.prototype.hasEventListener=function(b){b=this._eventMap[b];return b!=null&&b.length>0};c.prototype.on=c.prototype.addEventListener;c.prototype.un=c.prototype.removeEventListener;c.prototype.fire=c.prototype.dispatchEvent})();(function(){var c=Quark.UIDUtil={_counter:0};c.createUID=function(b){var a=b.charCodeAt(b.length-1);a>=48&&a<=57&&(b+="_");return b+this._counter++};c.displayObjectToString=function(b){for(var a;b!=null;b=b.parent){var f=b.id!=null?b.id:b.name;a=a==null?f:f+"."+a;if(b==b.parent)break}return a}})();(function(){function c(a,b){for(var f=0;f<a.children.length;f++){var h=a.children[f];if(h.children)c(h,b);else if(b!=null){var i=h.getBounds();if(h._rotatedPoints!=null){b.globalAlpha=0.2;b.beginPath();var j=h._rotatedPoints[0];b.moveTo(j.x-0.5,j.y-0.5);for(var k=1;k<h._rotatedPoints.length;k++){var l=h._rotatedPoints[k];b.lineTo(l.x-0.5,l.y-0.5)}b.lineTo(j.x-0.5,j.y-0.5);b.stroke();b.closePath();b.globalAlpha=0.5}b.beginPath();b.rect((i.x>>0)-0.5,(i.y>>0)-0.5,i.width>>0,i.height>>0);b.stroke();b.closePath()}else if(h.drawable.domDrawable)h.drawable.domDrawable.style.border=
"1px solid #f00"}}Quark.getUrlParams=function(){var d;var a={},b=window.location.href,f=b.indexOf("?");if(f>0)for(var b=b.substring(f+1).split("&"),f=0,c;c=b[f];f++)d=b[f]=c.split("="),c=d,a[c[0]]=c.length>1?c[1]:!0;return a};var b=document.head,a=b.getElementsByTagName("meta"),f=a.length>0?a[a.length-1].nextSibling:b.childNodes[0];Quark.addMeta=function(a){var c=document.createElement("meta"),e;for(e in a)c.setAttribute(e,a[e]);b.insertBefore(c,f)};Quark.toggleDebugRect=function(a){a.paused=!a.paused;
if(a.paused){var b=a.context;a._update(b);b=b.context;if(b!=null)b.save(),b.lineWidth=1,b.strokeStyle="#f00",b.globalAlpha=0.5;c(a,b);b!=null&&b.restore()}}})();(function(){var c=Quark.Timer=function(b){this.interval=b||50;this.paused=!1;this.info={lastTime:0,currentTime:0,deltaTime:0,realDeltaTime:0};this._startTime=0;this._intervalID=null;this._listeners=[]};c.prototype.start=function(){if(this._intervalID==null){this._startTime=this.info.lastTime=this.info.currentTime=Date.now();var b=this,a=function(){b._intervalID=setTimeout(a,b.interval);b._run()};a()}};c.prototype.stop=function(){clearTimeout(this._intervalID);this._intervalID=null;this._startTime=
0};c.prototype.pause=function(){this.paused=!0};c.prototype.resume=function(){this.paused=!1};c.prototype._run=function(){if(!this.paused){var b=this.info,a=b.currentTime=Date.now();b.deltaTime=b.realDeltaTime=a-b.lastTime;for(var f=0,c=this._listeners.length,d,e;f<c;f++)d=this._listeners[f],e=d.__runTime||0,e==0?d.step(this.info):a>e&&(d.step(this.info),this._listeners.splice(f,1),f--,c--);b.lastTime=a}};c.prototype.delay=function(b,a){this.addListener({step:b,__runTime:Date.now()+a})};c.prototype.addListener=
function(b){if(b==null||typeof b.step!="function")throw"Timer Error: The listener object must implement a step() method!";this._listeners.push(b)};c.prototype.removeListener=function(b){b=this._listeners.indexOf(b);b>-1&&this._listeners.splice(b,1)}})();(function(){var c=Quark.ImageLoader=function(b){c.superClass.constructor.call(this);this.loading=!1;this._index=-1;this._loaded=0;this._images={};this._totalSize=0;this._loadHandler=Quark.delegate(this._loadHandler,this);this._addSource(b)};Quark.inherit(c,Quark.EventDispatcher);c.prototype.load=function(b){this._addSource(b);this.loading||this._loadNext()};c.prototype._addSource=function(b){if(b){for(var b=b instanceof Array?b:[b],a=0;a<b.length;a++)this._totalSize+=b[a].size||0;this._source=this._source?
this._source.concat(b):b}};c.prototype._loadNext=function(){this._index++;if(this._index>=this._source.length)this.dispatchEvent({type:"complete",target:this,images:this._images}),this._source=[],this.loading=!1,this._index=-1;else{var b=new Image;b.onload=this._loadHandler;b.src=this._source[this._index].src;this.loading=!0}};c.prototype._loadHandler=function(b){this._loaded++;var a=this._source[this._index];a.image=b.target;this._images[a.id||a.src]=a;this.dispatchEvent({type:"loaded",target:this,
image:a});this._loadNext()};c.prototype.getLoaded=function(){return this._loaded};c.prototype.getTotal=function(){return this._source.length};c.prototype.getLoadedSize=function(){var b=0,a;for(a in this._images)b+=this._images[a].size||0;return b};c.prototype.getTotalSize=function(){return this._totalSize}})();(function(){var c=Quark.Tween=function(a,f,c){this.target=a;this.delay=this.time=0;this.reverse=this.loop=this.paused=!1;this.interval=0;this.ease=b.Linear.EaseNone;this.onComplete=this.onUpdate=this.onStart=this.next=null;this._oldProps={};this._newProps={};this._deltaProps={};this._lastTime=this._startTime=0;this._reverseFlag=1;this._frameCount=this._frameTotal=0;for(var d in f){var e=a[d],h=f[d];e!==void 0&&typeof e=="number"&&typeof h=="number"&&(this._oldProps[d]=e,this._newProps[d]=h,this._deltaProps[d]=
h-e)}for(d in c)this[d]!==void 0&&(this[d]=c[d])};c.prototype.setProps=function(a,b){for(var c in a)this.target[c]=this._oldProps[c]=a[c];for(c in b)this._newProps[c]=b[c],this._deltaProps[c]=b[c]-this.target[c]};c.prototype._init=function(){this._startTime=Date.now()+this.delay;if(this.interval>0)this._frameTotal=Math.round(this.time/this.interval);c.add(this)};c.prototype.start=function(){this._init();this.paused=!1};c.prototype.stop=function(){this.paused=!0;c.remove(this)};c.prototype.pause=function(){this.paused=
!0};c.prototype._update=function(){if(!this.paused){var a=Date.now(),b=a-this._startTime;if(!(b<0)){if(this._lastTime==0&&this.onStart!=null)this.onStart(this);this._lastTime=a;a=this._frameTotal>0?++this._frameCount/this._frameTotal:b/this.time;a>1&&(a=1);var b=this.ease(a),g;for(g in this._oldProps)this.target[g]=this._oldProps[g]+this._deltaProps[g]*this._reverseFlag*b;if(this.onUpdate!=null)this.onUpdate(this,b);if(a>=1){if(this.reverse){if(g=this._oldProps,this._oldProps=this._newProps,this._newProps=
g,this._startTime=Date.now(),this._frameCount=0,this._reverseFlag*=-1,!this.loop)this.reverse=!1}else if(this.loop){for(g in this._oldProps)this.target[g]=this._oldProps[g];this._startTime=Date.now();this._frameCount=0}else if(c.remove(this),g=this.next,g!=null&&(g instanceof c?(a=g,g=null):a=g.shift(),a!=null))a.next=g,a.start();if(this.onComplete!=null)this.onComplete(this)}}}};c._tweens=[];c.step=function(){for(var a=this._tweens,b=a.length;--b>=0;)a[b]._update()};c.add=function(a){this._tweens.indexOf(a)==
-1&&this._tweens.push(a);return this};c.remove=function(a){var b=this._tweens,a=b.indexOf(a);a>-1&&b.splice(a,1);return this};c.to=function(a,b,g){a=new c(a,b,g);a._init();return a};c.from=function(a,b,g){b=new c(a,b,g);g=b._oldProps;b._oldProps=b._newProps;b._newProps=g;b._reverseFlag=-1;for(var d in b._oldProps)a[d]=b._oldProps[d];b._init();return b};var b=Quark.Easing={Linear:{},Quadratic:{},Cubic:{},Quartic:{},Quintic:{},Sinusoidal:{},Exponential:{},Circular:{},Elastic:{},Back:{},Bounce:{}};b.Linear.EaseNone=
function(a){return a};b.Quadratic.EaseIn=function(a){return a*a};b.Quadratic.EaseOut=function(a){return-a*(a-2)};b.Quadratic.EaseInOut=function(a){return(a*=2)<1?0.5*a*a:-0.5*(--a*(a-2)-1)};b.Cubic.EaseIn=function(a){return a*a*a};b.Cubic.EaseOut=function(a){return--a*a*a+1};b.Cubic.EaseInOut=function(a){return(a*=2)<1?0.5*a*a*a:0.5*((a-=2)*a*a+2)};b.Quartic.EaseIn=function(a){return a*a*a*a};b.Quartic.EaseOut=function(a){return-(--a*a*a*a-1)};b.Quartic.EaseInOut=function(a){return(a*=2)<1?0.5*a*
a*a*a:-0.5*((a-=2)*a*a*a-2)};b.Quintic.EaseIn=function(a){return a*a*a*a*a};b.Quintic.EaseOut=function(a){return(a-=1)*a*a*a*a+1};b.Quintic.EaseInOut=function(a){return(a*=2)<1?0.5*a*a*a*a*a:0.5*((a-=2)*a*a*a*a+2)};b.Sinusoidal.EaseIn=function(a){return-Math.cos(a*Math.PI/2)+1};b.Sinusoidal.EaseOut=function(a){return Math.sin(a*Math.PI/2)};b.Sinusoidal.EaseInOut=function(a){return-0.5*(Math.cos(Math.PI*a)-1)};b.Exponential.EaseIn=function(a){return a==0?0:Math.pow(2,10*(a-1))};b.Exponential.EaseOut=
function(a){return a==1?1:-Math.pow(2,-10*a)+1};b.Exponential.EaseInOut=function(a){return a==0?0:a==1?1:(a*=2)<1?0.5*Math.pow(2,10*(a-1)):0.5*(-Math.pow(2,-10*(a-1))+2)};b.Circular.EaseIn=function(a){return-(Math.sqrt(1-a*a)-1)};b.Circular.EaseOut=function(a){return Math.sqrt(1- --a*a)};b.Circular.EaseInOut=function(a){return(a/=0.5)<1?-0.5*(Math.sqrt(1-a*a)-1):0.5*(Math.sqrt(1-(a-=2)*a)+1)};b.Elastic.EaseIn=function(a){var b,c=0.1,d=0.4;if(a==0)return 0;else if(a==1)return 1;else d||(d=0.3);!c||
c<1?(c=1,b=d/4):b=d/(2*Math.PI)*Math.asin(1/c);return-(c*Math.pow(2,10*(a-=1))*Math.sin((a-b)*2*Math.PI/d))};b.Elastic.EaseOut=function(a){var b,c=0.1,d=0.4;if(a==0)return 0;else if(a==1)return 1;else d||(d=0.3);!c||c<1?(c=1,b=d/4):b=d/(2*Math.PI)*Math.asin(1/c);return c*Math.pow(2,-10*a)*Math.sin((a-b)*2*Math.PI/d)+1};b.Elastic.EaseInOut=function(a){var b,c=0.1,d=0.4;if(a==0)return 0;else if(a==1)return 1;else d||(d=0.3);!c||c<1?(c=1,b=d/4):b=d/(2*Math.PI)*Math.asin(1/c);return(a*=2)<1?-0.5*c*Math.pow(2,
10*(a-=1))*Math.sin((a-b)*2*Math.PI/d):c*Math.pow(2,-10*(a-=1))*Math.sin((a-b)*2*Math.PI/d)*0.5+1};b.Back.EaseIn=function(a){return a*a*(2.70158*a-1.70158)};b.Back.EaseOut=function(a){return(a-=1)*a*(2.70158*a+1.70158)+1};b.Back.EaseInOut=function(a){return(a*=2)<1?0.5*a*a*(3.5949095*a-2.5949095):0.5*((a-=2)*a*(3.5949095*a+2.5949095)+2)};b.Bounce.EaseIn=function(a){return 1-b.Bounce.EaseOut(1-a)};b.Bounce.EaseOut=function(a){return(a/=1)<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+0.75:a<2.5/
2.75?7.5625*(a-=2.25/2.75)*a+0.9375:7.5625*(a-=2.625/2.75)*a+0.984375};b.Bounce.EaseInOut=function(a){return a<0.5?b.Bounce.EaseIn(a*2)*0.5:b.Bounce.EaseOut(a*2-1)*0.5+0.5}})();(function(){var c=Quark.Audio=function(b,a,f,g){c.superClass.constructor.call(this);this.src=b;this.autoPlay=a&&f;this.loop=g;this._playing=this._loaded=!1;this._evtHandler=Quark.delegate(this._evtHandler,this);this._element=document.createElement("audio");this._element.preload=a;this._element.src=b;a&&this.load()};Quark.inherit(c,Quark.EventDispatcher);c.prototype.load=function(){this._element.addEventListener("progress",this._evtHandler,!1);this._element.addEventListener("ended",this._evtHandler,
!1);this._element.addEventListener("error",this._evtHandler,!1);try{this._element.load()}catch(b){trace(b)}};c.prototype._evtHandler=function(b){if(b.type=="progress"){var a=0,c=0,g=b.target.buffered;if(g&&g.length>0)for(a=g.length;a>=0;a--)c=g.end(a)-g.start(a);if(c/b.target.duration>=1)this._element.removeEventListener("progress",this._evtHandler),this._element.removeEventListener("error",this._evtHandler),this._loaded=!0,this.dispatchEvent({type:"loaded",target:this}),this.autoPlay&&this.play()}else b.type==
"ended"?(this.dispatchEvent({type:"ended",target:this}),this.loop?this.play():this._playing=!1):b.type=="error"&&trace("Quark.Audio Error: "+b.target.src)};c.prototype.play=function(){this._loaded?(this._element.play(),this._playing=!0):(this.autoPlay=!0,this.load())};c.prototype.stop=function(){if(this._playing)this._element.pause(),this._playing=!1};c.prototype.loaded=function(){return this._loaded};c.prototype.playing=function(){return this._playing}})();(function(){(Quark.Drawable=function(c,b){if(c instanceof HTMLImageElement||c instanceof HTMLCanvasElement||c instanceof HTMLVideoElement)this.rawDrawable=c;if(b===!0)this.domDrawable=c}).prototype.get=function(c,b){if(b==null||b.canvas.getContext!=null)return this.rawDrawable;else{if(this.domDrawable==null)this.domDrawable=Quark.createDOMDrawable(c,{image:this.rawDrawable});return this.domDrawable}}})();(function(){function c(a){for(var b=new Quark.Matrix(1,0,0,1,0,0);a.parent!=null;a=a.parent){var c=1,e=0;a.rotation%360!=0&&(e=a.rotation*Quark.RADIAN,c=Math.cos(e),e=Math.sin(e));a.regX!=0&&(b.tx-=a.regX);a.regY!=0&&(b.ty-=a.regY);b.concat(new Quark.Matrix(c*a.scaleX,e*a.scaleX,-e*a.scaleY,c*a.scaleY,a.x,a.y))}return b}function b(a,b,c,e){return{x:(b.x-a.x)*e-(b.y-a.y)*c+a.x+0.5>>0,y:(b.y-a.y)*e+(b.x-a.x)*c+a.y+0.5>>0}}var a=Quark.DisplayObject=function(a){this.id=Quark.UIDUtil.createUID("DisplayObject");
this.name=null;this.height=this.width=this.regY=this.regX=this.y=this.x=0;this.scaleY=this.scaleX=this.alpha=1;this.rotation=0;this.transformEnabled=this.eventEnabled=this.visible=!0;this.context=this.parent=this.drawable=null;this._depth=0;this._lastState={};this._stateList=["x","y","regX","regY","width","height","alpha","scaleX","scaleY","rotation","visible","_depth"];Quark.merge(this,a)};a.prototype.setDrawable=function(a){if(this.drawable==null||this.drawable.rawDrawable!=a)this.drawable=new Quark.Drawable(a)};
a.prototype.getDrawable=function(a){return this.drawable&&this.drawable.get(this,a)};a.prototype._update=function(a){this.update(a)};a.prototype.update=function(){};a.prototype._render=function(a){a=this.context||a;!this.visible||this.alpha<=0?(a.hide!=null&&a.hide(this),this.saveState(["visible","alpha"])):(a.startDraw(),a.transform(this),this.render(a),a.endDraw(),this.saveState())};a.prototype.render=function(a){a.draw(this,0,0,this.width,this.height,0,0,this.width,this.height)};a.prototype._onEvent=
function(a){if(this.onEvent!=null)this.onEvent(a)};a.prototype.onEvent=null;a.prototype.saveState=function(a){for(var a=a||this._stateList,b=this._lastState,c=0,e=a.length;c<e;c++){var h=a[c];b["last"+h]=this[h]}};a.prototype.getState=function(a){return this._lastState["last"+a]};a.prototype.propChanged=function(){for(var a=arguments.length>0?arguments:this._stateList,b=0,c=a.length;b<c;b++){var e=a[b];if(this._lastState["last"+e]!=this[e])return!0}return!1};a.prototype.hitTestPoint=function(a,b,
c){return!c?(c=this.getBounds(),a>=c.x&&a<=c.x+c.width&&b>=c.y&&b<=c.y+c.height):!1};a.prototype.hitTestObject=function(a,b){var c=this.getBounds(),e=a.getBounds();return!b?c.x<=e.x+e.width&&e.x<=c.x+c.width&&c.y<=e.y+e.height&&e.y<=c.y+c.height:!1};a.prototype.localToGlobal=function(a,b){var d=c(this);return{x:d.tx+a,y:d.ty+b}};a.prototype.globalToLocal=function(a,b){var d=c(this).invert();return{x:d.tx+a,y:d.ty+b}};a.prototype.localToTarget=function(a,b,c){a=this.localToGlobal(a,b);return c.globalToLocal(a.x,
a.y)};a.prototype.getBounds=function(a){var a=a==null?this.localToGlobal(0,0):this.localToTarget(0,0,a),c=this.x,d=this.y,e=this.regX,h=this.regY,i=this.getCurrentWidth(),j=this.getCurrentHeight();if(this.rotation%360!=0){var a=this.rotation*Quark.RADIAN,k=Math.sin(a),l=Math.cos(a),n={x:c,y:d},a=b(n,{x:c-e,y:d-h},k,l),m=b(n,{x:c-e+i,y:d-h},k,l),i=b(n,{x:c-e+i,y:d-h+j},k,l),c=b(n,{x:c-e,y:d-h+j},k,l);this._rotatedPoints=[a,m,i,c];d=Math.min(a.x,m.x,i.x,c.x);e=Math.min(a.y,m.y,i.y,c.y);return{x:d,y:e,
width:Math.max(a.x,m.x,i.x,c.x)-d,height:Math.max(a.y,m.y,i.y,c.y)-e}}return{x:a.x,y:a.y,width:i,height:j}};a.prototype.getCurrentWidth=function(){return Math.abs(this.width*this.scaleX)};a.prototype.getCurrentHeight=function(){return Math.abs(this.height*this.scaleY)};a.prototype.getStage=function(){for(var a=this;a.parent;)a=a.parent;return a instanceof Quark.Stage?a:null};a.prototype.toString=function(){return Quark.UIDUtil.displayObjectToString(this)}})();(function(){var c=Quark.DisplayObjectContainer=function(b){this.eventChildren=!0;this.autoSize=!1;this.children=[];b=b||{};c.superClass.constructor.call(this,b);this.id=b.id||Quark.UIDUtil.createUID("DisplayObjectContainer");this.setDrawable(b.drawable||b.image||null);if(b.children)for(var a=0;a<b.children.length;a++)this.addChild(b.children[a])};Quark.inherit(c,Quark.DisplayObject);c.prototype.addChildAt=function(b,a){if(a<0)a=0;else if(a>this.children.length)a=this.children.length;var c=this.getChildIndex(b);
if(c!=-1){if(c==a)return this;this.children.splice(c,1)}else b.parent&&b.parent.removeChild(b);this.children.splice(a,0,b);b.parent=this;if(this.autoSize){var c=new Quark.Rectangle(0,0,this.rectWidth||this.width,this.rectHeight||this.height),g=new Quark.Rectangle(b.x,b.y,b.rectWidth||b.width,b.rectHeight||b.height);c.union(g);this.width=c.width;this.height=c.height}return this};c.prototype.addChild=function(b){for(var a=this.children.length,c=0;c<arguments.length;c++)b=arguments[c],this.addChildAt(b,
a+c);return this};c.prototype.removeChildAt=function(b){if(b<0||b>=this.children.length)return!1;var a=this.children[b];if(a!=null)this.getStage().context.remove(a),a.parent=null;this.children.splice(b,1);return!0};c.prototype.removeChild=function(b){return this.removeChildAt(this.children.indexOf(b))};c.prototype.removeAllChildren=function(){for(;this.children.length>0;)this.removeChildAt(0)};c.prototype.getChildAt=function(b){return b<0||b>=this.children.length?null:this.children[b]};c.prototype.getChildIndex=
function(b){return this.children.indexOf(b)};c.prototype.setChildIndex=function(b,a){if(b.parent==this){var c=this.children.indexOf(b);a!=c&&(this.children.splice(c,1),this.children.splice(a,0,b))}};c.prototype.contains=function(b){return this.getChildIndex(b)!=-1};c.prototype.getNumChildren=function(){return this.children.length};c.prototype._update=function(b){this.update!=null&&this.update(b);for(var a=0,c=this.children.length;a<c;a++){var g=this.children[a];g._depth=a;g._update(b)}};c.prototype.render=
function(b){c.superClass.render.call(this,b);for(var a=0,f=this.children.length;a<f;a++)this.children[a]._render(b)};c.prototype.getObjectUnderPoint=function(b,a,c,g,d){if(d)var e=[];for(var h=this.children.length-1;h>=0;h--){var i=this.children[h];if(!(i==null||!i.eventEnabled||!i.visible||i.alpha<=0))if(i.children!=void 0&&i.eventChildren&&i.getNumChildren()>0){var j=i.getObjectUnderPoint(b,a,c,g,d);if(j)if(d)j.length>0&&(e=e.concat(j));else return j;else if(i.hitTestPoint(b,a,c,g))if(d)e.push(i);
else return i}else if(i.hitTestPoint(b,a,c,g))if(d)e.push(i);else return i}return d?e:null}})();(function(){var c=Quark.Stage=function(b){this.stageY=this.stageX=0;this.paused=!1;b=b||{};c.superClass.constructor.call(this,b);this.id=b.id||Quark.UIDUtil.createUID("Stage");if(this.context==null)throw"Quark.Stage Error: context is required.";this.updatePosition()};Quark.inherit(c,Quark.DisplayObjectContainer);c.prototype.step=function(b){this.paused||(this._update(b),this._render(this.context))};c.prototype._update=function(b){for(var a=0,c=this.children.length;a<c;a++){var g=this.children[a];
g._depth=a;g._update(b)}this.update!=null&&this.update(b)};c.prototype._render=function(b){b.clear!=null&&b.clear(0,0,this.width,this.height);c.superClass._render.call(this,b)};c.prototype.onEvent=function(b){var a=this.getObjectUnderPoint(b.pageX-this.stageX,b.pageY-this.stageY);a!=null&&a._onEvent(b)};c.prototype.updatePosition=function(){var b=Quark.getElementOffset(this.context.canvas);this.stageX=b.left;this.stageY=b.top}})();(function(){var c=Quark.Bitmap=function(b){this.image=null;this.rectHeight=this.rectWidth=this.rectY=this.rectX=0;b=b||{};c.superClass.constructor.call(this,b);this.id=b.id||Quark.UIDUtil.createUID("Bitmap");this.setRect(b.rect||[0,0,this.image.width,this.image.height]);this.setDrawable(this.image);this._stateList.push("rectX","rectY","rectWidth","rectHeight")};Quark.inherit(c,Quark.DisplayObject);c.prototype.setRect=function(b){this.rectX=b[0];this.rectY=b[1];this.rectWidth=this.width=b[2];this.rectHeight=
this.height=b[3]};c.prototype.render=function(b){b.draw(this,this.rectX,this.rectY,this.rectWidth,this.rectHeight,0,0,this.width,this.height)}})();(function(){var c=Quark.MovieClip=function(b){this.interval=0;this.useFrames=this.paused=!1;this.currentFrame=0;this._frames=[];this._frameLabels={};this._frameDisObj=null;this._displayedCount=0;b=b||{};c.superClass.constructor.call(this,b);this.id=b.id||Quark.UIDUtil.createUID("MovieClip")};Quark.inherit(c,Quark.Bitmap);c.prototype.addFrame=function(b){var a=this._frames.length;if(b instanceof Array)for(var c=0;c<b.length;c++)this.setFrame(b[c],a+c);else this.setFrame(b,a);return this};c.prototype.setFrame=
function(b,a){a==void 0||a>this._frames.length?a=this._frames.length:a<0&&(a=0);this._frames[a]=b;b.label&&(this._frameLabels[b.label]=b);if(b.interval==void 0)b.interval=this.interval;a==0&&this.currentFrame==0&&this.setRect(b.rect)};c.prototype.getFrame=function(b){return typeof b=="number"?this._frames[b]:this._frameLabels[b]};c.prototype.play=function(){this.paused=!1};c.prototype.stop=function(){this.paused=!0};c.prototype.gotoAndStop=function(b){this.currentFrame=this.getFrameIndex(b);this.paused=
!0};c.prototype.gotoAndPlay=function(b){this.currentFrame=this.getFrameIndex(b);this.paused=!1};c.prototype.getFrameIndex=function(b){if(typeof b=="number")return b;for(var b=this._frameLabels[b],a=this._frames,c=0;c<a.length;c++)if(b==a[c])return c;return-1};c.prototype.nextFrame=function(b){var a=this._frames[this.currentFrame];if(a.interval>0)b=this._displayedCount+b,this._displayedCount=a.interval>b?b:0;if(a.jump>=0||typeof a.jump=="string")if(this._displayedCount==0||!a.interval)return this.currentFrame=
this.getFrameIndex(a.jump);return a.interval>0&&this._displayedCount>0?this.currentFrame:this.currentFrame>=this._frames.length-1?this.currentFrame=0:++this.currentFrame};c.prototype._update=function(b){var a=this._frames[this.currentFrame];a.stop?this.stop():(this.paused||this.nextFrame(this.useFrames?1:b&&b.deltaTime),this.setRect(a.rect),c.superClass._update.call(this,b))};c.prototype.render=function(b){var a=this._frames[this.currentFrame].rect;b.draw(this,a[0],a[1],a[2],a[3],0,0,this.width,this.height)}})();(function(){var c=Quark.Context=function(b){if(b.canvas==null)throw"Quark.Context Error: canvas is required.";this.canvas=null;Quark.merge(this,b)};c.prototype.startDraw=function(){};c.prototype.draw=function(){};c.prototype.endDraw=function(){};c.prototype.transform=function(){};c.prototype.remove=function(){}})();(function(){var c=Quark.CanvasContext=function(a){c.superClass.constructor.call(this,a);this.context=this.canvas.getContext("2d")};Quark.inherit(c,Quark.Context);c.prototype.startDraw=function(){this.context.save()};c.prototype.draw=function(a){var b=a.getDrawable(this);b!=null&&(arguments[0]=b,this.context.drawImage.apply(this.context,arguments))};c.prototype.endDraw=function(){this.context.restore()};c.prototype.transform=function(a){var c=this.context;(a.x!=0||a.y!=0)&&c.translate(a.x,a.y);a.rotation%
360!=0&&c.rotate(a.rotation%360*b);(a.scaleX!=1||a.scaleY!=1)&&c.scale(a.scaleX,a.scaleY);(a.regX!=0||a.regY!=0)&&c.translate(-a.regX,-a.regY);a.alpha>0&&(c.globalAlpha*=a.alpha)};c.prototype.clear=function(a,b,c,d){this.context.clearRect(a,b,c,d)};var b=Math.PI/180})();(function(){function c(a,b){var c="";c+=b?"translate3d("+(a.x-a.regX)+"px, "+(a.y-a.regY)+"px, 0px)rotate3d(0, 0, 1, "+a.rotation+"deg)scale3d("+a.scaleX+", "+a.scaleY+", 1)":"translate("+(a.x-a.regX)+"px, "+(a.y-a.regY)+"px)rotate("+a.rotation+"deg)scale("+a.scaleX+", "+a.scaleY+")";return c}var b=document.createElement("div"),a=b.style[Quark.cssPrefix+"Transform"]!=void 0,f=b.style[Quark.cssPrefix+"Perspective"]!=void 0,g=document.documentElement;if(f&&"webkitPerspective"in g.style){b.id="test3d";
var d=document.createElement("style");d.textContent="@media (-webkit-transform-3d){#test3d{height:3px}}";document.head.appendChild(d);g.appendChild(b);f=b.offsetHeight===3;d.parentNode.removeChild(d);b.parentNode.removeChild(b)}Quark.supportTransform=a;Quark.supportTransform3D=f;if(!a)throw"Error: DOMContext requires css transfrom support.";var e=Quark.DOMContext=function(a){e.superClass.constructor.call(this,a)};Quark.inherit(e,Quark.Context);e.prototype.draw=function(a){if(!a._addedToDOM){var b=
a.parent,c=a.getDrawable(this);b==null&&c.parentNode==null?this.canvas.appendChild(c):(b=b.getDrawable(this),c.parentNode!=b&&b.appendChild(c));a._addedToDOM=!0}};e.prototype.transform=function(a){var b=a.getDrawable(this);if(a.transformEnabled||!a._addedToDOM){var d=Quark.cssPrefix,e=d+"TransformOrigin";d+="Transform";if(a.propChanged("visible","alpha"))b.style.display=!a.visible||a.alpha<=0?"none":"";if(a.propChanged("alpha"))b.style.opacity=a.alpha;if(a.propChanged("rectX","rectY"))b.style.backgroundPosition=
-a.rectX+"px "+-a.rectY+"px";if(a.propChanged("width","height"))b.style.width=a.width+"px",b.style.height=a.height+"px";a.propChanged("regX","regY")&&(b.style[e]=a.regX+"px "+a.regY+"px");a.propChanged("x","y","regX","regY","scaleX","scaleY","rotation")&&(e=Quark.supportTransform3D?c(a,!0):c(a,!1),b.style[d]=e);if(a.propChanged("_depth"))b.style.zIndex=a._depth}};e.prototype.hide=function(a){a.getDrawable(this).style.display="none"};e.prototype.remove=function(a){var b=a.getDrawable(this),c=b.parentNode;
c!=null&&c.removeChild(b);a._addedToDOM=!1}})();