Files
Foundry-VTT-Docker/resources/app/node_modules/@pixi/graphics-smooth/dist/pixi-graphics-smooth.mjs

493 lines
49 KiB
JavaScript
Raw Normal View History

2025-01-04 00:34:03 +01:00
/*!
* @pixi/graphics-smooth - v1.1.0
* Compiled Sat, 25 Mar 2023 18:46:44 UTC
*
* @pixi/graphics-smooth is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*
* Copyright 2023, Ivan Popelyshev, All Rights Reserved
*/import{BatchTextureArray as Et,BLEND_MODES as ct,BaseTexture as It,Matrix as j,Texture as V,SHAPES as P,Point as q,utils as ut,Geometry as St,Buffer as dt,TYPES as C,WRAP_MODES as Nt,Color as B,Shader as Pt,Program as At,State as Ot,Polygon as it,PI_2 as pt,Rectangle as Dt,RoundedRectangle as wt,Circle as Ct,Ellipse as Mt,MSAA_QUALITY as Bt,DRAW_MODES as Rt}from"@pixi/core";import{LINE_CAP as $,LINE_JOIN as R,Graphics as Ut,graphicsUtils as Ft,curves as kt}from"@pixi/graphics";import{Bounds as ft,Container as zt}from"@pixi/display";function st(n,t,s=.001){return this===t||Math.abs(n.a-t.a)<s&&Math.abs(n.b-t.b)<s&&Math.abs(n.c-t.c)<s&&Math.abs(n.d-t.d)<s&&Math.abs(n.tx-t.tx)<s&&Math.abs(n.ty-t.ty)<s}class yt{constructor(){this.textureIds=[],this.matrices=[],this.lines=[],this.count=0}clear(){for(let t=0;t<this.count;t++)this.textureIds[t]=null,this.matrices[t]=null;this.count=0}add(t,s,e,r,i,l){const{textureIds:a,matrices:c,lines:p,count:u}=this;t=t*4+i;for(let o=0;o<u;o++)if(p[o*2]===e&&p[o*2+1]===r&&a[o]===t&&st(c[o],s))return o;return u>=l.maxStyles?-1:(a[u]=t,c[u]=s,p[u*2]=e,p[u*2+1]=r,this.count++,u)}}class nt{constructor(){this.texArray=new Et,this.styleArray=new yt,this.shader=null,this.blend=ct.NORMAL,this.start=0,this.size=0,this.TICK=0,this.settings=null,this.data=null}clear(){this.texArray.clear(),this.styleArray.clear(),this.settings=null,this.data=null,this.shader=null}begin(t,s){this.TICK=++It._globalBatch,this.settings=t,this.shader=s,this.start=0,this.size=0,this.data=null,s&&s.settings&&(this.settings=s.settings)}check(t){return this.size===0?(this.shader=t,!0):this.shader===t}add(t,s,e,r,i){const{texArray:l,TICK:a,styleArray:c,settings:p}=this,{baseTexture:u}=t;if(u._batchEnabled!==a&&l.count===p.maxTextures)return-1;const o=u._batchEnabled!==a?l.count:u._batchLocation,h=c.add(o,s||j.IDENTITY,e,r,i,p);return h>=0&&u._batchEnabled!==a&&(u._batchEnabled=a,u._batchLocation=l.count,l.elements[l.count++]=u),h}}class xt{constructor(){this.reset()}begin(t,s,e){this.reset(),this.style=t,this.start=s,this.attribStart=e,this.jointEnd=0}end(t,s){this.attribSize=s-this.attribStart,this.size=t-this.start}reset(){this.style=null,this.size=0,this.start=0,this.attribStart=0,this.attribSize=0,this.styleId=-1,this.rgba=0,this.jointEnd=0}}class Y{constructor(){this.reset()}toJSON(){return this.copyTo({})}clone(){return this.copyTo(new Y)}copyTo(t){return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.shader=this.shader,t.visible=this.visible,t.smooth=this.smooth,t.matrixTex=null,t}packLineScale(){return 0}reset(){this.color=16777215,this.alpha=1,this.texture=V.WHITE,this.matrix=null,this.shader=null,this.visible=!1,this.smooth=!1,this.matrixTex=null}destroy(){this.texture=null,this.matrix=null,this.matrixTex=null}getTextureMatrix(){const t=this.texture;return this.matrix?t.frame.width===t.baseTexture.width&&t.frame.height===t.baseTexture.height?this.matrix:(this.matrixTex?this.matrixTex.copyFrom(this.matrix):this.matrixTex=this.matrix.clone(),this.matrixTex.translate(Number(t.frame.x),Number(t.frame.y)),this.matrixTex):null}}var M=(n=>(n.NONE="none",n.NORMAL="normal",n.HORIZONTAL="horizontal",n.VERTICAL="vertical",n))(M||{});class et extends Y{clone(){return this.copyTo(new et)}copyTo(t){return t.color=this.color,t.alpha=this.alpha,t.texture=this.texture,t.matrix=this.matrix,t.shader=this.shader,t.visible=this.visible,t.width=this.width,t.alignment=this.alignment,t.cap=this.cap,t.join=this.join,t.miterLimit=this.miterLimit,t.scaleMode=this.scaleMode,t}packLineScale(){switch(this.scaleMode){case"normal":return 1;case"horizontal":return 2;case"vertical":return 3;default:return 0}}reset(){super.reset(),this.smooth=!0,this.color=0,this.width=0,this.alignment=.5,this.cap=$.BUTT,this.join=R.MITER,this.miterLimit=10,this.scaleMode="normal"}}class vt{constructor(){this.verts=[],this.joints=[],this.vertexSize=0,this.indexSize=0,this.closePointEps=1e-4}clear(){this.verts.length=0,this.joints.length=0,this.vertexSize=0,this.indexSize=0}destroy(){this.verts.length=0,this.joints.length=0}}var f=
precision highp float;
const float FILL = 1.0;
const float BEVEL = 4.0;
const float MITER = 8.0;
const float ROUND = 12.0;
const float JOINT_CAP_BUTT = 16.0;
const float JOINT_CAP_SQUARE = 18.0;
const float JOINT_CAP_ROUND = 20.0;
const float FILL_EXPAND = 24.0;
const float CAP_BUTT = 1.0;
const float CAP_SQUARE = 2.0;
const float CAP_ROUND = 3.0;
const float CAP_BUTT2 = 4.0;
const float MITER_LIMIT = 10.0;
// === geom ===
attribute vec2 aPrev;
attribute vec2 aPoint1;
attribute vec2 aPoint2;
attribute vec2 aNext;
attribute float aVertexJoint;
attribute float aTravel;
uniform mat3 projectionMatrix;
uniform mat3 translationMatrix;
uniform vec4 tint;
varying vec4 vLine1;
varying vec4 vLine2;
varying vec4 vArc;
varying float vType;
uniform float resolution;
uniform float expand;
// === style ===
attribute float aStyleId;
attribute vec4 aColor;
varying float vTextureId;
varying vec4 vColor;
varying vec2 vTextureCoord;
varying vec2 vTravel;
uniform vec2 styleLine[%MAX_STYLES%];
uniform vec3 styleMatrix[2 * %MAX_STYLES%];
uniform float styleTextureId[%MAX_STYLES%];
uniform vec2 samplerSize[%MAX_TEXTURES%];
vec2 doBisect(vec2 norm, float len, vec2 norm2, float len2,
float dy, float inner) {
vec2 bisect = (norm + norm2) / 2.0;
bisect /= dot(norm, bisect);
vec2 shift = dy * bisect;
if (inner > 0.5) {
if (len < len2) {
if (abs(dy * (bisect.x * norm.y - bisect.y * norm.x)) > len) {
return dy * norm;
}
} else {
if (abs(dy * (bisect.x * norm2.y - bisect.y * norm2.x)) > len2) {
return dy * norm;
}
}
}
return dy * bisect;
}
void main(void){
vec2 pointA = (translationMatrix * vec3(aPoint1, 1.0)).xy;
vec2 pointB = (translationMatrix * vec3(aPoint2, 1.0)).xy;
vec2 xBasis = pointB - pointA;
float len = length(xBasis);
vec2 forward = xBasis / len;
vec2 norm = vec2(forward.y, -forward.x);
float type = floor(aVertexJoint / 16.0);
float vertexNum = aVertexJoint - type * 16.0;
float dx = 0.0, dy = 1.0;
float capType = floor(type / 32.0);
type -= capType * 32.0;
int styleId = int(aStyleId + 0.5);
float lineWidth = styleLine[styleId].x;
vTextureId = floor(styleTextureId[styleId] / 4.0);
float scaleMode = styleTextureId[styleId] - vTextureId * 4.0;
float avgScale = 1.0;
if (scaleMode > 2.5) {
avgScale = length(translationMatrix * vec3(1.0, 0.0, 0.0));
} else if (scaleMode > 1.5) {
avgScale = length(translationMatrix * vec3(0.0, 1.0, 0.0));
} else if (scaleMode > 0.5) {
vec2 avgDiag = (translationMatrix * vec3(1.0, 1.0, 0.0)).xy;
avgScale = sqrt(dot(avgDiag, avgDiag) * 0.5);
}
lineWidth *= 0.5 * avgScale;
float lineAlignment = 2.0 * styleLine[styleId].y - 1.0;
vTextureCoord = vec2(0.0);
vec2 pos;
if (capType == CAP_ROUND) {
vertexNum += 4.0;
type = JOINT_CAP_ROUND;
capType = 0.0;
lineAlignment = -lineAlignment;
}
vLine1 = vec4(0.0, 10.0, 1.0, 0.0);
vLine2 = vec4(0.0, 10.0, 1.0, 0.0);
vArc = vec4(0.0);
if (type == FILL) {
pos = pointA;
vType = 0.0;
vLine2 = vec4(-2.0, -2.0, -2.0, 0.0);
vec2 vTexturePixel;
vTexturePixel.x = dot(vec3(aPoint1, 1.0), styleMatrix[styleId * 2]);
vTexturePixel.y = dot(vec3(aPoint1, 1.0), styleMatrix[styleId * 2 + 1]);
vTextureCoord = vTexturePixel / samplerSize[int(vTextureId)];
} else if (type >= FILL_EXPAND && type < FILL_EXPAND + 7.5) {
// expand vertices
float flags = type - FILL_EXPAND;
float flag3 = floor(flags / 4.0);
float flag2 = floor((flags - flag3 * 4.0) / 2.0);
float flag1 = flags - flag3 * 4.0 - flag2 * 2.0;
vec2 prev = (translationMatrix * vec3(aPrev, 1.0)).xy;
if (vertexNum < 0.5) {
pos = prev;
} else if (vertexNum < 1.5) {
pos = pointA;
} else {
pos = pointB;
}
float len2 = length(aNext);
vec2 bisect = (translationMatrix * vec3(aNext, 0.0)).xy;
if (len2 > 0.01) {
bisect = normalize(bisect) * len2;
}
vec2 n1 = normalize(vec2(pointA.y - prev.y, -(pointA.x - prev.x)));
vec2 n2 = normalize(vec2(pointB.y - pointA.y, -(pointB.x - pointA.x)));
vec2 n3 = normalize(vec2(prev.y - pointB.y, -(prev.x - pointB.x)));
if (n1.x * n2.y - n1.y * n2.x < 0.0) {
n1 = -n1;
n2 = -n2;
n3 = -n3;
}
pos += bisect * expand;
vLine1 = vec4(16.0, 16.0, 16.0, -1.0);
if (flag1 > 0.5) {
vLine1.x = -dot(pos - prev, n1);
}
if (flag2 > 0.5) {
vLine1.y = -dot(pos - pointA, n2);
}
if (flag3 > 0.5) {
vLine1.z = -dot(pos - pointB, n3);
}
vLine1.xyz *= resolution;
vType = 2.0;
} else if (type >= BEVEL) {
float dy = lineWidth + expand;
float shift = lineWidth * lineAlignment;
float inner = 0.0;
if (vertexNum >= 1.5) {
dy = -dy;
inner = 1.0;
}
vec2 base, next, xBasis2, bisect;
float flag = 0.0;
float side2 = 1.0;
if (vertexNum < 0.5 || vertexNum > 2.5 && vertexNum < 3.5) {
next = (translationMatrix * vec3(aPrev, 1.0)).xy;
base = pointA;
flag = type - floor(type / 2.0) * 2.0;
side2 = -1.0;
} else {
next = (translationMatrix * vec3(aNext, 1.0)).xy;
base = pointB;
if (type >= MITER && type < MITER + 3.5) {
flag = step(MITER + 1.5, type);
// check miter limit here?
}
}
xBasis2 = next - base;
float len2 = length(xBasis2);
vec2 norm2 = vec2(xBasis2.y, -xBasis2.x) / len2;
float D = norm.x * norm2.y - norm.y * norm2.x;
if (D < 0.0) {
inner = 1.0 - inner;
}
norm2 *= side2;
float collinear = step(0.0, dot(norm, norm2));
vType = 0.0;
float dy2 = -1000.0;
if (abs(D) < 0.01 && collinear < 0.5) {
if (type >= ROUND && type < ROUND + 1.5) {
type = JOINT_CAP_ROUND;
}
//TODO: BUTT here too
}
vLine1 = vec4(0.0, lineWidth, max(abs(norm.x), abs(norm.y)), min(abs(norm.x), abs(norm.y)));
vLine2 = vec4(0.0, lineWidth, max(abs(norm2.x), abs(norm2.y)), min(abs(norm2.x), abs(norm2.y)));
if (vertexNum < 3.5) {
if (abs(D) < 0.01 && collinear < 0.5) {
pos = (shift + dy) * norm;
} else {
if (flag < 0.5 && inner < 0.5) {
pos = (shift + dy) * norm;
} else {
pos = doBisect(norm, len, norm2, len2, shift + dy, inner);
}
}
vLine2.y = -1000.0;
if (capType >= CAP_BUTT && capType < CAP_ROUND) {
float extra = step(CAP_SQUARE, capType) * lineWidth;
vec2 back = -forward;
if (vertexNum < 0.5 || vertexNum > 2.5) {
pos += back * (expand + extra);
dy2 = expand;
} else {
dy2 = dot(pos + base - pointA, back) - extra;
}
}
if (type >= JOINT_CAP_BUTT && type < JOINT_CAP_SQUARE + 0.5) {
float extra = step(JOINT_CAP_SQUARE, type) * lineWidth;
if (vertexNum < 0.5 || vertexNum > 2.5) {
vLine2.y = dot(pos + base - pointB, forward) - extra;
} else {
pos += forward * (expand + extra);
vLine2.y = expand;
if (capType >= CAP_BUTT) {
dy2 -= expand + extra;
}
}
}
} else if (type >= JOINT_CAP_ROUND && type < JOINT_CAP_ROUND + 1.5) {
base += shift * norm;
if (inner > 0.5) {
dy = -dy;
inner = 0.0;
}
vec2 d2 = abs(dy) * forward;
if (vertexNum < 4.5) {
dy = -dy;
pos = dy * norm;
} else if (vertexNum < 5.5) {
pos = dy * norm;
} else if (vertexNum < 6.5) {
pos = dy * norm + d2;
vArc.x = abs(dy);
} else {
dy = -dy;
pos = dy * norm + d2;
vArc.x = abs(dy);
}
vLine2 = vec4(0.0, lineWidth * 2.0 + 10.0, 1.0 , 0.0); // forget about line2 with type=3
vArc.y = dy;
vArc.z = 0.0;
vArc.w = lineWidth;
vType = 3.0;
} else if (abs(D) < 0.01 && collinear < 0.5) {
pos = dy * norm;
} else {
if (inner > 0.5) {
dy = -dy;
inner = 0.0;
}
float side = sign(dy);
vec2 norm3 = normalize(norm + norm2);
if (type >= MITER && type < MITER + 3.5) {
vec2 farVertex = doBisect(norm, len, norm2, len2, shift + dy, 0.0);
if (length(farVertex) > abs(shift + dy) * MITER_LIMIT) {
type = BEVEL;
}
}
if (vertexNum < 4.5) {
pos = doBisect(norm, len, norm2, len2, shift - dy, 1.0);
} else if (vertexNum < 5.5) {
pos = (shift + dy) * norm;
} else if (vertexNum > 7.5) {
pos = (shift + dy) * norm2;
} else {
if (type >= ROUND && type < ROUND + 1.5) {
pos = doBisect(norm, len, norm2, len2, shift + dy, 0.0);
float d2 = abs(shift + dy);
if (length(pos) > abs(shift + dy) * 1.5) {
if (vertexNum < 6.5) {
pos.x = (shift + dy) * norm.x - d2 * norm.y;
pos.y = (shift + dy) * norm.y + d2 * norm.x;
} else {
pos.x = (shift + dy) * norm2.x + d2 * norm2.y;
pos.y = (shift + dy) * norm2.y - d2 * norm2.x;
}
}
} else if (type >= MITER && type < MITER + 3.5) {
pos = doBisect(norm, len, norm2, len2, shift + dy, 0.0); //farVertex
} else if (type >= BEVEL && type < BEVEL + 1.5) {
float d2 = side / resolution;
if (vertexNum < 6.5) {
pos = (shift + dy) * norm + d2 * norm3;
} else {
pos = (shift + dy) * norm2 + d2 * norm3;
}
}
}
if (type >= ROUND && type < ROUND + 1.5) {
vArc.x = side * dot(pos, norm3);
vArc.y = pos.x * norm3.y - pos.y * norm3.x;
vArc.z = dot(norm, norm3) * (lineWidth + side * shift);
vArc.w = lineWidth + side * shift;
vType = 3.0;
} else if (type >= MITER && type < MITER + 3.5) {
vType = 1.0;
} else if (type >= BEVEL && type < BEVEL + 1.5) {
vType = 4.0;
vArc.z = dot(norm, norm3) * (lineWidth + side * shift) - side * dot(pos, norm3);
}
dy = side * (dot(pos, norm) - shift);
dy2 = side * (dot(pos, norm2) - shift);
}
pos += base;
vLine1.xy = vec2(dy, vLine1.y) * resolution;
vLine2.xy = vec2(dy2, vLine2.y) * resolution;
vArc = vArc * resolution;
vTravel = vec2(aTravel * avgScale + dot(pos - pointA, vec2(-norm.y, norm.x)), avgScale);
}
gl_Position = vec4((projectionMatrix * vec3(pos, 1.0)).xy, 0.0, 1.0);
vColor = aColor * tint;
}`,jt=`#version 100
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
`,Tt=`%PRECISION%
varying vec4 vColor;
varying vec4 vLine1;
varying vec4 vLine2;
varying vec4 vArc;
varying float vType;
varying float vTextureId;
varying vec2 vTextureCoord;
varying vec2 vTravel;
uniform sampler2D uSamplers[%MAX_TEXTURES%];
%PIXEL_LINE%
void main(void){
%PIXEL_COVERAGE%
vec4 texColor;
float textureId = floor(vTextureId+0.5);
%FOR_LOOP%
gl_FragColor = vColor * texColor * alpha;
}
`,Vt=[`
float pixelLine(float x, float A, float B) {
return clamp(x + 0.5, 0.0, 1.0);
}
`,`
float pixelLine(float x, float A, float B) {
float y = abs(x), s = sign(x);
if (y * 2.0 < A - B) {
return 0.5 + s * y / A;
}
y -= (A - B) * 0.5;
y = max(1.0 - y / B, 0.0);
return (1.0 + s * (1.0 - y * y)) * 0.5;
//return clamp(x + 0.5, 0.0, 1.0);
}
`],Ht=`float alpha = 1.0;
if (vType < 0.5) {
float left = pixelLine(-vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float right = pixelLine(vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float near = vLine2.x - 0.5;
float far = min(vLine2.x + 0.5, 0.0);
float top = vLine2.y - 0.5;
float bottom = min(vLine2.y + 0.5, 0.0);
alpha = (right - left) * max(bottom - top, 0.0) * max(far - near, 0.0);
} else if (vType < 1.5) {
float a1 = pixelLine(- vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float a2 = pixelLine(vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float b1 = pixelLine(- vLine2.y - vLine2.x, vLine2.z, vLine2.w);
float b2 = pixelLine(vLine2.y - vLine2.x, vLine2.z, vLine2.w);
alpha = a2 * b2 - a1 * b1;
} else if (vType < 2.5) {
alpha *= max(min(vLine1.x + 0.5, 1.0), 0.0);
alpha *= max(min(vLine1.y + 0.5, 1.0), 0.0);
alpha *= max(min(vLine1.z + 0.5, 1.0), 0.0);
} else if (vType < 3.5) {
float a1 = pixelLine(- vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float a2 = pixelLine(vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float b1 = pixelLine(- vLine2.y - vLine2.x, vLine2.z, vLine2.w);
float b2 = pixelLine(vLine2.y - vLine2.x, vLine2.z, vLine2.w);
float alpha_miter = a2 * b2 - a1 * b1;
float alpha_plane = clamp(vArc.z - vArc.x + 0.5, 0.0, 1.0);
float d = length(vArc.xy);
float circle_hor = max(min(vArc.w, d + 0.5) - max(-vArc.w, d - 0.5), 0.0);
float circle_vert = min(vArc.w * 2.0, 1.0);
float alpha_circle = circle_hor * circle_vert;
alpha = min(alpha_miter, max(alpha_circle, alpha_plane));
} else {
float a1 = pixelLine(- vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float a2 = pixelLine(vLine1.y - vLine1.x, vLine1.z, vLine1.w);
float b1 = pixelLine(- vLine2.y - vLine2.x, vLine2.z, vLine2.w);
float b2 = pixelLine(vLine2.y - vLine2.x, vLine2.z, vLine2.w);
alpha = a2 * b2 - a1 * b1;
alpha *= clamp(vArc.z + 0.5, 0.0, 1.0);
}
`;class z extends Pt{constructor(t,s=_t,e=Tt,r={}){s=z.generateVertexSrc(t,s),e=z.generateFragmentSrc(t,e);const{maxStyles:i,maxTextures:l}=t,a=new Int32Array(l);for(let c=0;c<l;c++)a[c]=c;super(At.from(s,e),Object.assign(r,{styleMatrix:new Float32Array(6*i),styleTextureId:new Float32Array(i),styleLine:new Float32Array(2*i),samplerSize:new Float32Array(2*l),uSamplers:a,tint:new Float32Array([1,1,1,1]),resolution:1,expand:1})),this.settings=t}static generateVertexSrc(t,s=_t){const{maxStyles:e,maxTextures:r}=t;return s=s.replace(/%MAX_TEXTURES%/gi,`${r}`).replace(/%MAX_STYLES%/gi,`${e}`),s}static generateFragmentSrc(t,s=Tt){const{maxTextures:e,pixelLine:r}=t;return s=s.replace(/%PRECISION%/gi,jt).replace(/%PIXEL_LINE%/gi,Vt[r]).replace(/%PIXEL_COVERAGE%/gi,Ht).replace(/%MAX_TEXTURES%/gi,`${e}`).replace(/%FOR_LOOP%/gi,this.generateSampleSrc(e)),s}static generateSampleSrc(t){let s="";s+=`
`,s+=`
`;for(let e=0;e<t;e++)e>0&&(s+=`
else `),e<t-1&&(s+=`if(textureId < ${e}.5)`),s+=`
{`,s+=`
texColor = texture2D(uSamplers[${e}], vTextureCoord);`,s+=`
}`;return s+=`
`,s+=`
`,s}}const k={LINE_SCALE_MODE:M.NORMAL,SHADER_MAX_STYLES:24,SHADER_MAX_TEXTURES:4,PIXEL_LINE:0},Wt=Ut,{BezierUtils:Yt,QuadraticUtils:Gt,ArcUtils:Lt}=Ft,ot={},tt=class extends zt{constructor(n=null){super(),this._geometry=n||new lt,this._geometry.refCount++,this.shader=null,this.shaderSettings={maxStyles:k.SHADER_MAX_STYLES,maxTextures:k.SHADER_MAX_TEXTURES,pixelLine:k.PIXEL_LINE},this.state=Ot.for2d(),this._fillStyle=new Y,this._lineStyle=new et,this._matrix=null,this._holeMode=!1,this.currentPath=null,this.batches=[],this.batchTint=-1,this.batchDirty=-1,this.vertexData=null,this.pluginName="smooth",this._transformID=-1,this._tintColor=new B(16777215),this.blendMode=ct.NORMAL}get geometry(){return this._geometry}clone(){return this.finishPoly(),new tt(this._geometry)}set blendMode(n){this.state.blendMode=n}get blendMode(){return this.state.blendMode}get tint(){return this._tintColor.value}set tint(n){this._tintColor.setValue(n)}get fill(){return this._fillStyle}get line(){return this._lineStyle}lineStyle(n=null,t=0,s=1,e=.5,r=k.LINE_SCALE_MODE){if(typeof n=="number")typeof r=="boolean"&&(r=r?M.NONE:M.NORMAL),n={width:n,color:t,alpha:s,alignment:e,scaleMode:r};else{const i=n.native;i!==void 0&&(n.scaleMode=i?M.NONE:M.NORMAL)}return this.lineTextureStyle(n)}lineTextureStyle(n){n=Object.assign({width:0,texture:V.WHITE,color:n&&n.texture?16777215:0,alpha:1,matrix:null,alignment:.5,native:!1,cap:$.BUTT,join:R.MITER,miterLimit:10,shader:null,scaleMode:k.LINE_SCALE_MODE},n),this.normalizeColor(n),this.currentPath&&this.startPoly();const t=n.width>0&&n.alpha>0;return t?(n.matrix&&(n.matrix=n.matrix.clone(),n.matrix.invert()),Object.assign(this._lineStyle,{visible:t},n)):this._lineStyle.reset(),this}startPoly(){if(this.currentPath){const n=this.currentPath.points,t=this.currentPath.points.length;t>2&&(this.drawShape(this.currentPath),this.currentPath=new it,this.currentPath.closeStroke=!1,this.currentPath.points.push(n[t-2],n[t-1]))}else this.currentPath=new it,this.currentPath.closeStroke=!1}finishPoly(){this.currentPath&&(this.currentPath.points.length>2?(this.drawShape(this.currentPath),this.currentPath=null):this.currentPath.points.length=0)}moveTo(n,t){return this.startPoly(),this.currentPath.points[0]=n,this.currentPath.points[1]=t,this}lineTo(n,t){this.currentPath||this.moveTo(0,0);const s=this.currentPath.points,e=s[s.length-2],r=s[s.length-1];return(e!==n||r!==t)&&s.push(n,t),this}_initCurve(n=0,t=0){this.currentPath?this.currentPath.points.length===0&&(this.currentPath.points=[n,t]):this.moveTo(n,t)}quadraticCurveTo(n,t,s,e){this._initCurve();const r=this.currentPath.points;return r.length===0&&this.moveTo(0,0),Gt.curveTo(n,t,s,e,r),this}bezierCurveTo(n,t,s,e,r,i){return this._initCurve(),Yt.curveTo(n,t,s,e,r,i,this.currentPath.points),this}arcTo(n,t,s,e,r){this._initCurve(n,t);const i=this.currentPath.points,l=Lt.curveTo(n,t,s,e,r,i);if(l){const{cx:a,cy:c,radius:p,startAngle:u,endAngle:o,anticlockwise:h}=l;this.arc(a,c,p,u,o,h)}return this}arc(n,t,s,e,r,i=!1){if(e===r)return this;if(!i&&r<=e?r+=pt:i&&e<=r&&(e+=pt),r-e===0)return this;const l=n+Math.cos(e)*s,a=t+Math.sin(e)*s,c=this._geometry.closePointEps;let p=this.currentPath?this.currentPath.points:null;if(p){const u=Math.abs(p[p.length-2]-l),o=Math.abs(p[p.length-1]-a);u<c&&o<c||p.push(l,a)}else this.moveTo(l,a),p=this.currentPath.points;return Lt.arc(l,a,n,t,s,e,r,i,p),this}beginFill(n=0,t=1,s=!1){return this.beginTextureFill({texture:V.WHITE,color:n,alpha:t,smooth:s})}normalizeColor(n){var t,s;const e=B.shared.setValue((t=n.color)!=null?t:0);n.color=e.toNumber(),(s=n.alpha)!=null||(n.alpha=e.alpha)}beginTextureFill(n){n=Object.assign({texture:V.WHITE,color:16777215,alpha:1,matrix:null,smooth:!1},n),this.normalizeColor(n),this.currentPath&&this.startPoly();const t=n.alpha>0;return t?(n.matrix&&(n.matrix=n.matrix.clone(),n.matrix.invert()),Object.assign(this._fillStyle,{visible:t},n)):this._fillStyle.reset(),this}endFill(){return this.finishPoly(),this._fillStyle.reset(),this}drawRect(n,t,s,e){return this.drawShape(new Dt(n,t,s,e))}drawRoundedRect(n,t,s,e,r){retur
varying vec4 vColor;
varying vec4 vLine1;
varying vec4 vLine2;
varying vec4 vArc;
varying float vType;
varying float vTextureId;
varying vec2 vTextureCoord;
varying vec2 vTravel;
uniform sampler2D uSamplers[%MAX_TEXTURES%];
uniform float dash;
uniform float gap;
%PIXEL_LINE%
void main(void){
%PIXEL_COVERAGE%
float d = dash * vTravel.y;
if (d > 0.0) {
float g = gap * vTravel.y;
if (g > 0.0) {
float t = mod(vTravel.x, d + g);
alpha *= mix(
min(0.5 * d + 0.5 - abs(t - 0.5 * d), 1.0),
max(abs(t - 0.5 * g - d) - 0.5 * g + 0.5, 0.0),
step(d, t)
);
}
} else {
alpha = 0.0;
}
vec4 texColor;
float textureId = floor(vTextureId+0.5);
%FOR_LOOP%
gl_FragColor = vColor * texColor * alpha;
}
`;class qt extends z{constructor(t){const s={maxStyles:16,maxTextures:1,pixelLine:1};super(s,void 0,Qt,t||{dash:8,gap:5})}}export{at as BATCH_POOL,nt as BatchDrawCall,xt as BatchPart,yt as BatchStyleArray,vt as BuildData,Z as CircleBuilder,W as DRAW_CALL_POOL,qt as DashLineShader,H as FILL_COMMANDS,Y as FillStyle,f as JOINT_TYPE,M as LINE_SCALE_MODE,et as LineStyle,rt as PolyBuilder,gt as RectangleBuilder,bt as RoundedRectangleBuilder,K as SegmentPacker,ht as SmoothGraphics,G as SmoothGraphicsData,lt as SmoothGraphicsGeometry,z as SmoothGraphicsShader,st as matrixEquals,k as settings};
//# sourceMappingURL=pixi-graphics-smooth.mjs.map