modern-path2d 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +112 -40
- package/dist/index.d.cts +131 -85
- package/dist/index.d.mts +131 -85
- package/dist/index.d.ts +131 -85
- package/dist/index.js +1 -1
- package/dist/index.mjs +107 -41
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(M,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(M=typeof globalThis<"u"?globalThis:M||self,l(M.modernPath2d={}))})(this,function(M){"use strict";var jt=Object.defineProperty;var Zt=(M,l,v)=>l in M?jt(M,l,{enumerable:!0,configurable:!0,writable:!0,value:v}):M[l]=v;var T=(M,l,v)=>Zt(M,typeof l!="symbol"?l+"":l,v);class l{constructor(e=0,t=0){this.x=e,this.y=t}static get MAX(){return new l(1/0,1/0)}static get MIN(){return new l(-1/0,-1/0)}set(e,t){return this.x=e,this.y=t,this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y;return t*t+s*s}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}multiplyScalar(e){return this.x*=e,this.y*=e,this}divideScalar(e){return this.multiplyScalar(1/e)}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}normalize(){return this.divideScalar(this.length()||1)}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this}equals(e){return this.x===e.x&&this.y===e.y}applyMatrix3(e){const t=this.x,s=this.y,n=e.elements;return this.x=n[0]*t+n[3]*s+n[6],this.y=n[1]*t+n[4]*s+n[7],this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new l(this.x,this.y)}}class v{constructor(e=0,t=0,s=0,n=0){this.left=e,this.top=t,this.width=s,this.height=n}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}get right(){return this.left+this.width}get bottom(){return this.top+this.height}static from(...e){const t=e[0],s=e.slice(1).reduce((n,o)=>(n.left=Math.min(n.left,o.left),n.top=Math.min(n.top,o.top),n.right=Math.max(n.right,o.right),n.bottom=Math.max(n.bottom,o.bottom),n),{left:(t==null?void 0:t.left)??0,top:(t==null?void 0:t.top)??0,right:(t==null?void 0:t.right)??0,bottom:(t==null?void 0:t.bottom)??0});return new v(s.left,s.top,s.right-s.left,s.bottom-s.top)}translate(e,t){return this.left+=e,this.top+=t,this}getCenterPoint(){return new l((this.left+this.right)/2,(this.top+this.bottom)/2)}clone(){return new v(this.left,this.top,this.width,this.height)}toArray(){return[this.left,this.top,this.width,this.height]}}class C{constructor(e=1,t=0,s=0,n=0,o=1,i=0,a=0,c=0,h=1){T(this,"elements",[]);this.set(e,t,s,n,o,i,a,c,h)}set(e,t,s,n,o,i,a,c,h){const u=this.elements;return u[0]=e,u[1]=n,u[2]=a,u[3]=t,u[4]=o,u[5]=c,u[6]=s,u[7]=i,u[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,n=t.elements,o=this.elements,i=s[0],a=s[3],c=s[6],h=s[1],u=s[4],g=s[7],f=s[2],p=s[5],y=s[8],x=n[0],d=n[3],w=n[6],L=n[1],b=n[4],k=n[7],N=n[2],$=n[5],q=n[8];return o[0]=i*x+a*L+c*N,o[3]=i*d+a*b+c*$,o[6]=i*w+a*k+c*q,o[1]=h*x+u*L+g*N,o[4]=h*d+u*b+g*$,o[7]=h*w+u*k+g*q,o[2]=f*x+p*L+y*N,o[5]=f*d+p*b+y*$,o[8]=f*w+p*k+y*q,this}invert(){const e=this.elements,t=e[0],s=e[1],n=e[2],o=e[3],i=e[4],a=e[5],c=e[6],h=e[7],u=e[8],g=u*i-a*h,f=a*c-u*o,p=h*o-i*c,y=t*g+s*f+n*p;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/y;return e[0]=g*x,e[1]=(n*h-u*s)*x,e[2]=(a*s-n*i)*x,e[3]=f*x,e[4]=(u*t-n*c)*x,e[5]=(n*o-a*t)*x,e[6]=p*x,e[7]=(s*c-h*t)*x,e[8]=(i*t-s*o)*x,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}scale(e,t){return this.premultiply(U.makeScale(e,t)),this}rotate(e){return this.premultiply(U.makeRotation(-e)),this}translate(e,t){return this.premultiply(U.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,s,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}fromArray(e,t=0){for(let s=0;s<9;s++)this.elements[s]=e[s+t];return this}clone(){return new this.constructor().fromArray(this.elements)}}const U=new C;function W(r,e,t,s){const n=r*t+e*s,o=Math.sqrt(r*r+e*e)*Math.sqrt(t*t+s*s);let i=Math.acos(Math.max(-1,Math.min(1,n/o)));return r*s-e*t<0&&(i=-i),i}function Mt(r,e,t,s,n,o,i,a){if(e===0||t===0){r.lineTo(a.x,a.y);return}s=s*Math.PI/180,e=Math.abs(e),t=Math.abs(t);const c=(i.x-a.x)/2,h=(i.y-a.y)/2,u=Math.cos(s)*c+Math.sin(s)*h,g=-Math.sin(s)*c+Math.cos(s)*h;let f=e*e,p=t*t;const y=u*u,x=g*g,d=y/f+x/p;if(d>1){const dt=Math.sqrt(d);e=dt*e,t=dt*t,f=e*e,p=t*t}const w=f*x+p*y,L=(f*p-w)/w;let b=Math.sqrt(Math.max(0,L));n===o&&(b=-b);const k=b*e*g/t,N=-b*t*u/e,$=Math.cos(s)*k-Math.sin(s)*N+(i.x+a.x)/2,q=Math.sin(s)*k+Math.cos(s)*N+(i.y+a.y)/2,F=W(1,0,(u-k)/e,(g-N)/t),Q=W((u-k)/e,(g-N)/t,(-u-k)/e,(-g-N)/t)%(Math.PI*2);r.ellipse($,q,e,t,s,F,F+Q,o===1)}function D(r,e){return r-(e-r)}function H(r,e){const t=new l,s=new l;for(let n=0,o=r.length;n<o;n++){const i=r[n];if(i.type==="m"||i.type==="M")i.type==="m"?t.add(i):t.copy(i),e.moveTo(t.x,t.y),s.copy(t);else if(i.type==="h"||i.type==="H")i.type==="h"?t.x+=i.x:t.x=i.x,e.lineTo(t.x,t.y),s.copy(t);else if(i.type==="v"||i.type==="V")i.type==="v"?t.y+=i.y:t.y=i.y,e.lineTo(t.x,t.y),s.copy(t);else if(i.type==="l"||i.type==="L")i.type==="l"?t.add(i):t.copy(i),e.lineTo(t.x,t.y),s.copy(t);else if(i.type==="c"||i.type==="C")i.type==="c"?(e.bezierCurveTo(t.x+i.x1,t.y+i.y1,t.x+i.x2,t.y+i.y2,t.x+i.x,t.y+i.y),s.x=t.x+i.x2,s.y=t.y+i.y2,t.add(i)):(e.bezierCurveTo(i.x1,i.y1,i.x2,i.y2,i.x,i.y),s.x=i.x2,s.y=i.y2,t.copy(i));else if(i.type==="s"||i.type==="S")i.type==="s"?(e.bezierCurveTo(D(t.x,s.x),D(t.y,s.y),t.x+i.x2,t.y+i.y2,t.x+i.x,t.y+i.y),s.x=t.x+i.x2,s.y=t.y+i.y2,t.add(i)):(e.bezierCurveTo(D(t.x,s.x),D(t.y,s.y),i.x2,i.y2,i.x,i.y),s.x=i.x2,s.y=i.y2,t.copy(i));else if(i.type==="q"||i.type==="Q")i.type==="q"?(e.quadraticCurveTo(t.x+i.x1,t.y+i.y1,t.x+i.x,t.y+i.y),s.x=t.x+i.x1,s.y=t.y+i.y1,t.add(i)):(e.quadraticCurveTo(i.x1,i.y1,i.x,i.y),s.x=i.x1,s.y=i.y1,t.copy(i));else if(i.type==="t"||i.type==="T"){const a=D(t.x,s.x),c=D(t.y,s.y);s.x=a,s.y=c,i.type==="t"?(e.quadraticCurveTo(a,c,t.x+i.x,t.y+i.y),t.add(i)):(e.quadraticCurveTo(a,c,i.x,i.y),t.copy(i))}else if(i.type==="a"||i.type==="A"){const a=t.clone();if(i.type==="a"){if(i.x===0&&i.y===0)continue;t.add(i)}else{if(t.equals(i))continue;t.copy(i)}s.copy(t),Mt(e,i.rx,i.ry,i.angle,i.largeArcFlag,i.sweepFlag,a,t)}else i.type==="z"||i.type==="Z"?(e.startPoint&&t.copy(e.startPoint),e.closePath()):console.warn("Unsupported commands",i)}}const P={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function S(r,e,t=0){let a=0,c=!0,h="",u="";const g=[];function f(d,w,L){const b=new SyntaxError(`Unexpected character "${d}" at index ${w}.`);throw b.partial=L,b}function p(){h!==""&&(u===""?g.push(Number(h)):g.push(Number(h)*10**Number(u))),h="",u=""}let y;const x=r.length;for(let d=0;d<x;d++){if(y=r[d],Array.isArray(e)&&e.includes(g.length%t)&&P.FLAGS.test(y)){a=1,h=y,p();continue}if(a===0){if(P.WHITESPACE.test(y))continue;if(P.DIGIT.test(y)||P.SIGN.test(y)){a=1,h=y;continue}if(P.POINT.test(y)){a=2,h=y;continue}P.COMMA.test(y)&&(c&&f(y,d,g),c=!0)}if(a===1){if(P.DIGIT.test(y)){h+=y;continue}if(P.POINT.test(y)){h+=y,a=2;continue}if(P.EXP.test(y)){a=3;continue}P.SIGN.test(y)&&h.length===1&&P.SIGN.test(h[0])&&f(y,d,g)}if(a===2){if(P.DIGIT.test(y)){h+=y;continue}if(P.EXP.test(y)){a=3;continue}P.POINT.test(y)&&h[h.length-1]==="."&&f(y,d,g)}if(a===3){if(P.DIGIT.test(y)){u+=y;continue}if(P.SIGN.test(y)){if(u===""){u+=y;continue}u.length===1&&P.SIGN.test(u)&&f(y,d,g)}}P.WHITESPACE.test(y)?(p(),a=0,c=!1):P.COMMA.test(y)?(p(),a=0,c=!0):P.SIGN.test(y)?(p(),a=1,h=y):P.POINT.test(y)?(p(),a=2,h=y):f(y,d,g)}return p(),g}function mt(r){switch(r.type){case"m":case"M":return`${r.type} ${r.x} ${r.y}`;case"h":case"H":return`${r.type} ${r.x}`;case"v":case"V":return`${r.type} ${r.y}`;case"l":case"L":return`${r.type} ${r.x} ${r.y}`;case"c":case"C":return`${r.type} ${r.x1} ${r.y1} ${r.x2} ${r.y2} ${r.x} ${r.y}`;case"s":case"S":return`${r.type} ${r.x2} ${r.y2} ${r.x} ${r.y}`;case"q":case"Q":return`${r.type} ${r.x1} ${r.y1} ${r.x} ${r.y}`;case"t":case"T":return`${r.type} ${r.x} ${r.y}`;case"a":case"A":return`${r.type} ${r.rx} ${r.ry} ${r.angle} ${r.largeArcFlag} ${r.sweepFlag} ${r.x} ${r.y}`;case"z":case"Z":return r.type;default:return""}}function Pt(r){let e="";for(let t=0,s=r.length;t<s;t++)e+=`${mt(r[t])} `;return e}const Tt=/[a-df-z][^a-df-z]*/gi;function V(r){const e=[],t=r.match(Tt);if(!t)return e;for(let s=0,n=t.length;s<n;s++){const o=t[s],i=o.charAt(0),a=o.slice(1).trim();let c;switch(i){case"m":case"M":c=S(a);for(let h=0,u=c.length;h<u;h+=2)h===0?e.push({type:i,x:c[h],y:c[h+1]}):e.push({type:i==="m"?"l":"L",x:c[h],y:c[h+1]});break;case"h":case"H":c=S(a);for(let h=0,u=c.length;h<u;h++)e.push({type:i,x:c[h]});break;case"v":case"V":c=S(a);for(let h=0,u=c.length;h<u;h++)e.push({type:i,y:c[h]});break;case"l":case"L":c=S(a);for(let h=0,u=c.length;h<u;h+=2)e.push({type:i,x:c[h],y:c[h+1]});break;case"c":case"C":c=S(a);for(let h=0,u=c.length;h<u;h+=6)e.push({type:i,x1:c[h],y1:c[h+1],x2:c[h+2],y2:c[h+3],x:c[h+4],y:c[h+5]});break;case"s":case"S":c=S(a);for(let h=0,u=c.length;h<u;h+=4)e.push({type:i,x2:c[h],y2:c[h+1],x:c[h+2],y:c[h+3]});break;case"q":case"Q":c=S(a);for(let h=0,u=c.length;h<u;h+=4)e.push({type:i,x1:c[h],y1:c[h+1],x:c[h+2],y:c[h+3]});break;case"t":case"T":c=S(a);for(let h=0,u=c.length;h<u;h+=2)e.push({type:i,x:c[h],y:c[h+1]});break;case"a":case"A":c=S(a,[3,4],7);for(let h=0,u=c.length;h<u;h+=7)e.push({type:i,rx:c[h],ry:c[h+1],angle:c[h+2],largeArcFlag:c[h+3],sweepFlag:c[h+4],x:c[h+5],y:c[h+6]});break;case"z":case"Z":e.push({type:i});break;default:console.warn(o)}}return e}class A{constructor(){T(this,"arcLengthDivisions",200);T(this,"_cacheArcLengths");T(this,"_needsUpdate",!1)}getPointAt(e,t=new l){return this.getPoint(this.getUtoTmapping(e),t)}getPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return t}getSpacedPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPointAt(s/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this._cacheArcLengths&&this._cacheArcLengths.length===e+1&&!this._needsUpdate)return this._cacheArcLengths;this._needsUpdate=!1;const t=[];let s,n=this.getPoint(0),o=0;t.push(0);for(let i=1;i<=e;i++)s=this.getPoint(i/e),o+=s.distanceTo(n),t.push(o),n=s;return this._cacheArcLengths=t,t}updateArcLengths(){this._needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const s=this.getLengths();let n=0;const o=s.length;let i;t?i=t:i=e*s[o-1];let a=0,c=o-1,h;for(;a<=c;)if(n=Math.floor(a+(c-a)/2),h=s[n]-i,h<0)a=n+1;else if(h>0)c=n-1;else{c=n;break}if(n=c,s[n]===i)return n/(o-1);const u=s[n],f=s[n+1]-u,p=(i-u)/f;return(n+p)/(o-1)}getTangent(e,t=new l){const n=Math.max(0,e-1e-4),o=Math.min(1,e+1e-4);return t.copy(this.getPoint(o).sub(this.getPoint(n)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUtoTmapping(e),t)}transformPoint(e){return this}transform(e){return this.transformPoint(t=>t.applyMatrix3(e)),this}getDivisions(e){return e}getMinMax(e=l.MAX,t=l.MIN){return this.getPoints().forEach(s=>{e.x=Math.min(e.x,s.x),e.y=Math.min(e.y,s.y),t.x=Math.max(t.x,s.x),t.y=Math.max(t.y,s.y)}),{min:e,max:t}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new v(e.x,e.y,t.x-e.x,t.y-e.y)}getCommands(){return this.getPoints().map((e,t)=>t===0?{type:"M",x:e.x,y:e.y}:{type:"L",x:e.x,y:e.y})}getData(){return Pt(this.getCommands())}drawTo(e){return this}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}clone(){return new this.constructor().copy(this)}}class O extends A{constructor(e,t,s=0,n=Math.PI*2){super(),this.center=e,this.radius=t,this.start=s,this.end=n}getPoint(e){const{radius:t,center:s}=this;return s.clone().add(this.getNormal(e).clone().multiplyScalar(t))}getTangent(e){const{x:t,y:s}=this.getNormal(e);return new l(-s,t)}getNormal(e){const{start:t,end:s}=this,n=e*(s-t)+t-.5*Math.PI;return new l(Math.cos(n),Math.sin(n))}transformPoint(e){return e(this.center),this}getMinMax(e=l.MAX,t=l.MIN){return e.x=Math.min(e.x,this.center.x-this.radius),e.y=Math.min(e.y,this.center.y-this.radius),t.x=Math.max(t.x,this.center.x+this.radius),t.y=Math.max(t.y,this.center.y+this.radius),{min:e,max:t}}}function j(r,e,t,s,n){const o=(s-e)*.5,i=(n-t)*.5,a=r*r,c=r*a;return(2*t-2*s+o+i)*c+(-3*t+3*s-2*o-i)*a+o*r+t}function wt(r,e){const t=1-r;return t*t*e}function bt(r,e){return 2*(1-r)*r*e}function vt(r,e){return r*r*e}function Z(r,e,t,s){return wt(r,e)+bt(r,t)+vt(r,s)}function Ct(r,e){const t=1-r;return t*t*t*e}function At(r,e){const t=1-r;return 3*t*t*r*e}function It(r,e){return 3*(1-r)*r*r*e}function kt(r,e){return r*r*r*e}function J(r,e,t,s,n){return Ct(r,e)+At(r,t)+It(r,s)+kt(r,n)}class K extends A{constructor(e=new l,t=new l,s=new l,n=new l){super(),this.start=e,this.startControl=t,this.endControl=s,this.end=n}getPoint(e,t=new l){const{start:s,startControl:n,endControl:o,end:i}=this;return t.set(J(e,s.x,n.x,o.x,i.x),J(e,s.y,n.y,o.y,i.y)),t}transformPoint(e){return e(this.start),e(this.startControl),e(this.endControl),e(this.end),this}getMinMax(e=l.MAX,t=l.MIN){const{start:s,startControl:n,endControl:o,end:i}=this;return e.x=Math.min(e.x,s.x,n.x,o.x,i.x),e.y=Math.min(e.y,s.y,n.y,o.y,i.y),t.x=Math.max(t.x,s.x,n.x,o.x,i.x),t.y=Math.max(t.y,s.y,n.y,o.y,i.y),{min:e,max:t}}getCommands(){const{start:e,startControl:t,endControl:s,end:n}=this;return[{type:"M",x:e.x,y:e.y},{type:"C",x1:t.x,y1:t.y,x2:s.x,y2:s.y,x:n.x,y:n.y}]}drawTo(e){const{startControl:t,endControl:s,end:n}=this;return e.bezierCurveTo(t.x,t.y,s.x,s.y,n.x,n.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.startControl.copy(e.startControl),this.endControl.copy(e.endControl),this.end.copy(e.end),this}}const Nt=new C,tt=new C,et=new C,R=new l;class st extends A{constructor(e=new l,t=1,s=1,n=0,o=0,i=Math.PI*2,a=!1){super(),this.center=e,this.radiusX=t,this.radiusY=s,this.rotation=n,this.startAngle=o,this.endAngle=i,this.clockwise=a}getPoint(e,t=new l){const s=Math.PI*2;let n=this.endAngle-this.startAngle;const o=Math.abs(n)<Number.EPSILON;for(;n<0;)n+=s;for(;n>s;)n-=s;n<Number.EPSILON&&(o?n=0:n=s),this.clockwise&&!o&&(n===s?n=-s:n=n-s);const i=this.startAngle+e*n;let a=this.center.x+this.radiusX*Math.cos(i),c=this.center.y+this.radiusY*Math.sin(i);if(this.rotation!==0){const h=Math.cos(this.rotation),u=Math.sin(this.rotation),g=a-this.center.x,f=c-this.center.y;a=g*h-f*u+this.center.x,c=g*u+f*h+this.center.y}return t.set(a,c)}getDivisions(e=12){return e*2}getCommands(){const{center:e,radiusX:t,radiusY:s,startAngle:n,endAngle:o,clockwise:i,rotation:a}=this,{x:c,y:h}=e,u=c+t*Math.cos(n)*Math.cos(a)-s*Math.sin(n)*Math.sin(a),g=h+t*Math.cos(n)*Math.sin(a)+s*Math.sin(n)*Math.cos(a),f=Math.abs(n-o),p=f>Math.PI?1:0,y=i?1:0,x=a*180/Math.PI;if(f>=2*Math.PI){const d=n+Math.PI,w=c+t*Math.cos(d)*Math.cos(a)-s*Math.sin(d)*Math.sin(a),L=h+t*Math.cos(d)*Math.sin(a)+s*Math.sin(d)*Math.cos(a);return[{type:"M",x:u,y:g},{type:"A",rx:t,ry:s,angle:x,largeArcFlag:0,sweepFlag:y,x:w,y:L},{type:"A",rx:t,ry:s,angle:x,largeArcFlag:0,sweepFlag:y,x:u,y:g}]}else{const d=c+t*Math.cos(o)*Math.cos(a)-s*Math.sin(o)*Math.sin(a),w=h+t*Math.cos(o)*Math.sin(a)+s*Math.sin(o)*Math.cos(a);return[{type:"M",x:u,y:g},{type:"A",rx:t,ry:s,angle:x,largeArcFlag:p,sweepFlag:y,x:d,y:w}]}}drawTo(e){const{center:t,radiusX:s,radiusY:n,rotation:o,startAngle:i,endAngle:a,clockwise:c}=this;return e.ellipse(t.x,t.y,s,n,o,i,a,!c),this}transform(e){return R.set(this.center.x,this.center.y),R.applyMatrix3(e),this.center.x=R.x,this.center.y=R.y,Lt(e)?St(this,e):Et(this,e),this}transformPoint(e){return e(this.center),this}getMinMax(e=l.MAX,t=l.MIN){const{center:s,radiusX:n,radiusY:o,rotation:i}=this,{x:a,y:c}=s,h=Math.cos(i),u=Math.sin(i),g=Math.sqrt(n*n*h*h+o*o*u*u),f=Math.sqrt(n*n*u*u+o*o*h*h);return e.x=Math.min(e.x,a-g),e.y=Math.min(e.y,c-f),t.x=Math.max(t.x,a+g),t.y=Math.max(t.y,c+f),{min:e,max:t}}copy(e){return super.copy(e),this.center.x=e.center.x,this.center.y=e.center.y,this.radiusX=e.radiusX,this.radiusY=e.radiusY,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotation=e.rotation,this}}function St(r,e){const t=r.radiusX,s=r.radiusY,n=Math.cos(r.rotation),o=Math.sin(r.rotation),i=new l(t*n,t*o),a=new l(-s*o,s*n),c=i.applyMatrix3(e),h=a.applyMatrix3(e),u=Nt.set(c.x,h.x,0,c.y,h.y,0,0,0,1),g=tt.copy(u).invert(),y=et.copy(g).transpose().multiply(g).elements,x=$t(y[0],y[1],y[4]),d=Math.sqrt(x.rt1),w=Math.sqrt(x.rt2);if(r.radiusX=1/d,r.radiusY=1/w,r.rotation=Math.atan2(x.sn,x.cs),!((r.endAngle-r.startAngle)%(2*Math.PI)<Number.EPSILON)){const b=tt.set(d,0,0,0,w,0,0,0,1),k=et.set(x.cs,x.sn,0,-x.sn,x.cs,0,0,0,1),N=b.multiply(k).multiply(u),$=q=>{const{x:F,y:Q}=new l(Math.cos(q),Math.sin(q)).applyMatrix3(N);return Math.atan2(Q,F)};r.startAngle=$(r.startAngle),r.endAngle=$(r.endAngle),nt(e)&&(r.clockwise=!r.clockwise)}}function Et(r,e){const t=rt(e),s=it(e);r.radiusX*=t,r.radiusY*=s;const n=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);r.rotation+=n,nt(e)&&(r.startAngle*=-1,r.endAngle*=-1,r.clockwise=!r.clockwise)}function nt(r){const e=r.elements;return e[0]*e[4]-e[1]*e[3]<0}function Lt(r){const e=r.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const s=rt(r),n=it(r);return Math.abs(t/(s*n))>Number.EPSILON}function rt(r){const e=r.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function it(r){const e=r.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function $t(r,e,t){let s,n,o,i,a;const c=r+t,h=r-t,u=Math.sqrt(h*h+4*e*e);return c>0?(s=.5*(c+u),a=1/s,n=r*a*t-e*a*e):c<0?n=.5*(c-u):(s=.5*u,n=-.5*u),h>0?o=h+u:o=h-u,Math.abs(o)>2*Math.abs(e)?(a=-2*e/o,i=1/Math.sqrt(1+a*a),o=a*i):Math.abs(e)===0?(o=1,i=0):(a=-.5*o/e,o=1/Math.sqrt(1+a*a),i=a*o),h>0&&(a=o,o=-i,i=a),{rt1:s,rt2:n,cs:o,sn:i}}class z extends A{constructor(e=new l,t=new l){super(),this.start=e,this.end=t}getPoint(e,t=new l){return e===1?t.copy(this.end):t.copy(this.end).sub(this.start).multiplyScalar(e).add(this.start),t}getPointAt(e,t=new l){return this.getPoint(e,t)}getTangent(e,t=new l){return t.subVectors(this.end,this.start).normalize()}getTangentAt(e,t=new l){return this.getTangent(e,t)}getNormal(e,t=new l){const{x:s,y:n}=this.getPoint(e).sub(this.start);return t.set(n,-s).normalize()}transformPoint(e){return e(this.start),e(this.end),this}getDivisions(){return 1}getMinMax(e=l.MAX,t=l.MIN){const{start:s,end:n}=this;return e.x=Math.min(e.x,s.x,n.x),e.y=Math.min(e.y,s.y,n.y),t.x=Math.max(t.x,s.x,n.x),t.y=Math.max(t.y,s.y,n.y),{min:e,max:t}}getCommands(){const{start:e,end:t}=this;return[{type:"M",x:e.x,y:e.y},{type:"L",x:t.x,y:t.y}]}drawTo(e){const{end:t}=this;return e.lineTo(t.x,t.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.end.copy(e.end),this}}class qt extends A{constructor(t,s,n=0,o=1){super();T(this,"curveT",0);this.center=t,this.size=s,this.start=n,this.end=o,this.update()}update(){const{x:t,y:s}=this.center,n=new l(t+.5*this.size,s-.5*this.size),o=new l(t-.5*this.size,s-.5*this.size),i=new l(t,s+.5*this.size),a=new O(n,Math.SQRT1_2*this.size,-.25*Math.PI,.75*Math.PI),c=new O(o,Math.SQRT1_2*this.size,-.75*Math.PI,.25*Math.PI),h=new O(i,.5*Math.SQRT1_2*this.size,.75*Math.PI,1.25*Math.PI),u=new l(t,s+this.size),g=new l(t+this.size,s),f=new l().lerpVectors(g,u,.75),p=new l(t-this.size,s),y=new l().lerpVectors(p,u,.75),x=new z(g,f),d=new z(y,p);return this.curves=[a,x,h,d,c],this}getPoint(t){return this.getCurve(t).getPoint(this.curveT)}getPointAt(t){return this.getPoint(t)}getCurve(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1),s*=9*Math.PI/8+1.5;let n;const o=.5*Math.PI;return s<o?(n=0,this.curveT=s/o):s<o+.75?(n=1,this.curveT=(s-o)/.75):s<5*Math.PI/8+.75?(n=2,this.curveT=(s-o-.75)/(Math.PI/8)):s<5*Math.PI/8+1.5?(n=3,this.curveT=(s-5*Math.PI/8-.75)/.75):(n=4,this.curveT=(s-5*Math.PI/8-1.5)/o),this.curves[n]}getTangent(t){return this.getCurve(t).getTangent(this.curveT)}getNormal(t){return this.getCurve(t).getNormal(this.curveT)}transformPoint(t){return this.curves.forEach(s=>s.transformPoint(t)),this}getMinMax(t=l.MAX,s=l.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}getCommands(){return this.curves.flatMap(t=>t.getCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class zt extends A{constructor(t,s=0,n=0,o=0,i=1){super();T(this,"curves",[]);T(this,"curveT",0);T(this,"points",[]);this.center=t,this.radius=s,this.number=n,this.start=o,this.end=i,this.update()}update(){for(let t=0;t<this.number;t++){let s=t*2*Math.PI/this.number;s-=.5*Math.PI,this.points.push(new l(this.radius*Math.cos(s),this.radius*Math.sin(s)).add(this.center))}for(let t=0;t<this.number;t++)this.curves.push(new z(this.points[t],this.points[(t+1)%this.number]));return this}getCurve(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1);const n=s*this.number,o=Math.floor(n);return this.curveT=n-o,this.curves[o]}getPoint(t,s){return this.getCurve(t).getPoint(this.curveT,s)}getPointAt(t,s){return this.getPoint(t,s)}getTangent(t,s){return this.getCurve(t).getTangent(this.curveT,s)}getNormal(t,s){return this.getCurve(t).getNormal(this.curveT,s)}transformPoint(t){return this.curves.forEach(s=>s.transformPoint(t)),this}getMinMax(t=l.MAX,s=l.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}getCommands(){return this.curves.flatMap(t=>t.getCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class ot extends A{constructor(e=new l,t=new l,s=new l){super(),this.start=e,this.control=t,this.end=s}getPoint(e,t=new l){const{start:s,control:n,end:o}=this;return t.set(Z(e,s.x,n.x,o.x),Z(e,s.y,n.y,o.y)),t}transformPoint(e){return e(this.start),e(this.control),e(this.end),this}getMinMax(e=l.MAX,t=l.MIN){const{start:s,control:n,end:o}=this,i=.5*(s.x+n.x),a=.5*(s.y+n.y),c=.5*(s.x+o.x),h=.5*(s.y+o.y);return e.x=Math.min(e.x,s.x,o.x,i,c),e.y=Math.min(e.y,s.y,o.y,a,h),t.x=Math.max(t.x,s.x,o.x,i,c),t.y=Math.max(t.y,s.y,o.y,a,h),{min:e,max:t}}getCommands(){const{start:e,control:t,end:s}=this;return[{type:"M",x:e.x,y:e.y},{type:"Q",x1:t.x,y1:t.y,x:s.x,y:s.y}]}drawTo(e){const{control:t,end:s}=this;return e.quadraticCurveTo(t.x,t.y,s.x,s.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.control.copy(e.control),this.end.copy(e.end),this}}class at extends A{constructor(t,s,n=1,o=0,i=1){super();T(this,"curves",[]);T(this,"curveT",0);this.center=t,this.rx=s,this.aspectRatio=n,this.start=o,this.end=i,this.update()}get x(){return this.center.x-this.rx}get y(){return this.center.y-this.rx/this.aspectRatio}get width(){return this.rx*2}get height(){return this.rx/this.aspectRatio*2}update(){const{x:t,y:s}=this.center,n=this.rx,o=this.rx/this.aspectRatio,i=[new l(t-n,s-o),new l(t+n,s-o),new l(t+n,s+o),new l(t-n,s+o)];for(let a=0;a<4;a++)this.curves.push(new z(i[a].clone(),i[(a+1)%4].clone()));return this}getCurve(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1),s*=(1+this.aspectRatio)*2;let n;return s<this.aspectRatio?(n=0,this.curveT=s/this.aspectRatio):s<this.aspectRatio+1?(n=1,this.curveT=(s-this.aspectRatio)/1):s<2*this.aspectRatio+1?(n=2,this.curveT=(s-this.aspectRatio-1)/this.aspectRatio):(n=3,this.curveT=(s-2*this.aspectRatio-1)/1),this.curves[n]}getPoint(t,s){return this.getCurve(t).getPoint(this.curveT,s)}getPointAt(t,s){return this.getPoint(t,s)}getTangent(t,s){return this.getCurve(t).getTangent(this.curveT,s)}getNormal(t,s){return this.getCurve(t).getNormal(this.curveT,s)}transformPoint(t){return this.curves.forEach(s=>s.transformPoint(t)),this}getMinMax(t=l.MAX,s=l.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}getCommands(){return this.curves.flatMap(t=>t.getCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class ht extends A{constructor(e=[]){super(),this.points=e}getDivisions(e=12){return e*this.points.length}getPoint(e,t=new l){const{points:s}=this,n=(s.length-1)*e,o=Math.floor(n),i=n-o,a=s[o===0?o:o-1],c=s[o],h=s[o>s.length-2?s.length-1:o+1],u=s[o>s.length-3?s.length-1:o+2];return t.set(j(i,a.x,c.x,h.x,u.x),j(i,a.y,c.y,h.y,u.y)),t}transformPoint(e){return this.points.forEach(t=>e(t)),this}copy(e){super.copy(e),this.points=[];for(let t=0,s=e.points.length;t<s;t++)this.points.push(e.points[t].clone());return this}}class X extends A{constructor(t){super();T(this,"curves",[]);T(this,"startPoint");T(this,"currentPoint",new l);T(this,"autoClose",!1);T(this,"_cacheLengths",[]);t&&this.addPoints(t)}addCurve(t){return this.curves.push(t),this}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let s=1,n=t.length;s<n;s++){const{x:o,y:i}=t[s];this.lineTo(o,i)}return this}addCommands(t){return H(t,this),this}addData(t){return this.addCommands(V(t)),this}getPoint(t,s=new l){const n=t*this.getLength(),o=this.getCurveLengths();let i=0;for(;i<o.length;){if(o[i]>=n){const a=o[i]-n,c=this.curves[i],h=c.getLength();return c.getPointAt(h===0?0:1-a/h,s)}i++}return s}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){super.updateArcLengths(),this._cacheLengths=[],this.getCurveLengths()}getCurveLengths(){if(this._cacheLengths.length===this.curves.length)return this._cacheLengths;const t=[];let s=0;for(let n=0,o=this.curves.length;n<o;n++)s+=this.curves[n].getLength(),t.push(s);return this._cacheLengths=t,t}getSpacedPoints(t=40){const s=[];for(let n=0;n<=t;n++)s.push(this.getPoint(n/t));return this.autoClose&&s.push(s[0]),s}getPoints(t=12){const s=[];let n;for(let o=0,i=this.curves;o<i.length;o++){const a=i[o],c=a.getPoints(a.getDivisions(t));for(let h=0;h<c.length;h++){const u=c[h];n!=null&&n.equals(u)||(s.push(u),n=u)}}return this.autoClose&&s.length>1&&!s[s.length-1].equals(s[0])&&s.push(s[0]),s}_setCurrentPoint(t){return this.currentPoint.copy(t),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}closePath(){const t=this.startPoint;if(t){const s=this.currentPoint;t.equals(s)||(this.curves.push(new z(s,t)),this.currentPoint.copy(t)),this.startPoint=void 0}return this}moveTo(t,s){return this.currentPoint.set(t,s),this.startPoint=this.currentPoint.clone(),this}lineTo(t,s){return this.curves.push(new z(this.currentPoint.clone(),new l(t,s))),this._setCurrentPoint({x:t,y:s}),this}bezierCurveTo(t,s,n,o,i,a){return this.curves.push(new K(this.currentPoint.clone(),new l(t,s),new l(n,o),new l(i,a))),this._setCurrentPoint({x:i,y:a}),this}quadraticCurveTo(t,s,n,o){return this.curves.push(new ot(this.currentPoint.clone(),new l(t,s),new l(n,o))),this._setCurrentPoint({x:n,y:o}),this}arc(t,s,n,o,i,a){return this.ellipse(t,s,n,n,0,o,i,a),this}relativeArc(t,s,n,o,i,a){const c=this.currentPoint;return this.arc(t+c.x,s+c.y,n,o,i,a),this}arcTo(t,s,n,o,i){return console.warn("Method arcTo not supported yet"),this}ellipse(t,s,n,o,i,a,c,h=!0){const u=new st(new l(t,s),n,o,i,a,c,!h);if(this.curves.length>0){const g=u.getPoint(0);g.equals(this.currentPoint)||this.lineTo(g.x,g.y)}return this.curves.push(u),this._setCurrentPoint(u.getPoint(1)),this}relativeEllipse(t,s,n,o,i,a,c,h){const u=this.currentPoint;return this.ellipse(t+u.x,s+u.y,n,o,i,a,c,h),this}rect(t,s,n,o){return this.curves.push(new at(new l(t+n/2,s+o/2),n/2,n/o)),this._setCurrentPoint({x:t,y:s}),this}splineThru(t){return this.curves.push(new ht([this.currentPoint.clone()].concat(t))),this._setCurrentPoint(t[t.length-1]),this}transformPoint(t){return this.curves.forEach(s=>s.transformPoint(t)),this}getMinMax(t=l.MAX,s=l.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}getBoundingBox(){const{min:t,max:s}=this.getMinMax();return new v(t.x,t.y,s.x-t.x,s.y-t.y)}getCommands(){return this.curves.flatMap(t=>t.getCommands())}drawTo(t){var n;const s=(n=this.curves[0])==null?void 0:n.getPoint(0);return s&&t.moveTo(s.x,s.y),this.curves.forEach(o=>o.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){super.copy(t),this.curves=[];for(let s=0,n=t.curves.length;s<n;s++)this.curves.push(t.curves[s].clone());return this.autoClose=t.autoClose,this.currentPoint.copy(t.currentPoint),this}}class I{constructor(e){T(this,"currentPath",new X);T(this,"paths",[this.currentPath]);T(this,"userData");e&&(e instanceof I?this.addPath(e):Array.isArray(e)?this.addCommands(e):this.addData(e))}get startPoint(){return this.currentPath.startPoint}get currentPoint(){return this.currentPath.currentPoint}addPath(e){return e instanceof I?this.paths.push(...e.paths.map(t=>t.clone())):this.paths.push(e),this}closePath(){const e=this.startPoint;return e&&(this.currentPath.closePath(),this.currentPath.curves.length>0&&(this.currentPath=new X().moveTo(e.x,e.y),this.paths.push(this.currentPath))),this}moveTo(e,t){const{currentPoint:s,curves:n}=this.currentPath;return s.equals({x:e,y:t})||(n.length?(this.currentPath=new X().moveTo(e,t),this.paths.push(this.currentPath)):this.currentPath.moveTo(e,t)),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}bezierCurveTo(e,t,s,n,o,i){return this.currentPath.bezierCurveTo(e,t,s,n,o,i),this}quadraticCurveTo(e,t,s,n){return this.currentPath.quadraticCurveTo(e,t,s,n),this}arc(e,t,s,n,o,i){return this.currentPath.arc(e,t,s,n,o,i),this}arcTo(e,t,s,n,o){return this.currentPath.arcTo(e,t,s,n,o),this}ellipse(e,t,s,n,o,i,a,c){return this.currentPath.ellipse(e,t,s,n,o,i,a,c),this}rect(e,t,s,n){return this.currentPath.rect(e,t,s,n),this}addCommands(e){return H(e,this),this}addData(e){return this.addCommands(V(e)),this}splineThru(e){return this.currentPath.splineThru(e),this}forEachCurve(e){return this.paths.forEach(t=>t.curves.forEach(s=>e(s))),this}transformPoint(e){return this.forEachCurve(t=>t.transformPoint(e)),this}transform(e){return this.forEachCurve(t=>t.transform(e)),this}getMinMax(e=l.MAX,t=l.MIN){return this.forEachCurve(s=>s.getMinMax(e,t)),{min:e,max:t}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new v(e.x,e.y,t.x-e.x,t.y-e.y)}getCommands(){return this.paths.flatMap(e=>e.getCommands())}getData(){return this.paths.map(e=>e.getData()).join(" ")}getSvgString(){const{x:e,y:t,width:s,height:n}=this.getBoundingBox(),o=1;return`<svg viewBox="${e-o} ${t-o} ${s+o*2} ${n+o*2}" xmlns="http://www.w3.org/2000/svg"><path fill="none" stroke="currentColor" d="${this.getData()}"></path></svg>`}getSvgDataUri(){return`data:image/svg+xml;base64,${btoa(this.getSvgString())}`}drawTo(e){this.paths.forEach(t=>{t.drawTo(e)})}strokeTo(e){this.drawTo(e),e.stroke()}fillTo(e){this.drawTo(e),e.fill()}copy(e){return this.currentPath=e.currentPath.clone(),this.paths=e.paths.map(t=>t.clone()),this.userData=e.userData,this}toCanvas(e=!0){const t=document.createElement("canvas"),{left:s,top:n,width:o,height:i}=this.getBoundingBox();t.width=o,t.height=i;const a=t.getContext("2d");return a&&(a.translate(-s,-n),e?this.fillTo(a):this.strokeTo(a)),t}clone(){return new this.constructor().copy(this)}}const Y="px",ct=90,ut=["mm","cm","in","pt","pc","px"],G={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function m(r){let e="px";if(typeof r=="string"||r instanceof String)for(let s=0,n=ut.length;s<n;s++){const o=ut[s];if(r.endsWith(o)){e=o,r=r.substring(0,r.length-o.length);break}}let t;return e==="px"&&Y!=="px"?t=G.in[Y]/ct:(t=G[e][Y],t<0&&(t=G[e].in*ct)),t*Number.parseFloat(r)}const Dt=new C,_=new C,lt=new C,gt=new C;function Xt(r,e,t){if(!(r.hasAttribute("transform")||r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))))return null;const s=Ot(r);return t.length>0&&s.premultiply(t[t.length-1]),e.copy(s),t.push(s),s}function Ot(r){const e=new C,t=Dt;if(r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))&&e.translate(m(r.getAttribute("x")),m(r.getAttribute("y"))),r.hasAttribute("transform")){const s=r.getAttribute("transform").split(")");for(let n=s.length-1;n>=0;n--){const o=s[n].trim();if(o==="")continue;const i=o.indexOf("("),a=o.length;if(i>0&&i<a){const c=o.slice(0,i),h=S(o.slice(i+1));switch(t.identity(),c){case"translate":if(h.length>=1){const u=h[0];let g=0;h.length>=2&&(g=h[1]),t.translate(u,g)}break;case"rotate":if(h.length>=1){let u=0,g=0,f=0;u=h[0]*Math.PI/180,h.length>=3&&(g=h[1],f=h[2]),_.makeTranslation(-g,-f),lt.makeRotation(u),gt.multiplyMatrices(lt,_),_.makeTranslation(g,f),t.multiplyMatrices(_,gt)}break;case"scale":h.length>=1&&t.scale(h[0],h[1]??h[0]);break;case"skewX":h.length===1&&t.set(1,Math.tan(h[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":h.length===1&&t.set(1,0,0,Math.tan(h[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":h.length===6&&t.set(h[0],h[2],h[4],h[1],h[3],h[5],0,0,1);break}}e.premultiply(t)}}return e}function Rt(r){return new I().addPath(new X().arc(m(r.getAttribute("cx")||0),m(r.getAttribute("cy")||0),m(r.getAttribute("r")||0),0,Math.PI*2))}function _t(r,e){if(!(!r.sheet||!r.sheet.cssRules||!r.sheet.cssRules.length))for(let t=0;t<r.sheet.cssRules.length;t++){const s=r.sheet.cssRules[t];if(s.type!==1)continue;const n=s.selectorText.split(/,/g).filter(Boolean).map(o=>o.trim());for(let o=0;o<n.length;o++){const i=Object.fromEntries(Object.entries(s.style).filter(([,a])=>a!==""));e[n[o]]=Object.assign(e[n[o]]||{},i)}}}function Ft(r){return new I().addPath(new X().ellipse(m(r.getAttribute("cx")||0),m(r.getAttribute("cy")||0),m(r.getAttribute("rx")||0),m(r.getAttribute("ry")||0),0,0,Math.PI*2))}function Ut(r){return new I().moveTo(m(r.getAttribute("x1")||0),m(r.getAttribute("y1")||0)).lineTo(m(r.getAttribute("x2")||0),m(r.getAttribute("y2")||0))}function Yt(r){const e=new I,t=r.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const Gt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Bt(r){var s;const e=new I;let t=0;return(s=r.getAttribute("points"))==null||s.replace(Gt,(n,o,i)=>{const a=m(o),c=m(i);return t===0?e.moveTo(a,c):e.lineTo(a,c),t++,n}),e.currentPath.autoClose=!0,e}const Qt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Wt(r){var s;const e=new I;let t=0;return(s=r.getAttribute("points"))==null||s.replace(Qt,(n,o,i)=>{const a=m(o),c=m(i);return t===0?e.moveTo(a,c):e.lineTo(a,c),t++,n}),e.currentPath.autoClose=!1,e}function Ht(r){const e=m(r.getAttribute("x")||0),t=m(r.getAttribute("y")||0),s=m(r.getAttribute("rx")||r.getAttribute("ry")||0),n=m(r.getAttribute("ry")||r.getAttribute("rx")||0),o=m(r.getAttribute("width")),i=m(r.getAttribute("height")),a=1-.551915024494,c=new I;return c.moveTo(e+s,t),c.lineTo(e+o-s,t),(s!==0||n!==0)&&c.bezierCurveTo(e+o-s*a,t,e+o,t+n*a,e+o,t+n),c.lineTo(e+o,t+i-n),(s!==0||n!==0)&&c.bezierCurveTo(e+o,t+i-n*a,e+o-s*a,t+i,e+o-s,t+i),c.lineTo(e+s,t+i),(s!==0||n!==0)&&c.bezierCurveTo(e+s*a,t+i,e,t+i-n*a,e,t+i-n),c.lineTo(e,t+n),(s!==0||n!==0)&&c.bezierCurveTo(e,t+n*a,e+s*a,t,e+s,t),c}function E(r,e,t){e=Object.assign({},e);let s={};if(r.hasAttribute("class")){const a=r.getAttribute("class").split(/\s/).filter(Boolean).map(c=>c.trim());for(let c=0;c<a.length;c++)s=Object.assign(s,t[`.${a[c]}`])}r.hasAttribute("id")&&(s=Object.assign(s,t[`#${r.getAttribute("id")}`]));function n(a,c,h){h===void 0&&(h=function(g){return g.startsWith("url")&&console.warn("url access in attributes is not implemented."),g}),r.hasAttribute(a)&&(e[c]=h(r.getAttribute(a))),s[a]&&(e[c]=h(s[a])),r.style&&r.style[a]!==""&&(e[c]=h(r.style[a]))}function o(a){return Math.max(0,Math.min(1,m(a)))}function i(a){return Math.max(0,m(a))}return n("fill","fill"),n("fill-opacity","fillOpacity",o),n("fill-rule","fillRule"),n("opacity","opacity",o),n("stroke","stroke"),n("stroke-dashoffset","strokeDashoffset"),n("stroke-dasharray","strokeDasharray"),n("stroke-linecap","strokeLineCap"),n("stroke-linejoin","strokeLineJoin"),n("stroke-miterlimit","strokeMiterLimit",i),n("stroke-opacity","strokeOpacity",o),n("stroke-width","strokeWidth",i),n("visibility","visibility"),e}function B(r,e,t=[]){var u;if(r.nodeType!==1)return t;let s=!1,n=null;const o={};switch(r.nodeName){case"svg":e=E(r,e,o);break;case"style":_t(r,o);break;case"g":e=E(r,e,o);break;case"path":e=E(r,e,o),r.hasAttribute("d")&&(n=Yt(r));break;case"rect":e=E(r,e,o),n=Ht(r);break;case"polygon":e=E(r,e,o),n=Bt(r);break;case"polyline":e=E(r,e,o),n=Wt(r);break;case"circle":e=E(r,e,o),n=Rt(r);break;case"ellipse":e=E(r,e,o),n=Ft(r);break;case"line":e=E(r,e,o),n=Ut(r);break;case"defs":s=!0;break;case"use":{e=E(r,e,o);const f=(r.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),p=(u=r.viewportElement)==null?void 0:u.getElementById(f);p?B(p,e,t):console.warn(`'use node' references non-existent node id: ${f}`);break}default:console.warn(r);break}const i=new C,a=[],c=Xt(r,i,a);n&&(n.transform(i),t.push(n),n.userData={node:r,style:e});const h=r.childNodes;for(let g=0,f=h.length;g<f;g++){const p=h[g];s&&p.nodeName!=="style"&&p.nodeName!=="defs"||B(p,e,t)}return c&&(a.pop(),a.length>0?i.copy(a[a.length-1]):i.identity()),t}const yt="data:image/svg+xml;",ft=`${yt}base64,`,pt=`${yt}charset=utf8,`;function xt(r){if(typeof r=="string"){let e;return r.startsWith(ft)?(r=r.substring(ft.length,r.length),e=atob(r)):r.startsWith(pt)?(r=r.substring(pt.length,r.length),e=decodeURIComponent(r)):e=r,new DOMParser().parseFromString(e,"image/svg+xml").documentElement}else return r}function Vt(r){return B(xt(r),{fill:"#000",fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:"miter",strokeLineCap:"butt",strokeMiterLimit:4})}M.BoundingBox=v,M.CircleCurve=O,M.CubicBezierCurve=K,M.Curve=A,M.CurvePath=X,M.EllipseCurve=st,M.HeartCurve=qt,M.LineCurve=z,M.Matrix3=C,M.Path2D=I,M.PloygonCurve=zt,M.QuadraticBezierCurve=ot,M.RectangularCurve=at,M.SplineCurve=ht,M.Vector2=l,M.parseSvg=Vt,M.parseSvgToDom=xt,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(p,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(p=typeof globalThis<"u"?globalThis:p||self,v(p.modernPath2d={}))})(this,function(p){"use strict";var Kt=Object.defineProperty;var te=(p,v,z)=>v in p?Kt(p,v,{enumerable:!0,configurable:!0,writable:!0,value:z}):p[v]=z;var T=(p,v,z)=>te(p,typeof v!="symbol"?v+"":v,z);const v={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function z(r,e){const{fill:t="#000",stroke:s="none",strokeWidth:n=s==="none"?0:1,strokeLinecap:o="round",strokeLinejoin:i="miter",strokeMiterlimit:c=0,strokeDasharray:h,strokeDashoffset:a=0}=e.style;r.fillStyle=t,r.strokeStyle=s,r.lineWidth=n,r.lineCap=o,r.lineJoin=v[i],r.miterLimit=c,r.lineDashOffset=a,h&&r.setLineDash(h)}class l{constructor(e=0,t=0){this.x=e,this.y=t}static get MAX(){return new l(1/0,1/0)}static get MIN(){return new l(-1/0,-1/0)}set(e,t){return this.x=e,this.y=t,this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y;return t*t+s*s}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}multiplyScalar(e){return this.x*=e,this.y*=e,this}divideScalar(e){return this.multiplyScalar(1/e)}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}normalize(){return this.divideScalar(this.length()||1)}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this}equals(e){return this.x===e.x&&this.y===e.y}applyMatrix3(e){const t=this.x,s=this.y,n=e.elements;return this.x=n[0]*t+n[3]*s+n[6],this.y=n[1]*t+n[4]*s+n[7],this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new l(this.x,this.y)}}class q{constructor(e=0,t=0,s=0,n=0){this.left=e,this.top=t,this.width=s,this.height=n}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}get right(){return this.left+this.width}get bottom(){return this.top+this.height}static from(...e){const t=e[0],s=e.slice(1).reduce((n,o)=>(n.left=Math.min(n.left,o.left),n.top=Math.min(n.top,o.top),n.right=Math.max(n.right,o.right),n.bottom=Math.max(n.bottom,o.bottom),n),{left:(t==null?void 0:t.left)??0,top:(t==null?void 0:t.top)??0,right:(t==null?void 0:t.right)??0,bottom:(t==null?void 0:t.bottom)??0});return new q(s.left,s.top,s.right-s.left,s.bottom-s.top)}translate(e,t){return this.left+=e,this.top+=t,this}getCenterPoint(){return new l((this.left+this.right)/2,(this.top+this.bottom)/2)}clone(){return new q(this.left,this.top,this.width,this.height)}toArray(){return[this.left,this.top,this.width,this.height]}}class C{constructor(e=1,t=0,s=0,n=0,o=1,i=0,c=0,h=0,a=1){T(this,"elements",[]);this.set(e,t,s,n,o,i,c,h,a)}set(e,t,s,n,o,i,c,h,a){const u=this.elements;return u[0]=e,u[1]=n,u[2]=c,u[3]=t,u[4]=o,u[5]=h,u[6]=s,u[7]=i,u[8]=a,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,n=t.elements,o=this.elements,i=s[0],c=s[3],h=s[6],a=s[1],u=s[4],y=s[7],f=s[2],d=s[5],g=s[8],x=n[0],m=n[3],w=n[6],E=n[1],b=n[4],S=n[7],N=n[2],L=n[5],D=n[8];return o[0]=i*x+c*E+h*N,o[3]=i*m+c*b+h*L,o[6]=i*w+c*S+h*D,o[1]=a*x+u*E+y*N,o[4]=a*m+u*b+y*L,o[7]=a*w+u*S+y*D,o[2]=f*x+d*E+g*N,o[5]=f*m+d*b+g*L,o[8]=f*w+d*S+g*D,this}invert(){const e=this.elements,t=e[0],s=e[1],n=e[2],o=e[3],i=e[4],c=e[5],h=e[6],a=e[7],u=e[8],y=u*i-c*a,f=c*h-u*o,d=a*o-i*h,g=t*y+s*f+n*d;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/g;return e[0]=y*x,e[1]=(n*a-u*s)*x,e[2]=(c*s-n*i)*x,e[3]=f*x,e[4]=(u*t-n*h)*x,e[5]=(n*o-c*t)*x,e[6]=d*x,e[7]=(s*h-a*t)*x,e[8]=(i*t-s*o)*x,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}scale(e,t){return this.premultiply(W.makeScale(e,t)),this}rotate(e){return this.premultiply(W.makeRotation(-e)),this}translate(e,t){return this.premultiply(W.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,s,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}fromArray(e,t=0){for(let s=0;s<9;s++)this.elements[s]=e[s+t];return this}clone(){return new this.constructor().fromArray(this.elements)}}const W=new C;function Z(r,e,t,s){const n=r*t+e*s,o=Math.sqrt(r*r+e*e)*Math.sqrt(t*t+s*s);let i=Math.acos(Math.max(-1,Math.min(1,n/o)));return r*s-e*t<0&&(i=-i),i}function J(r,e,t,s,n,o,i,c){if(e===0||t===0){r.lineTo(c.x,c.y);return}s=s*Math.PI/180,e=Math.abs(e),t=Math.abs(t);const h=(i.x-c.x)/2,a=(i.y-c.y)/2,u=Math.cos(s)*h+Math.sin(s)*a,y=-Math.sin(s)*h+Math.cos(s)*a;let f=e*e,d=t*t;const g=u*u,x=y*y,m=g/f+x/d;if(m>1){const Tt=Math.sqrt(m);e=Tt*e,t=Tt*t,f=e*e,d=t*t}const w=f*x+d*g,E=(f*d-w)/w;let b=Math.sqrt(Math.max(0,E));n===o&&(b=-b);const S=b*e*y/t,N=-b*t*u/e,L=Math.cos(s)*S-Math.sin(s)*N+(i.x+c.x)/2,D=Math.sin(s)*S+Math.cos(s)*N+(i.y+c.y)/2,U=Z(1,0,(u-S)/e,(y-N)/t),V=Z((u-S)/e,(y-N)/t,(-u-S)/e,(-y-N)/t)%(Math.PI*2);r.ellipse(L,D,e,t,s,U,U+V,o===1)}function O(r,e){return r-(e-r)}function Y(r,e){const t=new l,s=new l;for(let n=0,o=r.length;n<o;n++){const i=r[n];if(i.type==="m"||i.type==="M")i.type==="m"?t.add(i):t.copy(i),e.moveTo(t.x,t.y),s.copy(t);else if(i.type==="h"||i.type==="H")i.type==="h"?t.x+=i.x:t.x=i.x,e.lineTo(t.x,t.y),s.copy(t);else if(i.type==="v"||i.type==="V")i.type==="v"?t.y+=i.y:t.y=i.y,e.lineTo(t.x,t.y),s.copy(t);else if(i.type==="l"||i.type==="L")i.type==="l"?t.add(i):t.copy(i),e.lineTo(t.x,t.y),s.copy(t);else if(i.type==="c"||i.type==="C")i.type==="c"?(e.bezierCurveTo(t.x+i.x1,t.y+i.y1,t.x+i.x2,t.y+i.y2,t.x+i.x,t.y+i.y),s.x=t.x+i.x2,s.y=t.y+i.y2,t.add(i)):(e.bezierCurveTo(i.x1,i.y1,i.x2,i.y2,i.x,i.y),s.x=i.x2,s.y=i.y2,t.copy(i));else if(i.type==="s"||i.type==="S")i.type==="s"?(e.bezierCurveTo(O(t.x,s.x),O(t.y,s.y),t.x+i.x2,t.y+i.y2,t.x+i.x,t.y+i.y),s.x=t.x+i.x2,s.y=t.y+i.y2,t.add(i)):(e.bezierCurveTo(O(t.x,s.x),O(t.y,s.y),i.x2,i.y2,i.x,i.y),s.x=i.x2,s.y=i.y2,t.copy(i));else if(i.type==="q"||i.type==="Q")i.type==="q"?(e.quadraticCurveTo(t.x+i.x1,t.y+i.y1,t.x+i.x,t.y+i.y),s.x=t.x+i.x1,s.y=t.y+i.y1,t.add(i)):(e.quadraticCurveTo(i.x1,i.y1,i.x,i.y),s.x=i.x1,s.y=i.y1,t.copy(i));else if(i.type==="t"||i.type==="T"){const c=O(t.x,s.x),h=O(t.y,s.y);s.x=c,s.y=h,i.type==="t"?(e.quadraticCurveTo(c,h,t.x+i.x,t.y+i.y),t.add(i)):(e.quadraticCurveTo(c,h,i.x,i.y),t.copy(i))}else if(i.type==="a"||i.type==="A"){const c=t.clone();if(i.type==="a"){if(i.x===0&&i.y===0)continue;t.add(i)}else{if(t.equals(i))continue;t.copy(i)}s.copy(t),J(e,i.rx,i.ry,i.angle,i.largeArcFlag,i.sweepFlag,c,t)}else i.type==="z"||i.type==="Z"?(e.startPoint&&t.copy(e.startPoint),e.closePath()):console.warn("Unsupported commands",i)}}const P={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function A(r,e,t=0){let c=0,h=!0,a="",u="";const y=[];function f(m,w,E){const b=new SyntaxError(`Unexpected character "${m}" at index ${w}.`);throw b.partial=E,b}function d(){a!==""&&(u===""?y.push(Number(a)):y.push(Number(a)*10**Number(u))),a="",u=""}let g;const x=r.length;for(let m=0;m<x;m++){if(g=r[m],Array.isArray(e)&&e.includes(y.length%t)&&P.FLAGS.test(g)){c=1,a=g,d();continue}if(c===0){if(P.WHITESPACE.test(g))continue;if(P.DIGIT.test(g)||P.SIGN.test(g)){c=1,a=g;continue}if(P.POINT.test(g)){c=2,a=g;continue}P.COMMA.test(g)&&(h&&f(g,m,y),h=!0)}if(c===1){if(P.DIGIT.test(g)){a+=g;continue}if(P.POINT.test(g)){a+=g,c=2;continue}if(P.EXP.test(g)){c=3;continue}P.SIGN.test(g)&&a.length===1&&P.SIGN.test(a[0])&&f(g,m,y)}if(c===2){if(P.DIGIT.test(g)){a+=g;continue}if(P.EXP.test(g)){c=3;continue}P.POINT.test(g)&&a[a.length-1]==="."&&f(g,m,y)}if(c===3){if(P.DIGIT.test(g)){u+=g;continue}if(P.SIGN.test(g)){if(u===""){u+=g;continue}u.length===1&&P.SIGN.test(u)&&f(g,m,y)}}P.WHITESPACE.test(g)?(d(),c=0,h=!1):P.COMMA.test(g)?(d(),c=0,h=!0):P.SIGN.test(g)?(d(),c=1,a=g):P.POINT.test(g)?(d(),c=2,a=g):f(g,m,y)}return d(),y}function wt(r){switch(r.type){case"m":case"M":return`${r.type} ${r.x} ${r.y}`;case"h":case"H":return`${r.type} ${r.x}`;case"v":case"V":return`${r.type} ${r.y}`;case"l":case"L":return`${r.type} ${r.x} ${r.y}`;case"c":case"C":return`${r.type} ${r.x1} ${r.y1} ${r.x2} ${r.y2} ${r.x} ${r.y}`;case"s":case"S":return`${r.type} ${r.x2} ${r.y2} ${r.x} ${r.y}`;case"q":case"Q":return`${r.type} ${r.x1} ${r.y1} ${r.x} ${r.y}`;case"t":case"T":return`${r.type} ${r.x} ${r.y}`;case"a":case"A":return`${r.type} ${r.rx} ${r.ry} ${r.angle} ${r.largeArcFlag} ${r.sweepFlag} ${r.x} ${r.y}`;case"z":case"Z":return r.type;default:return""}}function K(r){let e="";for(let t=0,s=r.length;t<s;t++)e+=`${wt(r[t])} `;return e}const vt=/[a-df-z][^a-df-z]*/gi;function G(r){const e=[],t=r.match(vt);if(!t)return e;for(let s=0,n=t.length;s<n;s++){const o=t[s],i=o.charAt(0),c=o.slice(1).trim();let h;switch(i){case"m":case"M":h=A(c);for(let a=0,u=h.length;a<u;a+=2)a===0?e.push({type:i,x:h[a],y:h[a+1]}):e.push({type:i==="m"?"l":"L",x:h[a],y:h[a+1]});break;case"h":case"H":h=A(c);for(let a=0,u=h.length;a<u;a++)e.push({type:i,x:h[a]});break;case"v":case"V":h=A(c);for(let a=0,u=h.length;a<u;a++)e.push({type:i,y:h[a]});break;case"l":case"L":h=A(c);for(let a=0,u=h.length;a<u;a+=2)e.push({type:i,x:h[a],y:h[a+1]});break;case"c":case"C":h=A(c);for(let a=0,u=h.length;a<u;a+=6)e.push({type:i,x1:h[a],y1:h[a+1],x2:h[a+2],y2:h[a+3],x:h[a+4],y:h[a+5]});break;case"s":case"S":h=A(c);for(let a=0,u=h.length;a<u;a+=4)e.push({type:i,x2:h[a],y2:h[a+1],x:h[a+2],y:h[a+3]});break;case"q":case"Q":h=A(c);for(let a=0,u=h.length;a<u;a+=4)e.push({type:i,x1:h[a],y1:h[a+1],x:h[a+2],y:h[a+3]});break;case"t":case"T":h=A(c);for(let a=0,u=h.length;a<u;a+=2)e.push({type:i,x:h[a],y:h[a+1]});break;case"a":case"A":h=A(c,[3,4],7);for(let a=0,u=h.length;a<u;a+=7)e.push({type:i,rx:h[a],ry:h[a+1],angle:h[a+2],largeArcFlag:h[a+3],sweepFlag:h[a+4],x:h[a+5],y:h[a+6]});break;case"z":case"Z":e.push({type:i});break;default:console.warn(o)}}return e}class k{constructor(){T(this,"arcLengthDivisions",200);T(this,"_cacheArcLengths");T(this,"_needsUpdate",!1)}getPointAt(e,t=new l){return this.getPoint(this.getUtoTmapping(e),t)}getPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return t}getSpacedPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPointAt(s/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this._cacheArcLengths&&this._cacheArcLengths.length===e+1&&!this._needsUpdate)return this._cacheArcLengths;this._needsUpdate=!1;const t=[];let s,n=this.getPoint(0),o=0;t.push(0);for(let i=1;i<=e;i++)s=this.getPoint(i/e),o+=s.distanceTo(n),t.push(o),n=s;return this._cacheArcLengths=t,t}updateArcLengths(){this._needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const s=this.getLengths();let n=0;const o=s.length;let i;t?i=t:i=e*s[o-1];let c=0,h=o-1,a;for(;c<=h;)if(n=Math.floor(c+(h-c)/2),a=s[n]-i,a<0)c=n+1;else if(a>0)h=n-1;else{h=n;break}if(n=h,s[n]===i)return n/(o-1);const u=s[n],f=s[n+1]-u,d=(i-u)/f;return(n+d)/(o-1)}getTangent(e,t=new l){const n=Math.max(0,e-1e-4),o=Math.min(1,e+1e-4);return t.copy(this.getPoint(o).sub(this.getPoint(n)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUtoTmapping(e),t)}transformPoint(e){return this}transform(e){return this.transformPoint(t=>t.applyMatrix3(e)),this}getDivisions(e){return e}getMinMax(e=l.MAX,t=l.MIN){return this.getPoints().forEach(s=>{e.x=Math.min(e.x,s.x),e.y=Math.min(e.y,s.y),t.x=Math.max(t.x,s.x),t.y=Math.max(t.y,s.y)}),{min:e,max:t}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new q(e.x,e.y,t.x-e.x,t.y-e.y)}getCommands(){return this.getPoints().map((e,t)=>t===0?{type:"M",x:e.x,y:e.y}:{type:"L",x:e.x,y:e.y})}getData(){return K(this.getCommands())}drawTo(e){return this}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}clone(){return new this.constructor().copy(this)}}class F extends k{constructor(e,t,s=0,n=Math.PI*2){super(),this.center=e,this.radius=t,this.start=s,this.end=n}getPoint(e){const{radius:t,center:s}=this;return s.clone().add(this.getNormal(e).clone().multiplyScalar(t))}getTangent(e){const{x:t,y:s}=this.getNormal(e);return new l(-s,t)}getNormal(e){const{start:t,end:s}=this,n=e*(s-t)+t-.5*Math.PI;return new l(Math.cos(n),Math.sin(n))}transformPoint(e){return e(this.center),this}getMinMax(e=l.MAX,t=l.MIN){return e.x=Math.min(e.x,this.center.x-this.radius),e.y=Math.min(e.y,this.center.y-this.radius),t.x=Math.max(t.x,this.center.x+this.radius),t.y=Math.max(t.y,this.center.y+this.radius),{min:e,max:t}}}function tt(r,e,t,s,n){const o=(s-e)*.5,i=(n-t)*.5,c=r*r,h=r*c;return(2*t-2*s+o+i)*h+(-3*t+3*s-2*o-i)*c+o*r+t}function bt(r,e){const t=1-r;return t*t*e}function Ct(r,e){return 2*(1-r)*r*e}function At(r,e){return r*r*e}function et(r,e,t,s){return bt(r,e)+Ct(r,t)+At(r,s)}function kt(r,e){const t=1-r;return t*t*t*e}function It(r,e){const t=1-r;return 3*t*t*r*e}function St(r,e){return 3*(1-r)*r*r*e}function Nt(r,e){return r*r*r*e}function st(r,e,t,s,n){return kt(r,e)+It(r,t)+St(r,s)+Nt(r,n)}class nt extends k{constructor(e=new l,t=new l,s=new l,n=new l){super(),this.start=e,this.startControl=t,this.endControl=s,this.end=n}getPoint(e,t=new l){const{start:s,startControl:n,endControl:o,end:i}=this;return t.set(st(e,s.x,n.x,o.x,i.x),st(e,s.y,n.y,o.y,i.y)),t}transformPoint(e){return e(this.start),e(this.startControl),e(this.endControl),e(this.end),this}getMinMax(e=l.MAX,t=l.MIN){const{start:s,startControl:n,endControl:o,end:i}=this;return e.x=Math.min(e.x,s.x,n.x,o.x,i.x),e.y=Math.min(e.y,s.y,n.y,o.y,i.y),t.x=Math.max(t.x,s.x,n.x,o.x,i.x),t.y=Math.max(t.y,s.y,n.y,o.y,i.y),{min:e,max:t}}getCommands(){const{start:e,startControl:t,endControl:s,end:n}=this;return[{type:"M",x:e.x,y:e.y},{type:"C",x1:t.x,y1:t.y,x2:s.x,y2:s.y,x:n.x,y:n.y}]}drawTo(e){const{startControl:t,endControl:s,end:n}=this;return e.bezierCurveTo(t.x,t.y,s.x,s.y,n.x,n.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.startControl.copy(e.startControl),this.endControl.copy(e.endControl),this.end.copy(e.end),this}}const $t=new C,rt=new C,it=new C,_=new l;class ot extends k{constructor(e=new l,t=1,s=1,n=0,o=0,i=Math.PI*2,c=!1){super(),this.center=e,this.radiusX=t,this.radiusY=s,this.rotation=n,this.startAngle=o,this.endAngle=i,this.clockwise=c}getPoint(e,t=new l){const s=Math.PI*2;let n=this.endAngle-this.startAngle;const o=Math.abs(n)<Number.EPSILON;for(;n<0;)n+=s;for(;n>s;)n-=s;n<Number.EPSILON&&(o?n=0:n=s),this.clockwise&&!o&&(n===s?n=-s:n=n-s);const i=this.startAngle+e*n;let c=this.center.x+this.radiusX*Math.cos(i),h=this.center.y+this.radiusY*Math.sin(i);if(this.rotation!==0){const a=Math.cos(this.rotation),u=Math.sin(this.rotation),y=c-this.center.x,f=h-this.center.y;c=y*a-f*u+this.center.x,h=y*u+f*a+this.center.y}return t.set(c,h)}getDivisions(e=12){return e*2}getCommands(){const{center:e,radiusX:t,radiusY:s,startAngle:n,endAngle:o,clockwise:i,rotation:c}=this,{x:h,y:a}=e,u=h+t*Math.cos(n)*Math.cos(c)-s*Math.sin(n)*Math.sin(c),y=a+t*Math.cos(n)*Math.sin(c)+s*Math.sin(n)*Math.cos(c),f=Math.abs(n-o),d=f>Math.PI?1:0,g=i?1:0,x=c*180/Math.PI;if(f>=2*Math.PI){const m=n+Math.PI,w=h+t*Math.cos(m)*Math.cos(c)-s*Math.sin(m)*Math.sin(c),E=a+t*Math.cos(m)*Math.sin(c)+s*Math.sin(m)*Math.cos(c);return[{type:"M",x:u,y},{type:"A",rx:t,ry:s,angle:x,largeArcFlag:0,sweepFlag:g,x:w,y:E},{type:"A",rx:t,ry:s,angle:x,largeArcFlag:0,sweepFlag:g,x:u,y}]}else{const m=h+t*Math.cos(o)*Math.cos(c)-s*Math.sin(o)*Math.sin(c),w=a+t*Math.cos(o)*Math.sin(c)+s*Math.sin(o)*Math.cos(c);return[{type:"M",x:u,y},{type:"A",rx:t,ry:s,angle:x,largeArcFlag:d,sweepFlag:g,x:m,y:w}]}}drawTo(e){const{center:t,radiusX:s,radiusY:n,rotation:o,startAngle:i,endAngle:c,clockwise:h}=this;return e.ellipse(t.x,t.y,s,n,o,i,c,!h),this}transform(e){return _.set(this.center.x,this.center.y),_.applyMatrix3(e),this.center.x=_.x,this.center.y=_.y,Dt(e)?Et(this,e):Lt(this,e),this}transformPoint(e){return e(this.center),this}getMinMax(e=l.MAX,t=l.MIN){const{center:s,radiusX:n,radiusY:o,rotation:i}=this,{x:c,y:h}=s,a=Math.cos(i),u=Math.sin(i),y=Math.sqrt(n*n*a*a+o*o*u*u),f=Math.sqrt(n*n*u*u+o*o*a*a);return e.x=Math.min(e.x,c-y),e.y=Math.min(e.y,h-f),t.x=Math.max(t.x,c+y),t.y=Math.max(t.y,h+f),{min:e,max:t}}copy(e){return super.copy(e),this.center.x=e.center.x,this.center.y=e.center.y,this.radiusX=e.radiusX,this.radiusY=e.radiusY,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotation=e.rotation,this}}function Et(r,e){const t=r.radiusX,s=r.radiusY,n=Math.cos(r.rotation),o=Math.sin(r.rotation),i=new l(t*n,t*o),c=new l(-s*o,s*n),h=i.applyMatrix3(e),a=c.applyMatrix3(e),u=$t.set(h.x,a.x,0,h.y,a.y,0,0,0,1),y=rt.copy(u).invert(),g=it.copy(y).transpose().multiply(y).elements,x=zt(g[0],g[1],g[4]),m=Math.sqrt(x.rt1),w=Math.sqrt(x.rt2);if(r.radiusX=1/m,r.radiusY=1/w,r.rotation=Math.atan2(x.sn,x.cs),!((r.endAngle-r.startAngle)%(2*Math.PI)<Number.EPSILON)){const b=rt.set(m,0,0,0,w,0,0,0,1),S=it.set(x.cs,x.sn,0,-x.sn,x.cs,0,0,0,1),N=b.multiply(S).multiply(u),L=D=>{const{x:U,y:V}=new l(Math.cos(D),Math.sin(D)).applyMatrix3(N);return Math.atan2(V,U)};r.startAngle=L(r.startAngle),r.endAngle=L(r.endAngle),at(e)&&(r.clockwise=!r.clockwise)}}function Lt(r,e){const t=ht(e),s=ct(e);r.radiusX*=t,r.radiusY*=s;const n=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);r.rotation+=n,at(e)&&(r.startAngle*=-1,r.endAngle*=-1,r.clockwise=!r.clockwise)}function at(r){const e=r.elements;return e[0]*e[4]-e[1]*e[3]<0}function Dt(r){const e=r.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const s=ht(r),n=ct(r);return Math.abs(t/(s*n))>Number.EPSILON}function ht(r){const e=r.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function ct(r){const e=r.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function zt(r,e,t){let s,n,o,i,c;const h=r+t,a=r-t,u=Math.sqrt(a*a+4*e*e);return h>0?(s=.5*(h+u),c=1/s,n=r*c*t-e*c*e):h<0?n=.5*(h-u):(s=.5*u,n=-.5*u),a>0?o=a+u:o=a-u,Math.abs(o)>2*Math.abs(e)?(c=-2*e/o,i=1/Math.sqrt(1+c*c),o=c*i):Math.abs(e)===0?(o=1,i=0):(c=-.5*o/e,o=1/Math.sqrt(1+c*c),i=c*o),a>0&&(c=o,o=-i,i=c),{rt1:s,rt2:n,cs:o,sn:i}}class X extends k{constructor(e=new l,t=new l){super(),this.start=e,this.end=t}getPoint(e,t=new l){return e===1?t.copy(this.end):t.copy(this.end).sub(this.start).multiplyScalar(e).add(this.start),t}getPointAt(e,t=new l){return this.getPoint(e,t)}getTangent(e,t=new l){return t.subVectors(this.end,this.start).normalize()}getTangentAt(e,t=new l){return this.getTangent(e,t)}getNormal(e,t=new l){const{x:s,y:n}=this.getPoint(e).sub(this.start);return t.set(n,-s).normalize()}transformPoint(e){return e(this.start),e(this.end),this}getDivisions(){return 1}getMinMax(e=l.MAX,t=l.MIN){const{start:s,end:n}=this;return e.x=Math.min(e.x,s.x,n.x),e.y=Math.min(e.y,s.y,n.y),t.x=Math.max(t.x,s.x,n.x),t.y=Math.max(t.y,s.y,n.y),{min:e,max:t}}getCommands(){const{start:e,end:t}=this;return[{type:"M",x:e.x,y:e.y},{type:"L",x:t.x,y:t.y}]}drawTo(e){const{end:t}=this;return e.lineTo(t.x,t.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.end.copy(e.end),this}}class qt extends k{constructor(t,s,n=0,o=1){super();T(this,"curveT",0);this.center=t,this.size=s,this.start=n,this.end=o,this.update()}update(){const{x:t,y:s}=this.center,n=new l(t+.5*this.size,s-.5*this.size),o=new l(t-.5*this.size,s-.5*this.size),i=new l(t,s+.5*this.size),c=new F(n,Math.SQRT1_2*this.size,-.25*Math.PI,.75*Math.PI),h=new F(o,Math.SQRT1_2*this.size,-.75*Math.PI,.25*Math.PI),a=new F(i,.5*Math.SQRT1_2*this.size,.75*Math.PI,1.25*Math.PI),u=new l(t,s+this.size),y=new l(t+this.size,s),f=new l().lerpVectors(y,u,.75),d=new l(t-this.size,s),g=new l().lerpVectors(d,u,.75),x=new X(y,f),m=new X(g,d);return this.curves=[c,x,a,m,h],this}getPoint(t){return this.getCurve(t).getPoint(this.curveT)}getPointAt(t){return this.getPoint(t)}getCurve(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1),s*=9*Math.PI/8+1.5;let n;const o=.5*Math.PI;return s<o?(n=0,this.curveT=s/o):s<o+.75?(n=1,this.curveT=(s-o)/.75):s<5*Math.PI/8+.75?(n=2,this.curveT=(s-o-.75)/(Math.PI/8)):s<5*Math.PI/8+1.5?(n=3,this.curveT=(s-5*Math.PI/8-.75)/.75):(n=4,this.curveT=(s-5*Math.PI/8-1.5)/o),this.curves[n]}getTangent(t){return this.getCurve(t).getTangent(this.curveT)}getNormal(t){return this.getCurve(t).getNormal(this.curveT)}transformPoint(t){return this.curves.forEach(s=>s.transformPoint(t)),this}getMinMax(t=l.MAX,s=l.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}getCommands(){return this.curves.flatMap(t=>t.getCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class Xt extends k{constructor(t,s=0,n=0,o=0,i=1){super();T(this,"curves",[]);T(this,"curveT",0);T(this,"points",[]);this.center=t,this.radius=s,this.number=n,this.start=o,this.end=i,this.update()}update(){for(let t=0;t<this.number;t++){let s=t*2*Math.PI/this.number;s-=.5*Math.PI,this.points.push(new l(this.radius*Math.cos(s),this.radius*Math.sin(s)).add(this.center))}for(let t=0;t<this.number;t++)this.curves.push(new X(this.points[t],this.points[(t+1)%this.number]));return this}getCurve(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1);const n=s*this.number,o=Math.floor(n);return this.curveT=n-o,this.curves[o]}getPoint(t,s){return this.getCurve(t).getPoint(this.curveT,s)}getPointAt(t,s){return this.getPoint(t,s)}getTangent(t,s){return this.getCurve(t).getTangent(this.curveT,s)}getNormal(t,s){return this.getCurve(t).getNormal(this.curveT,s)}transformPoint(t){return this.curves.forEach(s=>s.transformPoint(t)),this}getMinMax(t=l.MAX,s=l.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}getCommands(){return this.curves.flatMap(t=>t.getCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class ut extends k{constructor(e=new l,t=new l,s=new l){super(),this.start=e,this.control=t,this.end=s}getPoint(e,t=new l){const{start:s,control:n,end:o}=this;return t.set(et(e,s.x,n.x,o.x),et(e,s.y,n.y,o.y)),t}transformPoint(e){return e(this.start),e(this.control),e(this.end),this}getMinMax(e=l.MAX,t=l.MIN){const{start:s,control:n,end:o}=this,i=.5*(s.x+n.x),c=.5*(s.y+n.y),h=.5*(s.x+o.x),a=.5*(s.y+o.y);return e.x=Math.min(e.x,s.x,o.x,i,h),e.y=Math.min(e.y,s.y,o.y,c,a),t.x=Math.max(t.x,s.x,o.x,i,h),t.y=Math.max(t.y,s.y,o.y,c,a),{min:e,max:t}}getCommands(){const{start:e,control:t,end:s}=this;return[{type:"M",x:e.x,y:e.y},{type:"Q",x1:t.x,y1:t.y,x:s.x,y:s.y}]}drawTo(e){const{control:t,end:s}=this;return e.quadraticCurveTo(t.x,t.y,s.x,s.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.control.copy(e.control),this.end.copy(e.end),this}}class lt extends k{constructor(t,s,n=1,o=0,i=1){super();T(this,"curves",[]);T(this,"curveT",0);this.center=t,this.rx=s,this.aspectRatio=n,this.start=o,this.end=i,this.update()}get x(){return this.center.x-this.rx}get y(){return this.center.y-this.rx/this.aspectRatio}get width(){return this.rx*2}get height(){return this.rx/this.aspectRatio*2}update(){const{x:t,y:s}=this.center,n=this.rx,o=this.rx/this.aspectRatio,i=[new l(t-n,s-o),new l(t+n,s-o),new l(t+n,s+o),new l(t-n,s+o)];for(let c=0;c<4;c++)this.curves.push(new X(i[c].clone(),i[(c+1)%4].clone()));return this}getCurve(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1),s*=(1+this.aspectRatio)*2;let n;return s<this.aspectRatio?(n=0,this.curveT=s/this.aspectRatio):s<this.aspectRatio+1?(n=1,this.curveT=(s-this.aspectRatio)/1):s<2*this.aspectRatio+1?(n=2,this.curveT=(s-this.aspectRatio-1)/this.aspectRatio):(n=3,this.curveT=(s-2*this.aspectRatio-1)/1),this.curves[n]}getPoint(t,s){return this.getCurve(t).getPoint(this.curveT,s)}getPointAt(t,s){return this.getPoint(t,s)}getTangent(t,s){return this.getCurve(t).getTangent(this.curveT,s)}getNormal(t,s){return this.getCurve(t).getNormal(this.curveT,s)}transformPoint(t){return this.curves.forEach(s=>s.transformPoint(t)),this}getMinMax(t=l.MAX,s=l.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}getCommands(){return this.curves.flatMap(t=>t.getCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class yt extends k{constructor(e=[]){super(),this.points=e}getDivisions(e=12){return e*this.points.length}getPoint(e,t=new l){const{points:s}=this,n=(s.length-1)*e,o=Math.floor(n),i=n-o,c=s[o===0?o:o-1],h=s[o],a=s[o>s.length-2?s.length-1:o+1],u=s[o>s.length-3?s.length-1:o+2];return t.set(tt(i,c.x,h.x,a.x,u.x),tt(i,c.y,h.y,a.y,u.y)),t}transformPoint(e){return this.points.forEach(t=>e(t)),this}copy(e){super.copy(e),this.points=[];for(let t=0,s=e.points.length;t<s;t++)this.points.push(e.points[t].clone());return this}}class R extends k{constructor(t){super();T(this,"curves",[]);T(this,"startPoint");T(this,"currentPoint",new l);T(this,"autoClose",!1);T(this,"_cacheLengths",[]);t&&this.addPoints(t)}addCurve(t){return this.curves.push(t),this}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let s=1,n=t.length;s<n;s++){const{x:o,y:i}=t[s];this.lineTo(o,i)}return this}addCommands(t){return Y(t,this),this}addData(t){return this.addCommands(G(t)),this}getPoint(t,s=new l){const n=t*this.getLength(),o=this.getCurveLengths();let i=0;for(;i<o.length;){if(o[i]>=n){const c=o[i]-n,h=this.curves[i],a=h.getLength();return h.getPointAt(a===0?0:1-c/a,s)}i++}return s}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){super.updateArcLengths(),this._cacheLengths=[],this.getCurveLengths()}getCurveLengths(){if(this._cacheLengths.length===this.curves.length)return this._cacheLengths;const t=[];let s=0;for(let n=0,o=this.curves.length;n<o;n++)s+=this.curves[n].getLength(),t.push(s);return this._cacheLengths=t,t}getSpacedPoints(t=40){const s=[];for(let n=0;n<=t;n++)s.push(this.getPoint(n/t));return this.autoClose&&s.push(s[0]),s}getPoints(t=12){const s=[];let n;for(let o=0,i=this.curves;o<i.length;o++){const c=i[o],h=c.getPoints(c.getDivisions(t));for(let a=0;a<h.length;a++){const u=h[a];n!=null&&n.equals(u)||(s.push(u),n=u)}}return this.autoClose&&s.length>1&&!s[s.length-1].equals(s[0])&&s.push(s[0]),s}_setCurrentPoint(t){return this.currentPoint.copy(t),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}closePath(){const t=this.startPoint;if(t){const s=this.currentPoint;t.equals(s)||(this.curves.push(new X(s,t)),this.currentPoint.copy(t)),this.startPoint=void 0}return this}moveTo(t,s){return this.currentPoint.set(t,s),this.startPoint=this.currentPoint.clone(),this}lineTo(t,s){return this.curves.push(new X(this.currentPoint.clone(),new l(t,s))),this._setCurrentPoint({x:t,y:s}),this}bezierCurveTo(t,s,n,o,i,c){return this.curves.push(new nt(this.currentPoint.clone(),new l(t,s),new l(n,o),new l(i,c))),this._setCurrentPoint({x:i,y:c}),this}quadraticCurveTo(t,s,n,o){return this.curves.push(new ut(this.currentPoint.clone(),new l(t,s),new l(n,o))),this._setCurrentPoint({x:n,y:o}),this}arc(t,s,n,o,i,c){return this.ellipse(t,s,n,n,0,o,i,c),this}relativeArc(t,s,n,o,i,c){const h=this.currentPoint;return this.arc(t+h.x,s+h.y,n,o,i,c),this}arcTo(t,s,n,o,i){return console.warn("Method arcTo not supported yet"),this}ellipse(t,s,n,o,i,c,h,a=!0){const u=new ot(new l(t,s),n,o,i,c,h,!a);if(this.curves.length>0){const y=u.getPoint(0);y.equals(this.currentPoint)||this.lineTo(y.x,y.y)}return this.curves.push(u),this._setCurrentPoint(u.getPoint(1)),this}relativeEllipse(t,s,n,o,i,c,h,a){const u=this.currentPoint;return this.ellipse(t+u.x,s+u.y,n,o,i,c,h,a),this}rect(t,s,n,o){return this.curves.push(new lt(new l(t+n/2,s+o/2),n/2,n/o)),this._setCurrentPoint({x:t,y:s}),this}splineThru(t){return this.curves.push(new yt([this.currentPoint.clone()].concat(t))),this._setCurrentPoint(t[t.length-1]),this}transformPoint(t){return this.curves.forEach(s=>s.transformPoint(t)),this}getMinMax(t=l.MAX,s=l.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}getBoundingBox(){const{min:t,max:s}=this.getMinMax();return new q(t.x,t.y,s.x-t.x,s.y-t.y)}getCommands(){return this.curves.flatMap(t=>t.getCommands())}drawTo(t){var n;const s=(n=this.curves[0])==null?void 0:n.getPoint(0);return s&&t.moveTo(s.x,s.y),this.curves.forEach(o=>o.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){super.copy(t),this.curves=[];for(let s=0,n=t.curves.length;s<n;s++)this.curves.push(t.curves[s].clone());return this.autoClose=t.autoClose,this.currentPoint.copy(t.currentPoint),this}}function Ot(r){return r.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}class I{constructor(e){T(this,"currentPath",new R);T(this,"paths",[this.currentPath]);T(this,"style",{});e&&(e instanceof I?this.addPath(e):Array.isArray(e)?this.addCommands(e):this.addData(e))}get startPoint(){return this.currentPath.startPoint}get currentPoint(){return this.currentPath.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}addPath(e){return e instanceof I?this.paths.push(...e.paths.map(t=>t.clone())):this.paths.push(e),this}closePath(){const e=this.startPoint;return e&&(this.currentPath.closePath(),this.currentPath.curves.length>0&&(this.currentPath=new R().moveTo(e.x,e.y),this.paths.push(this.currentPath))),this}moveTo(e,t){const{currentPoint:s,curves:n}=this.currentPath;return s.equals({x:e,y:t})||(n.length?(this.currentPath=new R().moveTo(e,t),this.paths.push(this.currentPath)):this.currentPath.moveTo(e,t)),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}bezierCurveTo(e,t,s,n,o,i){return this.currentPath.bezierCurveTo(e,t,s,n,o,i),this}quadraticCurveTo(e,t,s,n){return this.currentPath.quadraticCurveTo(e,t,s,n),this}arc(e,t,s,n,o,i){return this.currentPath.arc(e,t,s,n,o,i),this}arcTo(e,t,s,n,o){return this.currentPath.arcTo(e,t,s,n,o),this}ellipse(e,t,s,n,o,i,c,h){return this.currentPath.ellipse(e,t,s,n,o,i,c,h),this}rect(e,t,s,n){return this.currentPath.rect(e,t,s,n),this}addCommands(e){return Y(e,this),this}addData(e){return this.addCommands(G(e)),this}splineThru(e){return this.currentPath.splineThru(e),this}forEachCurve(e){return this.paths.forEach(t=>t.curves.forEach(s=>e(s))),this}transformPoint(e){return this.forEachCurve(t=>t.transformPoint(e)),this}transform(e){return this.forEachCurve(t=>t.transform(e)),this}getMinMax(e=l.MAX,t=l.MIN){return this.forEachCurve(s=>s.getMinMax(e,t)),{min:e,max:t}}getBoundingBox(e=!0){const{min:t,max:s}=this.getMinMax(),n=new q(t.x,t.y,s.x-t.x,s.y-t.y);if(e){const o=this.strokeWidth;n.left-=o/2,n.top-=o/2,n.width+=o,n.height+=o}return n}getCommands(){return this.paths.flatMap(e=>e.getCommands())}getData(){return this.paths.map(e=>e.getData()).join(" ")}getSvgPathXml(){const e={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},t={};for(const n in e)e[n]!==void 0&&(t[Ot(n)]=e[n]);Object.assign(t,{"stroke-width":`${this.strokeWidth}px`});let s="";for(const n in t)t[n]!==void 0&&(s+=`${n}:${t[n]};`);return`<path d="${this.getData()}" style="${s}"></path>`}getSvgXml(){const{x:e,y:t,width:s,height:n}=this.getBoundingBox(),o=this.getSvgPathXml();return`<svg viewBox="${e} ${t} ${s} ${n}" width="${s}px" height="${n}px" xmlns="http://www.w3.org/2000/svg">${o}</svg>`}getSvgDataUri(){return`data:image/svg+xml;base64,${btoa(this.getSvgXml())}`}drawTo(e){const{fill:t="#000",stroke:s="none"}=this.style;z(e,this),this.paths.forEach(n=>{n.drawTo(e)}),t!=="none"&&e.fill(),s!=="none"&&e.stroke()}copy(e){return this.currentPath=e.currentPath.clone(),this.paths=e.paths.map(t=>t.clone()),this.style={...e.style},this}toSvg(){return new DOMParser().parseFromString(this.getSvgXml(),"image/svg+xml").documentElement}toCanvas(e=2){const{left:t,top:s,width:n,height:o}=this.getBoundingBox(),i=document.createElement("canvas");i.width=n*e,i.height=o*e,i.style.width=`${n}px`,i.style.height=`${o}px`;const c=i.getContext("2d");return c&&(c.scale(e,e),c.translate(-t,-s),this.drawTo(c)),i}clone(){return new this.constructor().copy(this)}}const Q="px",gt=90,ft=["mm","cm","in","pt","pc","px"],H={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function M(r){let e="px";if(typeof r=="string"||r instanceof String)for(let s=0,n=ft.length;s<n;s++){const o=ft[s];if(r.endsWith(o)){e=o,r=r.substring(0,r.length-o.length);break}}let t;return e==="px"&&Q!=="px"?t=H.in[Q]/gt:(t=H[e][Q],t<0&&(t=H[e].in*gt)),t*Number.parseFloat(r)}const Rt=new C,B=new C,pt=new C,dt=new C;function Ft(r,e,t){if(!(r.hasAttribute("transform")||r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))))return null;const s=_t(r);return t.length>0&&s.premultiply(t[t.length-1]),e.copy(s),t.push(s),s}function _t(r){const e=new C,t=Rt;if(r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))&&e.translate(M(r.getAttribute("x")),M(r.getAttribute("y"))),r.hasAttribute("transform")){const s=r.getAttribute("transform").split(")");for(let n=s.length-1;n>=0;n--){const o=s[n].trim();if(o==="")continue;const i=o.indexOf("("),c=o.length;if(i>0&&i<c){const h=o.slice(0,i),a=A(o.slice(i+1));switch(t.identity(),h){case"translate":if(a.length>=1){const u=a[0];let y=0;a.length>=2&&(y=a[1]),t.translate(u,y)}break;case"rotate":if(a.length>=1){let u=0,y=0,f=0;u=a[0]*Math.PI/180,a.length>=3&&(y=a[1],f=a[2]),B.makeTranslation(-y,-f),pt.makeRotation(u),dt.multiplyMatrices(pt,B),B.makeTranslation(y,f),t.multiplyMatrices(B,dt)}break;case"scale":a.length>=1&&t.scale(a[0],a[1]??a[0]);break;case"skewX":a.length===1&&t.set(1,Math.tan(a[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":a.length===1&&t.set(1,0,0,Math.tan(a[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":a.length===6&&t.set(a[0],a[2],a[4],a[1],a[3],a[5],0,0,1);break}}e.premultiply(t)}}return e}function Bt(r){return new I().addPath(new R().arc(M(r.getAttribute("cx")||0),M(r.getAttribute("cy")||0),M(r.getAttribute("r")||0),0,Math.PI*2))}function Ut(r,e){if(!(!r.sheet||!r.sheet.cssRules||!r.sheet.cssRules.length))for(let t=0;t<r.sheet.cssRules.length;t++){const s=r.sheet.cssRules[t];if(s.type!==1)continue;const n=s.selectorText.split(/,/g).filter(Boolean).map(o=>o.trim());for(let o=0;o<n.length;o++){const i=Object.fromEntries(Object.entries(s.style).filter(([,c])=>c!==""));e[n[o]]=Object.assign(e[n[o]]||{},i)}}}function Wt(r){return new I().addPath(new R().ellipse(M(r.getAttribute("cx")||0),M(r.getAttribute("cy")||0),M(r.getAttribute("rx")||0),M(r.getAttribute("ry")||0),0,0,Math.PI*2))}function Yt(r){return new I().moveTo(M(r.getAttribute("x1")||0),M(r.getAttribute("y1")||0)).lineTo(M(r.getAttribute("x2")||0),M(r.getAttribute("y2")||0))}function Gt(r){const e=new I,t=r.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const Qt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Ht(r){var s;const e=new I;let t=0;return(s=r.getAttribute("points"))==null||s.replace(Qt,(n,o,i)=>{const c=M(o),h=M(i);return t===0?e.moveTo(c,h):e.lineTo(c,h),t++,n}),e.currentPath.autoClose=!0,e}const jt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Vt(r){var s;const e=new I;let t=0;return(s=r.getAttribute("points"))==null||s.replace(jt,(n,o,i)=>{const c=M(o),h=M(i);return t===0?e.moveTo(c,h):e.lineTo(c,h),t++,n}),e.currentPath.autoClose=!1,e}function Zt(r){const e=M(r.getAttribute("x")||0),t=M(r.getAttribute("y")||0),s=M(r.getAttribute("rx")||r.getAttribute("ry")||0),n=M(r.getAttribute("ry")||r.getAttribute("rx")||0),o=M(r.getAttribute("width")),i=M(r.getAttribute("height")),c=1-.551915024494,h=new I;return h.moveTo(e+s,t),h.lineTo(e+o-s,t),(s!==0||n!==0)&&h.bezierCurveTo(e+o-s*c,t,e+o,t+n*c,e+o,t+n),h.lineTo(e+o,t+i-n),(s!==0||n!==0)&&h.bezierCurveTo(e+o,t+i-n*c,e+o-s*c,t+i,e+o-s,t+i),h.lineTo(e+s,t+i),(s!==0||n!==0)&&h.bezierCurveTo(e+s*c,t+i,e,t+i-n*c,e,t+i-n),h.lineTo(e,t+n),(s!==0||n!==0)&&h.bezierCurveTo(e,t+n*c,e+s*c,t,e+s,t),h}function $(r,e,t){e=Object.assign({},e);let s={};if(r.hasAttribute("class")){const h=r.getAttribute("class").split(/\s/).filter(Boolean).map(a=>a.trim());for(let a=0;a<h.length;a++)s=Object.assign(s,t[`.${h[a]}`])}r.hasAttribute("id")&&(s=Object.assign(s,t[`#${r.getAttribute("id")}`]));function n(h,a,u){u===void 0&&(u=function(f){return f.startsWith("url")&&console.warn("url access in attributes is not implemented."),f}),r.hasAttribute(h)&&(e[a]=u(r.getAttribute(h))),s[h]&&(e[a]=u(s[h])),r.style&&r.style[h]!==""&&(e[a]=u(r.style[h]))}function o(h){return Math.max(0,Math.min(1,M(h)))}function i(h){return Math.max(0,M(h))}function c(h){return h.split(" ").filter(a=>a!=="").map(a=>M(a))}return n("fill","fill"),n("fill-opacity","fillOpacity",o),n("fill-rule","fillRule"),n("opacity","opacity",o),n("stroke","stroke"),n("stroke-opacity","strokeOpacity",o),n("stroke-width","strokeWidth",i),n("stroke-linecap","strokeLinecap"),n("stroke-linejoin","strokeLinejoin"),n("stroke-miterlimit","strokeMiterlimit",i),n("stroke-dasharray","strokeDasharray",c),n("stroke-dashoffset","strokeDashoffset",M),n("visibility","visibility"),e}function j(r,e,t=[]){var u;if(r.nodeType!==1)return t;let s=!1,n=null;const o={};switch(r.nodeName){case"svg":e=$(r,e,o);break;case"style":Ut(r,o);break;case"g":e=$(r,e,o);break;case"path":e=$(r,e,o),r.hasAttribute("d")&&(n=Gt(r));break;case"rect":e=$(r,e,o),n=Zt(r);break;case"polygon":e=$(r,e,o),n=Ht(r);break;case"polyline":e=$(r,e,o),n=Vt(r);break;case"circle":e=$(r,e,o),n=Bt(r);break;case"ellipse":e=$(r,e,o),n=Wt(r);break;case"line":e=$(r,e,o),n=Yt(r);break;case"defs":s=!0;break;case"use":{e=$(r,e,o);const f=(r.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),d=(u=r.viewportElement)==null?void 0:u.getElementById(f);d?j(d,e,t):console.warn(`'use node' references non-existent node id: ${f}`);break}default:console.warn(r);break}const i=new C,c=[],h=Ft(r,i,c);n&&(n.transform(i),t.push(n),n.style=e);const a=r.childNodes;for(let y=0,f=a.length;y<f;y++){const d=a[y];s&&d.nodeName!=="style"&&d.nodeName!=="defs"||j(d,e,t)}return h&&(c.pop(),c.length>0?i.copy(c[c.length-1]):i.identity()),t}const xt="data:image/svg+xml;",mt=`${xt}base64,`,Mt=`${xt}charset=utf8,`;function Pt(r){if(typeof r=="string"){let e;return r.startsWith(mt)?(r=r.substring(mt.length,r.length),e=atob(r)):r.startsWith(Mt)?(r=r.substring(Mt.length,r.length),e=decodeURIComponent(r)):e=r,new DOMParser().parseFromString(e,"image/svg+xml").documentElement}else return r}function Jt(r){return j(Pt(r),{})}p.BoundingBox=q,p.CircleCurve=F,p.CubicBezierCurve=nt,p.Curve=k,p.CurvePath=R,p.EllipseCurve=ot,p.HeartCurve=qt,p.LineCurve=X,p.Matrix3=C,p.Path2D=I,p.PloygonCurve=Xt,p.QuadraticBezierCurve=ut,p.RectangularCurve=lt,p.SplineCurve=yt,p.Vector2=l,p.addPathCommandsToPath2D=Y,p.parseArcCommand=J,p.parsePathDataArgs=A,p.parseSvg=Jt,p.parseSvgToDom=Pt,p.pathCommandsToPathData=K,p.pathDataToPathCommands=G,p.setCanvasContextByPath=z,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
const lineJoinMap = {
|
|
2
|
+
"arcs": "bevel",
|
|
3
|
+
"bevel": "bevel",
|
|
4
|
+
"miter": "miter",
|
|
5
|
+
"miter-clip": "miter",
|
|
6
|
+
"round": "round"
|
|
7
|
+
};
|
|
8
|
+
function setCanvasContextByPath(ctx, path) {
|
|
9
|
+
const {
|
|
10
|
+
fill = "#000",
|
|
11
|
+
stroke = "none",
|
|
12
|
+
strokeWidth = stroke === "none" ? 0 : 1,
|
|
13
|
+
strokeLinecap = "round",
|
|
14
|
+
strokeLinejoin = "miter",
|
|
15
|
+
strokeMiterlimit = 0,
|
|
16
|
+
strokeDasharray,
|
|
17
|
+
strokeDashoffset = 0
|
|
18
|
+
} = path.style;
|
|
19
|
+
ctx.fillStyle = fill;
|
|
20
|
+
ctx.strokeStyle = stroke;
|
|
21
|
+
ctx.lineWidth = strokeWidth;
|
|
22
|
+
ctx.lineCap = strokeLinecap;
|
|
23
|
+
ctx.lineJoin = lineJoinMap[strokeLinejoin];
|
|
24
|
+
ctx.miterLimit = strokeMiterlimit;
|
|
25
|
+
ctx.lineDashOffset = strokeDashoffset;
|
|
26
|
+
strokeDasharray && ctx.setLineDash(strokeDasharray);
|
|
27
|
+
}
|
|
28
|
+
|
|
1
29
|
class Vector2 {
|
|
2
30
|
constructor(x = 0, y = 0) {
|
|
3
31
|
this.x = x;
|
|
@@ -2078,6 +2106,10 @@ class CurvePath extends Curve {
|
|
|
2078
2106
|
}
|
|
2079
2107
|
}
|
|
2080
2108
|
|
|
2109
|
+
function toKebabCase(str) {
|
|
2110
|
+
return str.replace(/[^a-z0-9]/gi, "-").replace(/\B([A-Z])/g, "-$1").toLowerCase();
|
|
2111
|
+
}
|
|
2112
|
+
|
|
2081
2113
|
var __defProp = Object.defineProperty;
|
|
2082
2114
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2083
2115
|
var __publicField = (obj, key, value) => {
|
|
@@ -2088,7 +2120,7 @@ class Path2D {
|
|
|
2088
2120
|
constructor(path) {
|
|
2089
2121
|
__publicField(this, "currentPath", new CurvePath());
|
|
2090
2122
|
__publicField(this, "paths", [this.currentPath]);
|
|
2091
|
-
__publicField(this, "
|
|
2123
|
+
__publicField(this, "style", {});
|
|
2092
2124
|
if (path) {
|
|
2093
2125
|
if (path instanceof Path2D) {
|
|
2094
2126
|
this.addPath(path);
|
|
@@ -2105,6 +2137,9 @@ class Path2D {
|
|
|
2105
2137
|
get currentPoint() {
|
|
2106
2138
|
return this.currentPath.currentPoint;
|
|
2107
2139
|
}
|
|
2140
|
+
get strokeWidth() {
|
|
2141
|
+
return this.style.strokeWidth ?? ((this.style.stroke ?? "none") === "none" ? 0 : 1);
|
|
2142
|
+
}
|
|
2108
2143
|
addPath(path) {
|
|
2109
2144
|
if (path instanceof Path2D) {
|
|
2110
2145
|
this.paths.push(...path.paths.map((v) => v.clone()));
|
|
@@ -2192,9 +2227,17 @@ class Path2D {
|
|
|
2192
2227
|
this.forEachCurve((curve) => curve.getMinMax(min, max));
|
|
2193
2228
|
return { min, max };
|
|
2194
2229
|
}
|
|
2195
|
-
getBoundingBox() {
|
|
2230
|
+
getBoundingBox(withStrokeWidth = true) {
|
|
2196
2231
|
const { min, max } = this.getMinMax();
|
|
2197
|
-
|
|
2232
|
+
const bbox = new BoundingBox(min.x, min.y, max.x - min.x, max.y - min.y);
|
|
2233
|
+
if (withStrokeWidth) {
|
|
2234
|
+
const strokeWidth = this.strokeWidth;
|
|
2235
|
+
bbox.left -= strokeWidth / 2;
|
|
2236
|
+
bbox.top -= strokeWidth / 2;
|
|
2237
|
+
bbox.width += strokeWidth;
|
|
2238
|
+
bbox.height += strokeWidth;
|
|
2239
|
+
}
|
|
2240
|
+
return bbox;
|
|
2198
2241
|
}
|
|
2199
2242
|
getCommands() {
|
|
2200
2243
|
return this.paths.flatMap((path) => path.getCommands());
|
|
@@ -2202,46 +2245,74 @@ class Path2D {
|
|
|
2202
2245
|
getData() {
|
|
2203
2246
|
return this.paths.map((path) => path.getData()).join(" ");
|
|
2204
2247
|
}
|
|
2205
|
-
|
|
2248
|
+
getSvgPathXml() {
|
|
2249
|
+
const style = {
|
|
2250
|
+
...this.style,
|
|
2251
|
+
fill: this.style.fill ?? "#000",
|
|
2252
|
+
stroke: this.style.stroke ?? "none"
|
|
2253
|
+
};
|
|
2254
|
+
const cssStyle = {};
|
|
2255
|
+
for (const key in style) {
|
|
2256
|
+
if (style[key] !== void 0) {
|
|
2257
|
+
cssStyle[toKebabCase(key)] = style[key];
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
Object.assign(cssStyle, {
|
|
2261
|
+
"stroke-width": `${this.strokeWidth}px`
|
|
2262
|
+
});
|
|
2263
|
+
let cssText = "";
|
|
2264
|
+
for (const key in cssStyle) {
|
|
2265
|
+
if (cssStyle[key] !== void 0) {
|
|
2266
|
+
cssText += `${key}:${cssStyle[key]};`;
|
|
2267
|
+
}
|
|
2268
|
+
}
|
|
2269
|
+
return `<path d="${this.getData()}" style="${cssText}"></path>`;
|
|
2270
|
+
}
|
|
2271
|
+
getSvgXml() {
|
|
2206
2272
|
const { x, y, width, height } = this.getBoundingBox();
|
|
2207
|
-
const
|
|
2208
|
-
return `<svg viewBox="${x
|
|
2273
|
+
const path = this.getSvgPathXml();
|
|
2274
|
+
return `<svg viewBox="${x} ${y} ${width} ${height}" width="${width}px" height="${height}px" xmlns="http://www.w3.org/2000/svg">${path}</svg>`;
|
|
2209
2275
|
}
|
|
2210
2276
|
getSvgDataUri() {
|
|
2211
|
-
return `data:image/svg+xml;base64,${btoa(this.
|
|
2277
|
+
return `data:image/svg+xml;base64,${btoa(this.getSvgXml())}`;
|
|
2212
2278
|
}
|
|
2213
2279
|
drawTo(ctx) {
|
|
2280
|
+
const {
|
|
2281
|
+
fill = "#000",
|
|
2282
|
+
stroke = "none"
|
|
2283
|
+
} = this.style;
|
|
2284
|
+
setCanvasContextByPath(ctx, this);
|
|
2214
2285
|
this.paths.forEach((path) => {
|
|
2215
2286
|
path.drawTo(ctx);
|
|
2216
2287
|
});
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
this.drawTo(ctx);
|
|
2224
|
-
ctx.fill();
|
|
2288
|
+
if (fill !== "none") {
|
|
2289
|
+
ctx.fill();
|
|
2290
|
+
}
|
|
2291
|
+
if (stroke !== "none") {
|
|
2292
|
+
ctx.stroke();
|
|
2293
|
+
}
|
|
2225
2294
|
}
|
|
2226
2295
|
copy(source) {
|
|
2227
2296
|
this.currentPath = source.currentPath.clone();
|
|
2228
2297
|
this.paths = source.paths.map((path) => path.clone());
|
|
2229
|
-
this.
|
|
2298
|
+
this.style = { ...source.style };
|
|
2230
2299
|
return this;
|
|
2231
2300
|
}
|
|
2232
|
-
|
|
2233
|
-
|
|
2301
|
+
toSvg() {
|
|
2302
|
+
return new DOMParser().parseFromString(this.getSvgXml(), "image/svg+xml").documentElement;
|
|
2303
|
+
}
|
|
2304
|
+
toCanvas(pixelRatio = 2) {
|
|
2234
2305
|
const { left, top, width, height } = this.getBoundingBox();
|
|
2235
|
-
canvas
|
|
2236
|
-
canvas.
|
|
2306
|
+
const canvas = document.createElement("canvas");
|
|
2307
|
+
canvas.width = width * pixelRatio;
|
|
2308
|
+
canvas.height = height * pixelRatio;
|
|
2309
|
+
canvas.style.width = `${width}px`;
|
|
2310
|
+
canvas.style.height = `${height}px`;
|
|
2237
2311
|
const ctx = canvas.getContext("2d");
|
|
2238
2312
|
if (ctx) {
|
|
2313
|
+
ctx.scale(pixelRatio, pixelRatio);
|
|
2239
2314
|
ctx.translate(-left, -top);
|
|
2240
|
-
|
|
2241
|
-
this.fillTo(ctx);
|
|
2242
|
-
} else {
|
|
2243
|
-
this.strokeTo(ctx);
|
|
2244
|
-
}
|
|
2315
|
+
this.drawTo(ctx);
|
|
2245
2316
|
}
|
|
2246
2317
|
return canvas;
|
|
2247
2318
|
}
|
|
@@ -2634,18 +2705,21 @@ function parseStyle(node, style, stylesheets) {
|
|
|
2634
2705
|
function positive(v) {
|
|
2635
2706
|
return Math.max(0, parseFloatWithUnits(v));
|
|
2636
2707
|
}
|
|
2708
|
+
function array(v) {
|
|
2709
|
+
return v.split(" ").filter((v2) => v2 !== "").map((v2) => parseFloatWithUnits(v2));
|
|
2710
|
+
}
|
|
2637
2711
|
addStyle("fill", "fill");
|
|
2638
2712
|
addStyle("fill-opacity", "fillOpacity", clamp);
|
|
2639
2713
|
addStyle("fill-rule", "fillRule");
|
|
2640
2714
|
addStyle("opacity", "opacity", clamp);
|
|
2641
2715
|
addStyle("stroke", "stroke");
|
|
2642
|
-
addStyle("stroke-dashoffset", "strokeDashoffset");
|
|
2643
|
-
addStyle("stroke-dasharray", "strokeDasharray");
|
|
2644
|
-
addStyle("stroke-linecap", "strokeLineCap");
|
|
2645
|
-
addStyle("stroke-linejoin", "strokeLineJoin");
|
|
2646
|
-
addStyle("stroke-miterlimit", "strokeMiterLimit", positive);
|
|
2647
2716
|
addStyle("stroke-opacity", "strokeOpacity", clamp);
|
|
2648
2717
|
addStyle("stroke-width", "strokeWidth", positive);
|
|
2718
|
+
addStyle("stroke-linecap", "strokeLinecap");
|
|
2719
|
+
addStyle("stroke-linejoin", "strokeLinejoin");
|
|
2720
|
+
addStyle("stroke-miterlimit", "strokeMiterlimit", positive);
|
|
2721
|
+
addStyle("stroke-dasharray", "strokeDasharray", array);
|
|
2722
|
+
addStyle("stroke-dashoffset", "strokeDashoffset", parseFloatWithUnits);
|
|
2649
2723
|
addStyle("visibility", "visibility");
|
|
2650
2724
|
return style;
|
|
2651
2725
|
}
|
|
@@ -2720,7 +2794,7 @@ function parseNode(node, style, paths = []) {
|
|
|
2720
2794
|
if (path) {
|
|
2721
2795
|
path.transform(currentTransform);
|
|
2722
2796
|
paths.push(path);
|
|
2723
|
-
path.
|
|
2797
|
+
path.style = style;
|
|
2724
2798
|
}
|
|
2725
2799
|
const childNodes = node.childNodes;
|
|
2726
2800
|
for (let i = 0, len = childNodes.length; i < len; i++) {
|
|
@@ -2764,15 +2838,7 @@ function parseSvgToDom(svg) {
|
|
|
2764
2838
|
}
|
|
2765
2839
|
}
|
|
2766
2840
|
function parseSvg(svg) {
|
|
2767
|
-
return parseNode(parseSvgToDom(svg), {
|
|
2768
|
-
fill: "#000",
|
|
2769
|
-
fillOpacity: 1,
|
|
2770
|
-
strokeOpacity: 1,
|
|
2771
|
-
strokeWidth: 1,
|
|
2772
|
-
strokeLineJoin: "miter",
|
|
2773
|
-
strokeLineCap: "butt",
|
|
2774
|
-
strokeMiterLimit: 4
|
|
2775
|
-
});
|
|
2841
|
+
return parseNode(parseSvgToDom(svg), {});
|
|
2776
2842
|
}
|
|
2777
2843
|
|
|
2778
|
-
export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, QuadraticBezierCurve, RectangularCurve, SplineCurve, Vector2, parseSvg, parseSvgToDom };
|
|
2844
|
+
export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, QuadraticBezierCurve, RectangularCurve, SplineCurve, Vector2, addPathCommandsToPath2D, parseArcCommand, parsePathDataArgs, parseSvg, parseSvgToDom, pathCommandsToPathData, pathDataToPathCommands, setCanvasContextByPath };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "modern-path2d",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.11",
|
|
5
5
|
"packageManager": "pnpm@9.9.0",
|
|
6
6
|
"description": "A modern Path2D library, fully compatible with Web Path2D, with additional support for path animation, path deformation, path playback, etc.",
|
|
7
7
|
"author": "wxm",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "vite build && unbuild",
|
|
49
49
|
"dev": "vite docs",
|
|
50
|
-
"lint": "eslint
|
|
50
|
+
"lint": "eslint ./src",
|
|
51
51
|
"version": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md",
|
|
52
52
|
"release": "bumpp package.json --commit \"release: v%s\" --push --all --tag",
|
|
53
53
|
"start": "esno src/index.ts",
|
|
@@ -72,6 +72,6 @@
|
|
|
72
72
|
"pre-commit": "pnpm lint-staged"
|
|
73
73
|
},
|
|
74
74
|
"lint-staged": {
|
|
75
|
-
"*": "eslint --fix"
|
|
75
|
+
"*": "eslint ./src --fix"
|
|
76
76
|
}
|
|
77
77
|
}
|