/* Phaser v2.7.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.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,d,e,f,g,h,i=b.worldTransform,j=this.worldTransform;return this.rotation%Phaser.Math.PI2?(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,d=this._sr*this.scale.x,e=-this._sr*this.scale.y,f=this._cr*this.scale.y,g=this.position.x,h=this.position.y,(this.pivot.x||this.pivot.y)&&(g-=this.pivot.x*c+this.pivot.y*e,h-=this.pivot.x*d+this.pivot.y*f),j.a=c*i.a+d*i.c,j.b=c*i.b+d*i.d,j.c=e*i.a+f*i.c,j.d=e*i.b+f*i.d,j.tx=g*i.a+h*i.c+i.tx,j.ty=g*i.b+h*i.d+i.ty):(c=this.scale.x,f=this.scale.y,g=this.position.x-this.pivot.x*c,h=this.position.y-this.pivot.y*f,j.a=c*i.a,j.b=c*i.b,j.c=f*i.c,j.d=f*i.d,j.tx=g*i.a+h*i.c+i.tx,j.ty=g*i.b+h*i.d+i.ty),this.worldAlpha=this.alpha*b.worldAlpha,this.worldPosition.set(j.tx,j.ty),this.worldScale.set(this.scale.x*Math.sqrt(j.a*j.a+j.c*j.c),this.scale.y*Math.sqrt(j.b*j.b+j.d*j.d)),this.worldRotation=Math.atan2(-j.c,j.d),this._currentBounds=null,this.transformCallback&&this.transformCallback.call(this.transformCallbackContext,j,i),this},preUpdate:function(){},generateTexture:function(a,b,c){var e=this.getLocalBounds(),f=new Phaser.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 Phaser.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 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=Phaser._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 h=c._uvs;if(h){var i,j,k,l,m=a.anchor.x,n=a.anchor.y;if(c.trim){var o=c.trim;j=o.x-m*o.width,i=j+c.crop.width,l=o.y-n*o.height,k=l+c.crop.height}else i=c.frame.width*(1-m),j=c.frame.width*-m,k=c.frame.height*(1-n),l=c.frame.height*-n;var p=this.currentBatchSize*this.vertexSize,q=(4*this.currentBatchSize,c.baseTexture.resolution),r=c.baseTexture.textureIndex,s=g.a/q,t=g.b/q,u=g.c/q,v=g.d/q,w=g.tx,x=g.ty,y=(c.crop.width,c.crop.height);if(c.rotated){var z=g.a,A=g.b,B=g.c,C=g.d,D=j,E=i;w=g.c*y+w,x=g.d*y+x,s=6.123233995736766e-17*z+-B,t=6.123233995736766e-17*A+-C,u=z+6.123233995736766e-17*B,v=A+6.123233995736766e-17*C,c._updateUvsInverted(),i=k,j=l,k=E,l=D}var F=this.colors,G=this.positions,H=a.tint,I=(H>>16)+(65280&H)+((255&H)<<16)+(255*a.worldAlpha<<24);this.renderSession.roundPixels?(G[p++]=s*j+u*l+w|0,G[p++]=v*l+t*j+x|0,G[p++]=h.x0,G[p++]=h.y0,F[p++]=I,G[p++]=r,G[p++]=s*i+u*l+w|0,G[p++]=v*l+t*i+x|0,G[p++]=h.x1,G[p++]=h.y1,F[p++]=I,G[p++]=r,G[p++]=s*i+u*k+w|0,G[p++]=v*k+t*i+x|0,G[p++]=h.x2,G[p++]=h.y2,F[p++]=I,G[p++]=r,G[p++]=s*j+u*k+w|0,G[p++]=v*k+t*j+x|0,G[p++]=h.x3,G[p++]=h.y3,F[p++]=I,G[p++]=r):(G[p++]=s*j+u*l+w,G[p++]=v*l+t*j+x,G[p++]=h.x0,G[p++]=h.y0,F[p++]=I,G[p++]=r,G[p++]=s*i+u*l+w,G[p++]=v*l+t*i+x,G[p++]=h.x1,G[p++]=h.y1,F[p++]=I,G[p++]=r,G[p++]=s*i+u*k+w,G[p++]=v*k+t*i+x,G[p++]=h.x2,G[p++]=h.y2,F[p++]=I,G[p++]=r,G[p++]=s*j+u*k+w,G[p++]=v*k+t*j+x,G[p++]=h.x3,G[p++]=h.y3,F[p++]=I,G[p++]=r),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;d.WebGLRenderer.textureArray[f]!=c&&(this.flush(),e.activeTexture(e.TEXTURE0+f),e.bindTexture(e.TEXTURE_2D,c._glTextures[e.id]),d.WebGLRenderer.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 Float32Array(b),this.indices=new Uint16Array(c),this.vertexBuffer=null,this.indexBuffer=null,this.lastIndexCount=0;for(var d=0,e=0;d=this.size&&this.flush()}},d.WebGLFastSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var a=this.gl;if(!this.currentBaseTexture._glTextures[a.id])return void this.renderSession.renderer.updateTexture(this.currentBaseTexture,a);if(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 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 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 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},"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