/* Phaser v3.0.0 PIXI Build - http://phaser.io - @photonstorm - (c) 2016 Photon Storm Ltd. */ (function(){function a(a,b,c,e){var f=a.createTexture();return a.bindTexture(a.TEXTURE_2D,f),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,e===d.scaleModes.LINEAR?a.LINEAR:a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,e===d.scaleModes.LINEAR?a.LINEAR:a.NEAREST),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,b,c,0,a.RGBA,a.UNSIGNED_BYTE,null),f}function b(b,c,d,f,g){var h=b.createFramebuffer(),i=b.createRenderbuffer(),j=null,k=0;return b.activeTexture(b.TEXTURE0+g),b.bindFramebuffer(b.FRAMEBUFFER,h),b.bindRenderbuffer(b.RENDERBUFFER,i),b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_STENCIL_ATTACHMENT,b.RENDERBUFFER,this.renderBuffer),j=a(b,c,d,f),b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,j,0),k=b.checkFramebufferStatus(b.FRAMEBUFFER),k!==b.FRAMEBUFFER_COMPLETE&&console.error("Incomplete GL framebuffer. ",e[k]),h.width=c,h.height=d,h.targetTexture=j,h.renderBuffer=i,h}var c=this,d=d||{};d.game=null,d.WEBGL_RENDERER=0,d.CANVAS_RENDERER=1,d.VERSION="v2.2.9",d._UID=0,"undefined"!=typeof Float32Array?(d.Float32Array=Float32Array,d.Uint16Array=Uint16Array,d.Uint32Array=Uint32Array,d.ArrayBuffer=ArrayBuffer):(d.Float32Array=Array,d.Uint16Array=Array),d.PI_2=2*Math.PI,d.RAD_TO_DEG=180/Math.PI,d.DEG_TO_RAD=Math.PI/180,d.RETINA_PREFIX="@2x",d.DisplayObject=function(){this.position=new d.Point(0,0),this.scale=new d.Point(1,1),this.pivot=new d.Point(0,0),this.rotation=0,this.alpha=1,this.visible=!0,this.hitArea=null,this.renderable=!1,this.parent=null,this.worldAlpha=1,this.worldTransform=new d.Matrix,this.worldPosition=new d.Point(0,0),this.worldScale=new d.Point(1,1),this.worldRotation=0,this.filterArea=null,this._sr=0,this._cr=1,this._bounds=new d.Rectangle(0,0,0,0),this._currentBounds=null,this._mask=null,this._cacheAsBitmap=!1,this._cacheIsDirty=!1},d.DisplayObject.prototype.constructor=d.DisplayObject,d.DisplayObject.prototype={destroy:function(){if(this.children){for(var a=this.children.length;a--;)this.children[a].destroy();this.children=[]}this.hitArea=null,this.parent=null,this.worldTransform=null,this.filterArea=null,this.renderable=!1,this._bounds=null,this._currentBounds=null,this._mask=null,this._destroyCachedSprite()},updateTransform:function(a){if(!a&&!this.parent&&!this.game)return this;var b=this.parent;a?b=a:this.parent||(b=this.game.world);var c,e,f,g,h,i,j=b.worldTransform,k=this.worldTransform;return this.rotation%d.PI_2?(this.rotation!==this.rotationCache&&(this.rotationCache=this.rotation,this._sr=Math.sin(this.rotation),this._cr=Math.cos(this.rotation)),c=this._cr*this.scale.x,e=this._sr*this.scale.x,f=-this._sr*this.scale.y,g=this._cr*this.scale.y,h=this.position.x,i=this.position.y,(this.pivot.x||this.pivot.y)&&(h-=this.pivot.x*c+this.pivot.y*f,i-=this.pivot.x*e+this.pivot.y*g),k.a=c*j.a+e*j.c,k.b=c*j.b+e*j.d,k.c=f*j.a+g*j.c,k.d=f*j.b+g*j.d,k.tx=h*j.a+i*j.c+j.tx,k.ty=h*j.b+i*j.d+j.ty):(c=this.scale.x,g=this.scale.y,h=this.position.x-this.pivot.x*c,i=this.position.y-this.pivot.y*g,k.a=c*j.a,k.b=c*j.b,k.c=g*j.c,k.d=g*j.d,k.tx=h*j.a+i*j.c+j.tx,k.ty=h*j.b+i*j.d+j.ty),this.worldAlpha=this.alpha*b.worldAlpha,this.worldPosition.set(k.tx,k.ty),this.worldScale.set(this.scale.x*Math.sqrt(k.a*k.a+k.c*k.c),this.scale.y*Math.sqrt(k.b*k.b+k.d*k.d)),this.worldRotation=Math.atan2(-k.c,k.d),this._currentBounds=null,this.transformCallback&&this.transformCallback.call(this.transformCallbackContext,k,j),this},preUpdate:function(){},generateTexture:function(a,b,c){var e=this.getLocalBounds(),f=new d.RenderTexture(0|e.width,0|e.height,c,b,a);return d.DisplayObject._tempMatrix.tx=-e.x,d.DisplayObject._tempMatrix.ty=-e.y,f.render(this,d.DisplayObject._tempMatrix),f},updateCache:function(){return this._generateCachedSprite(),this},toGlobal:function(a){return this.updateTransform(),this.worldTransform.apply(a)},toLocal:function(a,b){return b&&(a=b.toGlobal(a)),this.updateTransform(),this.worldTransform.applyInverse(a)},_renderCachedSprite:function(a){this._cachedSprite.worldAlpha=this.worldAlpha,a.gl?d.Sprite.prototype._renderWebGL.call(this._cachedSprite,a):d.Sprite.prototype._renderCanvas.call(this._cachedSprite,a)},_generateCachedSprite:function(){this._cacheAsBitmap=!1;var a=this.getLocalBounds();if(a.width=Math.max(1,Math.ceil(a.width)),a.height=Math.max(1,Math.ceil(a.height)),this.updateTransform(),this._cachedSprite)this._cachedSprite.texture.resize(a.width,a.height);else{var b=0;this.texture&&this.texture.baseTexture&&d._enableMultiTextureToggle&&(b=this.texture.baseTexture.textureIndex);var c=new d.RenderTexture(a.width,a.height,null,null,null,b);this._cachedSprite=new d.Sprite(c),this._cachedSprite.worldTransform=this.worldTransform}var e=this._filters;this._filters=null,this._cachedSprite.filters=e,d.DisplayObject._tempMatrix.tx=-a.x,d.DisplayObject._tempMatrix.ty=-a.y,this._cachedSprite.texture.render(this,d.DisplayObject._tempMatrix,!0),this._cachedSprite.anchor.x=-(a.x/a.width),this._cachedSprite.anchor.y=-(a.y/a.height),this._filters=e,this._cacheAsBitmap=!0},_destroyCachedSprite:function(){this._cachedSprite&&(this._cachedSprite.texture.destroy(!0),this._cachedSprite=null)}},d.DisplayObject.prototype.displayObjectUpdateTransform=d.DisplayObject.prototype.updateTransform,Object.defineProperties(d.DisplayObject.prototype,{x:{get:function(){return this.position.x},set:function(a){this.position.x=a}},y:{get:function(){return this.position.y},set:function(a){this.position.y=a}},worldVisible:{get:function(){if(this.visible){var a=this.parent;if(!a)return this.visible;do{if(!a.visible)return!1;a=a.parent}while(a);return!0}return!1}},mask:{get:function(){return this._mask},set:function(a){this._mask&&(this._mask.isMask=!1),this._mask=a,a&&(this._mask.isMask=!0)}},filters:{get:function(){return this._filters},set:function(a){if(Array.isArray(a)){for(var b=[],c=0;c=0&&b<=this.children.length)return a.parent&&a.parent.removeChild(a),a.parent=this,this.children.splice(b,0,a),a;throw new Error(a+"addChildAt: The index "+b+" supplied is out of bounds "+this.children.length)},d.DisplayObjectContainer.prototype.swapChildren=function(a,b){if(a!==b){var c=this.getChildIndex(a),d=this.getChildIndex(b);if(c<0||d<0)throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");this.children[c]=b,this.children[d]=a}},d.DisplayObjectContainer.prototype.getChildIndex=function(a){var b=this.children.indexOf(a);if(b===-1)throw new Error("The supplied DisplayObject must be a child of the caller");return b},d.DisplayObjectContainer.prototype.setChildIndex=function(a,b){if(b<0||b>=this.children.length)throw new Error("The supplied index is out of bounds");var c=this.getChildIndex(a);this.children.splice(c,1),this.children.splice(b,0,a)},d.DisplayObjectContainer.prototype.getChildAt=function(a){if(a<0||a>=this.children.length)throw new Error("getChildAt: Supplied index "+a+" does not exist in the child list, or the supplied DisplayObject must be a child of the caller");return this.children[a]},d.DisplayObjectContainer.prototype.removeChild=function(a){var b=this.children.indexOf(a);if(b!==-1)return this.removeChildAt(b)},d.DisplayObjectContainer.prototype.removeChildAt=function(a){var b=this.getChildAt(a);return b&&(b.parent=void 0,this.children.splice(a,1)),b},d.DisplayObjectContainer.prototype.removeChildren=function(a,b){void 0===a&&(a=0),void 0===b&&(b=this.children.length);var c=b-a;if(c>0&&c<=b){for(var d=this.children.splice(a,c),e=0;eh?l:h,m=m>i?m:i)}var p=this._bounds;if(!n){p=new d.Rectangle;var q=p.x,r=p.width+p.x,s=p.y,t=p.height+p.y,u=this.worldTransform,v=u.a,w=u.b,x=u.c,y=u.d,z=u.tx,A=u.ty,B=v*r+x*t+z,C=y*t+w*r+A,D=v*q+x*t+z,E=y*t+w*q+A,F=v*q+x*s+z,G=y*s+w*q+A,H=v*r+x*s+z,I=y*s+w*r+A;l=B,m=C,j=B,k=C,j=Dl?D:l,l=F>l?F:l,l=H>l?H:l,m=E>m?E:m,m=G>m?G:m,m=I>m?I:m}if(p.x=j,p.y=k,p.width=l-j,p.height=m-k,b)for(a.worldTransform=f,e=0;eo?t:o,o=v>o?v:o,o=x>o?x:o,o=z>o?z:o,p=u>p?u:p,p=w>p?w:p,p=y>p?y:p,p=A>p?A:p}var B=this._bounds;return B.x=q,B.width=o-q,B.y=r,B.height=p-r,this._currentBounds=B,B},d.Sprite.prototype.getLocalBounds=function(){var a=this.worldTransform;this.worldTransform=d.identityMatrix;for(var b=0;b>16&255)/255,(a>>8&255)/255,(255&a)/255]},d.rgb2hex=function(a){return(255*a[0]<<16)+(255*a[1]<<8)+255*a[2]},d.canUseNewCanvasBlendModes=function(){if(void 0===document)return!1;var a="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/",b="AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==",c=new Image;c.src=a+"AP804Oa6"+b;var e=new Image;e.src=a+"/wCKxvRF"+b;var f=d.CanvasPool.create(this,6,1),g=f.getContext("2d");if(g.globalCompositeOperation="multiply",g.drawImage(c,0,0),g.drawImage(e,2,0),!g.getImageData(2,0,1,1))return!1;var h=g.getImageData(2,0,1,1).data;return d.CanvasPool.remove(this),255===h[0]&&0===h[1]&&0===h[2]},d.getNextPowerOfTwo=function(a){if(a>0&&0===(a&a-1))return a;for(var b=1;b0&&0===(a&a-1)&&b>0&&0===(b&b-1)},d.CanvasPool={create:function(a,b,c){var e,f=d.CanvasPool.getFirst();if(f===-1){var g={parent:a,canvas:document.createElement("canvas")};d.CanvasPool.pool.push(g),e=g.canvas}else d.CanvasPool.pool[f].parent=a,e=d.CanvasPool.pool[f].canvas;return void 0!==b&&(e.width=b,e.height=c),e},getFirst:function(){for(var a=d.CanvasPool.pool,b=0;b 0.0) gl_Position = vec4(0.0);"," gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = vec4(aColor.rgb * aColor.a, aColor.a);"," vTextureIndex = aTextureIndex;","}"],d.PixiFastShader=function(a){if(this._UID=d._UID++,this.gl=a,this.program=null,d._enableMultiTextureToggle){var a=this.gl;this.MAX_TEXTURES=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS);for(var b="\tif (vTextureIndex == 0.0) gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor;\n",c=1;c=this.size&&(this.flush(),this.currentBaseTexture=c.baseTexture);var g=c._uvs;if(g){var h,i,j,k,l=a.anchor.x,m=a.anchor.y;if(c.trim){var n=c.trim;i=n.x-l*n.width,h=i+c.crop.width,k=n.y-m*n.height,j=k+c.crop.height}else h=c.frame.width*(1-l),i=c.frame.width*-l,j=c.frame.height*(1-m),k=c.frame.height*-m;var o=this.currentBatchSize*this.vertexSize,p=(4*this.currentBatchSize,c.baseTexture.resolution),q=c.baseTexture.textureIndex,r=f.a/p,s=f.b/p,t=f.c/p,u=f.d/p,v=f.tx,w=f.ty,x=(c.crop.width,c.crop.height);if(c.rotated){var y=f.a,z=f.b,A=f.c,B=f.d,C=i,D=h;v=f.c*x+v,w=f.d*x+w,r=6.123233995736766e-17*y+-A,s=6.123233995736766e-17*z+-B,t=y+6.123233995736766e-17*A,u=z+6.123233995736766e-17*B,c._updateUvsInverted(),h=j,i=k,j=D,k=C}var E=this.colors,F=this.positions,G=a.tint,H=(G>>16)+(65280&G)+((255&G)<<16)+(255*a.worldAlpha<<24);this.renderSession.roundPixels?(F[o++]=r*i+t*k+v|0,F[o++]=u*k+s*i+w|0,F[o++]=g.x0,F[o++]=g.y0,E[o++]=H,F[o++]=q,F[o++]=r*h+t*k+v|0,F[o++]=u*k+s*h+w|0,F[o++]=g.x1,F[o++]=g.y1,E[o++]=H,F[o++]=q,F[o++]=r*h+t*j+v|0,F[o++]=u*j+s*h+w|0,F[o++]=g.x2,F[o++]=g.y2,E[o++]=H,F[o++]=q,F[o++]=r*i+t*j+v|0,F[o++]=u*j+s*i+w|0,F[o++]=g.x3,F[o++]=g.y3,E[o++]=H,F[o++]=q):(F[o++]=r*i+t*k+v,F[o++]=u*k+s*i+w,F[o++]=g.x0,F[o++]=g.y0,E[o++]=H,F[o++]=q,F[o++]=r*h+t*k+v,F[o++]=u*k+s*h+w,F[o++]=g.x1,F[o++]=g.y1,E[o++]=H,F[o++]=q,F[o++]=r*h+t*j+v,F[o++]=u*j+s*h+w,F[o++]=g.x2,F[o++]=g.y2,E[o++]=H,F[o++]=q,F[o++]=r*i+t*j+v,F[o++]=u*j+s*i+w,F[o++]=g.x3,F[o++]=g.y3,E[o++]=H,F[o++]=q),this.sprites[this.currentBatchSize++]=a}},d.WebGLSpriteBatch.prototype.renderTilingSprite=function(a){var b=a.tilingTexture,c=b.baseTexture,e=this.gl,f=a.texture.baseTexture.textureIndex;this.textureArray[f]!=c&&(this.flush(),e.activeTexture(e.TEXTURE0+f),e.bindTexture(e.TEXTURE_2D,c._glTextures[e.id]),this.textureArray[f]=c),this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=b.baseTexture),a._uvs||(a._uvs=new d.TextureUvs);var g=a._uvs,h=b.baseTexture.width,i=b.baseTexture.height;a.tilePosition.x%=h*a.tileScaleOffset.x,a.tilePosition.y%=i*a.tileScaleOffset.y;var j=a.tilePosition.x/(h*a.tileScaleOffset.x),k=a.tilePosition.y/(i*a.tileScaleOffset.y),l=a.width/h/(a.tileScale.x*a.tileScaleOffset.x),m=a.height/i/(a.tileScale.y*a.tileScaleOffset.y);g.x0=0-j,g.y0=0-k,g.x1=1*l-j,g.y1=0-k,g.x2=1*l-j,g.y2=1*m-k,g.x3=0-j,g.y3=1*m-k;var n=a.tint,o=(n>>16)+(65280&n)+((255&n)<<16)+(255*a.worldAlpha<<24),p=this.positions,q=this.colors,r=a.width,s=a.height,t=a.anchor.x,u=a.anchor.y,v=r*(1-t),w=r*-t,x=s*(1-u),y=s*-u,z=this.currentBatchSize*this.vertexSize,A=b.baseTexture.resolution,B=a.worldTransform,C=B.a/A,D=B.b/A,E=B.c/A,F=B.d/A,G=B.tx,H=B.ty;p[z++]=C*w+E*y+G,p[z++]=F*y+D*w+H,p[z++]=g.x0,p[z++]=g.y0,q[z++]=o,p[z++]=f,p[z++]=C*v+E*y+G,p[z++]=F*y+D*v+H,p[z++]=g.x1,p[z++]=g.y1,q[z++]=o,p[z++]=f,p[z++]=C*v+E*x+G,p[z++]=F*x+D*v+H,p[z++]=g.x2,p[z++]=g.y2,q[z++]=o,p[z++]=f,p[z++]=C*w+E*x+G,p[z++]=F*x+D*w+H,p[z++]=g.x3,p[z++]=g.y3,q[z++]=o,p[z++]=f,this.sprites[this.currentBatchSize++]=a},d.WebGLSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var a,b=this.gl;if(this.dirty){this.dirty=!1,a=this.defaultShader.shaders[b.id],b.activeTexture(b.TEXTURE0),b.bindBuffer(b.ARRAY_BUFFER,this.vertexBuffer),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var c=this.vertexSize;b.vertexAttribPointer(a.aVertexPosition,2,b.FLOAT,!1,c,0),b.vertexAttribPointer(a.aTextureCoord,2,b.FLOAT,!1,c,8),b.vertexAttribPointer(a.colorAttribute,4,b.UNSIGNED_BYTE,!0,c,16),b.vertexAttribPointer(a.aTextureIndex,1,b.FLOAT,!1,c,20)}if(this.currentBatchSize>.5*this.size)b.bufferSubData(b.ARRAY_BUFFER,0,this.vertices);else{b.bindBuffer(b.ARRAY_BUFFER,this.vertexBuffer);var e=this.positions.subarray(0,this.currentBatchSize*this.vertexSize);b.bufferSubData(b.ARRAY_BUFFER,0,e)}for(var f,g,h,i,j=0,k=0,l=null,m=this.renderSession.blendModeManager.currentBlendMode,n=null,o=!1,p=!1,q=0,r=this.currentBatchSize;q0&&(s=!1),(o||p)&&(this.renderBatch(l,j,k),k=q,j=0,l=f,o&&(m=g,this.renderSession.blendModeManager.setBlendMode(m)),p)){n=h,a=n.shaders[b.id],a||(a=new d.PixiShader(b),a.fragmentSrc=n.fragmentSrc,a.uniforms=n.uniforms,a.init(),n.shaders[b.id]=a),this.renderSession.shaderManager.setShader(a),a.dirty&&a.syncUniforms();var t=this.renderSession.projection;b.uniform2f(a.projectionVector,t.x,t.y);var u=this.renderSession.offset;b.uniform2f(a.offsetVector,u.x,u.y)}j++}this.renderBatch(l,j,k),this.currentBatchSize=0}},d.WebGLSpriteBatch.prototype.renderBatch=function(a,b,c){if(0!==b){var d=this.gl;a._dirty[d.id]&&!this.renderSession.renderer.updateTexture(a)||(d.drawElements(d.TRIANGLES,6*b,d.UNSIGNED_SHORT,6*c*2),this.renderSession.drawCount++)}},d.WebGLSpriteBatch.prototype.stop=function(){this.flush(),this.dirty=!0},d.WebGLSpriteBatch.prototype.start=function(){this.dirty=!0},d.WebGLSpriteBatch.prototype.destroy=function(){this.vertices=null,this.indices=null,this.gl.deleteBuffer(this.vertexBuffer),this.gl.deleteBuffer(this.indexBuffer),this.currentBaseTexture=null,this.gl=null},d.WebGLFastSpriteBatch=function(a){this.vertSize=11,this.maxSize=6e3,this.size=this.maxSize;var b=4*this.size*this.vertSize,c=6*this.maxSize;this.vertices=new d.Float32Array(b),this.indices=new d.Uint16Array(c),this.vertexBuffer=null,this.indexBuffer=null,this.lastIndexCount=0;for(var e=0,f=0;e=this.size&&this.flush()}},d.WebGLFastSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var a=this.gl;if(this.currentBaseTexture._glTextures[a.id]||this.renderSession.renderer.updateTexture(this.currentBaseTexture,a),this.currentBatchSize>.5*this.size)a.bufferSubData(a.ARRAY_BUFFER,0,this.vertices);else{var b=this.vertices.subarray(0,4*this.currentBatchSize*this.vertSize);a.bufferSubData(a.ARRAY_BUFFER,0,b)}a.drawElements(a.TRIANGLES,6*this.currentBatchSize,a.UNSIGNED_SHORT,0),this.currentBatchSize=0,this.renderSession.drawCount++}},d.WebGLFastSpriteBatch.prototype.stop=function(){this.flush()},d.WebGLFastSpriteBatch.prototype.start=function(){var a=this.gl;a.activeTexture(a.TEXTURE0),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var b=this.renderSession.projection;a.uniform2f(this.shader.projectionVector,b.x,b.y),a.uniformMatrix3fv(this.shader.uMatrix,!1,this.matrix);var c=4*this.vertSize;a.vertexAttribPointer(this.shader.aVertexPosition,2,a.FLOAT,!1,c,0),a.vertexAttribPointer(this.shader.aPositionCoord,2,a.FLOAT,!1,c,8),a.vertexAttribPointer(this.shader.aScale,2,a.FLOAT,!1,c,16),a.vertexAttribPointer(this.shader.aRotation,1,a.FLOAT,!1,c,24),a.vertexAttribPointer(this.shader.aTextureCoord,2,a.FLOAT,!1,c,28),a.vertexAttribPointer(this.shader.colorAttribute,1,a.FLOAT,!1,c,36), a.vertexAttribPointer(this.shader.aTextureIndex,1,a.FLOAT,!1,c,40)},d.WebGLFilterManager=function(){this.filterStack=[],this.offsetX=0,this.offsetY=0},d.WebGLFilterManager.prototype.constructor=d.WebGLFilterManager,d.WebGLFilterManager.prototype.setContext=function(a){this.gl=a,this.texturePool=[],this.initShaderBuffers()},d.WebGLFilterManager.prototype.begin=function(a,b){this.renderSession=a,this.defaultShader=a.shaderManager.defaultShader;var c=this.renderSession.projection;this.width=2*c.x,this.height=2*-c.y,this.buffer=b},d.WebGLFilterManager.prototype.pushFilter=function(a){var b=this.gl,c=this.renderSession.projection,e=this.renderSession.offset;a._filterArea=a.target.filterArea||a.target.getBounds(),a._previous_stencil_mgr=this.renderSession.stencilManager,this.renderSession.stencilManager=new d.WebGLStencilManager,this.renderSession.stencilManager.setContext(b),b.disable(b.STENCIL_TEST),this.filterStack.push(a);var f=a.filterPasses[0];this.offsetX+=a._filterArea.x,this.offsetY+=a._filterArea.y;var g=this.texturePool.pop();g?g.resize(this.width*this.renderSession.resolution,this.height*this.renderSession.resolution):g=new d.FilterTexture(this.gl,this.width*this.renderSession.resolution,this.height*this.renderSession.resolution),b.bindTexture(b.TEXTURE_2D,g.texture);var h=a._filterArea,i=f.padding;h.x-=i,h.y-=i,h.width+=2*i,h.height+=2*i,h.x<0&&(h.x=0),h.width>this.width&&(h.width=this.width),h.y<0&&(h.y=0),h.height>this.height&&(h.height=this.height),b.bindFramebuffer(b.FRAMEBUFFER,g.frameBuffer),b.viewport(0,0,h.width*this.renderSession.resolution,h.height*this.renderSession.resolution),c.x=h.width/2,c.y=-h.height/2,e.x=-h.x,e.y=-h.y,b.colorMask(!0,!0,!0,!0),b.clearColor(0,0,0,0),b.clear(b.COLOR_BUFFER_BIT),a._glFilterTexture=g},d.WebGLFilterManager.prototype.popFilter=function(){var a=this.gl,b=this.filterStack.pop(),c=b._filterArea,e=b._glFilterTexture,f=this.renderSession.projection,g=this.renderSession.offset;if(b.filterPasses.length>1){a.viewport(0,0,c.width*this.renderSession.resolution,c.height*this.renderSession.resolution),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=0,this.vertexArray[1]=c.height,this.vertexArray[2]=c.width,this.vertexArray[3]=c.height,this.vertexArray[4]=0,this.vertexArray[5]=0,this.vertexArray[6]=c.width,this.vertexArray[7]=0,a.bufferSubData(a.ARRAY_BUFFER,0,this.vertexArray),a.bindBuffer(a.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=c.width/this.width,this.uvArray[5]=c.height/this.height,this.uvArray[6]=c.width/this.width,this.uvArray[7]=c.height/this.height,a.bufferSubData(a.ARRAY_BUFFER,0,this.uvArray);var h=e,i=this.texturePool.pop();i||(i=new d.FilterTexture(this.gl,this.width*this.renderSession.resolution,this.height*this.renderSession.resolution)),i.resize(this.width*this.renderSession.resolution,this.height*this.renderSession.resolution),a.bindFramebuffer(a.FRAMEBUFFER,i.frameBuffer),a.clear(a.COLOR_BUFFER_BIT),a.disable(a.BLEND);for(var j=0;j0?a.enable(a.STENCIL_TEST):a.disable(a.STENCIL_TEST),this.applyFilterPass(m,c,n,o),this.texturePool.push(e),b._glFilterTexture=null},d.WebGLFilterManager.prototype.applyFilterPass=function(a,b,c,e){var f=this.gl,g=a.shaders[f.id];g||(g=new d.PixiShader(f),g.fragmentSrc=a.fragmentSrc,g.uniforms=a.uniforms,g.init(!0),a.shaders[f.id]=g),this.renderSession.shaderManager.setShader(g),f.uniform2f(g.projectionVector,c/2,-e/2),f.uniform2f(g.offsetVector,0,0),a.uniforms.dimensions&&(a.uniforms.dimensions.value[0]=this.width,a.uniforms.dimensions.value[1]=this.height,a.uniforms.dimensions.value[2]=this.vertexArray[0],a.uniforms.dimensions.value[3]=this.vertexArray[5]),g.syncUniforms(),f.bindBuffer(f.ARRAY_BUFFER,this.vertexBuffer),f.vertexAttribPointer(g.aVertexPosition,2,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,this.uvBuffer),f.vertexAttribPointer(g.aTextureCoord,2,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,this.colorBuffer),f.vertexAttribPointer(g.colorAttribute,2,f.FLOAT,!1,0,0),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,this.indexBuffer),f.drawElements(f.TRIANGLES,6,f.UNSIGNED_SHORT,0),this.renderSession.drawCount++},d.WebGLFilterManager.prototype.initShaderBuffers=function(){var a=this.gl;this.vertexBuffer=a.createBuffer(),this.uvBuffer=a.createBuffer(),this.colorBuffer=a.createBuffer(),this.indexBuffer=a.createBuffer(),this.vertexArray=new d.Float32Array([0,0,1,0,0,1,1,1]),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),a.bufferData(a.ARRAY_BUFFER,this.vertexArray,a.STATIC_DRAW),this.uvArray=new d.Float32Array([0,0,1,0,0,1,1,1]),a.bindBuffer(a.ARRAY_BUFFER,this.uvBuffer),a.bufferData(a.ARRAY_BUFFER,this.uvArray,a.STATIC_DRAW),this.colorArray=new d.Float32Array([1,16777215,1,16777215,1,16777215,1,16777215]),a.bindBuffer(a.ARRAY_BUFFER,this.colorBuffer),a.bufferData(a.ARRAY_BUFFER,this.colorArray,a.STATIC_DRAW),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,new Uint16Array([0,1,2,1,3,2]),a.STATIC_DRAW)},d.WebGLFilterManager.prototype.destroy=function(){var a=this.gl;this.filterStack=null,this.offsetX=0,this.offsetY=0;for(var b=0;b=0;a--){var b=this._glTextures[a],c=d.glContexts[a];c&&b&&c.deleteTexture(b)}this._glTextures.length=0,this.dirty()},d.BaseTexture.fromCanvas=function(a,b){return 0===a.width&&(a.width=1),0===a.height&&(a.height=1),new d.BaseTexture(a,b)},d.TextureSilentFail=!1,d.Texture=function(a,b,c,e){this.noFrame=!1,b||(this.noFrame=!0,b=new d.Rectangle(0,0,1,1)),a instanceof d.Texture&&(a=a.baseTexture),this.baseTexture=a,this.frame=b,this.trim=e,this.valid=!1,this.isTiling=!1,this.requiresUpdate=!1,this.requiresReTint=!1,this._uvs=null,this.width=0,this.height=0,this.crop=c||new d.Rectangle(0,0,1,1),this.rotated=!1,a.hasLoaded&&(this.noFrame&&(b=new d.Rectangle(0,0,a.width,a.height)),this.setFrame(b))},d.Texture.prototype.constructor=d.Texture,d.Texture.prototype.onBaseTextureLoaded=function(){var a=this.baseTexture;this.noFrame&&(this.frame=new d.Rectangle(0,0,a.width,a.height)),this.setFrame(this.frame)},d.Texture.prototype.destroy=function(a){a&&this.baseTexture.destroy(),this.valid=!1},d.Texture.prototype.setFrame=function(a){if(this.noFrame=!1,this.frame=a,this.width=a.width,this.height=a.height,this.crop.x=a.x,this.crop.y=a.y,this.crop.width=a.width,this.crop.height=a.height,!this.trim&&(a.x+a.width>this.baseTexture.width||a.y+a.height>this.baseTexture.height)){if(!d.TextureSilentFail)throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);return void(this.valid=!1)}this.valid=a&&a.width&&a.height&&this.baseTexture.source&&this.baseTexture.hasLoaded,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()},d.Texture.prototype._updateUvs=function(){this._uvs||(this._uvs=new d.TextureUvs);var a=this.crop,b=this.baseTexture.width,c=this.baseTexture.height;this._uvs.x0=a.x/b,this._uvs.y0=a.y/c,this._uvs.x1=(a.x+a.width)/b,this._uvs.y1=a.y/c,this._uvs.x2=(a.x+a.width)/b,this._uvs.y2=(a.y+a.height)/c,this._uvs.x3=a.x/b,this._uvs.y3=(a.y+a.height)/c},d.Texture.prototype._updateUvsInverted=function(){this._uvs||(this._uvs=new d.TextureUvs);var a=this.crop,b=this.baseTexture.width,c=this.baseTexture.height;this._uvs.x0=a.x/b,this._uvs.y0=a.y/c,this._uvs.x1=(a.x+a.height)/b,this._uvs.y1=a.y/c,this._uvs.x2=(a.x+a.height)/b,this._uvs.y2=(a.y+a.width)/c,this._uvs.x3=a.x/b,this._uvs.y3=(a.y+a.width)/c},d.Texture.fromCanvas=function(a,b){var c=d.BaseTexture.fromCanvas(a,b);return new d.Texture(c)},d.TextureUvs=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},d.RenderTexture=function(a,b,c,e,f,g){if(g="number"==typeof g?g:0,this.width=a||100,this.height=b||100,this.resolution=f||1,this.frame=new d.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution),this.crop=new d.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution),this.baseTexture=new d.BaseTexture,this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution,this.baseTexture._glTextures=[],this.baseTexture.resolution=this.resolution,this.baseTexture.scaleMode=e||d.scaleModes.DEFAULT,this.baseTexture.hasLoaded=!0,d.Texture.call(this,this.baseTexture,new d.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution)),this.renderer=c||d.defaultRenderer,this.renderer.type===d.WEBGL_RENDERER){var h=this.renderer.gl;this.baseTexture.textureIndex=g,this.baseTexture._dirty[h.id]=!1,this.textureBuffer=new d.FilterTexture(h,this.width,this.height,this.baseTexture.scaleMode,g),this.baseTexture._glTextures[h.id]=this.textureBuffer.texture,this.render=this.renderWebGL,this.projection=new d.Point(.5*this.width,.5*-this.height)}else this.render=this.renderCanvas,this.textureBuffer=new d.CanvasBuffer(this.width*this.resolution,this.height*this.resolution),this.baseTexture.source=this.textureBuffer.canvas;this.valid=!0,this.tempMatrix=new Phaser.Matrix,this._updateUvs()},d.RenderTexture.prototype=Object.create(d.Texture.prototype),d.RenderTexture.prototype.constructor=d.RenderTexture,d.RenderTexture.prototype.resize=function(a,b,c){a===this.width&&b===this.height||(this.valid=a>0&&b>0,this.width=a,this.height=b,this.frame.width=this.crop.width=a*this.resolution,this.frame.height=this.crop.height=b*this.resolution,c&&(this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution),this.renderer.type===d.WEBGL_RENDERER&&(this.projection.x=this.width/2,this.projection.y=-this.height/2),this.valid&&this.textureBuffer.resize(this.width,this.height))},d.RenderTexture.prototype.clear=function(){this.valid&&(this.renderer.type===d.WEBGL_RENDERER&&this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER,this.textureBuffer.frameBuffer),this.textureBuffer.clear())},d.RenderTexture.prototype.renderWebGL=function(a,b,c){if(this.valid&&0!==a.alpha){var d=a.worldTransform;d.identity(),d.translate(0,2*this.projection.y),b&&d.append(b),d.scale(1,-1);for(var e=0;e0){var v=this.canvasPadding/this.worldTransform.a,w=this.canvasPadding/this.worldTransform.d,x=(j+k+l)/3,y=(m+n+o)/3,z=j-x,A=m-y,B=Math.sqrt(z*z+A*A);j=x+z/B*(B+v),m=y+A/B*(B+w),z=k-x,A=n-y,B=Math.sqrt(z*z+A*A),k=x+z/B*(B+v),n=y+A/B*(B+w),z=l-x,A=o-y,B=Math.sqrt(z*z+A*A),l=x+z/B*(B+v),o=y+A/B*(B+w)}a.save(),a.beginPath(),a.moveTo(j,m),a.lineTo(k,n),a.lineTo(l,o),a.closePath(),a.clip();var C=p*t+s*r+q*u-t*r-s*q-p*u,D=j*t+s*l+k*u-t*l-s*k-j*u,E=p*k+j*r+q*l-k*r-j*q-p*l,F=p*t*l+s*k*r+j*q*u-j*t*r-s*q*l-p*k*u,G=m*t+s*o+n*u-t*o-s*n-m*u,H=p*n+m*r+q*o-n*r-m*q-p*o,I=p*t*o+s*n*r+m*q*u-m*t*r-s*q*o-p*n*u;a.transform(D/C,G/C,E/C,H/C,F/C,I/C),a.drawImage(g,0,0),a.restore()},d.Strip.prototype.renderStripFlat=function(a){var b=this.context,c=a.vertices,d=c.length/2;this.count++,b.beginPath();for(var e=1;ej?s:j,k=t>k?t:k}if(l===-(1/0)||k===1/0)return d.EmptyRectangle;var u=this._bounds;return u.x=l,u.width=j-l,u.y=m,u.height=k-m,this._currentBounds=u,u},d.Strip.DrawModes={TRIANGLE_STRIP:0,TRIANGLES:1},d.Rope=function(a,b){d.Strip.call(this,a),this.points=b,this.vertices=new d.Float32Array(4*b.length),this.uvs=new d.Float32Array(4*b.length),this.colors=new d.Float32Array(2*b.length),this.indices=new d.Uint16Array(2*b.length),this.refresh()},d.Rope.prototype=Object.create(d.Strip.prototype),d.Rope.prototype.constructor=d.Rope,d.Rope.prototype.refresh=function(){var a=this.points;if(!(a.length<1)){var b=this.uvs,c=a[0],d=this.indices,e=this.colors;this.count-=.2,b[0]=0,b[1]=0,b[2]=0,b[3]=1,e[0]=1,e[1]=1,d[0]=0,d[1]=1;for(var f,g,h,i=a.length,j=1;j1&&(h=1),i=Math.sqrt(e.x*e.x+e.y*e.y),j=this.texture.height/2,e.x/=i,e.y/=i,e.x*=j,e.y*=j,k[g]=f.x+e.x,k[g+1]=f.y+e.y,k[g+2]=f.x-e.x,k[g+3]=f.y-e.y,c=f;d.DisplayObjectContainer.prototype.updateTransform.call(this)}},d.Rope.prototype.setTexture=function(a){this.texture=a},d.TilingSprite=function(a,b,c){d.Sprite.call(this,a),this._width=b||128,this._height=c||128,this.tileScale=new d.Point(1,1),this.tileScaleOffset=new d.Point(1,1),this.tilePosition=new d.Point,this.renderable=!0,this.tint=16777215,this.textureDebug=!1,this.blendMode=d.blendModes.NORMAL,this.canvasBuffer=null,this.tilingTexture=null,this.tilePattern=null,this.refreshTexture=!0,this.frameWidth=0,this.frameHeight=0},d.TilingSprite.prototype=Object.create(d.Sprite.prototype),d.TilingSprite.prototype.constructor=d.TilingSprite,d.TilingSprite.prototype.setTexture=function(a){this.texture!==a&&(this.texture=a,this.refreshTexture=!0,this.cachedTint=16777215)},d.TilingSprite.prototype._renderWebGL=function(a){if(this.visible&&this.renderable&&0!==this.alpha){if(this._mask&&(a.spriteBatch.stop(),a.maskManager.pushMask(this.mask,a),a.spriteBatch.start()),this._filters&&(a.spriteBatch.flush(),a.filterManager.pushFilter(this._filterBlock)),this.refreshTexture){if(this.generateTilingTexture(!0,a),!this.tilingTexture)return;this.tilingTexture.needsUpdate&&(this.tilingTexture.baseTexture.textureIndex=this.texture.baseTexture.textureIndex,a.renderer.updateTexture(this.tilingTexture.baseTexture),this.tilingTexture.needsUpdate=!1)}a.spriteBatch.renderTilingSprite(this);for(var b=0;bv?n:v,v=p>v?p:v,v=r>v?r:v,v=t>v?t:v,w=o>w?o:w,w=q>w?q:w,w=s>w?s:w,w=u>w?u:w;var z=this._bounds;return z.x=x,z.width=v-x,z.y=y,z.height=w-y,this._currentBounds=z,z},d.TilingSprite.prototype.destroy=function(){d.Sprite.prototype.destroy.call(this),this.canvasBuffer&&(this.canvasBuffer.destroy(),this.canvasBuffer=null),this.tileScale=null,this.tileScaleOffset=null,this.tilePosition=null,this.tilingTexture&&(this.tilingTexture.destroy(!0),this.tilingTexture=null)},Object.defineProperty(d.TilingSprite.prototype,"width",{get:function(){return this._width},set:function(a){this._width=a}}),Object.defineProperty(d.TilingSprite.prototype,"height",{get:function(){return this._height},set:function(a){this._height=a}}),"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=d),exports.PIXI=d):"undefined"!=typeof define&&define.amd?define("PIXI",function(){return c.PIXI=d}()):c.PIXI=d,d}).call(this); //# sourceMappingURL=pixi.map