/*! * @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 */ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e,i=require("@pixi/core"),r=require("@pixi/math"),s=require("@pixi/utils"),n=require("@pixi/constants"),h=require("@pixi/display");exports.LINE_JOIN=void 0,(t=exports.LINE_JOIN||(exports.LINE_JOIN={})).MITER="miter",t.BEVEL="bevel",t.ROUND="round",exports.LINE_CAP=void 0,(e=exports.LINE_CAP||(exports.LINE_CAP={})).BUTT="butt",e.ROUND="round",e.SQUARE="square";var a={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}},o=function(){function t(){this.color=16777215,this.alpha=1,this.texture=i.Texture.WHITE,this.matrix=null,this.visible=!1,this.reset()}return t.prototype.clone=function(){var e=new t;return e.color=this.color,e.alpha=this.alpha,e.texture=this.texture,e.matrix=this.matrix,e.visible=this.visible,e},t.prototype.reset=function(){this.color=16777215,this.alpha=1,this.texture=i.Texture.WHITE,this.matrix=null,this.visible=!1},t.prototype.destroy=function(){this.texture=null,this.matrix=null},t}(),l=function(t,e){return l=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])},l(t,e)};function u(t,e){function i(){this.constructor=t}l(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}function p(t,e){var i,r;void 0===e&&(e=!1);var s=t.length;if(!(s<6)){for(var n=0,h=0,a=t[s-2],o=t[s-1];h0||e&&n<=0){var p=s/2;for(h=p+p%2;h=6){p(i,!1);for(var a=[],o=0;o=0&&a>=0&&s>=0&&n>=0){var d=Math.ceil(2.3*Math.sqrt(h+a)),y=8*d+(s?4:0)+(n?4:0);if(o.length=y,0!==y){if(0===d)return o.length=8,o[0]=o[6]=e+s,o[1]=o[3]=i+n,o[2]=o[4]=e-s,void(o[5]=o[7]=i-n);var v=0,g=4*d+(s?2:0)+2,b=g,x=y,m=e+(E=s+h),_=e-E,S=i+(A=n);if(o[v++]=m,o[v++]=S,o[--g]=S,o[--g]=_,n){var P=i-A;o[b++]=_,o[b++]=P,o[--x]=P,o[--x]=m}for(var w=1;wp&&(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,x=c;b=0&&(h.join===exports.LINE_JOIN.ROUND?v+=x(M,E,M-T*O,E-I*O,M-C*O,E-R*O,d,!1)+4:v+=2,d.push(M-C*B,E-R*B),d.push(M+C*O,E+R*O));else{var W=(-T+P)*(-I+E)-(-T+M)*(-I+w),J=(-C+A)*(-R+E)-(-C+M)*(-R+D),V=(H*J-F*W)/k,Y=(q*W-j*J)/k,Q=(V-M)*(V-M)+(Y-E)*(Y-E),X=M+(V-M)*O,Z=E+(Y-E)*O,K=M-(V-M)*B,$=E-(Y-E)*B,tt=G?O:B;Q<=Math.min(H*H+j*j,F*F+q*q)+tt*tt*_?h.join===exports.LINE_JOIN.BEVEL||Q/_>S?(G?(d.push(X,Z),d.push(M+T*B,E+I*B),d.push(X,Z),d.push(M+C*B,E+R*B)):(d.push(M-T*O,E-I*O),d.push(K,$),d.push(M-C*O,E-R*O),d.push(K,$)),v+=2):h.join===exports.LINE_JOIN.ROUND?G?(d.push(X,Z),d.push(M+T*B,E+I*B),v+=x(M,E,M+T*B,E+I*B,M+C*B,E+R*B,d,!0)+4,d.push(X,Z),d.push(M+C*B,E+R*B)):(d.push(M-T*O,E-I*O),d.push(K,$),v+=x(M,E,M-T*O,E-I*O,M-C*O,E-R*O,d,!1)+4,d.push(M-C*O,E-R*O),d.push(K,$)):(d.push(X,Z),d.push(K,$)):(d.push(M-T*O,E-I*O),d.push(M+T*B,E+I*B),h.join===exports.LINE_JOIN.ROUND?v+=G?x(M,E,M+T*B,E+I*B,M+C*B,E+R*B,d,!0)+2:x(M,E,M-T*O,E-I*O,M-C*O,E-R*O,d,!1)+2:h.join===exports.LINE_JOIN.MITER&&Q/_<=S&&(G?(d.push(K,$),d.push(K,$)):(d.push(X,Z),d.push(X,Z)),v+=2),d.push(M-C*O,E-R*O),d.push(M+C*B,E+R*B),v+=2)}}P=s[2*(y-2)],w=s[2*(y-2)+1],M=s[2*(y-1)],T=-(w-(E=s[2*(y-1)+1])),I=P-M,T/=L=Math.sqrt(T*T+I*I),I/=L,T*=m,I*=m,d.push(M-T*O,E-I*O),d.push(M+T*B,E+I*B),u||(h.cap===exports.LINE_CAP.ROUND?v+=x(M-T*(O-B)*.5,E-I*(O-B)*.5,M-T*O,E-I*O,M+T*B,E+I*B,d,!1)+2:h.cap===exports.LINE_CAP.SQUARE&&(v+=b(M,E,T,I,O,B,!1,d)));var et=e.indices,it=a.epsilon*a.epsilon;for(U=g;Uu*a}},t.arc=function(t,e,i,s,n,h,o,l,u){for(var p=o-h,c=a._segmentsCount(Math.abs(p)*n,40*Math.ceil(Math.abs(p)/r.PI_2)),f=p/(2*c),d=2*f,y=Math.cos(f),v=Math.sin(f),g=c-1,b=g%1/g,x=0;x<=g;++x){var m=f+h+d*(x+b*x),_=Math.cos(m),S=-Math.sin(m);u.push((y*_+v*S)*n+i,(y*-S+v*_)*n+s)}},t}(),P=function(){function t(){}return t.curveLength=function(t,e,i,r,s,n,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,x=t,m=e,_=1;_<=10;++_)g=x-(y=(d=(f=(c=1-(l=_/10))*c)*c)*t+3*f*l*i+3*c*(u=l*l)*s+(p=u*l)*h),b=m-(v=d*e+3*f*l*r+3*c*u*n+p*a),x=y,m=v,o+=Math.sqrt(g*g+b*b);return o},t.curveTo=function(e,i,r,s,n,h,o){var l=o[o.length-2],u=o[o.length-1];o.length-=2;var p=a._segmentsCount(t.curveLength(l,u,e,i,r,s,n,h)),c=0,f=0,d=0,y=0,v=0;o.push(l,u);for(var g=1,b=0;g<=p;++g)d=(f=(c=1-(b=g/p))*c)*c,v=(y=b*b)*b,o.push(d*l+3*f*b*e+3*c*y*r+v*n,d*u+3*f*b*i+3*c*y*s+v*h)},t}(),w=function(){function t(){}return t.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),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,s,n){for(var h=n[n.length-2],o=n[n.length-1],l=a._segmentsCount(t.curveLength(h,o,e,i,r,s)),u=0,p=0,c=1;c<=l;++c){var f=c/l;u=h+(e-h)*f,p=o+(i-o)*f,n.push(u+(e+(r-e)*f-u)*f,p+(i+(s-i)*f-p)*f)}},t}(),M=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}(),E=((_={})[r.SHAPES.POLY]=c,_[r.SHAPES.CIRC]=f,_[r.SHAPES.ELIP]=f,_[r.SHAPES.RECT]=d,_[r.SHAPES.RREC]=g,_),A=[],D=[],T=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}(),I=new r.Point,C=function(t){function e(){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 h.Bounds,e.boundsDirty=-1,e}return u(e,t),Object.defineProperty(e.prototype,"bounds",{get:function(){return this.updateBatches(),this.boundsDirty!==this.dirty&&(this.boundsDirty=this.dirty,this.calculateBounds()),this._bounds},enumerable:!1,configurable:!0}),e.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},e.prototype.drawShape=function(t,e,i,r){void 0===e&&(e=null),void 0===i&&(i=null),void 0===r&&(r=null);var s=new T(t,e,i,r);return this.graphicsData.push(s),this.dirty++,this},e.prototype.drawHole=function(t,e){if(void 0===e&&(e=null),!this.graphicsData.length)return null;var i=new T(t,null,null,e),r=this.graphicsData[this.graphicsData.length-1];return i.lineStyle=r.lineStyle,r.holes.push(i),this.dirty++,this},e.prototype.destroy=function(){t.prototype.destroy.call(this);for(var e=0;e0&&(r=(i=this.batches[this.batches.length-1]).style);for(var s=this.shapeIndex;s65535;this.indicesUint16&&this.indices.length===this.indicesUint16.length&&g===this.indicesUint16.BYTES_PER_ELEMENT>2?this.indicesUint16.set(this.indices):this.indicesUint16=g?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},e.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))},e.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,i=0;i0&&((h=D.pop())||((h=new i.BatchDrawCall).texArray=new i.BatchTextureArray),this.drawCalls.push(h)),h.start=c,h.size=0,h.texArray.count=0,h.type=p),y.touched=1,y._batchEnabled=t,y._batchLocation=a,y.wrapMode=n.WRAP_MODES.REPEAT,h.texArray.elements[h.texArray.count++]=y,a++)),h.size+=f.size,c+=f.size,l=y._batchLocation,this.addColors(r,d.color,d.alpha,f.attribSize,f.attribStart),this.addTextureIds(s,l,f.attribSize,f.attribStart)}i.BaseTexture._globalBatch=t,this.packAttributes()},e.prototype.packAttributes=function(){for(var t=this.points,e=this.uvs,i=this.colors,r=this.textureIds,s=new ArrayBuffer(3*t.length*4),n=new Float32Array(s),h=new Uint32Array(s),a=0,o=0;o>16)+(65280&e)+((255&e)<<16),a=s.premultiplyTint(h,i);t.length=Math.max(t.length,n+r);for(var o=0;o0&&t.alpha>0;return e?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._lineStyle,{visible:e},t)):this._lineStyle.reset(),this},e.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 r.Polygon,this.currentPath.closeStroke=!1,this.currentPath.points.push(t[e-2],t[e-1]))}else this.currentPath=new r.Polygon,this.currentPath.closeStroke=!1},e.prototype.finishPoly=function(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)},e.prototype.moveTo=function(t,e){return this.startPoly(),this.currentPath.points[0]=t,this.currentPath.points[1]=e,this},e.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},e.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)},e.prototype.quadraticCurveTo=function(t,e,i,r){this._initCurve();var s=this.currentPath.points;return 0===s.length&&this.moveTo(0,0),w.curveTo(t,e,i,r,s),this},e.prototype.bezierCurveTo=function(t,e,i,r,s,n){return this._initCurve(),P.curveTo(t,e,i,r,s,n,this.currentPath.points),this},e.prototype.arcTo=function(t,e,i,r,s){this._initCurve(t,e);var n=this.currentPath.points,h=S.curveTo(t,e,i,r,s,n);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},e.prototype.arc=function(t,e,i,s,n,h){if(void 0===h&&(h=!1),s===n)return this;if(!h&&n<=s?n+=r.PI_2:h&&s<=n&&(s+=r.PI_2),0===n-s)return this;var a=t+Math.cos(s)*i,o=e+Math.sin(s)*i,l=this._geometry.closePointEps,u=this.currentPath?this.currentPath.points:null;if(u){var p=Math.abs(u[u.length-2]-a),c=Math.abs(u[u.length-1]-o);p0;return e?(t.matrix&&(t.matrix=t.matrix.clone(),t.matrix.invert()),Object.assign(this._fillStyle,{visible:e},t)):this._fillStyle.reset(),this},e.prototype.endFill=function(){return this.finishPoly(),this._fillStyle.reset(),this},e.prototype.drawRect=function(t,e,i,s){return this.drawShape(new r.Rectangle(t,e,i,s))},e.prototype.drawRoundedRect=function(t,e,i,s,n){return this.drawShape(new r.RoundedRectangle(t,e,i,s,n))},e.prototype.drawCircle=function(t,e,i){return this.drawShape(new r.Circle(t,e,i))},e.prototype.drawEllipse=function(t,e,i,s){return this.drawShape(new r.Ellipse(t,e,i,s))},e.prototype.drawPolygon=function(){for(var t,e=arguments,i=[],s=0;s>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>16)+(65280&n)+((255&n)<<16)}}},e.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,s=e.c,n=e.d,h=e.tx,a=e.ty,o=this._geometry.points,l=this.vertexData,u=0,p=0;p