UNPKG

@smoud/tiny

Version:

Fast and tiny JavaScript library for HTML5 game and playable ads creation.

1 lines 97.1 kB
!function(){var t={847:function(){Date.now||(Date.now=function(){return(new Date).getTime()}),'undefined'==typeof Float32Array&&(window.Float32Array=Array,window.Uint16Array=Array),void 0===Object.assign&&(Object.assign=function(t){'use strict';if(null==t)throw new TypeError('Cannot convert undefined or null to object');for(var e=Object(t),i=1;i<arguments.length;i++){var r=arguments[i];if(null!=r)for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e})}},e={};function i(r){var s=e[r];if(void 0!==s)return s.exports;var n=e[r]={exports:{}};return t[r](n,n.exports,i),n.exports}!function(){"use strict";i(847);var t=function(t,e,i){this.width=t,this.height=e,this.canvas=document.createElement('canvas'),this.context=this.canvas.getContext('2d',i),this.canvas.width=t,this.canvas.height=e};function e(){this.a=[],this.n=0}t.prototype.constructor=t,t.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.width,this.height)},t.prototype.resize=function(t,e){this.width=this.canvas.width=t,this.height=this.canvas.height=e};var r={call:function(t){t&&(t=t.prototype||t,r.mixin(t))},mixin:function(t){const i={};function r(t,r,s,n){var h=i[t];h||(h=i[t]=new e),h.a.push(r,s||null,n||!1),h.n+=3}t.once=function(t,e,i){r(t,e,i,!0)},t.on=r,t.off=function(t,e,r){if(i[t]){var s=i[t].a;if(e)if(r)for(n=0;n<s.length;n+=3)s[n]==e&&s[n+1]==r&&(s.splice(n,3),n-=3);else for(var n=0;n<s.length;n+=3)s[n]==e&&(s.splice(n,3),n-=3);else s.length=0;0==s.length&&delete i[t]}},t.emit=function(t,e,r,s){var n=i[t];if(n){var h=n.a;n.n=0;for(var o,a,u=arguments.length,l=0;l<h.length-n.n;l+=3)o=h[l],a=h[l+1],h[l+2]&&(h.splice(l,3),l-=3),u<=1?o.call(a):2==u?o.call(a,e):3==u?o.call(a,e,r):o.call(a,e,r,s);0==h.length&&delete i[t]}}}},s=0;function n(){return++s}function h(t){return!(t&t-1||!t)}var o=Math.PI/180,a=180/Math.PI,u={distance:function(t,e,i,r){var s=t-i,n=e-r;return Math.sqrt(s*s+n*n)},clamp:function(t,e,i){return Math.max(e,Math.min(i,t))},degToRad:function(t){return t*o},radToDeg:function(t){return t*a},isPow2:h,getNextPow2:function(t){if(t>0&&0==(t&t-1))return t;for(var e=1;e<t;)e<<=1;return e}};function l(t,e,i){return this.r=1,this.g=1,this.b=1,this.a=1,this.int=16777215,void 0===e&&void 0===i?this.set(t):this.setRGB(t,e,i)}Object.assign(l.prototype,{set:function(t){return t&&'number'==typeof t.int?this.copy(t):'number'==typeof t?this.setHex(t):'string'==typeof t&&this.setStyle(t),this},refresh:function(){return this.int=(255*this.r<<16)+(255*this.g<<8)+(255*this.b|0),this},setHex:function(t){return t|=0,this.int=t,this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,i){return this.r=t,this.g=e,this.b=i,this.refresh()},setStyle:function(t){var e=t.length;if(4===e){var i=t.charAt(1),r=t.charAt(2),s=t.charAt(3);return this.setHex(+('0x'+i+i+r+r+s+s))}return 7===e?this.setHex(+t.replace('#','0x')):this},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this.refresh()},toStyle(){return'#'+('00000'+this.int.toString(16)).slice(-6)},multiply:function(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this.refresh()},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}}),l.WHITE=new l;var c=function(t,e){this.x=t||0,this.y=e||0};c.prototype={set:function(t,e){return this.x=t||0,this.y=e||(0!==e?this.x:0),this},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},copy:function(t){return this.x=t.x,this.y=t.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this}};var d=function(){this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0};d.prototype.fromArray=function(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]},d.prototype.toArray=function(t){this.array||(this.array=new Float32Array(9));var e=this.array;return t?(e[0]=this.a,e[1]=this.b,e[2]=0,e[3]=this.c,e[4]=this.d,e[5]=0,e[6]=this.tx,e[7]=this.ty,e[8]=1):(e[0]=this.a,e[1]=this.c,e[2]=this.tx,e[3]=this.b,e[4]=this.d,e[5]=this.ty,e[6]=0,e[7]=0,e[8]=1),e},d.prototype.apply=function(t,e){e=e||new c;var i=t.x,r=t.y;return e.x=this.a*i+this.c*r+this.tx,e.y=this.b*i+this.d*r+this.ty,e},d.prototype.applyInverse=function(t,e){e=e||new c;var i=1/(this.a*this.d+this.c*-this.b),r=t.x,s=t.y;return e.x=this.d*i*r+-this.c*i*s+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*s+-this.b*i*r+(-this.ty*this.a+this.tx*this.b)*i,e},d.prototype.translate=function(t,e){return this.tx+=t,this.ty+=e,this},d.prototype.scale=function(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this},d.prototype.rotate=function(t){var e=Math.cos(t),i=Math.sin(t),r=this.a,s=this.c,n=this.tx;return this.a=r*e-this.b*i,this.b=r*i+this.b*e,this.c=s*e-this.d*i,this.d=s*i+this.d*e,this.tx=n*e-this.ty*i,this.ty=n*i+this.ty*e,this},d.prototype.append=function(t){var e=this.a,i=this.b,r=this.c,s=this.d;return this.a=t.a*e+t.b*r,this.b=t.a*i+t.b*s,this.c=t.c*e+t.d*r,this.d=t.c*i+t.d*s,this.tx=t.tx*e+t.ty*r+this.tx,this.ty=t.tx*i+t.ty*s+this.ty,this},d.prototype.identity=function(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this};var f=new d;const p={NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16},v={LINEAR:0,NEAREST:1},y={POLY:0,RECT:1,CIRC:2,ELIP:3,RREC:4};var g={VERSION:'3.0.3',CanvasBuffer:t,EventEmitter:r,Math:u,Mat3:d,Vec2:c,Color:l};Object.assign(g,p,v,y),window.Tiny=g;var x=[];function m(t,e){x.push({name:t,_class_:e})}var _,E,w,T,b,A=function(){},R=function(t){this.callbackContext=this,this.state=0,this.timeScale=1,this.width=0,this.height=0,this.systems=[],this.updatable=[],this.paused=!1,this.pauseDuration=0,this.inputView=document.body,Tiny.app||(Tiny.app=this),r.mixin(this),t=t||{},this.boot=t.boot||this.boot||A,this.preload=t.preload||this.preload||A,this.create=t.create||this.create||A,this.update=t.update||this.update||A,this.render=t.render||this.render||A,this._resize_cb=t.resize||A,this._destroy_cb=t.destroy||A;var e=this;setTimeout((function(){e._boot()}),0)};R.prototype._boot=function(){for(var t=0;t<x.length;t++){var e=x[t],i=new e._class_(this);this.systems.push(i),i.update&&this.updatable.push(i),e.name&&(this[e.name]=i)}Tiny.RAF&&(this.raf=new Tiny.RAF(this)),this.boot.call(this.callbackContext);var r=this;setTimeout((function(){r.load?r._preload():r._create()}),0)},R.prototype._preload=function(){this.preload.call(this.callbackContext),this.state=1,this.load.start(this._create)},R.prototype._create=function(){this.emit('load'),this.create.call(this.callbackContext),this.raf&&this.raf.start(),this.state=2},R.prototype.pause=function(){if(this.raf&&this.raf.reset(),!this.paused){for(var t=0;t<this.systems.length;t++)this.systems[t].pause&&this.systems[t].pause();this.paused=!0}},R.prototype.resume=function(){if(this.raf&&this.raf.reset(),this.paused){for(var t=0;t<this.systems.length;t++)this.systems[t].resume&&this.systems[t].resume();this.paused=!1}},R.prototype._update=function(t,e){if(this.paused)this.pauseDuration+=e;else{e*=this.timeScale,this.update.call(this.callbackContext,t,e),this.emit('update',e);for(var i=0;i<this.updatable.length;i++)this.updatable[i].update(e)}this.render(),this.emit('postrender')},R.prototype.resize=function(t,e){this.width=t||this.width,this.height=e||this.height,this.state>0&&(this._resize_cb.call(this.callbackContext,this.width,this.height),this.emit('resize',t,e));var i=this;setTimeout((function(){i.input&&i.input.updateBounds()}),0)},R.prototype.destroy=function(t){for(var e=0;e<this.systems.length;e++)this.systems[e].destroy&&this.systems[e].destroy(t);this.paused=!0,t&&this.load.clearCache(),this.raf&&this.raf.stop(),this._destroy_cb.call(this.callbackContext),Tiny.app===this&&(Tiny.app=null)};var S=function(){return(new Date).getTime()};void 0!==self.performance&&void 0!==self.performance.now?S=self.performance.now.bind(self.performance):void 0!==Date.now&&(S=Date.now);var B=function(t,e){void 0===e&&(e=!1),this.game=t,this.isRunning=!1,this.forceSetTimeOut=e;for(var i=['ms','moz','webkit','o'],r=0;r<i.length&&!window.requestAnimationFrame;r++)window.requestAnimationFrame=window[i[r]+'RequestAnimationFrame'],window.cancelAnimationFrame=window[i[r]+'CancelAnimationFrame']||window[i[r]+'CancelRequestAnimationFrame'];_=!1,E=null,w=null,T=0,b=0};B.prototype={start:function(){T=S(),this.isRunning=!0;var t=this;!window.requestAnimationFrame||this.forceSetTimeOut?(_=!0,E=function(){return t.updateSetTimeout()},w=window.setTimeout(E,0)):(_=!1,E=function(){return t.updateRAF()},w=window.requestAnimationFrame(E))},updateRAF:function(){b=S(),this.isRunning&&(this.game._update(Math.floor(b),b-T),w=window.requestAnimationFrame(E)),T=b},updateSetTimeout:function(){b=S(),this.isRunning&&(this.game._update(Math.floor(b),b-T),w=window.setTimeout(E,B.timeToCall)),T=b},reset:function(){T=S()},stop:function(){_?clearTimeout(w):window.cancelAnimationFrame(w),this.isRunning=!1}},B.timeToCall=15;var C={image:{},texture:{}},M=function(t){r.mixin(this),t.cache=C,this.game=t,this.list=[]};M.prototype={clearCache:function(){for(var t in C.texture)C.texture[t].destroy();for(var t in C)C[t]={}},all:function(t){this.list=this.list.concat(t)},start:function(t){var e=this,i=e.game,r=e.list,s=r.length;function n(){var t=r.shift(),e=M[t.type];e?e(t,h):h()}function h(h,o){e.emit('progress',1-r.length/s),0!=r.length?n():(e.emit('complete'),t.call(i))}0!=s?n():t.call(i)}},m('load',M);var F=function(t,e){this.resolution=1,this.width=100,this.height=100,this.scaleMode=e||0,this.valid=!1,this.source=t,this._UID=n(),this.premultipliedAlpha=!0,this._glTextures=[],this.mipmap=!1,this._dirty=[!0,!0,!0,!0],t&&((t.complete||t.getContext)&&t.width&&t.height?this.onLoad():t.onload=this.onLoad.bind(this),this.imageUrl=null,this._powerOf2=!1)};F.prototype.constructor=F,F.prototype.onLoad=function(t){this.valid=!0,this.width=this.source.naturalWidth||this.source.width,this.height=this.source.naturalHeight||this.source.height,this.dirty(),this.onload&&this.onload()},F.prototype.destroy=function(){this.imageUrl?(delete BaseTextureCache[this.imageUrl],delete PIXI.TextureCache[this.imageUrl],this.imageUrl=null,navigator.isCocoonJS||(this.source.src='')):this.source&&this.source._pixiId&&delete BaseTextureCache[this.source._pixiId],this.source=null,this.unloadFromGPU()},F.prototype.dirty=function(){for(var t=0;t<this._glTextures.length;t++)this._dirty[t]=!0},F.prototype.unloadFromGPU=function(){this.dirty();for(var t=this._glTextures.length-1;t>=0;t--){var e=this._glTextures[t],i=Tiny.glContexts[t];i&&e&&i.deleteTexture(e)}this._glTextures.length=0,this.dirty()};var P=function(t,e){var i=new Image;i.addEventListener('load',(function(){var r=new F(i);C.image[t.key]=r,e(t,r)})),i.src=t.src};M.image=P,M.prototype.image=function(t,e){this.list.push({src:e,key:t,type:'image'})};var L=function(t,e,i,r){this.x=t||0,this.y=e||0,this.width=i||0,this.height=r||0,this.type=y.RECT};L.prototype.contains=function(t,e){if(this.width<=0||this.height<=0)return!1;var i=this.x;if(t>=i&&t<=i+this.width){var r=this.y;if(e>=r&&e<=r+this.height)return!0}return!1},L.prototype.constructor=L;var U=new L(0,0,0,0),I=function(){this.x0=0,this.y0=0,this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.x3=0,this.y3=0},O=function(t,e,i,r){if(this.noFrame=!1,e||(this.noFrame=!0,e=new L(0,0,1,1)),'string'==typeof t){var s=t;if(!(t=C.image[s]))throw new Error('Cache Error: image '+s+' does`t found in cache');C.texture[s]=this,this.key=s}else t instanceof O?t=t.base:t instanceof F||(t=new F(t));this.base=t,this.frame=e,this.trim=r,this.valid=!1,this._uvs=null,this.width=0,this.height=0,this.crop=i||new L(0,0,1,1),t.valid?this.onBaseUpdate():t.onload=this.onBaseUpdate.bind(this)};O.prototype.constructor=O,O.prototype.onBaseUpdate=function(){var t=this.base;this.noFrame&&(this.frame=new L(0,0,t.width,t.height)),this.setFrame(this.frame)},O.prototype.addToCache=function(t,e){this.key=this.key||t,this.frame.name=this.frame.name||e,this.frame.name&&(t+='.'+this.frame.name),C.texture[t]=this},O.prototype.destroy=function(t){t&&this.base.destroy(),this.key&&delete C.texture[this.key],this.valid=!1},O.prototype.setFrame=function(t){this.noFrame=!1,this.frame=t,this.width=t.width,this.height=t.height,this.crop.x=t.x,this.crop.y=t.y,this.crop.width=t.width,this.crop.height=t.height,this.trim||!(t.x+t.width>this.base.width||t.y+t.height>this.base.height)?(this.valid=t&&t.width&&t.height&&this.base.valid,this.trim&&(this.width=this.trim.width,this.height=this.trim.height,this.frame.width=this.trim.width,this.frame.height=this.trim.height),this.valid&&this._updateUvs()):this.valid=!1},O.prototype._updateUvs=function(){this._uvs||(this._uvs=new I);var t=this.crop,e=this.base.width,i=this.base.height;this._uvs.x0=t.x/e,this._uvs.y0=t.y/i,this._uvs.x1=(t.x+t.width)/e,this._uvs.y1=t.y/i,this._uvs.x2=(t.x+t.width)/e,this._uvs.y2=(t.y+t.height)/i,this._uvs.x3=t.x/e,this._uvs.y3=(t.y+t.height)/i};M.atlas=function(t,e){var i=t.key;P(t,(function(t,r){for(var s=0;s<t.data.length;s++){var n=i+'.'+t.data[s].name,h=new O(r,t.data[s]);h.key=i,C.texture[n]=h}e()}))},M.prototype.atlas=function(t,e,i){this.list.push({src:e,key:t,data:i,type:'atlas'})};var D;M.spritesheet=function(t,e){var i=t.key;P(t,(function(t,r){var s,n,h;if(t.data){var o=t.data;s=o.length-1;for(var a=0;a<=s;a++)n=i+'.'+a,(h=new O(r,{name:a,x:Math.floor(o[a].x),y:Math.floor(o[a].y),width:Math.floor(o[a].width),height:Math.floor(o[a].height),duration:o[a].duration})).key=i,h.lastFrame=s,C.texture[n]=h}else{var u=r.width,l=r.height,c=t.width,d=t.height;c||(c=Math.floor(u/(t.cols||1))),d||(d=Math.floor(l/(t.rows||1)));var f=Math.floor(u/c)*Math.floor(l/d);if(0===f)return e();t.total&&(f=Math.min(f,t.total));var p=0,v=0;s=f-1;for(a=0;a<f;a++)n=i+'.'+a,(h=new O(r,{name:a,x:p,y:v,width:c,height:d,duration:t.duration})).key=i,h.lastFrame=s,C.texture[n]=h,(p+=c)+c>u&&(p=0,v+=d)}e()}))},M.prototype.spritesheet=function(t,e,i,r,s,n){var h={src:e,key:t,type:'spritesheet'};'number'==typeof i?(h.width=i,h.height=r,h.total=s,h.duration=n):i.length>0&&(h.data=i),this.list.push(h)};var N=function(t){this.game=t;var e=this.domElement=t.inputView;this.bounds={x:0,y:0,width:0,height:0},this.candidates=[],this.list=[],this.lastMove=null,this.isDown=!1,this.downHandler=this.downHandler.bind(this),this.moveHandler=this.moveHandler.bind(this),this.upHandler=this.upHandler.bind(this),e.addEventListener('touchstart',this.downHandler),e.addEventListener('touchmove',this.moveHandler),e.addEventListener('touchend',this.upHandler),e.addEventListener('touchcancel',this.upHandler),e.addEventListener('mousedown',this.downHandler),e.addEventListener('mousemove',this.moveHandler),e.addEventListener('mouseup',this.upHandler),r.mixin(this);for(var i=0;i<N.systems.length;i++)N.systems[i].init.call(this);this.updateBounds()};N.prototype={add:function(t,e){t.inputEnabled=!0,(e=e||{}).system=this,t.input=e,r.mixin(t.input),this.list.push(t)},remove:function(t){var e=this.list.indexOf(t);if(e>-1){var i=this.list[e];return i.input=null,i.inputEnabled=!1,this.list.splice(e,1),i}},inputHandler:function(t,e){var i=this.getCoords(e);if(null!==i){if('move'!=t){this.candidates.length=0;for(var r=0;r<N.systems.length;r++)N.systems[r].preHandle.call(this,i.x,i.y);for(var s,n=0;n<this.list.length;n++)(s=this.list[n]).inputEnabled&&s.parent&&(s.input.checkBounds?s.input.checkBounds.call(this,s,i.x,i.y):N.checkBounds.call(this,s,i.x,i.y))&&this.candidates.push(s);for(r=this.candidates.length-1;r>=0;r--){if((s=this.candidates[r]).input['last_'+t]={x:i.x,y:i.y},s.input.emit(t,{x:i.x,y:i.y}),'up'==t){var h=s.input.last_down;h&&u.distance(h.x,h.y,i.x,i.y)<30&&s.input.emit('click',{x:i.x,y:i.y})}if(!s.input.transparent)break}}this.emit(t,{x:i.x,y:i.y})}},moveHandler:function(t){this.lastMove=t,this.inputHandler('move',t)},upHandler:function(t){this.isDown=!1,this.inputHandler('up',this.lastMove)},downHandler:function(t){this.isDown=!0,this.lastMove=t,this.inputHandler('down',t)},clickHandler:function(t){this.inputHandler('click',t)},getCoords:function(t){var e=null;return'undefined'!=typeof TouchEvent&&t instanceof TouchEvent?(D=!0,t.touches.length>0?e={x:t.touches[0].clientX,y:t.touches[0].clientY}:t.clientX&&t.clientY&&(e={x:t.clientX,y:t.clientY})):e={x:t.clientX,y:t.clientY},D&&t instanceof MouseEvent||null===e?null:e={x:e.x-this.bounds.x,y:e.y-this.bounds.y}},updateBounds:function(){var t=this.bounds,e=this.domElement.getBoundingClientRect();t.x=e.left,t.y=e.top,t.width=e.width,t.height=e.height},destroy:function(){var t=this.domElement;t.removeEventListener('touchstart',this.downHandler),t.removeEventListener('touchmove',this.moveHandler),t.removeEventListener('touchend',this.upHandler),t.removeEventListener('touchcancel',this.upHandler),t.removeEventListener('mousedown',this.downHandler),t.removeEventListener('mousemove',this.moveHandler),t.removeEventListener('mouseup',this.upHandler)}},N.checkBounds=function(t,e,i){if(t.worldVisible&&t.getBounds().contains(e,i))return!0},N.systems=[],m('input',N);var k=function(){},j=function(t,e,i,r,s,n,h,o,a){this.game=i,this.cb=r||k,this.ctx=s||this,this.delay=null==n?1e3:n,this.loop=h,this.count=o||0,this.repeat=this.count>0,this.running=!!t,this._lastFrame=0,this.autoRemove=e,this.onComplete=a||k};j.prototype={start:function(){this.running=!0},pause:function(){this.running=!1},stop:function(){this.running=!1,this._lastFrame=0},update:function(t){this.running&&(this._lastFrame+=t,this._lastFrame>=this.delay&&(this.cb.call(this.ctx),this._lastFrame=0,this.repeat?(this.count--,0===this.count&&(this.running=!1,this.autoRemove&&this.game.timer.remove(this),this.onComplete())):this.loop||(this.running=!1,this.autoRemove&&this.game.timer.remove(this))))}};var G=function(t){this.game=t,this.list=[],this.autoStart=!0,this.autoRemove=!0};G.prototype={update:function(t){for(var e=0;e<this.list.length;e++)this.list[e].update(t)},removeAll:function(){for(var t=0;t<this.list.length;t++)this.list[t].stop();this.list=[]},remove:function(t){var e=this.list.indexOf(t);e>-1&&(t.stop(),this.list.splice(e,1))},add:function(t,e,i,r,s){r=null!=r?r:this.autoStart,s=null!=s?s:this.autoRemove;var n=new j(r,s,this.game,e,i,t);return this.list.push(n),n},loop:function(t,e,i,r,s){r=null!=r?r:this.autoStart,s=null!=s?s:this.autoRemove;var n=new j(r,s,this.game,e,i,t,!0);return this.list.push(n),n},repeat:function(t,e,i,r,s,n,h){s=null!=s?s:this.autoStart,n=null!=n?n:this.autoRemove;var o=new j(s,n,this.game,i,r,t,!1,e,h);return this.list.push(o),o},destroy:function(){this.removeAll()}},m('timer',G);var Y=function(){this._tweens={},this._tweensAddedDuringUpdate={}};Y.prototype={getAll:function(){return Object.keys(this._tweens).map(function(t){return this._tweens[t]}.bind(this))},removeAll:function(){this._tweens={}},add:function(t){var e=t.getId();this._tweens[e]=t,this._tweensAddedDuringUpdate[e]=t},remove:function(t){var e=t.getId();delete this._tweens[e],delete this._tweensAddedDuringUpdate[e]},update:function(t,e){var i=Object.keys(this._tweens);if(0===i.length)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r<i.length;r++){var s=this._tweens[i[r]];s&&!1===s.update(t)&&(s._isPlaying=!1,e||delete this._tweens[i[r]])}i=Object.keys(this._tweensAddedDuringUpdate)}return!0}};var H=new Y;H.Group=Y,H._nextId=0,H.nextId=function(){return H._nextId++};var V=function(t,e){this._isPaused=!1,this._object=t,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._repeat=0,this._repeatDelayTime=void 0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=null,this._time=0,this._easingFunction=z.Linear.None,this._interpolationFunction=W.Linear,this._chainedTweens=[],this._onStartCallback=null,this._onStartCallbackFired=!1,this._onUpdateCallback=null,this._onRepeatCallback=null,this._onCompleteCallback=null,this._onStopCallback=null,this._group=e||H,this._id=H.nextId()};V.prototype={getId:function(){return this._id},isPlaying:function(){return this._isPlaying},isPaused:function(){return this._isPaused},to:function(t,e){return this._valuesEnd=Object.create(t),void 0!==e&&(this._duration=e),this},duration:function(t){return this._duration=t,this},start:function(t){for(var e in this._group.add(this),this._isPlaying=!0,this._isPaused=!1,this._time=0,this._onStartCallbackFired=!1,this._startTime=this._delayTime,this._valuesEnd){if(this._valuesEnd[e]instanceof Array){if(0===this._valuesEnd[e].length)continue;this._valuesEnd[e]=[this._object[e]].concat(this._valuesEnd[e])}void 0!==this._object[e]&&(1!=t&&void 0!==this._valuesStart[e]||(this._valuesStart[e]=this._object[e]),this._valuesStart[e]instanceof Array==!1&&(this._valuesStart[e]*=1),this._valuesStartRepeat[e]=this._valuesStart[e]||0)}return this},stop:function(){return this._isPlaying?(this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,null!==this._onStopCallback&&this._onStopCallback(this._object),this.stopChainedTweens(),this):this},end:function(){return this.update(1/0),this},pause:function(){return this._isPaused||!this._isPlaying||(this._isPaused=!0,this._group.remove(this)),this},resume:function(){return this._isPaused&&this._isPlaying?(this._isPaused=!1,this._group.add(this),this):this},stopChainedTweens:function(){for(var t=0,e=this._chainedTweens.length;t<e;t++)this._chainedTweens[t].stop()},group:function(t){return this._group=t,this},delay:function(t){return this._delayTime=t,this},repeat:function(t){return this._repeat=t,this},repeatDelay:function(t){return this._repeatDelayTime=t,this},yoyo:function(t){return this._yoyo=t,this},easing:function(t){return this._easingFunction=t,this},interpolation:function(t){return this._interpolationFunction=t,this},chain:function(){return this._chainedTweens=arguments,this},onStart:function(t){return this._onStartCallback=t,this},onUpdate:function(t){return this._onUpdateCallback=t,this},onRepeat:function(t){return this._onRepeatCallback=t,this},onComplete:function(t){return this._onCompleteCallback=t,this},onStop:function(t){return this._onStopCallback=t,this},update:function(t){var e,i,r;if(this._time+=t,this._time<this._startTime)return!0;for(e in!1===this._onStartCallbackFired&&(null!==this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),i=(this._time-this._startTime)/this._duration,i=0===this._duration||i>1?1:i,r=this._easingFunction(i),this._valuesEnd)if(void 0!==this._valuesStart[e]){var s=this._valuesStart[e]||0,n=this._valuesEnd[e];n instanceof Array?this._object[e]=this._interpolationFunction(n,r):('string'==typeof n&&(n='+'===n.charAt(0)||'-'===n.charAt(0)?s+parseFloat(n):parseFloat(n)),'number'==typeof n&&(this._object[e]=s+(n-s)*r))}if(null!==this._onUpdateCallback&&this._onUpdateCallback(this._object,i),1===i){if(this._time=0,this._repeat>0){for(e in isFinite(this._repeat)&&this._repeat--,this._valuesStartRepeat){if('string'==typeof this._valuesEnd[e]&&(this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(this._valuesEnd[e])),this._yoyo){var h=this._valuesStartRepeat[e];this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=h}this._valuesStart[e]=this._valuesStartRepeat[e]}return this._yoyo&&(this._reversed=!this._reversed),void 0!==this._repeatDelayTime?this._startTime=this._repeatDelayTime:this._startTime=this._delayTime,null!==this._onRepeatCallback&&this._onRepeatCallback(this._object),!0}null!==this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var o=0,a=this._chainedTweens.length;o<a;o++)this._chainedTweens[o].start();return!1}return!0}};var X,z={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-z.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*z.Bounce.In(2*t):.5*z.Bounce.Out(2*t-1)+.5}}},W={Linear:function(t,e){var i=t.length-1,r=i*e,s=Math.floor(r),n=W.Utils.Linear;return e<0?n(t[0],t[1],r):e>1?n(t[i],t[i-1],i-r):n(t[s],t[s+1>i?i:s+1],r-s)},Bezier:function(t,e){for(var i=0,r=t.length-1,s=Math.pow,n=W.Utils.Bernstein,h=0;h<=r;h++)i+=s(1-e,r-h)*s(e,h)*t[h]*n(r,h);return i},CatmullRom:function(t,e){var i=t.length-1,r=i*e,s=Math.floor(r),n=W.Utils.CatmullRom;return t[0]===t[i]?(e<0&&(s=Math.floor(r=i*(1+e))),n(t[(s-1+i)%i],t[s],t[(s+1)%i],t[(s+2)%i],r-s)):e<0?t[0]-(n(t[0],t[0],t[1],t[1],-r)-t[0]):e>1?t[i]-(n(t[i],t[i],t[i-1],t[i-1],r-i)-t[i]):n(t[s?s-1:0],t[s],t[i<s+1?i:s+1],t[i<s+2?i:s+2],r-s)},Utils:{Linear:function(t,e,i){return(e-t)*i+t},Bernstein:function(t,e){var i=W.Utils.Factorial;return i(t)/i(e)/i(t-e)},Factorial:(X=[1],function(t){var e=1;if(X[t])return X[t];for(var i=t;i>1;i--)e*=i;return X[t]=e,e}),CatmullRom:function(t,e,i,r,s){var n=.5*(i-t),h=.5*(r-e),o=s*s;return(2*e-2*i+n+h)*(s*o)+(-3*e+3*i-2*n-h)*o+n*s+e}}},K=function(t){this.game=t,this.bufferList=[],this.group=new Y};K.prototype={remove:function(t){this.group.remove(t)},add:function(t){return new V(t,this.group)},pause:function(){for(var t in this.bufferList.length=0,this.group._tweens)this.bufferList.push(this.group._tweens[t]),this.group._tweens[t].pause()},resume(){for(var t=0;t<this.bufferList.length;t++)this.bufferList[t].resume();this.bufferList.length=0},update:function(t){this.group.update(t)},destroy:function(){this.bufferList.length=0,this.group.removeAll(),this.group=null}},m('tweens',K),Tiny.App=R,Tiny.RAF=B,Tiny.registerSystem=m,Tiny.systems=x,Tiny.TweenManager=K,Tiny.Cache=C,Tiny.Loader=M,Tiny.Easing=z,Tiny.Interpolation=W,Tiny.Input=N,Tiny.Timer=j;var q=2*Math.PI,Z=function(){this.position=new c(0,0),this.scale=new c(1,1),this.pivot=new c(0,0),this.rotation=0,this.alpha=1,this.visible=!0,this.renderable=!1,this.parent=null,this.worldAlpha=1,this.worldTransform=new d,this._sr=0,this._cr=1,this._cacheAsBitmap=!1};Z.prototype.constructor=Z,Z.prototype.destroy=function(){this.parent&&this.parent.remove(this),this.parent=null,this.worldTransform=null,this.visible=!1,this.renderable=!1,this._destroyCachedSprite()},Object.defineProperty(Z.prototype,'worldVisible',{get:function(){var t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}}),Object.defineProperty(Z.prototype,'cacheAsBitmap',{get:function(){return this._cacheAsBitmap},set:function(t){this._cacheAsBitmap!==t&&(t?this._generateCachedSprite():this._destroyCachedSprite(),this._cacheAsBitmap=t)}}),Z.prototype.updateTransform=function(){if(this.parent){var t,e,i,r,s,n,h=this.parent.worldTransform,o=this.worldTransform;this.rotation%q?(this.rotation!==this.rotationCache&&(this.rotationCache=this.rotation,this._sr=Math.sin(this.rotation),this._cr=Math.cos(this.rotation)),t=this._cr*this.scale.x,e=this._sr*this.scale.x,i=-this._sr*this.scale.y,r=this._cr*this.scale.y,s=this.position.x,n=this.position.y,(this.pivot.x||this.pivot.y)&&(s-=this.pivot.x*t+this.pivot.y*i,n-=this.pivot.x*e+this.pivot.y*r),o.a=t*h.a+e*h.c,o.b=t*h.b+e*h.d,o.c=i*h.a+r*h.c,o.d=i*h.b+r*h.d,o.tx=s*h.a+n*h.c+h.tx,o.ty=s*h.b+n*h.d+h.ty):(t=this.scale.x,r=this.scale.y,s=this.position.x-this.pivot.x*t,n=this.position.y-this.pivot.y*r,o.a=t*h.a,o.b=t*h.b,o.c=r*h.c,o.d=r*h.d,o.tx=s*h.a+n*h.c+h.tx,o.ty=s*h.b+n*h.d+h.ty),this.worldAlpha=this.alpha*this.parent.worldAlpha}},Z.prototype.displayObjectUpdateTransform=Z.prototype.updateTransform,Z.prototype.getBounds=function(t){return U},Z.prototype.getLocalBounds=function(){return this.getBounds(f)},Z.prototype.generateTexture=function(t,e){var i=this.getLocalBounds(),r=new Tiny.RenderTexture(0|i.width,0|i.height,e,t);return Z._tempMatrix.tx=-i.x,Z._tempMatrix.ty=-i.y,r.render(this,Z._tempMatrix),r},Z.prototype.updateCache=function(){this._generateCachedSprite()},Z.prototype.toGlobal=function(t){return this.displayObjectUpdateTransform(),this.worldTransform.apply(t)},Z.prototype.toLocal=function(t,e){return e&&(t=e.toGlobal(t)),this.displayObjectUpdateTransform(),this.worldTransform.applyInverse(t)},Z.prototype._renderCachedSprite=function(t){this._cachedSprite.worldAlpha=this.worldAlpha,t.gl?Tiny.Sprite.prototype.render.call(this._cachedSprite,t):Tiny.Sprite.prototype.renderCanvas.call(this._cachedSprite,t)},Z.prototype._generateCachedSprite=function(){this._cachedSprite=null,this._cacheAsBitmap=!1;var t=this.getLocalBounds(),e=new Tiny.RenderTexture(0|t.width,0|t.height);this._cachedSprite=new Tiny.Sprite(e),this._cachedSprite.worldTransform=this.worldTransform;var i=this._filters;this._filters=null,this._cachedSprite.filters=i,Z._tempMatrix.tx=-t.x,Z._tempMatrix.ty=-t.y,this._cachedSprite.texture.render(this,Z._tempMatrix,!0),this._cachedSprite.anchor.x=-t.x/t.width,this._cachedSprite.anchor.y=-t.y/t.height,this._cacheAsBitmap=!0},Z.prototype._destroyCachedSprite=function(){this._cachedSprite&&(this._cachedSprite.texture.destroy(!0),this._cachedSprite=null)},Z.prototype.render=function(t){},Object.defineProperty(Z.prototype,'x',{get:function(){return this.position.x},set:function(t){this.position.x=t}}),Object.defineProperty(Z.prototype,'y',{get:function(){return this.position.y},set:function(t){this.position.y=t}}),Z._tempMatrix=new d;var Q=function(){Z.call(this),this.children=[],this._bounds=new L(0,0,1,1),this._currentBounds=null,this._mask=null};(Q.prototype=Object.create(Z.prototype)).constructor=Q,Object.defineProperty(Q.prototype,'width',{get:function(){return this.scale.x*this.getLocalBounds().width},set:function(t){var e=this.getLocalBounds().width;this.scale.x=0!==e?t/e:1,this._width=t}}),Object.defineProperty(Q.prototype,'height',{get:function(){return this.scale.y*this.getLocalBounds().height},set:function(t){var e=this.getLocalBounds().height;this.scale.y=0!==e?t/e:1,this._height=t}}),Object.defineProperty(Q.prototype,'mask',{get:function(){return this._mask},set:function(t){this._mask&&(this._mask.isMask=!1),this._mask=t,this._mask&&(this._mask.isMask=!0)}}),Q.prototype.destroy=function(){for(var t=this.children.length;t--;)this.children[t].destroy();this.children=[],Z.prototype.destroy.call(this),this._bounds=null,this._currentBounds=null,this._mask=null,this.input&&this.input.system.remove(this)},Q.prototype.add=function(t){return this.addChildAt(t,this.children.length)},Q.prototype.addChildAt=function(t,e){if(e>=0&&e<=this.children.length)return t.parent&&t.parent.remove(t),t.parent=this,this.game&&(t.game=this.game),this.children.splice(e,0,t),t;throw new Error(t+'addChildAt: The index '+e+' supplied is out of bounds '+this.children.length)},Q.prototype.swapChildren=function(t,e){if(t!==e){var i=this.getChildIndex(t),r=this.getChildIndex(e);if(i<0||r<0)throw new Error('swapChildren: Both the supplied Objects must be a child of the caller.');this.children[i]=e,this.children[r]=t}},Q.prototype.getChildIndex=function(t){var e=this.children.indexOf(t);if(-1===e)throw new Error('The supplied Object must be a child of the caller');return e},Q.prototype.setChildIndex=function(t,e){if(e<0||e>=this.children.length)throw new Error('The supplied index is out of bounds');var i=this.getChildIndex(t);this.children.splice(i,1),this.children.splice(e,0,t)},Q.prototype.getChildAt=function(t){if(t<0||t>=this.children.length)throw new Error('getChildAt: Supplied index '+t+' does not exist in the child list, or the supplied Object must be a child of the caller');return this.children[t]},Q.prototype.remove=function(t){var e=this.children.indexOf(t);if(-1!==e)return this.removeChildAt(e)},Q.prototype.removeChildAt=function(t){var e=this.getChildAt(t);return e.parent=void 0,this.children.splice(t,1),e},Q.prototype.updateTransform=function(){if(this.visible&&(this.displayObjectUpdateTransform(),!this._cacheAsBitmap))for(var t=0,e=this.children.length;t<e;t++)this.children[t].updateTransform()},Q.prototype.displayObjectContainerUpdateTransform=Q.prototype.updateTransform,Q.prototype.getBounds=function(){if(0===this.children.length)return U;if(this._cachedSprite)return this._cachedSprite.getBounds();for(var t,e,i,r=1/0,s=1/0,n=-1/0,h=-1/0,o=!1,a=0,u=this.children.length;a<u;a++){this.children[a].visible&&(o=!0,r=r<(t=this.children[a].getBounds()).x?r:t.x,s=s<t.y?s:t.y,n=n>(e=t.width+t.x)?n:e,h=h>(i=t.height+t.y)?h:i)}if(!o)return U;var l=this._bounds;return l.x=r,l.y=s,l.width=n-r,l.height=h-s,l},Q.prototype.getLocalBounds=function(){var t=this.worldTransform;this.worldTransform=f;for(var e=0,i=this.children.length;e<i;e++)this.children[e].updateTransform();var r=this.getBounds();return this.worldTransform=t,r},Q.prototype.render=function(t){var e,i;if(this.visible&&!(this.alpha<=0))if(this._cacheAsBitmap)this._renderCachedSprite(t);else if(this._mask||this._filters){for(this._filters&&(t.spriteBatch.flush(),t.filterManager.pushFilter(this._filterBlock)),this._mask&&(t.spriteBatch.stop(),t.maskManager.pushMask(this.mask,t),t.spriteBatch.start()),e=0,i=this.children.length;e<i;e++)this.children[e].render(t);t.spriteBatch.stop(),this._mask&&t.maskManager.popMask(this._mask,t),this._filters&&t.filterManager.popFilter(),t.spriteBatch.start()}else for(e=0,i=this.children.length;e<i;e++)this.children[e].render(t)};var J=function(t){Q.call(this),this.game=t};(J.prototype=Object.create(Q.prototype)).constructor=J,J.prototype.updateTransform=function(){this.worldAlpha=1;for(var t=0,e=this.children.length;t<e;t++)this.children[t].updateTransform()};var $=function(t,e){Q.call(this),this.anchor=new c,this.setTexture(t,e,!1),this._width=0,this._height=0,this.tint=new l,this.blendMode=p.NORMAL,this.texture.valid&&this.onTextureUpdate(),this.renderable=!0};($.prototype=Object.create(Q.prototype)).constructor=$,Object.defineProperty($.prototype,'frameName',{get:function(){return this.texture.frame.name},set:function(t){this.texture.frame.name&&this.setTexture(C.texture[this.texture.key+'.'+t])}}),Object.defineProperty($.prototype,'width',{get:function(){return this.scale.x*this.texture.frame.width},set:function(t){this.scale.x=t/this.texture.frame.width,this._width=t}}),Object.defineProperty($.prototype,'height',{get:function(){return this.scale.y*this.texture.frame.height},set:function(t){this.scale.y=t/this.texture.frame.height,this._height=t}}),$.prototype.setTexture=function(t,e,i){if('string'==typeof t){var r=t;null!=e&&(r=r+'.'+e),(t=C.texture[r])||(t=new O(r))}return this.texture!==t&&(this.texture=t,this.cachedTint='#ffffff',!0===i&&this.onTextureUpdate(),!0)},$.prototype.onTextureUpdate=function(){this._width&&(this.scale.x=this._width/this.texture.frame.width),this._height&&(this.scale.y=this._height/this.texture.frame.height)},$.prototype.getBounds=function(t){var e=this.texture.frame.width/this.texture.base.resolution,i=this.texture.frame.height/this.texture.base.resolution,r=e*(1-this.anchor.x),s=e*-this.anchor.x,n=i*(1-this.anchor.y),h=i*-this.anchor.y,o=t||this.worldTransform,a=o.a,u=o.b,l=o.c,c=o.d,d=o.tx,f=o.ty,p=-1/0,v=-1/0,y=1/0,g=1/0;if(0===u&&0===l)a<0?(y=a*r+d,p=a*s+d):(y=a*s+d,p=a*r+d),c<0?(g=c*n+f,v=c*h+f):(g=c*h+f,v=c*n+f);else{var x=a*s+l*h+d,m=c*h+u*s+f,_=a*r+l*h+d,E=c*h+u*r+f,w=a*r+l*n+d,T=c*n+u*r+f,b=a*s+l*n+d,A=c*n+u*s+f;y=b<(y=w<(y=_<(y=x<y?x:y)?_:y)?w:y)?b:y,g=A<(g=T<(g=E<(g=m<g?m:g)?E:g)?T:g)?A:g,p=b>(p=w>(p=_>(p=x>p?x:p)?_:p)?w:p)?b:p,v=A>(v=T>(v=E>(v=m>v?m:v)?E:v)?T:v)?A:v}var R=this._bounds;return R.x=y,R.width=p-y,R.y=g,R.height=v-g,this._currentBounds=R,R},$.prototype.render=function(t){var e,i;if(this.visible&&!(this.alpha<=0))if(this._mask||this._filters){var r=t.spriteBatch;for(this._filters&&(r.flush(),t.filterManager.pushFilter(this._filterBlock)),this._mask&&(r.stop(),t.maskManager.pushMask(this.mask,t),r.start()),r.render(this),e=0,i=this.children.length;e<i;e++)this.children[e].render(t);r.stop(),this._mask&&t.maskManager.popMask(this._mask,t),this._filters&&t.filterManager.popFilter(),r.start()}else for(t.spriteBatch.render(this),e=0,i=this.children.length;e<i;e++)this.children[e].render(t)};var tt=function(t,e){this.canvas=document.createElement('canvas'),this.context=this.canvas.getContext('2d'),this.resolution=1,$.call(this,new O(this.canvas)),this.setText(t),this.setStyle(e)};(tt.prototype=Object.create($.prototype)).constructor=tt,Object.defineProperty(tt.prototype,'width',{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.x*this.texture.frame.width},set:function(t){this.scale.x=t/this.texture.frame.width,this._width=t}}),Object.defineProperty(tt.prototype,'height',{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.y*this.texture.frame.height},set:function(t){this.scale.y=t/this.texture.frame.height,this._height=t}}),tt.prototype.setStyle=function(t){(t=t||{}).font=t.font||'bold 20pt Arial',t.fill=t.fill||'black',t.align=t.align||'left',t.stroke=t.stroke||'black',t.strokeThickness=t.strokeThickness||0,t.wordWrap=t.wordWrap||!1,t.lineSpacing=t.lineSpacing||0,t.wordWrapWidth=void 0!==t.wordWrapWidth?t.wordWrapWidth:100,t.dropShadow=t.dropShadow||!1,t.dropShadowAngle=void 0!==t.dropShadowAngle?t.dropShadowAngle:Math.PI/6,t.dropShadowDistance=void 0!==t.dropShadowDistance?t.dropShadowDistance:4,t.dropShadowColor=t.dropShadowColor||'black',this.style=t,this.dirty=!0},tt.prototype.setText=function(t){this.text=t.toString()||' ',this.dirty=!0},tt.prototype.updateText=function(){this.texture.base.resolution=this.resolution,this.context.font=this.style.font;var t=this.text;this.style.wordWrap&&(t=this.wordWrap(this.text));for(var e=t.split(/(?:\r\n|\r|\n)/),i=[],r=0,s=this.determineFontProperties(this.style.font),n=0;n<e.length;n++){var h=this.context.measureText(e[n]).width;i[n]=h,r=Math.max(r,h)}var o=r+this.style.strokeThickness;this.style.dropShadow&&(o+=this.style.dropShadowDistance),this.canvas.width=(o+this.context.lineWidth)*this.resolution;var a,u,l=s.fontSize+this.style.strokeThickness+this.style.lineSpacing,c=l*e.length;if(this.style.dropShadow&&(c+=this.style.dropShadowDistance),this.canvas.height=(c-this.style.lineSpacing)*this.resolution,this.context.scale(this.resolution,this.resolution),navigator.isCocoonJS&&this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.font=this.style.font,this.context.strokeStyle=this.style.stroke,this.context.lineWidth=this.style.strokeThickness,this.context.textBaseline='alphabetic',this.context.miterLimit=2,this.style.dropShadow){this.context.fillStyle=this.style.dropShadowColor;var d=Math.sin(this.style.dropShadowAngle)*this.style.dropShadowDistance,f=Math.cos(this.style.dropShadowAngle)*this.style.dropShadowDistance;for(n=0;n<e.length;n++)a=this.style.strokeThickness/2,u=this.style.strokeThickness/2+n*l+s.ascent,'right'===this.style.align?a+=r-i[n]:'center'===this.style.align&&(a+=(r-i[n])/2),this.style.fill&&this.context.fillText(e[n],a+d,u+f)}for(this.context.fillStyle=this.style.fill,n=0;n<e.length;n++)a=this.style.strokeThickness/2,u=this.style.strokeThickness/2+n*l+s.ascent,'right'===this.style.align?a+=r-i[n]:'center'===this.style.align&&(a+=(r-i[n])/2),this.style.stroke&&this.style.strokeThickness&&this.context.strokeText(e[n],a,u),this.style.fill&&this.context.fillText(e[n],a,u);this.updateTexture()},tt.prototype.updateTexture=function(){this.texture.width=this.canvas.width,this.texture.height=this.canvas.height,this.texture.crop.width=this.texture.frame.width=this.canvas.width,this.texture.crop.height=this.texture.frame.height=this.canvas.height,this._width=this.canvas.width,this._height=this.canvas.height,this.texture.base.dirty()},tt.prototype.render=function(t){(this.dirty||this.resolution!==t.resolution)&&(this.resolution=t.resolution,this.updateText(),this.dirty=!1),$.prototype.render.call(this,t)},tt.prototype.determineFontProperties=function(t){var e=tt.fontPropertiesCache[t];if(!e){e={};var i=tt.fontPropertiesCanvas,r=tt.fontPropertiesContext;r.font=t;var s=Math.ceil(r.measureText('|MÉq').width),n=Math.ceil(r.measureText('|MÉq').width),h=2*n;n=1.4*n|0,i.width=s,i.height=h,r.fillStyle='#f00',r.fillRect(0,0,s,h),r.font=t,r.textBaseline='alphabetic',r.fillStyle='#000',r.fillText('|MÉq',0,n);var o,a,u=r.getImageData(0,0,s,h).data,l=u.length,c=4*s,d=0,f=!1;for(o=0;o<n;o++){for(a=0;a<c;a+=4)if(255!==u[d+a]){f=!0;break}if(f)break;d+=c}for(e.ascent=n-o,d=l-c,f=!1,o=h;o>n;o--){for(a=0;a<c;a+=4)if(255!==u[d+a]){f=!0;break}if(f)break;d-=c}e.descent=o-n,e.descent+=6,e.fontSize=e.ascent+e.descent,tt.fontPropertiesCache[t]=e}return e},tt.prototype.wordWrap=function(t){for(var e='',i=t.split('\n'),r=0;r<i.length;r++){for(var s=this.style.wordWrapWidth,n=i[r].split(' '),h=0;h<n.length;h++){var o=this.context.measureText(n[h]).width,a=o+this.context.measureText(' ').width;0===h||a>s?(h>0&&(e+='\n'),e+=n[h],s=this.style.wordWrapWidth-o):(s-=a,e+=' '+n[h])}r<i.length-1&&(e+='\n')}return e},tt.prototype.getBounds=function(t){return this.dirty&&(this.updateText(),this.dirty=!1),$.prototype.getBounds.call(this,t)},tt.prototype.destroy=function(){this.context=null,this.canvas=null,this.texture.destroy(),$.prototype.destroy.call(this)},tt.fontPropertiesCache={},tt.fontPropertiesCanvas=document.createElement('canvas'),tt.fontPropertiesContext=tt.fontPropertiesCanvas.getContext('2d');var et=function(t,e,i){this.x=t||0,this.y=e||0,this.radius=i||0,this.type=y.CIRC};(et.prototype={contains:function(t,e){if(this.radius<=0)return!1;var i=this.x-t,r=this.y-e;return(i*=i)+(r*=r)<=this.radius*this.radius},getBounds:function(){return new PIXI.Rectangle(this.x-this.radius,this.y-this.radius,2*this.radius,2*this.radius)}}).constructor=et;var it=function(t){if(t instanceof Array||(t=Array.prototype.slice.call(arguments)),'number'!=typeof t[0]){for(var e=[],i=0,r=t.length;i<r;i++)e.push(t[i].x,t[i].y);t=e}this.closed=!0,this.points=t,this.type=y.POLY};(it.prototype={toNumberArray:function(t){void 0===t&&(t=[]);for(var e=0;e<this.points.length;e++)'number'==typeof this.points[e]?(t.push(this.points[e]),t.push(this.points[e+1]),e++):(t.push(this.points[e].x),t.push(this.points[e].y));return t},flatten:function(){return this.points=this.toNumberArray(),this},contains:function(t,e){for(var i=!1,r=this.points.length/2,s=0,n=r-1;s<r;n=s++){var h=this.points[2*s],o=this.points[2*s+1],a=this.points[2*n],u=this.points[2*n+1];o>e!=u>e&&t<(a-h)*(e-o)/(u-o)+h&&(i=!i)}return i}}).constructor=it;var rt=function(t,e,i,r,s){this.x=t||0,this.y=e||0,this.width=i||0,this.height=r||0,this.radius=s||0,this.type=y.RREC};rt.prototype.contains=function(t,e){if(this.width<=0||this.height<=0)return!1;var i=this.x;if(t>=i&&t<=i+this.width){var r=this.y;if(e>=r&&e<=r+this.height)return!0}return!1},rt.prototype.constructor=rt;var st=function(t,e,i,r,s){this.lineWidth=t,this.lineColor=e,this._lineTint=e,this.fillColor=i,this._fillTint=i,this.fill=r,this.shape=s,this.type=s.type};st.prototype.constructor=st;var nt=function(){Q.call(this),this.renderable=!0,this.lineWidth=0,this.lineColor=new l,this.graphicsData=[],this.tint=new l,this.blendMode=p.NORMAL,this.currentPath=null,this._webGL=[],this.isMask=!1,this.boundsPadding=0,this._localBounds=new L(0,0,1,1),this.dirty=!0,this.webGLDirty=!1,this.cachedSpriteDirty=!1};(nt.prototype=Object.create(Q.prototype)).constructor=nt,Object.defineProperty(nt.prototype,'cacheAsBitmap',{get:function(){return this._cacheAsBitmap},set:function(t){this._cacheAsBitmap=t,this._cacheAsBitmap?this._generateCachedSprite():(this.destroyCachedSprite(),this.dirty=!0)}}),Object.assign(nt.prototype,{lineStyle:function(t,e,i){if(this.lineWidth=t||0,this.lineColor=new l(e||0),void 0!==i&&(this.lineColor.a=i),this.currentPath){if(this.currentPath.shape.points.length)return this.drawShape(new it(this.currentPath.shape.points.slice(-2))),this;this.currentPath.lineWidth=this.lineWidth,this.currentPath.lineColor=this.lineColor}return this},moveTo:function(t,e){return this.drawShape(new it([t,e])),this},lineTo:function(t,e){return this.currentPath||this.moveTo(0,0),this.currentPath.shape.points.push(t,e),this.dirty=!0,this},quadraticCurveTo:function(t,e,i,r){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);var s,n,h=this.currentPath.shape.points;0===h.length&&this.moveTo(0,0);for(var o=h[h.length-2],a=h[h.length-1],u=0,l=1;l<=20;l++)s=o+(t-o)*(u=l/20),n=a+(e-a)*u,h.push(s+(t+(i-t)*u-s)*u,n+(e+(r-e)*u-n)*u);return this.dirty=!0,this},bezierCurveTo:function(t,e,i,r,s,n){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);for(var h,o,a,u,l,c=this.currentPath.shape.points,d=c[c.length-2],f=c[c.length-1],p=0,v=1;v<=20;v++)a=(o=(h=1-(p=v/20))*h)*h,l=(u=p*p)*p,c.push(a*d+3*o*p*t+3*h*u*i+l*s,a*f+3*o*p*e+3*h*u*r+l*n);return this.dirty=!0,this},arcTo:function(t,e,i,r,s){this.currentPath?0===this.currentPath.shape.points.length&&this.currentPath.shape.points.push(t,e):this.moveTo(t,e);var n=this.currentPath.shape.points,h=n[n.length-2],o=n[n.length-1]-e,a=h-t,u=r-e,l=i-t,c=Math.abs(o*l-a*u);if(c<1e-8||0===s)n[n.length-2]===t&&n[n.length-1]===e||n.push(t,e);else{var d=o*o+a*a,f=u*u+l*l,p=o*u+a*l,v=s*Math.sqrt(d)/c,y=s*Math.sqrt(f)/c,g=v*p/d,x=y*p/f,m=v*l+y*a,_=v*u+y*o,E=a*(y+g),w=o*(y+g),T=l*(v+x),b=u*(v+x),A=Math.atan2(w-_,E-m),R=Math.atan2(b-_,T-m);this.arc(m+t,_+e,s,A,R,a*u>l*o)}return this.dirty=!0,this},arc:function(t,e,i,r,s,n){if(r===s)return this;!(n=n||!1)&&s<=r?s+=2*Math.PI:n&&r<=s&&(r+=2*Math.PI);var h=n?-1*(r-s):s-r,o=Math.abs(h)/(2*Math.PI)*40;if(0===h)return this;var a=t+Math.cos(r)*i,u=e+Math.sin(r)*i;n&&this.filling?this.moveTo(t,e):this.moveTo(a,u);for(var l=this.currentPath.shape.points,c=h/(2*o),d=2*c,f=Math.cos(c),p=Math.sin(c),v=o-1,y=v%1/v,g=0;g<=v;g++){var x=c+r+d*(g+y*g),m=Math.cos(x),_=-Math.sin(x);l.push((f*m+p*_)*i+t,(f*-_+p*m)*i+e)}return this.dirty=!0,this},beginFill:function(t,e){return this.filling=!0,this.fillColor=new l(t||0),void 0!==e&&(this.fillColor.a=e),this.currentPath&&this.currentPath.shape.points.length<=2&&(this.currentPath.fill=this.filling,this.currentPath.fillColor=this.fillColor),this},endFill:function(){return this.filling=!1,this.fillColor=null,this},drawRect:function(t,e,i,r){return this.drawShape(new L(t,e,i,r)),this},drawRoundedRect:function(t,e,i,r,s){return this.drawShape(new rt(t,e,i,r,s)),this},drawCircle:function(t,e,i){return this.drawShape(new et(t,e,i)),this},drawPolygon:function(t){return t instanceof Array||(t=Array.prototype.slice.call(arguments)),this.drawShape(new it(t)),this},clear:function(){return this.lineWidth=0,this.filling=!1,this.dirty=!0,this.clearDirty=!0,this.graphicsData=[],this},render:function(t){if(!1!==this.visible&&0!==this.alpha&&!0!==this.isMask){if(this._cacheAsBitmap)return(this.dirty||this.cachedSpriteDirty)&&(this._generateCachedSprite(),this.updateCachedSpriteTexture(),this.cachedSpriteDirty=!1,this.dirty=!1),this._cachedSprite.worldAlpha=this.worldAlpha,void $.prototype.render.call(this._cachedSprite,t);if(t.spriteBatch.stop(),t.blendModeManager.setBlendMode(this.blendMode),this._mask&&t.maskManager.pushMask(this._mask,t),this._filters&&t.filterManager.pushFilter(this._filterBlock),this.blendMode!==t.spriteBatch.currentBlendMode){t.spriteBatch.currentBlendMode=this.blendMode;var e=t.blendModes[t.spriteBatch.currentBlendMode];t.spriteBatch.gl.blendFunc(e[0],e[1])}if(this.webGLDirty&&(this.dirty=!0,this.webGLDirty=!1),Tiny.WebGLGraphics.renderGraphics(this,t),this.children.length){t.spriteBatch.start();for(var i=0,r=this.children.length;i<r;i++)this.children[i].render(t);t.spriteBatch.stop()}this._filters&&t.filterManager.popFilter(),this._mask&&t.maskManager.popMask(this.mask,t),t.drawCount++,t.spriteBatch.start()}},getBounds:function(t){if(this.isMask)return U;this.dirty&&(this.updateLocalBounds(),this.webGLDirty=!0,this.cachedSpriteDirty=!0,this.dirty=!1);var e=this._localBounds,i=e.x,r=e.width+e.x,s=e.y,n=e.height+e.y,h=t||this.worldTransform,o=h.a,a=h.b,u=h.c,l=h.d,c=h.tx,d=h.ty,f=o*r+u*n+c,p=l*n+a*r+d,v=o*i+u*n+c,y=l*n+a*i+d,g=o*i+u*s+c,x=l*s+a*i+d,m=o*r+u*s+c,_=l*s+a*r+d,E=f,w=p,T=f,b=p;return T=m<(T=g<(T=v<T?v:T)?g:T)?m:T,b=_<(b=x<(b=y<b?y:b)?x:b)?_:b,E=m>(E=g>(E=v>E?v:E)?g:E)?m:E,w=_>(w=x>(w=y>w?y:w)?x:w)?_:w,this._bounds.x=T,this._bounds.width=E-T,this._bounds.y=b,this._bounds.height=w-b,this._bounds},updateLocalBounds:function(){var t=1/0,e=-1/0,i=1/0,r=-1/0;if(this.g