/* * @license * Pixi.JS - v1.3.0 custom build * Copyright (c) 2012, Mat Groves * http://goodboydigital.com/ * * Compiled: 2013-08-13 * * Includes atlas file loader and text word wrap improvements * by Martin Kelm (http://github.com/mkelm) * * Pixi.JS is licensed under the MIT License. * http://www.opensource.org/licenses/mit-license.php */ (function(){function K(c){return[(c>>16&255)/255,(c>>8&255)/255,(c&255)/255]}function K(c){return[(c>>16&255)/255,(c>>8&255)/255,(c&255)/255]}var e=e||{};e.Point=function(c,d){this.x=c||0;this.y=d||0};e.Point.prototype.clone=function(){return new e.Point(this.x,this.y)};e.Point.prototype.constructor=e.Point;e.Rectangle=function(c,d,f,k){this.x=c||0;this.y=d||0;this.width=f||0;this.height=k||0};e.Rectangle.prototype.clone=function(){return new e.Rectangle(this.x,this.y,this.width,this.height)};e.Rectangle.prototype.contains= function(c,d){if(0>=this.width||0>=this.height)return!1;var f=this.x;return c>=f&&c<=f+this.width&&(f=this.y,d>=f&&d<=f+this.height)?!0:!1};e.Rectangle.prototype.constructor=e.Rectangle;e.Polygon=function(c){c instanceof Array||(c=Array.prototype.slice.call(arguments));if("number"===typeof c[0]){for(var d=[],f=0,k=c.length;fd!=e>d&&c<(p-l)*(d-m)/(e-m)+l&&(f=!f)}return f};e.Polygon.prototype.constructor=e.Polygon;e.Circle=function(c,d,f){this.x=c||0;this.y=d||0;this.radius=f||0};e.Circle.prototype.clone=function(){return new e.Circle(this.x,this.y,this.radius)};e.Circle.prototype.contains=function(c,d){if(0>=this.radius)return!1; var f=this.x-c,k=this.y-d,e=this.radius*this.radius;return f*f+k*k<=e};e.Circle.prototype.constructor=e.Circle;e.Ellipse=function(c,d,f,k){this.x=c||0;this.y=d||0;this.width=f||0;this.height=k||0};e.Ellipse.prototype.clone=function(){return new e.Ellipse(this.x,this.y,this.width,this.height)};e.Ellipse.prototype.contains=function(c,d){if(0>=this.width||0>=this.height)return!1;var f=(c-this.x)/this.width-0.5,k=(d-this.y)/this.height-0.5;return 0.25>f*f+k*k};e.Ellipse.getBounds=function(){return new e.Rectangle(this.x, this.y,this.width,this.height)};e.Ellipse.prototype.constructor=e.Ellipse;e.Matrix="undefined"!==typeof Float32Array?Float32Array:Array;e.mat3={};e.mat3.create=function(){var c=new e.Matrix(9);c[0]=1;c[1]=0;c[2]=0;c[3]=0;c[4]=1;c[5]=0;c[6]=0;c[7]=0;c[8]=1;return c};e.mat3.identity=function(c){c[0]=1;c[1]=0;c[2]=0;c[3]=0;c[4]=1;c[5]=0;c[6]=0;c[7]=0;c[8]=1;return c};e.mat4={};e.mat4.create=function(){var c=new e.Matrix(16);c[0]=1;c[1]=0;c[2]=0;c[3]=0;c[4]=0;c[5]=1;c[6]=0;c[7]=0;c[8]=0;c[9]=0;c[10]= 1;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c};e.mat3.multiply=function(c,d,f){f||(f=c);var k=c[0],e=c[1],l=c[2],m=c[3],p=c[4],v=c[5],t=c[6],q=c[7];c=c[8];var n=d[0],s=d[1],w=d[2],A=d[3],x=d[4],C=d[5],D=d[6],B=d[7];d=d[8];f[0]=n*k+s*m+w*t;f[1]=n*e+s*p+w*q;f[2]=n*l+s*v+w*c;f[3]=A*k+x*m+C*t;f[4]=A*e+x*p+C*q;f[5]=A*l+x*v+C*c;f[6]=D*k+B*m+d*t;f[7]=D*e+B*p+d*q;f[8]=D*l+B*v+d*c;return f};e.mat3.clone=function(c){var d=new e.Matrix(9);d[0]=c[0];d[1]=c[1];d[2]=c[2];d[3]=c[3];d[4]=c[4];d[5]=c[5];d[6]= c[6];d[7]=c[7];d[8]=c[8];return d};e.mat3.transpose=function(c,d){if(!d||c===d){var f=c[1],k=c[2],e=c[5];c[1]=c[3];c[2]=c[6];c[3]=f;c[5]=c[7];c[6]=k;c[7]=e;return c}d[0]=c[0];d[1]=c[3];d[2]=c[6];d[3]=c[1];d[4]=c[4];d[5]=c[7];d[6]=c[2];d[7]=c[5];d[8]=c[8];return d};e.mat3.toMat4=function(c,d){d||(d=e.mat4.create());d[15]=1;d[14]=0;d[13]=0;d[12]=0;d[11]=0;d[10]=c[8];d[9]=c[7];d[8]=c[6];d[7]=0;d[6]=c[5];d[5]=c[4];d[4]=c[3];d[3]=0;d[2]=c[2];d[1]=c[1];d[0]=c[0];return d};e.mat4.create=function(){var c= new e.Matrix(16);c[0]=1;c[1]=0;c[2]=0;c[3]=0;c[4]=0;c[5]=1;c[6]=0;c[7]=0;c[8]=0;c[9]=0;c[10]=1;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c};e.mat4.transpose=function(c,d){if(!d||c===d){var f=c[1],k=c[2],e=c[3],l=c[6],m=c[7],p=c[11];c[1]=c[4];c[2]=c[8];c[3]=c[12];c[4]=f;c[6]=c[9];c[7]=c[13];c[8]=k;c[9]=l;c[11]=c[14];c[12]=e;c[13]=m;c[14]=p;return c}d[0]=c[0];d[1]=c[4];d[2]=c[8];d[3]=c[12];d[4]=c[1];d[5]=c[5];d[6]=c[9];d[7]=c[13];d[8]=c[2];d[9]=c[6];d[10]=c[10];d[11]=c[14];d[12]=c[3];d[13]=c[7]; d[14]=c[11];d[15]=c[15];return d};e.mat4.multiply=function(c,d,f){f||(f=c);var k=c[0],e=c[1],l=c[2],m=c[3],p=c[4],v=c[5],t=c[6],q=c[7],n=c[8],s=c[9],w=c[10],A=c[11],x=c[12],C=c[13],D=c[14];c=c[15];var B=d[0],y=d[1],z=d[2],E=d[3];f[0]=B*k+y*p+z*n+E*x;f[1]=B*e+y*v+z*s+E*C;f[2]=B*l+y*t+z*w+E*D;f[3]=B*m+y*q+z*A+E*c;B=d[4];y=d[5];z=d[6];E=d[7];f[4]=B*k+y*p+z*n+E*x;f[5]=B*e+y*v+z*s+E*C;f[6]=B*l+y*t+z*w+E*D;f[7]=B*m+y*q+z*A+E*c;B=d[8];y=d[9];z=d[10];E=d[11];f[8]=B*k+y*p+z*n+E*x;f[9]=B*e+y*v+z*s+E*C;f[10]= B*l+y*t+z*w+E*D;f[11]=B*m+y*q+z*A+E*c;B=d[12];y=d[13];z=d[14];E=d[15];f[12]=B*k+y*p+z*n+E*x;f[13]=B*e+y*v+z*s+E*C;f[14]=B*l+y*t+z*w+E*D;f[15]=B*m+y*q+z*A+E*c;return f};e.DisplayObject=function(){this.last=this;this.first=this;this.position=new e.Point;this.scale=new e.Point(1,1);this.pivot=new e.Point(0,0);this.rotation=0;this.alpha=1;this.visible=!0;this.hitArea=null;this.worldVisible=this.renderable=this.buttonMode=!1;this.stage=this.parent=null;this.worldAlpha=1;this._interactive=!1;this.worldTransform= e.mat3.create();this.localTransform=e.mat3.create();this.color=[];this.dynamic=!0;this._sr=0;this._cr=1};e.DisplayObject.prototype.constructor=e.DisplayObject;e.DisplayObject.prototype.setInteractive=function(c){this.interactive=c};Object.defineProperty(e.DisplayObject.prototype,"interactive",{get:function(){return this._interactive},set:function(c){this._interactive=c;this.stage&&(this.stage.dirty=!0)}});Object.defineProperty(e.DisplayObject.prototype,"mask",{get:function(){return this._mask},set:function(c){(this._mask= c)?this.addFilter(c):this.removeFilter()}});e.DisplayObject.prototype.addFilter=function(c){if(!this.filter){this.filter=!0;var d=new e.FilterBlock,f=new e.FilterBlock;d.mask=c;f.mask=c;d.first=d.last=this;f.first=f.last=this;d.open=!0;var k=d,h=d,l,m;(m=this.first._iPrev)?(l=m._iNext,k._iPrev=m,m._iNext=k):l=this;l&&(l._iPrev=h,h._iNext=l);h=k=f;m=this.last;if(l=m._iNext)l._iPrev=h,h._iNext=l;k._iPrev=m;m._iNext=k;k=this;for(h=this.last;k;)k.last==h&&(k.last=f),k=k.parent;this.first=d;this.__renderGroup&& this.__renderGroup.addFilterBlocks(d,f);c.renderable=!1}};e.DisplayObject.prototype.removeFilter=function(){if(this.filter){this.filter=!1;var c=this.first,d=c._iNext,f=c._iPrev;d&&(d._iPrev=f);f&&(f._iNext=d);this.first=c._iNext;var k=this.last,d=k._iNext,f=k._iPrev;d&&(d._iPrev=f);f._iNext=d;d=k._iPrev;for(f=this;f.last==k&&(f.last=d,f=f.parent,f););c.mask.renderable=!0;this.__renderGroup&&this.__renderGroup.removeFilterBlocks(c,k)}};e.DisplayObject.prototype.updateTransform=function(){this.rotation!= this.rotationCache&&(this.rotationCache=this.rotation,this._sr=Math.sin(this.rotation),this._cr=Math.cos(this.rotation));var c=this.localTransform,d=this.parent.worldTransform,f=this.worldTransform;c[0]=this._cr*this.scale.x;c[1]=-this._sr*this.scale.y;c[3]=this._sr*this.scale.x;c[4]=this._cr*this.scale.y;var k=this.pivot.x,e=this.pivot.y,l=c[0],m=c[1],p=this.position.x-c[0]*k-e*c[1],v=c[3],n=c[4],k=this.position.y-c[4]*e-k*c[3],e=d[0],q=d[1],u=d[2],s=d[3],w=d[4],d=d[5];c[2]=p;c[5]=k;f[0]=e*l+q*v; f[1]=e*m+q*n;f[2]=e*p+q*k+u;f[3]=s*l+w*v;f[4]=s*m+w*n;f[5]=s*p+w*k+d;this.worldAlpha=this.alpha*this.parent.worldAlpha};e.DisplayObjectContainer=function(){e.DisplayObject.call(this);this.children=[]};e.DisplayObjectContainer.prototype=Object.create(e.DisplayObject.prototype);e.DisplayObjectContainer.prototype.constructor=e.DisplayObjectContainer;e.DisplayObjectContainer.prototype.addChild=function(c){void 0!=c.parent&&c.parent.removeChild(c);c.parent=this;this.children.push(c);if(this.stage){var d= c;do d.interactive&&(this.stage.dirty=!0),d.stage=this.stage,d=d._iNext;while(d)}var d=c.first,f=c.last,k,e;e=this.filter?this.last._iPrev:this.last;k=e._iNext;for(var l=this;l;)l.last==e&&(l.last=c.last),l=l.parent;k&&(k._iPrev=f,f._iNext=k);d._iPrev=e;e._iNext=d;this.__renderGroup&&(c.__renderGroup&&c.__renderGroup.removeDisplayObjectAndChildren(c),this.__renderGroup.addDisplayObjectAndChildren(c))};e.DisplayObjectContainer.prototype.addChildAt=function(c,d){if(0<=d&&d<=this.children.length){void 0!= c.parent&&c.parent.removeChild(c);c.parent=this;if(this.stage){var f=c;do f.interactive&&(this.stage.dirty=!0),f.stage=this.stage,f=f._iNext;while(f)}var f=c.first,k=c.last,e,l;if(d==this.children.length){l=this.last;e=this;for(var m=this.last;e;)e.last==m&&(e.last=c.last),e=e.parent}else l=0==d?this:this.children[d-1].last;if(e=l._iNext)e._iPrev=k,k._iNext=e;f._iPrev=l;l._iNext=f;this.children.splice(d,0,c);this.__renderGroup&&(c.__renderGroup&&c.__renderGroup.removeDisplayObjectAndChildren(c),this.__renderGroup.addDisplayObjectAndChildren(c))}else throw Error(c+ " The index "+d+" supplied is out of bounds "+this.children.length);};e.DisplayObjectContainer.prototype.swapChildren=function(c,d){};e.DisplayObjectContainer.prototype.getChildAt=function(c){if(0<=c&&c=this.textures.length&&(this.gotoAndStop(this.textures.length-1),this.onComplete))this.onComplete()}};e.FilterBlock= function(c){this.graphics=c;this.renderable=this.visible=!0};e.Text=function(c,d){this.canvas=document.createElement("canvas");this.context=this.canvas.getContext("2d");e.Sprite.call(this,e.Texture.fromCanvas(this.canvas));this.setStyle(d);this.setText(c);this.updateText();this.dirty=!1};e.Text.prototype=Object.create(e.Sprite.prototype);e.Text.prototype.constructor=e.Text;e.Text.prototype.setStyle=function(c){c=c||{};c.font=c.font||"bold 20pt Arial";c.fill=c.fill||"black";c.align=c.align||"left"; c.stroke=c.stroke||"black";c.strokeThickness=c.strokeThickness||0;c.wordWrap=c.wordWrap||!1;c.wordWrapWidth=c.wordWrapWidth||100;this.style=c;this.dirty=!0};e.Sprite.prototype.setText=function(c){this.text=c.toString()||" ";this.dirty=!0};e.Text.prototype.updateText=function(){this.context.font=this.style.font;var c=this.text;this.style.wordWrap&&(c=this.wordWrap(this.text));for(var c=c.split(/(?:\r\n|\r|\n)/),d=[],f=0,k=0;kk){if(" "!=d.substring(h-1,h)&&" "!=d.substring(h,h+1)){do h--;while(0f.length)return f;var k=d(c,f,0,f.length,e),h=f.substring(0,k)+"\n";" "==f.substring(k,k+1)&&k++;return h+ arguments.callee(c,f.substring(k),e)},e="";c=c.split("\n");for(var h=0;h30*d/1E3)){this.last=c;if(this.dirty){this.dirty=!1;d=this.interactiveItems.length;for(c=0;cp&&mm&&f>>>>>>>>");console.log("_");var d=0;c=c.first;for(console.log(c);c._iNext;)if(d++,c=c._iNext,console.log(c),100>1;if(3>f)return[];for(var k=[],h=[],l=0;l3*m)if(d){k=[];h=[];for(l=0;lp+m};e.PolyK._convex=function(c,d,f,e,h,l,m){return 0<=(d-e)*(h-f)+(f-c)*(l-e)==m};e.shaderFragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));","gl_FragColor = gl_FragColor * vColor;","}"];e.shaderVertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;", "attribute float aColor;","uniform vec2 projectionVector;","varying vec2 vTextureCoord;","varying float vColor;","void main(void) {","gl_Position = vec4( aVertexPosition.x / projectionVector.x -1.0, aVertexPosition.y / -projectionVector.y + 1.0 , 0.0, 1.0);","vTextureCoord = aTextureCoord;","vColor = aColor;","}"];e.stripShaderFragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying float vColor;","uniform float alpha;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));", "gl_FragColor = gl_FragColor * alpha;","}"];e.stripShaderVertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","varying vec2 vTextureCoord;","varying float vColor;","void main(void) {","vec3 v = translationMatrix * vec3(aVertexPosition, 1.0);","gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);","vTextureCoord = aTextureCoord;","vColor = aColor;", "}"];e.primitiveShaderFragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {","gl_FragColor = vColor;","}"];e.primitiveShaderVertexSrc=["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform float alpha;","varying vec4 vColor;","void main(void) {","vec3 v = translationMatrix * vec3(aVertexPosition, 1.0);","gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);", "vColor = aColor * alpha;","}"];e.initPrimitiveShader=function(){var c=e.gl,d=e.compileProgram(e.primitiveShaderVertexSrc,e.primitiveShaderFragmentSrc);c.useProgram(d);d.vertexPositionAttribute=c.getAttribLocation(d,"aVertexPosition");d.colorAttribute=c.getAttribLocation(d,"aColor");d.projectionVector=c.getUniformLocation(d,"projectionVector");d.translationMatrix=c.getUniformLocation(d,"translationMatrix");d.alpha=c.getUniformLocation(d,"alpha");e.primitiveProgram=d};e.initDefaultShader=function(){var c= this.gl,d=e.compileProgram(e.shaderVertexSrc,e.shaderFragmentSrc);c.useProgram(d);d.vertexPositionAttribute=c.getAttribLocation(d,"aVertexPosition");d.projectionVector=c.getUniformLocation(d,"projectionVector");d.textureCoordAttribute=c.getAttribLocation(d,"aTextureCoord");d.colorAttribute=c.getAttribLocation(d,"aColor");d.samplerUniform=c.getUniformLocation(d,"uSampler");e.shaderProgram=d};e.initDefaultStripShader=function(){var c=this.gl,d=e.compileProgram(e.stripShaderVertexSrc,e.stripShaderFragmentSrc); c.useProgram(d);d.vertexPositionAttribute=c.getAttribLocation(d,"aVertexPosition");d.projectionVector=c.getUniformLocation(d,"projectionVector");d.textureCoordAttribute=c.getAttribLocation(d,"aTextureCoord");d.translationMatrix=c.getUniformLocation(d,"translationMatrix");d.alpha=c.getUniformLocation(d,"alpha");d.colorAttribute=c.getAttribLocation(d,"aColor");d.projectionVector=c.getUniformLocation(d,"projectionVector");d.samplerUniform=c.getUniformLocation(d,"uSampler");e.stripShaderProgram=d};e.CompileVertexShader= function(c,d){return e._CompileShader(c,d,c.VERTEX_SHADER)};e.CompileFragmentShader=function(c,d){return e._CompileShader(c,d,c.FRAGMENT_SHADER)};e._CompileShader=function(c,d,f){d=d.join("\n");f=c.createShader(f);c.shaderSource(f,d);c.compileShader(f);return c.getShaderParameter(f,c.COMPILE_STATUS)?f:(alert(c.getShaderInfoLog(f)),null)};e.compileProgram=function(c,d){var f=e.gl,k=e.CompileFragmentShader(f,d),h=e.CompileVertexShader(f,c),l=f.createProgram();f.attachShader(l,h);f.attachShader(l,k); f.linkProgram(l);f.getProgramParameter(l,f.LINK_STATUS)||alert("Could not initialise shaders");return l};e.activateDefaultShader=function(){var c=e.gl,d=e.shaderProgram;c.useProgram(d);c.enableVertexAttribArray(d.vertexPositionAttribute);c.enableVertexAttribArray(d.textureCoordAttribute);c.enableVertexAttribArray(d.colorAttribute)};e.activatePrimitiveShader=function(){var c=e.gl;c.disableVertexAttribArray(e.shaderProgram.textureCoordAttribute);c.disableVertexAttribArray(e.shaderProgram.colorAttribute); c.useProgram(e.primitiveProgram);c.enableVertexAttribArray(e.primitiveProgram.vertexPositionAttribute);c.enableVertexAttribArray(e.primitiveProgram.colorAttribute)};e.WebGLGraphics=function(){};e.WebGLGraphics.renderGraphics=function(c,d){var f=e.gl;c._webGL||(c._webGL={points:[],indices:[],lastIndex:0,buffer:f.createBuffer(),indexBuffer:f.createBuffer()});c.dirty&&(c.dirty=!1,c.clearDirty&&(c.clearDirty=!1,c._webGL.lastIndex=0,c._webGL.points=[],c._webGL.indices=[]),e.WebGLGraphics.updateGraphics(c)); e.activatePrimitiveShader();var k=e.mat3.clone(c.worldTransform);e.mat3.transpose(k);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA);f.uniformMatrix3fv(e.primitiveProgram.translationMatrix,!1,k);f.uniform2f(e.primitiveProgram.projectionVector,d.x,d.y);f.uniform1f(e.primitiveProgram.alpha,c.worldAlpha);f.bindBuffer(f.ARRAY_BUFFER,c._webGL.buffer);f.vertexAttribPointer(e.shaderProgram.vertexPositionAttribute,2,f.FLOAT,!1,0,0);f.vertexAttribPointer(e.primitiveProgram.vertexPositionAttribute,2,f.FLOAT,!1,24, 0);f.vertexAttribPointer(e.primitiveProgram.colorAttribute,4,f.FLOAT,!1,24,8);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,c._webGL.indexBuffer);f.drawElements(f.TRIANGLE_STRIP,c._webGL.indices.length,f.UNSIGNED_SHORT,0);e.activateDefaultShader()};e.WebGLGraphics.updateGraphics=function(c){for(var d=c._webGL.lastIndex;dA;A++)u.push(k,h,t,q,p,n),u.push(k+Math.sin(m*A)*l,h+Math.cos(m*A)*f,t,q,p,n),s.push(w++,w++);s.push(w-1)}if(c.lineWidth){c.points=[];for(A=0;41>A;A++)c.points.push(k+Math.sin(m*A)*l,h+Math.cos(m*A)*f);e.WebGLGraphics.buildLine(c,d)}};e.WebGLGraphics.buildLine=function(c,d){var f=c.points;if(0!=f.length){var k= new e.Point(f[0],f[1]),h=new e.Point(f[f.length-2],f[f.length-1]);if(k.x==h.x&&k.y==h.y){f.pop();f.pop();var h=new e.Point(f[f.length-2],f[f.length-1]),l=h.x+0.5*(k.x-h.x),k=h.y+0.5*(k.y-h.y);f.unshift(l,k);f.push(l,k)}var l=d.points,k=d.indices,h=f.length/2,m=f.length,p=l.length/6,n=c.lineWidth/2,t=K(c.lineColor),q=c.lineAlpha,u=t[0]*q,s=t[1]*q,t=t[2]*q,w,A,x,C,D,B,y,z,E,G,F,I,J;w=f[0];A=f[1];x=f[2];C=f[3];y=-(A-C);z=w-x;F=Math.sqrt(y*y+z*z);y=y/F*n;z=z/F*n;l.push(w-y,A-z,u,s,t,q);l.push(w+y,A+z, u,s,t,q);for(var H=1;Hf.length)){for(var k=d.points,h=d.indices,l=f.length/2,m=K(c.fillColor), p=c.fillAlpha,n=m[0]*p,t=m[1]*p,m=m[2]*p,q=e.PolyK.Triangulate(f),u=k.length/6,s=0;sf;f++){var k=c.graphicsData[f],h=k.points;if(k.type==e.Graphics.POLY){d.beginPath(); d.moveTo(h[0],h[1]);for(k=1;kc.length)){var d=this.uvs,f=this.indices,e=this.colors;this.count-=0.2;d[0]=0;d[1]=1;d[2]=0;d[3]=1;e[0]=1;e[1]=1;f[0]=0;f[1]=1;for(var c=c.length,h=1;hc.length)){var d=this.verticies,f=c[0],k, h=k=0,l=c[0];this.count-=0.2;d[0]=l.x+k;d[1]=l.y+h;d[2]=l.x-k;d[3]=l.y-h;for(var m=c.length,p=1;p>>1;;){c[(l+1)*f]<=d?e=l+1:h=l;if(e==h)return(e+1)*f;l=e+h>>>1}};n.linearSearch=function(c,d,f){for(var e=0,h=c.length-f;e<=h;e+=f)if(c[e]>d)return e;return-1};n.Curves=function(c){this.curves= [];this.curves.length=6*(c-1)};n.Curves.prototype={setLinear:function(c){this.curves[6*c]=0},setStepped:function(c){this.curves[6*c]=-1},setCurve:function(c,d,f,e,h){var l=0.1*0.1,m=0.1*l,p=3*0.1,n=3*l,l=6*l,t=6*m,q=2*-d+e,u=2*-f+h;e=3*(d-e)+1;h=3*(f-h)+1;c*=6;var s=this.curves;s[c]=d*p+q*n+e*m;s[c+1]=f*p+u*n+h*m;s[c+2]=q*l+e*t;s[c+3]=u*l+h*t;s[c+4]=e*t;s[c+5]=h*t},getCurvePercent:function(c,d){d=0>d?0:1=d)return h=f-h,l=e-l,l+(e-l)*(d-h)/(f-h);if(0==q)break;q--;h+=m;l+=p;m+=n;p+=t;f+=h;e+=l}return e+(1-e)*(d-f)/(1-f)}};n.RotateTimeline=function(c){this.curves=new n.Curves(c);this.frames=[];this.frames.length=2*c};n.RotateTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/2},setFrame:function(c,d,f){c*=2;this.frames[c]=d;this.frames[c+1]=f},apply:function(c,d,f){var e=this.frames;if(!(d=e[e.length-2])e=c.data.rotation+e[e.length-1]-c.rotation;else{var h=n.binarySearch(e,d,2),l=e[h-1],m=e[h];d=1-(d-m)/(e[h-2]-m);d=this.curves.getCurvePercent(h/2-1,d);for(e=e[h+1]-l;180e;)e+=360;e=c.data.rotation+(l+e*d)-c.rotation}for(;180e;)e+=360;c.rotation+=e*f}}};n.TranslateTimeline=function(c){this.curves=new n.Curves(c);this.frames=[];this.frames.length=3*c};n.TranslateTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/ 3},setFrame:function(c,d,f,e){c*=3;this.frames[c]=d;this.frames[c+1]=f;this.frames[c+2]=e},apply:function(c,d,f){var e=this.frames;if(!(d=e[e.length-3])c.x+=(c.data.x+e[e.length-2]-c.x)*f,c.y+=(c.data.y+e[e.length-1]-c.y)*f;else{var h=n.binarySearch(e,d,3),l=e[h-2],m=e[h-1],p=e[h];d=1-(d-p)/(e[h+-3]-p);d=this.curves.getCurvePercent(h/3-1,d);c.x+=(c.data.x+l+(e[h+1]-l)*d-c.x)*f;c.y+=(c.data.y+m+(e[h+2]-m)*d-c.y)*f}}};n.ScaleTimeline=function(c){this.curves=new n.Curves(c); this.frames=[];this.frames.length=3*c};n.ScaleTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/3},setFrame:function(c,d,f,e){c*=3;this.frames[c]=d;this.frames[c+1]=f;this.frames[c+2]=e},apply:function(c,d,f){var e=this.frames;if(!(d=e[e.length-3])c.scaleX+=(c.data.scaleX-1+e[e.length-2]-c.scaleX)*f,c.scaleY+=(c.data.scaleY-1+e[e.length-1]-c.scaleY)*f;else{var h=n.binarySearch(e,d,3),l=e[h-2],m=e[h-1],p=e[h];d=1-(d-p)/(e[h+-3]- p);d=this.curves.getCurvePercent(h/3-1,d);c.scaleX+=(c.data.scaleX-1+l+(e[h+1]-l)*d-c.scaleX)*f;c.scaleY+=(c.data.scaleY-1+m+(e[h+2]-m)*d-c.scaleY)*f}}};n.ColorTimeline=function(c){this.curves=new n.Curves(c);this.frames=[];this.frames.length=5*c};n.ColorTimeline.prototype={slotIndex:0,getFrameCount:function(){return this.frames.length/2},setFrame:function(c,d,f,e){c*=5;this.frames[c]=d;this.frames[c+1]=r;this.frames[c+2]=g;this.frames[c+3]=b;this.frames[c+4]=a},apply:function(c,d,f){var e=this.frames; if(!(d=e[e.length-5])f=e.length-1,c.r=e[f-3],c.g=e[f-2],c.b=e[f-1],c.a=e[f];else{var h=n.binarySearch(e,d,5),l=e[h-4],m=e[h-3],p=e[h-2],v=e[h-1],t=e[h];d=1-(d-t)/(e[h-5]-t);d=this.curves.getCurvePercent(h/5-1,d);l+=(e[h+1]-l)*d;m+=(e[h+2]-m)*d;p+=(e[h+3]-p)*d;e=v+(e[h+4]-v)*d;1>f?(c.r+=(l-c.r)*f,c.g+=(m-c.g)*f,c.b+=(p-c.b)*f,c.a+=(e-c.a)*f):(c.r=l,c.g=m,c.b=p,c.a=e)}}};n.AttachmentTimeline=function(c){this.curves=new n.Curves(c);this.frames=[];this.frames.length= c;this.attachmentNames=[];this.attachmentNames.length=c};n.AttachmentTimeline.prototype={slotIndex:0,getFrameCount:function(){return this.frames.length},setFrame:function(c,d,f){this.frames[c]=d;this.attachmentNames[c]=f},apply:function(c,d,f){f=this.frames;d=f[f.length-1]?f.length-1:n.binarySearch(f,d,1)-1,d=this.attachmentNames[d],c.slots[this.slotIndex].setAttachment(d?c.getAttachmentBySlotIndex(this.slotIndex,d):null))}};n.SkeletonData=function(){this.bones=[];this.slots=[];this.skins= [];this.animations=[]};n.SkeletonData.prototype={defaultSkin:null,findBone:function(c){for(var d=this.bones,f=0,e=d.length;f=c.delay&&(this._setAnimation(c.animation,c.loop),this.queue.shift()))},apply:function(c){if(this.current)if(this.previous){this.previous.apply(c, this.previousTime,this.previousLoop);var d=this.mixTime/this.mixDuration;1<=d&&(d=1,this.previous=null);this.current.mix(c,this.currentTime,this.currentLoop,d)}else this.current.apply(c,this.currentTime,this.currentLoop)},clearAnimation:function(){this.current=this.previous=null;this.queue.length=0},_setAnimation:function(c,d){this.previous=null;c&&this.current&&(this.mixDuration=this.data.getMix(this.current,c),0=e)d=0==this.queue.length?this.current:this.queue[this.queue.length-1].animation,e=null!=d?d.duration-this.data.getMix(d,c)+(e||0):0;k.delay=e;this.queue.push(k)},isComplete:function(){return!this.current||this.currentTime>=this.current.duration}};n.SkeletonJson=function(c){this.attachmentLoader=c};n.SkeletonJson.prototype={scale:1,readSkeletonData:function(c){for(var d=new n.SkeletonData,e=c.bones,k=0,h=e.length;k= this.lines.length?null:this.lines[this.index++]},readValue:function(){var c=this.readLine(),d=c.indexOf(":");if(-1==d)throw"Invalid line: "+c;return this.trim(c.substring(d+1))},readTuple:function(c){var d=this.readLine(),e=d.indexOf(":");if(-1==e)throw"Invalid line: "+d;for(var k=0,e=e+1;3>k;k++){var h=d.indexOf(",",e);if(-1==h){if(0==k)throw"Invalid line: "+d;break}c[k]=this.trim(d.substr(e,h-e));e=h+1}c[k]=this.trim(d.substring(e));return k+1}};n.AtlasAttachmentLoader=function(c){this.atlas=c}; n.AtlasAttachmentLoader.prototype={newAttachment:function(c,d,e){switch(d){case n.AttachmentType.region:c=this.atlas.findRegion(e);if(!c)throw"Region not found in atlas: "+e+" ("+d+")";d=new n.RegionAttachment(e);d.rendererObject=c;d.setUVs(c.u,c.v,c.u2,c.v2,c.rotate);d.regionOffsetX=c.offsetX;d.regionOffsetY=c.offsetY;d.regionWidth=c.width;d.regionHeight=c.height;d.regionOriginalWidth=c.originalWidth;d.regionOriginalHeight=c.originalHeight;return d}throw"Unknown attachment type: "+d;}};e.AnimCache= {};n.Bone.yDown=!0;e.CustomRenderable=function(){e.DisplayObject.call(this)};e.CustomRenderable.prototype=Object.create(e.DisplayObject.prototype);e.CustomRenderable.prototype.constructor=e.CustomRenderable;e.CustomRenderable.prototype.renderCanvas=function(c){};e.CustomRenderable.prototype.initWebGL=function(c){};e.CustomRenderable.prototype.renderWebGL=function(c,d){};e.BaseTextureCache={};e.texturesToUpdate=[];e.texturesToDestroy=[];e.BaseTexture=function(c){e.EventTarget.call(this);this.height= this.width=100;this.hasLoaded=!1;if(this.source=c){if(this.source instanceof Image||this.source instanceof HTMLImageElement)if(this.source.complete)this.hasLoaded=!0,this.width=this.source.width,this.height=this.source.height,e.texturesToUpdate.push(this);else{var d=this;this.source.onload=function(){d.hasLoaded=!0;d.width=d.source.width;d.height=d.source.height;e.texturesToUpdate.push(d);d.dispatchEvent({type:"loaded",content:d})}}else this.hasLoaded=!0,this.width=this.source.width,this.height=this.source.height, e.texturesToUpdate.push(this);this._powerOf2=!1}};e.BaseTexture.prototype.constructor=e.BaseTexture;e.BaseTexture.prototype.destroy=function(){this.source instanceof Image&&(this.source.src=null);this.source=null;e.texturesToDestroy.push(this)};e.BaseTexture.fromImage=function(c,d){var f=e.BaseTextureCache[c];f||(f=new Image,d&&(f.crossOrigin=""),f.src=c,f=new e.BaseTexture(f),e.BaseTextureCache[c]=f);return f};e.TextureCache={};e.FrameCache={};e.Texture=function(c,d){e.EventTarget.call(this);d|| (this.noFrame=!0,d=new e.Rectangle(0,0,1,1));c instanceof e.Texture&&(c=c.baseTexture);this.baseTexture=c;this.frame=d;this.trim=new e.Point;this.scope=this;if(c.hasLoaded)this.noFrame&&(d=new e.Rectangle(0,0,c.width,c.height)),this.setFrame(d);else{var f=this;c.addEventListener("loaded",function(){f.onBaseTextureLoaded()})}};e.Texture.prototype.constructor=e.Texture;e.Texture.prototype.onBaseTextureLoaded=function(c){c=this.baseTexture;c.removeEventListener("loaded",this.onLoaded);this.noFrame&& (this.frame=new e.Rectangle(0,0,c.width,c.height));this.noFrame=!1;this.width=this.frame.width;this.height=this.frame.height;this.scope.dispatchEvent({type:"update",content:this})};e.Texture.prototype.destroy=function(c){c&&this.baseTexture.destroy()};e.Texture.prototype.setFrame=function(c){this.frame=c;this.width=c.width;this.height=c.height;if(c.x+c.width>this.baseTexture.width||c.y+c.height>this.baseTexture.height)throw Error("Texture Error: frame does not fit inside the base Texture dimensions "+ this);this.updateFrame=!0;e.Texture.frameUpdates.push(this)};e.Texture.fromImage=function(c,d){var f=e.TextureCache[c];f||(f=new e.Texture(e.BaseTexture.fromImage(c,d)),e.TextureCache[c]=f);return f};e.Texture.fromFrame=function(c){var d=e.TextureCache[c];if(!d)throw Error("The frameId '"+c+"' does not exist in the texture cache "+this);return d};e.Texture.fromCanvas=function(c){c=new e.BaseTexture(c);return new e.Texture(c)};e.Texture.addTextureToCache=function(c,d){e.TextureCache[d]=c};e.Texture.removeTextureFromCache= function(c){var d=e.TextureCache[c];e.TextureCache[c]=null;return d};e.Texture.frameUpdates=[];e.RenderTexture=function(c,d){e.EventTarget.call(this);this.width=c||100;this.height=d||100;this.indetityMatrix=e.mat3.create();this.frame=new e.Rectangle(0,0,this.width,this.height);e.gl?this.initWebGL():this.initCanvas()};e.RenderTexture.prototype=Object.create(e.Texture.prototype);e.RenderTexture.prototype.constructor=e.RenderTexture;e.RenderTexture.prototype.initWebGL=function(){var c=e.gl;this.glFramebuffer= c.createFramebuffer();c.bindFramebuffer(c.FRAMEBUFFER,this.glFramebuffer);this.glFramebuffer.width=this.width;this.glFramebuffer.height=this.height;this.baseTexture=new e.BaseTexture;this.baseTexture.width=this.width;this.baseTexture.height=this.height;this.baseTexture._glTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,this.baseTexture._glTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,this.width,this.height,0,c.RGBA,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.LINEAR); c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);this.baseTexture.isRender=!0;c.bindFramebuffer(c.FRAMEBUFFER,this.glFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,this.baseTexture._glTexture,0);this.projection=new e.Point(this.width/2,this.height/2);this.render=this.renderWebGL};e.RenderTexture.prototype.resize=function(c,d){this.width= c;this.height=d;if(e.gl){this.projection.x=this.width/2;this.projection.y=this.height/2;var f=e.gl;f.bindTexture(f.TEXTURE_2D,this.baseTexture._glTexture);f.texImage2D(f.TEXTURE_2D,0,f.RGBA,this.width,this.height,0,f.RGBA,f.UNSIGNED_BYTE,null)}else this.frame.width=this.width,this.frame.height=this.height,this.renderer.resize(this.width,this.height)};e.RenderTexture.prototype.initCanvas=function(){this.renderer=new e.CanvasRenderer(this.width,this.height,null,0);this.baseTexture=new e.BaseTexture(this.renderer.view); this.frame=new e.Rectangle(0,0,this.width,this.height);this.render=this.renderCanvas};e.RenderTexture.prototype.renderWebGL=function(c,d,f){var k=e.gl;k.colorMask(!0,!0,!0,!0);k.viewport(0,0,this.width,this.height);k.bindFramebuffer(k.FRAMEBUFFER,this.glFramebuffer);f&&(k.clearColor(0,0,0,0),k.clear(k.COLOR_BUFFER_BIT));var h=c.children;f=c.worldTransform;c.worldTransform=e.mat3.create();c.worldTransform[4]=-1;c.worldTransform[5]=2*this.projection.y;d&&(c.worldTransform[2]=d.x,c.worldTransform[5]-= d.y);d=0;for(var l=h.length;df.frame.w||h.h>f.frame.h?(f.trimmed=!0,f.realSize=h):f.trimmed=!1)}d++}null!=f&&(this.atlas.frames[f.name]=f);if(this.atlas.frames){var l=this,c=new e.ImageLoader(this.baseUrl+this.atlas.meta.image,this.crossorigin),d=this.atlas.frames;this.texture=c.texture.baseTexture;c.addEventListener("loaded",function(c){l.onLoaded()});for(k in d)if(f=d[k].frame)e.TextureCache[k]= new e.Texture(this.texture,{x:f.x,y:f.y,width:f.w,height:f.h}),!0==d[k].trimmed&&(e.TextureCache[k].realSize=d[k].realSize,e.TextureCache[k].trim.x=0,e.TextureCache[k].trim.y=0);c.load()}else this.onLoaded()}else this.onError()};e.AtlasLoader.prototype.onLoaded=function(){this.loaded=!0;this.dispatchEvent({type:"loaded",content:this})};e.AtlasLoader.prototype.onError=function(){this.dispatchEvent({type:"error",content:this})};e.ImageLoader=function(c,d){e.EventTarget.call(this);this.texture=e.Texture.fromImage(c, d)};e.ImageLoader.prototype.constructor=e.ImageLoader;e.ImageLoader.prototype.load=function(){if(this.texture.baseTexture.hasLoaded)this.onLoaded();else{var c=this;this.texture.baseTexture.addEventListener("loaded",function(){c.onLoaded()})}};e.ImageLoader.prototype.onLoaded=function(){this.dispatchEvent({type:"loaded",content:this})};e.BitmapFontLoader=function(c,d){e.EventTarget.call(this);this.url=c;this.crossorigin=d;this.baseUrl=c.replace(/[^\/]*$/,"");this.texture=null};e.BitmapFontLoader.prototype.constructor= e.BitmapFontLoader;e.BitmapFontLoader.prototype.load=function(){this.ajaxRequest=new XMLHttpRequest;var c=this;this.ajaxRequest.onreadystatechange=function(){c.onXMLLoaded()};this.ajaxRequest.open("GET",this.url,!0);this.ajaxRequest.overrideMimeType&&this.ajaxRequest.overrideMimeType("application/xml");this.ajaxRequest.send(null)};e.BitmapFontLoader.prototype.onXMLLoaded=function(){if(4==this.ajaxRequest.readyState&&(200==this.ajaxRequest.status||-1==window.location.href.indexOf("http"))){var c=this.baseUrl+ this.ajaxRequest.responseXML.getElementsByTagName("page")[0].attributes.getNamedItem("file").nodeValue,c=new e.ImageLoader(c,this.crossorigin);this.texture=c.texture.baseTexture;var d={},f=this.ajaxRequest.responseXML.getElementsByTagName("info")[0],k=this.ajaxRequest.responseXML.getElementsByTagName("common")[0];d.font=f.attributes.getNamedItem("face").nodeValue;d.size=parseInt(f.attributes.getNamedItem("size").nodeValue,10);d.lineHeight=parseInt(k.attributes.getNamedItem("lineHeight").nodeValue, 10);d.chars={};k=this.ajaxRequest.responseXML.getElementsByTagName("char");for(f=0;f