/*! * @pixi/graphics - v6.5.10 * Compiled Thu, 06 Jul 2023 15:25:11 UTC * * @pixi/graphics is licensed under the MIT License. * http://www.opensource.org/licenses/mit-license */ import{Texture as t,BaseTexture as e,BatchDrawCall as i,BatchTextureArray as r,BatchGeometry as n,UniformGroup as s,Shader as h,State as a}from"@pixi/core";import{SHAPES as o,Point as l,PI_2 as u,Polygon as p,Rectangle as c,RoundedRectangle as f,Circle as d,Ellipse as y,Matrix as v}from"@pixi/math";import{earcut as g,premultiplyTint as b,hex2rgb as m}from"@pixi/utils";import{WRAP_MODES as x,DRAW_MODES as _,BLEND_MODES as w}from"@pixi/constants";import{Bounds as M,Container as S}from"@pixi/display";var P,T;!function(t){t.MITER="miter",t.BEVEL="bevel",t.ROUND="round"}(P||(P={})),function(t){t.BUTT="butt",t.ROUND="round",t.SQUARE="square"}(T||(T={}));var D={adaptive:!0,maxLength:10,minSegments:8,maxSegments:2048,epsilon:1e-4,_segmentsCount:function(t,e){if(void 0===e&&(e=20),!this.adaptive||!t||isNaN(t))return e;var i=Math.ceil(t/this.maxLength);return ithis.maxSegments&&(i=this.maxSegments),i}},A=function(){function e(){this.color=16777215,this.alpha=1,this.texture=t.WHITE,this.matrix=null,this.visible=!1,this.reset()}return 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},e.prototype.reset=function(){this.color=16777215,this.alpha=1,this.texture=t.WHITE,this.matrix=null,this.visible=!1},e.prototype.destroy=function(){this.texture=null,this.matrix=null},e}(),E=function(t,e){return E=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])},E(t,e)};function C(t,e){function i(){this.constructor=t}E(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}function R(t,e){var i,r;void 0===e&&(e=!1);var n=t.length;if(!(n<6)){for(var s=0,h=0,a=t[n-2],o=t[n-1];h0||e&&s<=0){var p=n/2;for(h=p+p%2;h=6){R(i,!1);for(var h=[],a=0;a=0&&h>=0&&r>=0&&n>=0){var d=Math.ceil(2.3*Math.sqrt(s+h)),y=8*d+(r?4:0)+(n?4:0);if(a.length=y,0!==y){if(0===d)return a.length=8,a[0]=a[6]=e+r,a[1]=a[3]=i+n,a[2]=a[4]=e-r,void(a[5]=a[7]=i-n);var v=0,g=4*d+(r?2:0)+2,b=g,m=y,x=e+(T=r+s),_=e-T,w=i+(D=n);if(a[v++]=x,a[v++]=w,a[--g]=w,a[--g]=_,n){var M=i-D;a[b++]=_,a[b++]=M,a[--m]=M,a[--m]=x}for(var S=1;Sp&&(p+=2*Math.PI);var c=u,f=p-u,d=Math.abs(f),y=Math.sqrt(o*o+l*l),v=1+(15*d*Math.sqrt(y)/Math.PI>>0),g=f/v;if(c+=g,a){h.push(t,e),h.push(i,r);for(var b=1,m=c;b=0&&(s.join===P.ROUND?v+=F(M,S,M-C*O,S-R*O,M-I*O,S-B*O,d,!1)+4:v+=2,d.push(M-I*j,S-B*j),d.push(M+I*O,S+B*O));else{var Q=(-C+_)*(-R+S)-(-C+M)*(-R+w),X=(-I+A)*(-B+S)-(-I+M)*(-B+E),Z=(q*X-H*Q)/Y,J=(G*Q-k*X)/Y,K=(Z-M)*(Z-M)+(J-S)*(J-S),$=M+(Z-M)*O,tt=S+(J-S)*O,et=M-(Z-M)*j,it=S-(J-S)*j,rt=V?O:j;K<=Math.min(q*q+k*k,H*H+G*G)+rt*rt*m?s.join===P.BEVEL||K/m>x?(V?(d.push($,tt),d.push(M+C*j,S+R*j),d.push($,tt),d.push(M+I*j,S+B*j)):(d.push(M-C*O,S-R*O),d.push(et,it),d.push(M-I*O,S-B*O),d.push(et,it)),v+=2):s.join===P.ROUND?V?(d.push($,tt),d.push(M+C*j,S+R*j),v+=F(M,S,M+C*j,S+R*j,M+I*j,S+B*j,d,!0)+4,d.push($,tt),d.push(M+I*j,S+B*j)):(d.push(M-C*O,S-R*O),d.push(et,it),v+=F(M,S,M-C*O,S-R*O,M-I*O,S-B*O,d,!1)+4,d.push(M-I*O,S-B*O),d.push(et,it)):(d.push($,tt),d.push(et,it)):(d.push(M-C*O,S-R*O),d.push(M+C*j,S+R*j),s.join===P.ROUND?v+=V?F(M,S,M+C*j,S+R*j,M+I*j,S+B*j,d,!0)+2:F(M,S,M-C*O,S-R*O,M-I*O,S-B*O,d,!1)+2:s.join===P.MITER&&K/m<=x&&(V?(d.push(et,it),d.push(et,it)):(d.push($,tt),d.push($,tt)),v+=2),d.push(M-I*O,S-B*O),d.push(M+I*j,S+B*j),v+=2)}}_=r[2*(y-2)],w=r[2*(y-2)+1],M=r[2*(y-1)],C=-(w-(S=r[2*(y-1)+1])),R=_-M,C/=L=Math.sqrt(C*C+R*R),R/=L,C*=b,R*=b,d.push(M-C*O,S-R*O),d.push(M+C*j,S+R*j),u||(s.cap===T.ROUND?v+=F(M-C*(O-j)*.5,S-R*(O-j)*.5,M-C*O,S-R*O,M+C*j,S+R*j,d,!1)+2:s.cap===T.SQUARE&&(v+=N(M,S,C,R,O,j,!1,d)));var nt=e.indices,st=D.epsilon*D.epsilon;for(z=g;zu*a}},t.arc=function(t,e,i,r,n,s,h,a,o){for(var l=h-s,p=D._segmentsCount(Math.abs(l)*n,40*Math.ceil(Math.abs(l)/u)),c=l/(2*p),f=2*c,d=Math.cos(c),y=Math.sin(c),v=p-1,g=v%1/v,b=0;b<=v;++b){var m=c+s+f*(b+g*b),x=Math.cos(m),_=-Math.sin(m);o.push((d*x+y*_)*n+i,(d*-_+y*x)*n+r)}},t}(),H=function(){function t(){}return t.curveLength=function(t,e,i,r,n,s,h,a){for(var o=0,l=0,u=0,p=0,c=0,f=0,d=0,y=0,v=0,g=0,b=0,m=t,x=e,_=1;_<=10;++_)g=m-(y=(d=(f=(c=1-(l=_/10))*c)*c)*t+3*f*l*i+3*c*(u=l*l)*n+(p=u*l)*h),b=x-(v=d*e+3*f*l*r+3*c*u*s+p*a),m=y,x=v,o+=Math.sqrt(g*g+b*b);return o},t.curveTo=function(e,i,r,n,s,h,a){var o=a[a.length-2],l=a[a.length-1];a.length-=2;var u=D._segmentsCount(t.curveLength(o,l,e,i,r,n,s,h)),p=0,c=0,f=0,d=0,y=0;a.push(o,l);for(var v=1,g=0;v<=u;++v)f=(c=(p=1-(g=v/u))*p)*p,y=(d=g*g)*g,a.push(f*o+3*c*g*e+3*p*d*r+y*s,f*l+3*c*g*i+3*p*d*n+y*h)},t}(),G=function(){function t(){}return t.curveLength=function(t,e,i,r,n,s){var h=t-2*i+n,a=e-2*r+s,o=2*i-2*t,l=2*r-2*e,u=4*(h*h+a*a),p=4*(h*o+a*l),c=o*o+l*l,f=2*Math.sqrt(u+p+c),d=Math.sqrt(u),y=2*u*d,v=2*Math.sqrt(c),g=p/d;return(y*f+d*p*(f-v)+(4*c*u-p*p)*Math.log((2*d+g+f)/(g+v)))/(4*y)},t.curveTo=function(e,i,r,n,s){for(var h=s[s.length-2],a=s[s.length-1],o=D._segmentsCount(t.curveLength(h,a,e,i,r,n)),l=0,u=0,p=1;p<=o;++p){var c=p/o;l=h+(e-h)*c,u=a+(i-a)*c,s.push(l+(e+(r-e)*c-l)*c,u+(i+(n-i)*c-u)*c)}},t}(),W=function(){function t(){this.reset()}return t.prototype.begin=function(t,e,i){this.reset(),this.style=t,this.start=e,this.attribStart=i},t.prototype.end=function(t,e){this.attribSize=e-this.attribStart,this.size=t-this.start},t.prototype.reset=function(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0},t}(),Y=((q={})[o.POLY]=I,q[o.CIRC]=B,q[o.ELIP]=B,q[o.RECT]=L,q[o.RREC]=j,q),V=[],Q=[],X=function(){function t(t,e,i,r){void 0===e&&(e=null),void 0===i&&(i=null),void 0===r&&(r=null),this.points=[],this.holes=[],this.shape=t,this.lineStyle=i,this.fillStyle=e,this.matrix=r,this.type=t.type}return t.prototype.clone=function(){return new t(this.shape,this.fillStyle,this.lineStyle,this.matrix)},t.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},t}(),Z=new l,J=function(t){function n(){var e=t.call(this)||this;return e.closePointEps=1e-4,e.boundsPadding=0,e.uvsFloat32=null,e.indicesUint16=null,e.batchable=!1,e.points=[],e.colors=[],e.uvs=[],e.indices=[],e.textureIds=[],e.graphicsData=[],e.drawCalls=[],e.batchDirty=-1,e.batches=[],e.dirty=0,e.cacheDirty=-1,e.clearDirty=0,e.shapeIndex=0,e._bounds=new M,e.boundsDirty=-1,e}return C(n,t),Object.defineProperty(n.prototype,"bounds",{get:function(){return this.updateBatches(),this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds},enumerable:!1,configurable:!0}),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;t0&&(this.invalidate(),this.clearDirty++,this.graphicsData.length=0),this},n.prototype.drawShape=function(t,e,i,r){void 0===e&&(e=null),void 0===i&&(i=null),void 0===r&&(r=null);var n=new X(t,e,i,r);return this.graphicsData.push(n),this.dirty++,this},n.prototype.drawHole=function(t,e){if(void 0===e&&(e=null),!this.graphicsData.length)return null;var i=new X(t,null,null,e),r=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=r.lineStyle,r.holes.push(i),this.dirty++,this},n.prototype.destroy=function(){t.prototype.destroy.call(this);for(var e=0;e0&&(r=(i=this.batches[this.batches.length-1]).style);for(var n=this.shapeIndex;n65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&v===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=v?new Uint32Array(this.indices):new Uint16Array(this.indices),this.batchable=this.isBatchable(),this.batchable?this.packBatches():this.buildDrawCalls()}else this.batchable=!0}}else this.batchable=!0},n.prototype._compareStyles=function(t,e){return!(!t||!e)&&(t.texture.baseTexture===e.texture.baseTexture&&(t.color+t.alpha===e.color+e.alpha&&!!t.native==!!e.native))},n.prototype.validateBatching=function(){if(this.dirty===this.cacheDirty||!this.graphicsData.length)return!1;for(var t=0,e=this.graphicsData.length;t131070)return!1;for(var t=this.batches,e=0;e0&&((a=Q.pop())||((a=new i).texArray=new r),this.drawCalls.push(a)),a.start=f,a.size=0,a.texArray.count=0,a.type=c),v.touched=1,v._batchEnabled=t,v._batchLocation=o,v.wrapMode=x.REPEAT,a.texArray.elements[a.texArray.count++]=v,o++)),a.size+=d.size,f+=d.size,u=v._batchLocation,this.addColors(s,y.color,y.alpha,d.attribSize,d.attribStart),this.addTextureIds(h,u,d.attribSize,d.attribStart)}e._globalBatch=t,this.packAttributes()},n.prototype.packAttributes=function(){for(var t=this.points,e=this.uvs,i=this.colors,r=this.textureIds,n=new ArrayBuffer(3*t.length*4),s=new Float32Array(n),h=new Uint32Array(n),a=0,o=0;o>16)+(65280&e)+((255&e)<<16),i);t.length=Math.max(t.length,n+r);for(var h=0;h0&&e.alpha>0;return i?(e.matrix&&(e.matrix=e.matrix.clone(),e.matrix.invert()),Object.assign(this._lineStyle,{visible:i},e)):this._lineStyle.reset(),this},i.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 p,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new p,this.currentPath.closeStroke=!1},i.prototype.finishPoly=function(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)},i.prototype.moveTo=function(t,e){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=e,this},i.prototype.lineTo=function(t,e){this.currentPath||this.moveTo(0,0);var i=this.currentPath.points,r=i[i.length-2],n=i[i.length-1];return r===t&&n===e||i.push(t,e),this},i.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)},i.prototype.quadraticCurveTo=function(t,e,i,r){this._initCurve();var n=this.currentPath.points;return 0===n.length&&this.moveTo(0,0),G.curveTo(t,e,i,r,n),this},i.prototype.bezierCurveTo=function(t,e,i,r,n,s){return this._initCurve(),H.curveTo(t,e,i,r,n,s,this.currentPath.points),this},i.prototype.arcTo=function(t,e,i,r,n){this._initCurve(t,e);var s=this.currentPath.points,h=k.curveTo(t,e,i,r,n,s);if(h){var a=h.cx,o=h.cy,l=h.radius,u=h.startAngle,p=h.endAngle,c=h.anticlockwise;this.arc(a,o,l,u,p,c)}return this},i.prototype.arc=function(t,e,i,r,n,s){if(void 0===s&&(s=!1),r===n)return this;if(!s&&n<=r?n+=u:s&&r<=n&&(r+=u),0===n-r)return this;var h=t+Math.cos(r)*i,a=e+Math.sin(r)*i,o=this._geometry.closePointEps,l=this.currentPath?this.currentPath.points:null;if(l){var p=Math.abs(l[l.length-2]-h),c=Math.abs(l[l.length-1]-a);p0;return i?(e.matrix&&(e.matrix=e.matrix.clone(),e.matrix.invert()),Object.assign(this._fillStyle,{visible:i},e)):this._fillStyle.reset(),this},i.prototype.endFill=function(){return this.finishPoly(),this._fillStyle.reset(),this},i.prototype.drawRect=function(t,e,i,r){return this.drawShape(new c(t,e,i,r))},i.prototype.drawRoundedRect=function(t,e,i,r,n){return this.drawShape(new f(t,e,i,r,n))},i.prototype.drawCircle=function(t,e,i){return this.drawShape(new d(t,e,i))},i.prototype.drawEllipse=function(t,e,i,r){return this.drawShape(new y(t,e,i,r))},i.prototype.drawPolygon=function(){for(var t,e=arguments,i=[],r=0;r>16&255)/255*n,s.tint[1]=(r>>8&255)/255*n,s.tint[2]=(255&r)/255*n,s.tint[3]=n,t.shader.bind(e),t.geometry.bind(i,e),t.state.set(this.state);for(var a=0,o=h.length;a>16)+(65280&n)+((255&n)<<16)}}},i.prototype.calculateVertices=function(){var t=this.transform._worldID;if(this._transformID!==t){this._transformID=t;for(var e=this.transform.worldTransform,i=e.a,r=e.b,n=e.c,s=e.d,h=e.tx,a=e.ty,o=this._geometry.points,l=this.vertexData,u=0,p=0;p