@pixi/graphics
Advanced tools
Comparing version 5.1.2 to 5.1.3
/*! | ||
* @pixi/graphics - v5.1.2 | ||
* Compiled Sat, 24 Aug 2019 01:06:18 UTC | ||
* @pixi/graphics - v5.1.3 | ||
* Compiled Mon, 09 Sep 2019 04:51:53 UTC | ||
* | ||
@@ -8,3 +8,3 @@ * @pixi/graphics is licensed under the MIT License. | ||
*/ | ||
this.PIXI=this.PIXI||{};var _pixi_graphics=function(t,i,e,r,s,h){"use strict";var n={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,_segmentsCount:function(t,i){if(void 0===i&&(i=20),!this.adaptive)return i;var e=Math.ceil(t/this.maxLength);return e<this.minSegments?e=this.minSegments:e>this.maxSegments&&(e=this.maxSegments),e}},a=function(){this.reset()};a.prototype.clone=function(){var t=new a;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t},a.prototype.reset=function(){this.color=16777215,this.alpha=1,this.texture=i.Texture.WHITE,this.matrix=null,this.visible=!1},a.prototype.destroy=function(){this.texture=null,this.matrix=null};var o=function(t,i,e,r){void 0===i&&(i=null),void 0===e&&(e=null),void 0===r&&(r=null),this.shape=t,this.lineStyle=e,this.fillStyle=i,this.matrix=r,this.type=t.type,this.points=[],this.holes=[]};o.prototype.clone=function(){return new o(this.shape,this.fillStyle,this.lineStyle,this.matrix)},o.prototype.destroy=function(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null};var l={build:function(t){var i,r,s=t.shape,h=t.points,n=s.x,a=s.y;if(h.length=0,t.type===e.SHAPES.CIRC?(i=s.radius,r=s.radius):(i=s.width,r=s.height),0!==i&&0!==r){var o=Math.floor(30*Math.sqrt(s.radius))||Math.floor(15*Math.sqrt(s.width+s.height));o/=2.3;for(var l=2*Math.PI/o,u=0;u<o;u++)h.push(n+Math.sin(-l*u)*i,a+Math.cos(-l*u)*r);h.push(h[0],h[1])}},triangulate:function(t,i){var e=t.points,r=i.points,s=i.indices,h=r.length/2,n=h;r.push(t.shape.x,t.shape.y);for(var a=0;a<e.length;a+=2)r.push(e[a],e[a+1]),s.push(h++,n,h)}};function u(t,i){t.lineStyle.native?function(t,i){var r=0,s=t.shape,h=t.points||s.points,n=s.type!==e.SHAPES.POLY||s.closeStroke;if(0===h.length)return;var a=i.points,o=i.indices,l=h.length/2,u=a.length/2,c=u;for(a.push(h[0],h[1]),r=1;r<l;r++)a.push(h[2*r],h[2*r+1]),o.push(c,c+1),c++;n&&o.push(c,u)}(t,i):function(t,i){var r=t.shape,s=t.points||r.points.slice(),h=i.closePointEps;if(0===s.length)return;var n=t.lineStyle,a=new e.Point(s[0],s[1]),o=new e.Point(s[s.length-2],s[s.length-1]),l=r.type!==e.SHAPES.POLY||r.closeStroke,u=Math.abs(a.x-o.x)<h&&Math.abs(a.y-o.y)<h;if(l){s=s.slice(),u&&(s.pop(),s.pop(),o.set(s[s.length-2],s[s.length-1]));var c=o.x+.5*(a.x-o.x),p=o.y+.5*(a.y-o.y);s.unshift(c,p),s.push(c,p)}var d=i.points,f=s.length/2,y=s.length,v=d.length/2,g=n.width/2,b=s[0],x=s[1],S=s[2],w=s[3],m=0,P=0,_=-(x-w),M=b-S,D=0,T=0,I=0,C=0,E=Math.sqrt(_*_+M*M);_/=E,M/=E,_*=g,M*=g;var A=n.alignment,R=2*(1-A),B=2*A;d.push(b-_*R,x-M*R),d.push(b+_*B,x+M*B);for(var H=1;H<f-1;++H){b=s[2*(H-1)],x=s[2*(H-1)+1],S=s[2*H],w=s[2*H+1],m=s[2*(H+1)],P=s[2*(H+1)+1],_=-(x-w),M=b-S,E=Math.sqrt(_*_+M*M),_/=E,M/=E,_*=g,M*=g,D=-(w-P),T=S-m,E=Math.sqrt(D*D+T*T),D/=E,T/=E;var O=-M+x-(-M+w),z=-_+S-(-_+b),L=(-_+b)*(-M+w)-(-_+S)*(-M+x),F=-(T*=g)+P-(-T+w),q=-(D*=g)+S-(-D+m),U=(-D+m)*(-T+w)-(-D+S)*(-T+P),G=O*q-F*z;if(Math.abs(G)<.1)G+=10.1,d.push(S-_*R,w-M*R),d.push(S+_*B,w+M*B);else{var j=(z*U-q*L)/G,N=(F*L-O*U)/G,X=(j-S)*(j-S)+(N-w)*(N-w);X>196*g*g?(I=_-D,C=M-T,E=Math.sqrt(I*I+C*C),I/=E,C/=E,I*=g,C*=g,d.push(S-I*R,w-C*R),d.push(S+I*B,w+C*B),d.push(S-I*B*R,w-C*R),y++):(d.push(S+(j-S)*R,w+(N-w)*R),d.push(S-(j-S)*B,w-(N-w)*B))}}b=s[2*(f-2)],x=s[2*(f-2)+1],S=s[2*(f-1)],w=s[2*(f-1)+1],_=-(x-w),M=b-S,E=Math.sqrt(_*_+M*M),_/=E,M/=E,_*=g,M*=g,d.push(S-_*R,w-M*R),d.push(S+_*B,w+M*B);for(var W=i.indices,k=0;k<y-2;++k)W.push(v,v+1,v+2),v++}(t,i)}var c={build:function(t){t.points=t.shape.points.slice()},triangulate:function(t,i){var e=t.points,s=t.holes,h=i.points,n=i.indices;if(e.length>=6){for(var a=[],o=0;o<s.length;o++){var l=s[o];a.push(e.length/2),e=e.concat(l.points)}var u=r.earcut(e,a,2);if(!u)return;for(var c=h.length/2,p=0;p<u.length;p+=3)n.push(u[p]+c),n.push(u[p+1]+c),n.push(u[p+2]+c);for(var d=0;d<e.length;d++)h.push(e[d])}}},p={build:function(t){var i=t.shape,e=t.points,r=i.x,s=i.y,h=i.width,n=i.height,a=i.radius;e.length=0,f(r,s+a,r,s,r+a,s,e),f(r+h-a,s,r+h,s,r+h,s+a,e),f(r+h,s+n-a,r+h,s+n,r+h-a,s+n,e),f(r+a,s+n,r,s+n,r,s+n-a,e)},triangulate:function(t,i){for(var e=t.points,s=i.points,h=i.indices,n=s.length/2,a=r.earcut(e,null,2),o=0,l=a.length;o<l;o+=3)h.push(a[o]+n),h.push(a[o+1]+n),h.push(a[o+2]+n);for(var u=0,c=e.length;u<c;u++)s.push(e[u],e[++u])}};function d(t,i,e){return t+(i-t)*e}function f(t,i,e,r,s,h,n){void 0===n&&(n=[]);for(var a=n,o=0,l=0,u=0,c=0,p=0,f=0,y=0,v=0;y<=20;++y)o=d(t,e,v=y/20),l=d(i,r,v),u=d(e,s,v),c=d(r,h,v),p=d(o,u,v),f=d(l,c,v),a.push(p,f);return a}var y=[],v=[],g=new e.Point,b={};b[e.SHAPES.POLY]=c,b[e.SHAPES.CIRC]=l,b[e.SHAPES.ELIP]=l,b[e.SHAPES.RECT]={build:function(t){var i=t.shape,e=i.x,r=i.y,s=i.width,h=i.height,n=t.points;n.length=0,n.push(e,r,e+s,r,e+s,r+h,e,r+h)},triangulate:function(t,i){var e=t.points,r=i.points,s=r.length/2;r.push(e[0],e[1],e[2],e[3],e[6],e[7],e[4],e[5]),i.indices.push(s,s+1,s+2,s+1,s+2,s+3)}},b[e.SHAPES.RREC]=p;var x=function(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0},S=function(t){function n(){t.call(this),this.points=[],this.colors=[],this.uvs=[],this.indices=[],this.textureIds=[],this.graphicsData=[],this.dirty=0,this.batchDirty=-1,this.cacheDirty=-1,this.clearDirty=0,this.drawCalls=[],this.batches=[],this.shapeIndex=0,this._bounds=new s.Bounds,this.boundsDirty=-1,this.boundsPadding=0,this.batchable=!1,this.indicesUint16=null,this.uvsFloat32=null,this.closePointEps=1e-4}t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n;var a={bounds:{configurable:!0}};return a.bounds.get=function(){return this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds},n.prototype.invalidate=function(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(var t=0;t<this.drawCalls.length;t++)this.drawCalls[t].textures.length=0,v.push(this.drawCalls[t]);this.drawCalls.length=0;for(var i=0;i<this.batches.length;i++){var e=this.batches[i];e.start=0,e.attribStart=0,e.style=null,y.push(e)}this.batches.length=0},n.prototype.clear=function(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this},n.prototype.drawShape=function(t,i,e,r){var s=new o(t,i,e,r);return this.graphicsData.push(s),this.dirty++,this},n.prototype.drawHole=function(t,i){if(!this.graphicsData.length)return null;var e=new o(t,null,null,i),r=this.graphicsData[this.graphicsData.length-1];return e.lineStyle=r.lineStyle,r.holes.push(e),this.dirty++,this},n.prototype.destroy=function(i){t.prototype.destroy.call(this,i);for(var e=0;e<this.graphicsData.length;++e)this.graphicsData[e].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null},n.prototype.containsPoint=function(t){for(var i=this.graphicsData,e=0;e<i.length;++e){var r=i[e];if(r.fillStyle.visible&&(r.shape&&(r.matrix?r.matrix.applyInverse(t,g):g.copyFrom(t),r.shape.contains(g.x,g.y)))){if(r.holes)for(var s=0;s<r.holes.length;s++){if(r.holes[s].shape.contains(g.x,g.y))return!1}return!0}}return!1},n.prototype.updateBatches=function(){if(this.dirty!==this.cacheDirty)if(0!==this.graphicsData.length){if(this.dirty!==this.cacheDirty)for(var t=0;t<this.graphicsData.length;t++){var i=this.graphicsData[t];if(i.fillStyle&&!i.fillStyle.texture.baseTexture.valid)return;if(i.lineStyle&&!i.lineStyle.texture.baseTexture.valid)return}this.cacheDirty=this.dirty;var e=this.uvs,r=null,s=null,n=0,a=!1;if(this.batches.length>0){var o=(r=this.batches[this.batches.length-1]).style;s=o.texture.baseTexture,n=o.color+o.alpha,a=!!o.native}for(var l=this.shapeIndex;l<this.graphicsData.length;l++){this.shapeIndex++;var p=this.graphicsData[l],d=b[p.type],f=p.fillStyle,v=p.lineStyle;d.build(p),p.matrix&&this.transformPoints(p.points,p.matrix);for(var g=0;g<2;g++){var S=0===g?f:v;if(S.visible){var w=S.texture.baseTexture,m=this.indices.length,P=this.points.length/2;!r||s===w&&n===S.color+S.alpha&&a===!!S.native||(r.size=m-r.start,r.attribSize=P-r.attribStart,r.size>0&&(r=null)),r||(r=y.pop()||new x,this.batches.push(r),w.wrapMode=h.WRAP_MODES.REPEAT,s=w,n=S.color+S.alpha,a=S.native,r.style=S,r.start=m,r.attribStart=P);var _=this.points.length/2;if(0===g)p.holes.length?(this.processHoles(p.holes),c.triangulate(p,this)):d.triangulate(p,this);else{u(p,this);for(var M=0;M<p.holes.length;M++)u(p.holes[M],this)}var D=this.points.length/2-_;this.addUvs(this.points,e,S.texture,_,D,S.matrix)}}}var T=this.indices.length,I=this.points.length/2;if(r)if(r.size=T-r.start,r.attribSize=I-r.attribStart,this.indicesUint16=new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);for(var C=0;C<this.batches.length;C++)for(var E=this.batches[C],A=0;A<E.size;A++){var R=E.start+A;this.indicesUint16[R]=this.indicesUint16[R]-E.attribStart}}else this.buildDrawCalls();else this.batchable=!0}else this.batchable=!0},n.prototype.isBatchable=function(){for(var t=this.batches,i=0;i<t.length;i++)if(t[i].style.native)return!1;return this.points.length<2*n.BATCHABLE_SIZE},n.prototype.buildDrawCalls=function(){for(var t=++i.BaseTexture._globalBatch,e=0;e<this.drawCalls.length;e++)this.drawCalls[e].textures.length=0,v.push(this.drawCalls[e]);this.drawCalls.length=0;var r=this.uvs,s=this.colors,n=this.textureIds,a=v.pop()||new i.BatchDrawCall;a.textureCount=0,a.start=0,a.size=0,a.type=h.DRAW_MODES.TRIANGLES;var o=0,l=null,u=0,c=!1,p=h.DRAW_MODES.TRIANGLES,d=0;this.drawCalls.push(a);for(var f=0;f<this.batches.length;f++){var y=this.batches[f],g=y.style,b=g.texture.baseTexture;c!==!!g.native&&(p=(c=g.native)?h.DRAW_MODES.LINES:h.DRAW_MODES.TRIANGLES,l=null,o=8,t++),l!==b&&(l=b,b._batchEnabled!==t&&(8===o&&(t++,o=0,a.size>0&&(a=v.pop()||new i.BatchDrawCall,this.drawCalls.push(a)),a.start=d,a.size=0,a.textureCount=0,a.type=p),b.touched=1,b._batchEnabled=t,b._id=o,b.wrapMode=10497,a.textures[a.textureCount++]=b,o++)),a.size+=y.size,d+=y.size,u=b._id,this.addColors(s,g.color,g.alpha,y.attribSize),this.addTextureIds(n,u,y.attribSize)}i.BaseTexture._globalBatch=t;for(var x=this.points,S=new ArrayBuffer(3*x.length*4),w=new Float32Array(S),m=new Uint32Array(S),P=0,_=0;_<x.length/2;_++)w[P++]=x[2*_],w[P++]=x[2*_+1],w[P++]=r[2*_],w[P++]=r[2*_+1],m[P++]=s[_],w[P++]=n[_];this._buffer.update(S),this._indexBuffer.update(this.indicesUint16)},n.prototype.processHoles=function(t){for(var i=0;i<t.length;i++){var e=t[i];b[e.type].build(e),e.matrix&&this.transformPoints(e.points,e.matrix)}},n.prototype.calculateBounds=function(){var t=1/0,i=-1/0,r=1/0,s=-1/0;if(this.graphicsData.length)for(var h=null,n=0,a=0,o=0,l=0,u=0;u<this.graphicsData.length;u++){var c=this.graphicsData[u],p=c.type,d=c.lineStyle?c.lineStyle.width:0;if(h=c.shape,p===e.SHAPES.RECT||p===e.SHAPES.RREC)n=h.x-d/2,a=h.y-d/2,t=n<t?n:t,i=n+(o=h.width+d)>i?n+o:i,r=a<r?a:r,s=a+(l=h.height+d)>s?a+l:s;else if(p===e.SHAPES.CIRC)n=h.x,a=h.y,t=n-(o=h.radius+d/2)<t?n-o:t,i=n+o>i?n+o:i,r=a-(l=h.radius+d/2)<r?a-l:r,s=a+l>s?a+l:s;else if(p===e.SHAPES.ELIP)n=h.x,a=h.y,t=n-(o=h.width+d/2)<t?n-o:t,i=n+o>i?n+o:i,r=a-(l=h.height+d/2)<r?a-l:r,s=a+l>s?a+l:s;else for(var f=h.points,y=0,v=0,g=0,b=0,x=0,S=0,w=0,m=0,P=0;P+2<f.length;P+=2)n=f[P],a=f[P+1],y=f[P+2],v=f[P+3],g=Math.abs(y-n),b=Math.abs(v-a),l=d,(o=Math.sqrt(g*g+b*b))<1e-9||(t=(w=(y+n)/2)-(x=(l/o*b+g)/2)<t?w-x:t,i=w+x>i?w+x:i,r=(m=(v+a)/2)-(S=(l/o*g+b)/2)<r?m-S:r,s=m+S>s?m+S:s)}else t=0,i=0,r=0,s=0;var _=this.boundsPadding;this._bounds.minX=t-_,this._bounds.maxX=i+_,this._bounds.minY=r-_,this._bounds.maxY=s+_},n.prototype.transformPoints=function(t,i){for(var e=0;e<t.length/2;e++){var r=t[2*e],s=t[2*e+1];t[2*e]=i.a*r+i.c*s+i.tx,t[2*e+1]=i.b*r+i.d*s+i.ty}},n.prototype.addColors=function(t,i,e,s){for(var h=(i>>16)+(65280&i)+((255&i)<<16),n=r.premultiplyTint(h,e);s-- >0;)t.push(n)},n.prototype.addTextureIds=function(t,i,e){for(;e-- >0;)t.push(i)},n.prototype.addUvs=function(t,i,e,r,s,h){for(var n=0,a=i.length,o=e.frame;n<s;){var l=t[2*(r+n)],u=t[2*(r+n)+1];if(h){var c=h.a*l+h.c*u+h.tx;u=h.b*l+h.d*u+h.ty,l=c}n++,i.push(l/o.width,u/o.height)}var p=e.baseTexture;(o.width<p.width||o.height<p.height)&&this.adjustUvs(i,e,a,s)},n.prototype.adjustUvs=function(t,i,e,r){for(var s=i.baseTexture,h=e+2*r,n=i.frame,a=n.width/s.width,o=n.height/s.height,l=n.x/n.width,u=n.y/n.height,c=Math.floor(t[e]+1e-6),p=Math.floor(t[e+1]+1e-6),d=e+2;d<h;d+=2)c=Math.min(c,Math.floor(t[d]+1e-6)),p=Math.min(p,Math.floor(t[d+1]+1e-6));l-=c,u-=p;for(var f=e;f<h;f+=2)t[f]=(t[f]+l)*a,t[f+1]=(t[f+1]+u)*o},Object.defineProperties(n.prototype,a),n}(i.BatchGeometry);S.BATCHABLE_SIZE=100;var w=function(t){function i(){t.apply(this,arguments)}return t&&(i.__proto__=t),i.prototype=Object.create(t&&t.prototype),i.prototype.constructor=i,i.prototype.clone=function(){var t=new i;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.native=this.native,t},i.prototype.reset=function(){t.prototype.reset.call(this),this.color=0,this.width=0,this.alignment=.5,this.native=!1},i}(a),m=function(){};m.curveLength=function(t,i,e,r,s,h,n,a){for(var o=0,l=0,u=0,c=0,p=0,d=0,f=0,y=0,v=0,g=0,b=0,x=t,S=i,w=1;w<=10;++w)g=x-(y=(f=(d=(p=1-(l=w/10))*p)*p)*t+3*d*l*e+3*p*(u=l*l)*s+(c=u*l)*n),b=S-(v=f*i+3*d*l*r+3*p*u*h+c*a),x=y,S=v,o+=Math.sqrt(g*g+b*b);return o},m.curveTo=function(t,i,e,r,s,h,a){var o=a[a.length-2],l=a[a.length-1];a.length-=2;var u=n._segmentsCount(m.curveLength(o,l,t,i,e,r,s,h)),c=0,p=0,d=0,f=0,y=0;a.push(o,l);for(var v=1,g=0;v<=u;++v)d=(p=(c=1-(g=v/u))*c)*c,y=(f=g*g)*g,a.push(d*o+3*p*g*t+3*c*f*e+y*s,d*l+3*p*g*i+3*c*f*r+y*h)};var P=function(){};P.curveLength=function(t,i,e,r,s,h){var n=t-2*e+s,a=i-2*r+h,o=2*e-2*t,l=2*r-2*i,u=4*(n*n+a*a),c=4*(n*o+a*l),p=o*o+l*l,d=2*Math.sqrt(u+c+p),f=Math.sqrt(u),y=2*u*f,v=2*Math.sqrt(p),g=c/f;return(y*d+f*c*(d-v)+(4*p*u-c*c)*Math.log((2*f+g+d)/(g+v)))/(4*y)},P.curveTo=function(t,i,e,r,s){for(var h=s[s.length-2],a=s[s.length-1],o=n._segmentsCount(P.curveLength(h,a,t,i,e,r)),l=0,u=0,c=1;c<=o;++c){var p=c/o;l=h+(t-h)*p,u=a+(i-a)*p,s.push(l+(t+(e-t)*p-l)*p,u+(i+(r-i)*p-u)*p)}};var _=function(){};_.curveTo=function(t,i,e,r,s,h){var n=h[h.length-2],a=h[h.length-1]-i,o=n-t,l=r-i,u=e-t,c=Math.abs(a*u-o*l);if(c<1e-8||0===s)return h[h.length-2]===t&&h[h.length-1]===i||h.push(t,i),null;var p=a*a+o*o,d=l*l+u*u,f=a*l+o*u,y=s*Math.sqrt(p)/c,v=s*Math.sqrt(d)/c,g=y*f/p,b=v*f/d,x=y*u+v*o,S=y*l+v*a,w=o*(v+g),m=a*(v+g),P=u*(y+b),_=l*(y+b);return{cx:x+t,cy:S+i,radius:s,startAngle:Math.atan2(m-S,w-x),endAngle:Math.atan2(_-S,P-x),anticlockwise:o*l>u*a}},_.arc=function(t,i,r,s,h,a,o,l,u){for(var c=o-a,p=n._segmentsCount(Math.abs(c)*h,40*Math.ceil(Math.abs(c)/e.PI_2)),d=c/(2*p),f=2*d,y=Math.cos(d),v=Math.sin(d),g=p-1,b=g%1/g,x=0;x<=g;++x){var S=d+a+f*(x+b*x),w=Math.cos(S),m=-Math.sin(S);u.push((y*w+v*m)*h+r,(y*-m+v*w)*h+s)}};var M=function(t){function i(i,r,s,h,n,a){n=n||h/2;for(var o=-1*Math.PI/2+a,l=2*s,u=e.PI_2/l,c=[],p=0;p<l;p++){var d=p%2?n:h,f=p*u+o;c.push(i+d*Math.cos(f),r+d*Math.sin(f))}t.call(this,c)}return t&&(i.__proto__=t),i.prototype=Object.create(t&&t.prototype),i.prototype.constructor=i,i}(e.Polygon),D=new Float32Array(3),T=null,I=function(t){function s(e){void 0===e&&(e=null),t.call(this),this.geometry=e||new S,this.geometry.refCount++,this.shader=null,this.state=i.State.for2d(),this._fillStyle=new a,this._lineStyle=new w,this._matrix=null,this._holeMode=!1,this.currentPath=null,this.batches=[],this.batchTint=-1,this.vertexData=null,this._transformID=-1,this.batchDirty=-1,this.pluginName="batch",this.tint=16777215,this.blendMode=h.BLEND_MODES.NORMAL}t&&(s.__proto__=t),s.prototype=Object.create(t&&t.prototype),s.prototype.constructor=s;var n={blendMode:{configurable:!0},tint:{configurable:!0},fill:{configurable:!0},line:{configurable:!0}};return s.prototype.clone=function(){return this.finishPoly(),new s(this.geometry)},n.blendMode.set=function(t){this.state.blendMode=t},n.blendMode.get=function(){return this.state.blendMode},n.tint.get=function(){return this._tint},n.tint.set=function(t){this._tint=t},n.fill.get=function(){return this._fillStyle},n.line.get=function(){return this._lineStyle},s.prototype.lineStyle=function(t,e,r,s,h){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===r&&(r=1),void 0===s&&(s=.5),void 0===h&&(h=!1),this.lineTextureStyle(t,i.Texture.WHITE,e,r,null,s,h),this},s.prototype.lineTextureStyle=function(t,e,r,s,h,n,a){void 0===t&&(t=0),void 0===e&&(e=i.Texture.WHITE),void 0===r&&(r=16777215),void 0===s&&(s=1),void 0===h&&(h=null),void 0===n&&(n=.5),void 0===a&&(a=!1),this.currentPath&&this.startPoly();var o=t>0&&s>0;return o?(h&&(h=h.clone()).invert(),Object.assign(this._lineStyle,{color:r,width:t,alpha:s,matrix:h,texture:e,alignment:n,native:a,visible:o})):this._lineStyle.reset(),this},s.prototype.startPoly=function(){if(this.currentPath){var t=this.currentPath.points,i=this.currentPath.points.length;i>2&&(this.drawShape(this.currentPath),this.currentPath=new e.Polygon,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[i-2],t[i-1]))}else this.currentPath=new e.Polygon,this.currentPath.closeStroke=!1},s.prototype.finishPoly=function(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)},s.prototype.moveTo=function(t,i){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=i,this},s.prototype.lineTo=function(t,i){this.currentPath||this.moveTo(0,0);var e=this.currentPath.points,r=e[e.length-2],s=e[e.length-1];return r===t&&s===i||e.push(t,i),this},s.prototype._initCurve=function(t,i){void 0===t&&(t=0),void 0===i&&(i=0),this.currentPath?0===this.currentPath.points.length&&(this.currentPath.points=[t,i]):this.moveTo(t,i)},s.prototype.quadraticCurveTo=function(t,i,e,r){this._initCurve();var s=this.currentPath.points;return 0===s.length&&this.moveTo(0,0),P.curveTo(t,i,e,r,s),this},s.prototype.bezierCurveTo=function(t,i,e,r,s,h){return this._initCurve(),m.curveTo(t,i,e,r,s,h,this.currentPath.points),this},s.prototype.arcTo=function(t,i,e,r,s){this._initCurve(t,i);var h=this.currentPath.points,n=_.curveTo(t,i,e,r,s,h);if(n){var a=n.cx,o=n.cy,l=n.radius,u=n.startAngle,c=n.endAngle,p=n.anticlockwise;this.arc(a,o,l,u,c,p)}return this},s.prototype.arc=function(t,i,r,s,h,n){if(void 0===n&&(n=!1),s===h)return this;if(!n&&h<=s?h+=e.PI_2:n&&s<=h&&(s+=e.PI_2),0===h-s)return this;var a=t+Math.cos(s)*r,o=i+Math.sin(s)*r,l=this.geometry.closePointEps,u=this.currentPath?this.currentPath.points:null;if(u){var c=Math.abs(u[u.length-2]-a),p=Math.abs(u[u.length-1]-o);c<l&&p<l||u.push(a,o)}else this.moveTo(a,o),u=this.currentPath.points;return _.arc(a,o,t,i,r,s,h,n,u),this},s.prototype.beginFill=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=1),this.beginTextureFill(i.Texture.WHITE,t,e)},s.prototype.beginTextureFill=function(t,e,r,s){void 0===t&&(t=i.Texture.WHITE),void 0===e&&(e=16777215),void 0===r&&(r=1),void 0===s&&(s=null),this.currentPath&&this.startPoly();var h=r>0;return h?(s&&(s=s.clone()).invert(),Object.assign(this._fillStyle,{color:e,alpha:r,texture:t,matrix:s,visible:h})):this._fillStyle.reset(),this},s.prototype.endFill=function(){return this.finishPoly(),this._fillStyle.reset(),this},s.prototype.drawRect=function(t,i,r,s){return this.drawShape(new e.Rectangle(t,i,r,s))},s.prototype.drawRoundedRect=function(t,i,r,s,h){return this.drawShape(new e.RoundedRectangle(t,i,r,s,h))},s.prototype.drawCircle=function(t,i,r){return this.drawShape(new e.Circle(t,i,r))},s.prototype.drawEllipse=function(t,i,r,s){return this.drawShape(new e.Ellipse(t,i,r,s))},s.prototype.drawPolygon=function(t){var i=arguments,r=t,s=!0;if(r.points&&(s=r.closeStroke,r=r.points),!Array.isArray(r)){r=new Array(arguments.length);for(var h=0;h<r.length;++h)r[h]=i[h]}var n=new e.Polygon(r);return n.closeStroke=s,this.drawShape(n),this},s.prototype.drawShape=function(t){return this._holeMode?this.geometry.drawHole(t,this._matrix):this.geometry.drawShape(t,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this},s.prototype.drawStar=function(t,i,e,r,s,h){return void 0===h&&(h=0),this.drawPolygon(new M(t,i,e,r,s,h))},s.prototype.clear=function(){return this.geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._matrix=null,this._holeMode=!1,this.currentPath=null,this},s.prototype.isFastRect=function(){return!1},s.prototype._render=function(t){this.finishPoly();var s=this.geometry;if(s.updateBatches(),s.batchable){if(this.batchDirty!==s.batchDirty){this.batches=[],this.batchTint=-1,this._transformID=-1,this.batchDirty=s.batchDirty,this.vertexData=new Float32Array(s.points);for(var h=this.blendMode,n=0;n<s.batches.length;n++){var a=s.batches[n],o=a.style.color,l=new Float32Array(this.vertexData.buffer,4*a.attribStart*2,2*a.attribSize),u=new Float32Array(s.uvsFloat32.buffer,4*a.attribStart*2,2*a.attribSize),c={vertexData:l,blendMode:h,indices:new Uint16Array(s.indicesUint16.buffer,2*a.start,a.size),uvs:u,_batchRGB:r.hex2rgb(o),_tintRGB:o,_texture:a.style.texture,alpha:a.style.alpha,worldAlpha:1};this.batches[n]=c}}if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(var p=0;p<this.batches.length;p++){var d=this.batches[p];d.worldAlpha=this.worldAlpha*d.alpha,t.plugins[this.pluginName].render(d)}}}else{if(t.batch.flush(),!this.shader){if(!T){for(var f=new Int32Array(16),y=0;y<16;y++)f[y]=y;var v={tint:new Float32Array([1,1,1,1]),translationMatrix:new e.Matrix,default:i.UniformGroup.from({uSamplers:f},!0)},g=t.plugins.batch._shader.program;T=new i.Shader(g,v)}this.shader=T}var b=this.shader.uniforms;b.translationMatrix=this.transform.worldTransform;var x=this.tint,S=this.worldAlpha;b.tint[0]=(x>>16&255)/255*S,b.tint[1]=(x>>8&255)/255*S,b.tint[2]=(255&x)/255*S,b.tint[3]=S,t.shader.bind(this.shader),t.geometry.bind(s,this.shader),t.state.set(this.state);for(var w=0;w<s.drawCalls.length;w++){for(var m=s.drawCalls[w],P=m.textureCount,_=0;_<P;_++)t.texture.bind(m.textures[_],_);t.geometry.draw(m.type,m.size,m.start)}}},s.prototype._calculateBounds=function(){this.finishPoly();var t=this.geometry.bounds;this._bounds.addFrame(this.transform,t.minX,t.minY,t.maxX,t.maxY)},s.prototype.containsPoint=function(t){return this.worldTransform.applyInverse(t,s._TEMP_POINT),this.geometry.containsPoint(s._TEMP_POINT)},s.prototype.calculateTints=function(){if(this.batchTint!==this.tint){this.batchTint=this.tint;for(var t=r.hex2rgb(this.tint,D),i=0;i<this.batches.length;i++){var e=this.batches[i],s=e._batchRGB,h=(t[0]*s[0]*255<<16)+(t[1]*s[1]*255<<8)+(0|t[2]*s[2]*255);e._tintRGB=(h>>16)+(65280&h)+((255&h)<<16)}}},s.prototype.calculateVertices=function(){if(this._transformID!==this.transform._worldID){this._transformID=this.transform._worldID;for(var t=this.transform.worldTransform,i=t.a,e=t.b,r=t.c,s=t.d,h=t.tx,n=t.ty,a=this.geometry.points,o=this.vertexData,l=0,u=0;u<a.length;u+=2){var c=a[u],p=a[u+1];o[l++]=i*c+r*p+h,o[l++]=s*p+e*c+n}}},s.prototype.closePath=function(){var t=this.currentPath;return t&&(t.closeStroke=!0),this},s.prototype.setMatrix=function(t){return this._matrix=t,this},s.prototype.beginHole=function(){return this.finishPoly(),this._holeMode=!0,this},s.prototype.endHole=function(){return this.finishPoly(),this._holeMode=!1,this},s.prototype.destroy=function(i){t.prototype.destroy.call(this,i),this.geometry.refCount--,0===this.geometry.refCount&&this.geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this.geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,t.prototype.destroy.call(this,i)},Object.defineProperties(s.prototype,n),s}(s.Container);return I._TEMP_POINT=new e.Point,t.FillStyle=a,t.GRAPHICS_CURVES=n,t.Graphics=I,t.GraphicsData=o,t.GraphicsGeometry=S,t.LineStyle=w,t}({},PIXI,PIXI,PIXI.utils,PIXI,PIXI);Object.assign(this.PIXI,_pixi_graphics); | ||
this.PIXI=this.PIXI||{};var _pixi_graphics=function(t,e,i,r,s,n){"use strict";var h={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,_segmentsCount:function(t,e){if(void 0===e&&(e=20),!this.adaptive)return e;var i=Math.ceil(t/this.maxLength);return i<this.minSegments?i=this.minSegments:i>this.maxSegments&&(i=this.maxSegments),i}},a=function(){this.reset()};a.prototype.clone=function(){var t=new a;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t},a.prototype.reset=function(){this.color=16777215,this.alpha=1,this.texture=e.Texture.WHITE,this.matrix=null,this.visible=!1},a.prototype.destroy=function(){this.texture=null,this.matrix=null};var o=function(t,e,i,r){void 0===e&&(e=null),void 0===i&&(i=null),void 0===r&&(r=null),this.shape=t,this.lineStyle=i,this.fillStyle=e,this.matrix=r,this.type=t.type,this.points=[],this.holes=[]};o.prototype.clone=function(){return new o(this.shape,this.fillStyle,this.lineStyle,this.matrix)},o.prototype.destroy=function(){this.shape=null,this.holes.length=0,this.holes=null,this.points.length=0,this.points=null,this.lineStyle=null,this.fillStyle=null};var l={build:function(t){var e,r,s=t.shape,n=t.points,h=s.x,a=s.y;if(n.length=0,t.type===i.SHAPES.CIRC?(e=s.radius,r=s.radius):(e=s.width,r=s.height),0!==e&&0!==r){var o=Math.floor(30*Math.sqrt(s.radius))||Math.floor(15*Math.sqrt(s.width+s.height));o/=2.3;for(var l=2*Math.PI/o,u=0;u<o;u++)n.push(h+Math.sin(-l*u)*e,a+Math.cos(-l*u)*r);n.push(n[0],n[1])}},triangulate:function(t,e){var i=t.points,r=e.points,s=e.indices,n=r.length/2,h=n;r.push(t.shape.x,t.shape.y);for(var a=0;a<i.length;a+=2)r.push(i[a],i[a+1]),s.push(n++,h,n)}};function u(t,e){t.lineStyle.native?function(t,e){var r=0,s=t.shape,n=t.points||s.points,h=s.type!==i.SHAPES.POLY||s.closeStroke;if(0===n.length)return;var a=e.points,o=e.indices,l=n.length/2,u=a.length/2,c=u;for(a.push(n[0],n[1]),r=1;r<l;r++)a.push(n[2*r],n[2*r+1]),o.push(c,c+1),c++;h&&o.push(c,u)}(t,e):function(t,e){var r=t.shape,s=t.points||r.points.slice(),n=e.closePointEps;if(0===s.length)return;var h=t.lineStyle,a=new i.Point(s[0],s[1]),o=new i.Point(s[s.length-2],s[s.length-1]),l=r.type!==i.SHAPES.POLY||r.closeStroke,u=Math.abs(a.x-o.x)<n&&Math.abs(a.y-o.y)<n;if(l){s=s.slice(),u&&(s.pop(),s.pop(),o.set(s[s.length-2],s[s.length-1]));var c=o.x+.5*(a.x-o.x),p=o.y+.5*(a.y-o.y);s.unshift(c,p),s.push(c,p)}var d=e.points,f=s.length/2,y=s.length,v=d.length/2,g=h.width/2,b=s[0],S=s[1],x=s[2],_=s[3],w=0,m=0,P=-(S-_),M=b-x,D=0,T=0,I=0,C=0,E=Math.sqrt(P*P+M*M);P/=E,M/=E,P*=g,M*=g;var A=h.alignment,R=2*(1-A),B=2*A;d.push(b-P*R,S-M*R),d.push(b+P*B,S+M*B);for(var H=1;H<f-1;++H){b=s[2*(H-1)],S=s[2*(H-1)+1],x=s[2*H],_=s[2*H+1],w=s[2*(H+1)],m=s[2*(H+1)+1],P=-(S-_),M=b-x,E=Math.sqrt(P*P+M*M),P/=E,M/=E,P*=g,M*=g,D=-(_-m),T=x-w,E=Math.sqrt(D*D+T*T),D/=E,T/=E;var O=-M+S-(-M+_),z=-P+x-(-P+b),L=(-P+b)*(-M+_)-(-P+x)*(-M+S),F=-(T*=g)+m-(-T+_),q=-(D*=g)+x-(-D+w),U=(-D+w)*(-T+_)-(-D+x)*(-T+m),G=O*q-F*z;if(Math.abs(G)<.1)G+=10.1,d.push(x-P*R,_-M*R),d.push(x+P*B,_+M*B);else{var N=(z*U-q*L)/G,j=(F*L-O*U)/G,X=(N-x)*(N-x)+(j-_)*(j-_);X>196*g*g?(I=P-D,C=M-T,E=Math.sqrt(I*I+C*C),I/=E,C/=E,I*=g,C*=g,d.push(x-I*R,_-C*R),d.push(x+I*B,_+C*B),d.push(x-I*B*R,_-C*R),y++):(d.push(x+(N-x)*R,_+(j-_)*R),d.push(x-(N-x)*B,_-(j-_)*B))}}b=s[2*(f-2)],S=s[2*(f-2)+1],x=s[2*(f-1)],_=s[2*(f-1)+1],P=-(S-_),M=b-x,E=Math.sqrt(P*P+M*M),P/=E,M/=E,P*=g,M*=g,d.push(x-P*R,_-M*R),d.push(x+P*B,_+M*B);for(var W=e.indices,k=0;k<y-2;++k)W.push(v,v+1,v+2),v++}(t,e)}var c={build:function(t){t.points=t.shape.points.slice()},triangulate:function(t,e){var i=t.points,s=t.holes,n=e.points,h=e.indices;if(i.length>=6){for(var a=[],o=0;o<s.length;o++){var l=s[o];a.push(i.length/2),i=i.concat(l.points)}var u=r.earcut(i,a,2);if(!u)return;for(var c=n.length/2,p=0;p<u.length;p+=3)h.push(u[p]+c),h.push(u[p+1]+c),h.push(u[p+2]+c);for(var d=0;d<i.length;d++)n.push(i[d])}}},p={build:function(t){var e=t.shape,i=t.points,r=e.x,s=e.y,n=e.width,h=e.height,a=e.radius;i.length=0,f(r,s+a,r,s,r+a,s,i),f(r+n-a,s,r+n,s,r+n,s+a,i),f(r+n,s+h-a,r+n,s+h,r+n-a,s+h,i),f(r+a,s+h,r,s+h,r,s+h-a,i)},triangulate:function(t,e){for(var i=t.points,s=e.points,n=e.indices,h=s.length/2,a=r.earcut(i,null,2),o=0,l=a.length;o<l;o+=3)n.push(a[o]+h),n.push(a[o+1]+h),n.push(a[o+2]+h);for(var u=0,c=i.length;u<c;u++)s.push(i[u],i[++u])}};function d(t,e,i){return t+(e-t)*i}function f(t,e,i,r,s,n,h){void 0===h&&(h=[]);for(var a=h,o=0,l=0,u=0,c=0,p=0,f=0,y=0,v=0;y<=20;++y)o=d(t,i,v=y/20),l=d(e,r,v),u=d(i,s,v),c=d(r,n,v),p=d(o,u,v),f=d(l,c,v),a.push(p,f);return a}var y=[],v=[],g=new i.Point,b={};b[i.SHAPES.POLY]=c,b[i.SHAPES.CIRC]=l,b[i.SHAPES.ELIP]=l,b[i.SHAPES.RECT]={build:function(t){var e=t.shape,i=e.x,r=e.y,s=e.width,n=e.height,h=t.points;h.length=0,h.push(i,r,i+s,r,i+s,r+n,i,r+n)},triangulate:function(t,e){var i=t.points,r=e.points,s=r.length/2;r.push(i[0],i[1],i[2],i[3],i[6],i[7],i[4],i[5]),e.indices.push(s,s+1,s+2,s+1,s+2,s+3)}},b[i.SHAPES.RREC]=p;var S=function(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0},x=function(t){function h(){t.call(this),this.points=[],this.colors=[],this.uvs=[],this.indices=[],this.textureIds=[],this.graphicsData=[],this.dirty=0,this.batchDirty=-1,this.cacheDirty=-1,this.clearDirty=0,this.drawCalls=[],this.batches=[],this.shapeIndex=0,this._bounds=new s.Bounds,this.boundsDirty=-1,this.boundsPadding=0,this.batchable=!1,this.indicesUint16=null,this.uvsFloat32=null,this.closePointEps=1e-4}t&&(h.__proto__=t),h.prototype=Object.create(t&&t.prototype),h.prototype.constructor=h;var a={bounds:{configurable:!0}};return a.bounds.get=function(){return this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds},h.prototype.invalidate=function(){this.boundsDirty=-1,this.dirty++,this.batchDirty++,this.shapeIndex=0,this.points.length=0,this.colors.length=0,this.uvs.length=0,this.indices.length=0,this.textureIds.length=0;for(var t=0;t<this.drawCalls.length;t++)this.drawCalls[t].textures.length=0,v.push(this.drawCalls[t]);this.drawCalls.length=0;for(var e=0;e<this.batches.length;e++){var i=this.batches[e];i.start=0,i.attribStart=0,i.style=null,y.push(i)}this.batches.length=0},h.prototype.clear=function(){return this.graphicsData.length>0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this},h.prototype.drawShape=function(t,e,i,r){var s=new o(t,e,i,r);return this.graphicsData.push(s),this.dirty++,this},h.prototype.drawHole=function(t,e){if(!this.graphicsData.length)return null;var i=new o(t,null,null,e),r=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=r.lineStyle,r.holes.push(i),this.dirty++,this},h.prototype.destroy=function(e){t.prototype.destroy.call(this,e);for(var i=0;i<this.graphicsData.length;++i)this.graphicsData[i].destroy();this.points.length=0,this.points=null,this.colors.length=0,this.colors=null,this.uvs.length=0,this.uvs=null,this.indices.length=0,this.indices=null,this.indexBuffer.destroy(),this.indexBuffer=null,this.graphicsData.length=0,this.graphicsData=null,this.drawCalls.length=0,this.drawCalls=null,this.batches.length=0,this.batches=null,this._bounds=null},h.prototype.containsPoint=function(t){for(var e=this.graphicsData,i=0;i<e.length;++i){var r=e[i];if(r.fillStyle.visible&&(r.shape&&(r.matrix?r.matrix.applyInverse(t,g):g.copyFrom(t),r.shape.contains(g.x,g.y)))){if(r.holes)for(var s=0;s<r.holes.length;s++){if(r.holes[s].shape.contains(g.x,g.y))return!1}return!0}}return!1},h.prototype.updateBatches=function(){if(this.dirty!==this.cacheDirty)if(0!==this.graphicsData.length){if(this.dirty!==this.cacheDirty)for(var t=0;t<this.graphicsData.length;t++){var e=this.graphicsData[t];if(e.fillStyle&&!e.fillStyle.texture.baseTexture.valid)return;if(e.lineStyle&&!e.lineStyle.texture.baseTexture.valid)return}this.cacheDirty=this.dirty;var i=this.uvs,r=null,s=null,h=0,a=!1;if(this.batches.length>0){var o=(r=this.batches[this.batches.length-1]).style;s=o.texture.baseTexture,h=o.color+o.alpha,a=!!o.native}for(var l=this.shapeIndex;l<this.graphicsData.length;l++){this.shapeIndex++;var p=this.graphicsData[l],d=b[p.type],f=p.fillStyle,v=p.lineStyle;d.build(p),p.matrix&&this.transformPoints(p.points,p.matrix);for(var g=0;g<2;g++){var x=0===g?f:v;if(x.visible){var _=x.texture.baseTexture,w=this.indices.length,m=this.points.length/2;!r||s===_&&h===x.color+x.alpha&&a===!!x.native||(r.size=w-r.start,r.attribSize=m-r.attribStart,r.size>0&&(r=null)),r||(r=y.pop()||new S,this.batches.push(r),_.wrapMode=n.WRAP_MODES.REPEAT,s=_,h=x.color+x.alpha,a=x.native,r.style=x,r.start=w,r.attribStart=m);var P=this.points.length/2;if(0===g)p.holes.length?(this.processHoles(p.holes),c.triangulate(p,this)):d.triangulate(p,this);else{u(p,this);for(var M=0;M<p.holes.length;M++)u(p.holes[M],this)}var D=this.points.length/2-P;this.addUvs(this.points,i,x.texture,P,D,x.matrix)}}}var T=this.indices.length,I=this.points.length/2;if(r)if(r.size=T-r.start,r.attribSize=I-r.attribStart,this.indicesUint16=new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable){this.batchDirty++,this.uvsFloat32=new Float32Array(this.uvs);for(var C=0;C<this.batches.length;C++)for(var E=this.batches[C],A=0;A<E.size;A++){var R=E.start+A;this.indicesUint16[R]=this.indicesUint16[R]-E.attribStart}}else this.buildDrawCalls();else this.batchable=!0}else this.batchable=!0},h.prototype.isBatchable=function(){for(var t=this.batches,e=0;e<t.length;e++)if(t[e].style.native)return!1;return this.points.length<2*h.BATCHABLE_SIZE},h.prototype.buildDrawCalls=function(){for(var t=++e.BaseTexture._globalBatch,i=0;i<this.drawCalls.length;i++)this.drawCalls[i].textures.length=0,v.push(this.drawCalls[i]);this.drawCalls.length=0;var r=this.uvs,s=this.colors,h=this.textureIds,a=v.pop()||new e.BatchDrawCall;a.textureCount=0,a.start=0,a.size=0,a.type=n.DRAW_MODES.TRIANGLES;var o=0,l=null,u=0,c=!1,p=n.DRAW_MODES.TRIANGLES,d=0;this.drawCalls.push(a);for(var f=0;f<this.batches.length;f++){var y=this.batches[f],g=y.style,b=g.texture.baseTexture;c!==!!g.native&&(p=(c=g.native)?n.DRAW_MODES.LINES:n.DRAW_MODES.TRIANGLES,l=null,o=8,t++),l!==b&&(l=b,b._batchEnabled!==t&&(8===o&&(t++,o=0,a.size>0&&(a=v.pop()||new e.BatchDrawCall,this.drawCalls.push(a)),a.start=d,a.size=0,a.textureCount=0,a.type=p),b.touched=1,b._batchEnabled=t,b._id=o,b.wrapMode=10497,a.textures[a.textureCount++]=b,o++)),a.size+=y.size,d+=y.size,u=b._id,this.addColors(s,g.color,g.alpha,y.attribSize),this.addTextureIds(h,u,y.attribSize)}e.BaseTexture._globalBatch=t;for(var S=this.points,x=new ArrayBuffer(3*S.length*4),_=new Float32Array(x),w=new Uint32Array(x),m=0,P=0;P<S.length/2;P++)_[m++]=S[2*P],_[m++]=S[2*P+1],_[m++]=r[2*P],_[m++]=r[2*P+1],w[m++]=s[P],_[m++]=h[P];this._buffer.update(x),this._indexBuffer.update(this.indicesUint16)},h.prototype.processHoles=function(t){for(var e=0;e<t.length;e++){var i=t[e];b[i.type].build(i),i.matrix&&this.transformPoints(i.points,i.matrix)}},h.prototype.calculateBounds=function(){var t=1/0,e=-1/0,r=1/0,s=-1/0;if(this.graphicsData.length)for(var n=null,h=0,a=0,o=0,l=0,u=0;u<this.graphicsData.length;u++){var c=this.graphicsData[u],p=c.type,d=c.lineStyle?c.lineStyle.width:0;if(n=c.shape,p===i.SHAPES.RECT||p===i.SHAPES.RREC)h=n.x-d/2,a=n.y-d/2,t=h<t?h:t,e=h+(o=n.width+d)>e?h+o:e,r=a<r?a:r,s=a+(l=n.height+d)>s?a+l:s;else if(p===i.SHAPES.CIRC)h=n.x,a=n.y,t=h-(o=n.radius+d/2)<t?h-o:t,e=h+o>e?h+o:e,r=a-(l=n.radius+d/2)<r?a-l:r,s=a+l>s?a+l:s;else if(p===i.SHAPES.ELIP)h=n.x,a=n.y,t=h-(o=n.width+d/2)<t?h-o:t,e=h+o>e?h+o:e,r=a-(l=n.height+d/2)<r?a-l:r,s=a+l>s?a+l:s;else for(var f=n.points,y=0,v=0,g=0,b=0,S=0,x=0,_=0,w=0,m=0;m+2<f.length;m+=2)h=f[m],a=f[m+1],y=f[m+2],v=f[m+3],g=Math.abs(y-h),b=Math.abs(v-a),l=d,(o=Math.sqrt(g*g+b*b))<1e-9||(t=(_=(y+h)/2)-(S=(l/o*b+g)/2)<t?_-S:t,e=_+S>e?_+S:e,r=(w=(v+a)/2)-(x=(l/o*g+b)/2)<r?w-x:r,s=w+x>s?w+x:s)}else t=0,e=0,r=0,s=0;var P=this.boundsPadding;this._bounds.minX=t-P,this._bounds.maxX=e+P,this._bounds.minY=r-P,this._bounds.maxY=s+P},h.prototype.transformPoints=function(t,e){for(var i=0;i<t.length/2;i++){var r=t[2*i],s=t[2*i+1];t[2*i]=e.a*r+e.c*s+e.tx,t[2*i+1]=e.b*r+e.d*s+e.ty}},h.prototype.addColors=function(t,e,i,s){for(var n=(e>>16)+(65280&e)+((255&e)<<16),h=r.premultiplyTint(n,i);s-- >0;)t.push(h)},h.prototype.addTextureIds=function(t,e,i){for(;i-- >0;)t.push(e)},h.prototype.addUvs=function(t,e,i,r,s,n){for(var h=0,a=e.length,o=i.frame;h<s;){var l=t[2*(r+h)],u=t[2*(r+h)+1];if(n){var c=n.a*l+n.c*u+n.tx;u=n.b*l+n.d*u+n.ty,l=c}h++,e.push(l/o.width,u/o.height)}var p=i.baseTexture;(o.width<p.width||o.height<p.height)&&this.adjustUvs(e,i,a,s)},h.prototype.adjustUvs=function(t,e,i,r){for(var s=e.baseTexture,n=i+2*r,h=e.frame,a=h.width/s.width,o=h.height/s.height,l=h.x/h.width,u=h.y/h.height,c=Math.floor(t[i]+1e-6),p=Math.floor(t[i+1]+1e-6),d=i+2;d<n;d+=2)c=Math.min(c,Math.floor(t[d]+1e-6)),p=Math.min(p,Math.floor(t[d+1]+1e-6));l-=c,u-=p;for(var f=i;f<n;f+=2)t[f]=(t[f]+l)*a,t[f+1]=(t[f+1]+u)*o},Object.defineProperties(h.prototype,a),h}(e.BatchGeometry);x.BATCHABLE_SIZE=100;var _=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.clone=function(){var t=new e;return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.native=this.native,t},e.prototype.reset=function(){t.prototype.reset.call(this),this.color=0,this.width=0,this.alignment=.5,this.native=!1},e}(a),w=function(){};w.curveLength=function(t,e,i,r,s,n,h,a){for(var o=0,l=0,u=0,c=0,p=0,d=0,f=0,y=0,v=0,g=0,b=0,S=t,x=e,_=1;_<=10;++_)g=S-(y=(f=(d=(p=1-(l=_/10))*p)*p)*t+3*d*l*i+3*p*(u=l*l)*s+(c=u*l)*h),b=x-(v=f*e+3*d*l*r+3*p*u*n+c*a),S=y,x=v,o+=Math.sqrt(g*g+b*b);return o},w.curveTo=function(t,e,i,r,s,n,a){var o=a[a.length-2],l=a[a.length-1];a.length-=2;var u=h._segmentsCount(w.curveLength(o,l,t,e,i,r,s,n)),c=0,p=0,d=0,f=0,y=0;a.push(o,l);for(var v=1,g=0;v<=u;++v)d=(p=(c=1-(g=v/u))*c)*c,y=(f=g*g)*g,a.push(d*o+3*p*g*t+3*c*f*i+y*s,d*l+3*p*g*e+3*c*f*r+y*n)};var m=function(){};m.curveLength=function(t,e,i,r,s,n){var h=t-2*i+s,a=e-2*r+n,o=2*i-2*t,l=2*r-2*e,u=4*(h*h+a*a),c=4*(h*o+a*l),p=o*o+l*l,d=2*Math.sqrt(u+c+p),f=Math.sqrt(u),y=2*u*f,v=2*Math.sqrt(p),g=c/f;return(y*d+f*c*(d-v)+(4*p*u-c*c)*Math.log((2*f+g+d)/(g+v)))/(4*y)},m.curveTo=function(t,e,i,r,s){for(var n=s[s.length-2],a=s[s.length-1],o=h._segmentsCount(m.curveLength(n,a,t,e,i,r)),l=0,u=0,c=1;c<=o;++c){var p=c/o;l=n+(t-n)*p,u=a+(e-a)*p,s.push(l+(t+(i-t)*p-l)*p,u+(e+(r-e)*p-u)*p)}};var P=function(){};P.curveTo=function(t,e,i,r,s,n){var h=n[n.length-2],a=n[n.length-1]-e,o=h-t,l=r-e,u=i-t,c=Math.abs(a*u-o*l);if(c<1e-8||0===s)return n[n.length-2]===t&&n[n.length-1]===e||n.push(t,e),null;var p=a*a+o*o,d=l*l+u*u,f=a*l+o*u,y=s*Math.sqrt(p)/c,v=s*Math.sqrt(d)/c,g=y*f/p,b=v*f/d,S=y*u+v*o,x=y*l+v*a,_=o*(v+g),w=a*(v+g),m=u*(y+b),P=l*(y+b);return{cx:S+t,cy:x+e,radius:s,startAngle:Math.atan2(w-x,_-S),endAngle:Math.atan2(P-x,m-S),anticlockwise:o*l>u*a}},P.arc=function(t,e,r,s,n,a,o,l,u){for(var c=o-a,p=h._segmentsCount(Math.abs(c)*n,40*Math.ceil(Math.abs(c)/i.PI_2)),d=c/(2*p),f=2*d,y=Math.cos(d),v=Math.sin(d),g=p-1,b=g%1/g,S=0;S<=g;++S){var x=d+a+f*(S+b*S),_=Math.cos(x),w=-Math.sin(x);u.push((y*_+v*w)*n+r,(y*-w+v*_)*n+s)}};var M=function(t){function e(e,r,s,n,h,a){h=h||n/2;for(var o=-1*Math.PI/2+a,l=2*s,u=i.PI_2/l,c=[],p=0;p<l;p++){var d=p%2?h:n,f=p*u+o;c.push(e+d*Math.cos(f),r+d*Math.sin(f))}t.call(this,c)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(i.Polygon),D=new Float32Array(3),T={},I=function(t){function s(i){void 0===i&&(i=null),t.call(this),this.geometry=i||new x,this.geometry.refCount++,this.shader=null,this.state=e.State.for2d(),this._fillStyle=new a,this._lineStyle=new _,this._matrix=null,this._holeMode=!1,this.currentPath=null,this.batches=[],this.batchTint=-1,this.vertexData=null,this._transformID=-1,this.batchDirty=-1,this.pluginName="batch",this.tint=16777215,this.blendMode=n.BLEND_MODES.NORMAL}t&&(s.__proto__=t),s.prototype=Object.create(t&&t.prototype),s.prototype.constructor=s;var h={blendMode:{configurable:!0},tint:{configurable:!0},fill:{configurable:!0},line:{configurable:!0}};return s.prototype.clone=function(){return this.finishPoly(),new s(this.geometry)},h.blendMode.set=function(t){this.state.blendMode=t},h.blendMode.get=function(){return this.state.blendMode},h.tint.get=function(){return this._tint},h.tint.set=function(t){this._tint=t},h.fill.get=function(){return this._fillStyle},h.line.get=function(){return this._lineStyle},s.prototype.lineStyle=function(t,i,r,s,n){return void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===s&&(s=.5),void 0===n&&(n=!1),this.lineTextureStyle(t,e.Texture.WHITE,i,r,null,s,n),this},s.prototype.lineTextureStyle=function(t,i,r,s,n,h,a){void 0===t&&(t=0),void 0===i&&(i=e.Texture.WHITE),void 0===r&&(r=16777215),void 0===s&&(s=1),void 0===n&&(n=null),void 0===h&&(h=.5),void 0===a&&(a=!1),this.currentPath&&this.startPoly();var o=t>0&&s>0;return o?(n&&(n=n.clone()).invert(),Object.assign(this._lineStyle,{color:r,width:t,alpha:s,matrix:n,texture:i,alignment:h,native:a,visible:o})):this._lineStyle.reset(),this},s.prototype.startPoly=function(){if(this.currentPath){var t=this.currentPath.points,e=this.currentPath.points.length;e>2&&(this.drawShape(this.currentPath),this.currentPath=new i.Polygon,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new i.Polygon,this.currentPath.closeStroke=!1},s.prototype.finishPoly=function(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)},s.prototype.moveTo=function(t,e){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=e,this},s.prototype.lineTo=function(t,e){this.currentPath||this.moveTo(0,0);var i=this.currentPath.points,r=i[i.length-2],s=i[i.length-1];return r===t&&s===e||i.push(t,e),this},s.prototype._initCurve=function(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.currentPath?0===this.currentPath.points.length&&(this.currentPath.points=[t,e]):this.moveTo(t,e)},s.prototype.quadraticCurveTo=function(t,e,i,r){this._initCurve();var s=this.currentPath.points;return 0===s.length&&this.moveTo(0,0),m.curveTo(t,e,i,r,s),this},s.prototype.bezierCurveTo=function(t,e,i,r,s,n){return this._initCurve(),w.curveTo(t,e,i,r,s,n,this.currentPath.points),this},s.prototype.arcTo=function(t,e,i,r,s){this._initCurve(t,e);var n=this.currentPath.points,h=P.curveTo(t,e,i,r,s,n);if(h){var a=h.cx,o=h.cy,l=h.radius,u=h.startAngle,c=h.endAngle,p=h.anticlockwise;this.arc(a,o,l,u,c,p)}return this},s.prototype.arc=function(t,e,r,s,n,h){if(void 0===h&&(h=!1),s===n)return this;if(!h&&n<=s?n+=i.PI_2:h&&s<=n&&(s+=i.PI_2),0===n-s)return this;var a=t+Math.cos(s)*r,o=e+Math.sin(s)*r,l=this.geometry.closePointEps,u=this.currentPath?this.currentPath.points:null;if(u){var c=Math.abs(u[u.length-2]-a),p=Math.abs(u[u.length-1]-o);c<l&&p<l||u.push(a,o)}else this.moveTo(a,o),u=this.currentPath.points;return P.arc(a,o,t,e,r,s,n,h,u),this},s.prototype.beginFill=function(t,i){return void 0===t&&(t=0),void 0===i&&(i=1),this.beginTextureFill(e.Texture.WHITE,t,i)},s.prototype.beginTextureFill=function(t,i,r,s){void 0===t&&(t=e.Texture.WHITE),void 0===i&&(i=16777215),void 0===r&&(r=1),void 0===s&&(s=null),this.currentPath&&this.startPoly();var n=r>0;return n?(s&&(s=s.clone()).invert(),Object.assign(this._fillStyle,{color:i,alpha:r,texture:t,matrix:s,visible:n})):this._fillStyle.reset(),this},s.prototype.endFill=function(){return this.finishPoly(),this._fillStyle.reset(),this},s.prototype.drawRect=function(t,e,r,s){return this.drawShape(new i.Rectangle(t,e,r,s))},s.prototype.drawRoundedRect=function(t,e,r,s,n){return this.drawShape(new i.RoundedRectangle(t,e,r,s,n))},s.prototype.drawCircle=function(t,e,r){return this.drawShape(new i.Circle(t,e,r))},s.prototype.drawEllipse=function(t,e,r,s){return this.drawShape(new i.Ellipse(t,e,r,s))},s.prototype.drawPolygon=function(t){var e=arguments,r=t,s=!0;if(r.points&&(s=r.closeStroke,r=r.points),!Array.isArray(r)){r=new Array(arguments.length);for(var n=0;n<r.length;++n)r[n]=e[n]}var h=new i.Polygon(r);return h.closeStroke=s,this.drawShape(h),this},s.prototype.drawShape=function(t){return this._holeMode?this.geometry.drawHole(t,this._matrix):this.geometry.drawShape(t,this._fillStyle.clone(),this._lineStyle.clone(),this._matrix),this},s.prototype.drawStar=function(t,e,i,r,s,n){return void 0===n&&(n=0),this.drawPolygon(new M(t,e,i,r,s,n))},s.prototype.clear=function(){return this.geometry.clear(),this._lineStyle.reset(),this._fillStyle.reset(),this._matrix=null,this._holeMode=!1,this.currentPath=null,this},s.prototype.isFastRect=function(){return!1},s.prototype._render=function(t){this.finishPoly();var e=this.geometry;e.updateBatches(),e.batchable?(this.batchDirty!==e.batchDirty&&this._populateBatches(),this._renderBatched(t)):(t.batch.flush(),this._renderDirect(t))},s.prototype._populateBatches=function(){var t=this.geometry,e=this.blendMode;this.batches=[],this.batchTint=-1,this._transformID=-1,this.batchDirty=t.batchDirty,this.vertexData=new Float32Array(t.points);for(var i=0,s=t.batches.length;i<s;i++){var n=t.batches[i],h=n.style.color,a=new Float32Array(this.vertexData.buffer,4*n.attribStart*2,2*n.attribSize),o=new Float32Array(t.uvsFloat32.buffer,4*n.attribStart*2,2*n.attribSize),l={vertexData:a,blendMode:e,indices:new Uint16Array(t.indicesUint16.buffer,2*n.start,n.size),uvs:o,_batchRGB:r.hex2rgb(h),_tintRGB:h,_texture:n.style.texture,alpha:n.style.alpha,worldAlpha:1};this.batches[i]=l}},s.prototype._renderBatched=function(t){if(this.batches.length){t.batch.setObjectRenderer(t.plugins[this.pluginName]),this.calculateVertices(),this.calculateTints();for(var e=0,i=this.batches.length;e<i;e++){var r=this.batches[e];r.worldAlpha=this.worldAlpha*r.alpha,t.plugins[this.pluginName].render(r)}}},s.prototype._renderDirect=function(t){var e=this._resolveDirectShader(t),i=this.geometry,r=this.tint,s=this.worldAlpha,n=e.uniforms,h=i.drawCalls;n.translationMatrix=this.transform.worldTransform,n.tint[0]=(r>>16&255)/255*s,n.tint[1]=(r>>8&255)/255*s,n.tint[2]=(255&r)/255*s,n.tint[3]=s,t.shader.bind(e),t.geometry.bind(i,e),t.state.set(this.state);for(var a=0,o=h.length;a<o;a++)this._renderDrawCallDirect(t,i.drawCalls[a])},s.prototype._renderDrawCallDirect=function(t,e){for(var i=e.textureCount,r=0;r<i;r++)t.texture.bind(e.textures[r],r);t.geometry.draw(e.type,e.size,e.start)},s.prototype._resolveDirectShader=function(t){var r=this.shader,s=this.pluginName;if(!r){if(!T[s]){for(var n=new Int32Array(16),h=0;h<16;h++)n[h]=h;var a={tint:new Float32Array([1,1,1,1]),translationMatrix:new i.Matrix,default:e.UniformGroup.from({uSamplers:n},!0)},o=t.plugins[s]._shader.program;T[s]=new e.Shader(o,a)}r=T[s]}return r},s.prototype._calculateBounds=function(){this.finishPoly();var t=this.geometry.bounds;this._bounds.addFrame(this.transform,t.minX,t.minY,t.maxX,t.maxY)},s.prototype.containsPoint=function(t){return this.worldTransform.applyInverse(t,s._TEMP_POINT),this.geometry.containsPoint(s._TEMP_POINT)},s.prototype.calculateTints=function(){if(this.batchTint!==this.tint){this.batchTint=this.tint;for(var t=r.hex2rgb(this.tint,D),e=0;e<this.batches.length;e++){var i=this.batches[e],s=i._batchRGB,n=(t[0]*s[0]*255<<16)+(t[1]*s[1]*255<<8)+(0|t[2]*s[2]*255);i._tintRGB=(n>>16)+(65280&n)+((255&n)<<16)}}},s.prototype.calculateVertices=function(){if(this._transformID!==this.transform._worldID){this._transformID=this.transform._worldID;for(var t=this.transform.worldTransform,e=t.a,i=t.b,r=t.c,s=t.d,n=t.tx,h=t.ty,a=this.geometry.points,o=this.vertexData,l=0,u=0;u<a.length;u+=2){var c=a[u],p=a[u+1];o[l++]=e*c+r*p+n,o[l++]=s*p+i*c+h}}},s.prototype.closePath=function(){var t=this.currentPath;return t&&(t.closeStroke=!0),this},s.prototype.setMatrix=function(t){return this._matrix=t,this},s.prototype.beginHole=function(){return this.finishPoly(),this._holeMode=!0,this},s.prototype.endHole=function(){return this.finishPoly(),this._holeMode=!1,this},s.prototype.destroy=function(e){t.prototype.destroy.call(this,e),this.geometry.refCount--,0===this.geometry.refCount&&this.geometry.dispose(),this._matrix=null,this.currentPath=null,this._lineStyle.destroy(),this._lineStyle=null,this._fillStyle.destroy(),this._fillStyle=null,this.geometry=null,this.shader=null,this.vertexData=null,this.batches.length=0,this.batches=null,t.prototype.destroy.call(this,e)},Object.defineProperties(s.prototype,h),s}(s.Container);return I._TEMP_POINT=new i.Point,t.FillStyle=a,t.GRAPHICS_CURVES=h,t.Graphics=I,t.GraphicsData=o,t.GraphicsGeometry=x,t.LineStyle=_,t}({},PIXI,PIXI,PIXI.utils,PIXI,PIXI);Object.assign(this.PIXI,_pixi_graphics); | ||
//# sourceMappingURL=graphics.min.js.map |
{ | ||
"name": "@pixi/graphics", | ||
"version": "5.1.2", | ||
"version": "5.1.3", | ||
"main": "lib/graphics.js", | ||
@@ -28,9 +28,9 @@ "module": "lib/graphics.es.js", | ||
"@pixi/constants": "^5.1.0", | ||
"@pixi/core": "^5.1.2", | ||
"@pixi/display": "^5.1.2", | ||
"@pixi/core": "^5.1.3", | ||
"@pixi/display": "^5.1.3", | ||
"@pixi/math": "^5.1.0", | ||
"@pixi/sprite": "^5.1.2", | ||
"@pixi/utils": "^5.1.2" | ||
"@pixi/sprite": "^5.1.3", | ||
"@pixi/utils": "^5.1.3" | ||
}, | ||
"gitHead": "9d8381bfb348e8ba570e1cab26bf2f699446f0ca" | ||
"gitHead": "ee5ed4ddb3e1967f7e8a88c952479d51368fd3e2" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1000027
9016
Updated@pixi/core@^5.1.3
Updated@pixi/display@^5.1.3
Updated@pixi/sprite@^5.1.3
Updated@pixi/utils@^5.1.3