svg-path-commander 0.1.24 → 0.2.0-alpha2
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/README.md +5 -3
- package/dist/svg-path-commander.es5.js +3948 -0
- package/dist/svg-path-commander.es5.min.js +2 -0
- package/dist/svg-path-commander.esm.js +428 -407
- package/dist/svg-path-commander.esm.min.js +2 -2
- package/dist/svg-path-commander.js +1434 -1515
- package/dist/svg-path-commander.min.js +2 -2
- package/package.json +15 -2
- package/src/convert/pathToAbsolute.js +4 -4
- package/src/convert/pathToCurve.js +2 -2
- package/src/convert/pathToRelative.js +4 -4
- package/src/convert/pathToString.js +2 -2
- package/src/math/polygonLength.js +1 -2
- package/src/options/options.js +1 -1
- package/src/parser/error.js +2 -0
- package/src/parser/finalizeSegment.js +1 -1
- package/src/parser/isSpace.js +1 -1
- package/src/parser/paramsParser.js +1 -1
- package/src/parser/parsePathString.js +6 -11
- package/src/parser/pathParser.js +1 -1
- package/src/parser/scanFlag.js +3 -3
- package/src/parser/scanParam.js +7 -6
- package/src/parser/scanSegment.js +3 -2
- package/src/parser/skipSpaces.js +1 -1
- package/src/process/clonePath.js +1 -1
- package/src/process/fixArc.js +1 -1
- package/src/process/fixPath.js +2 -2
- package/src/process/getSVGMatrix.js +3 -2
- package/src/process/normalizePath.js +3 -3
- package/src/process/normalizeSegment.js +2 -2
- package/src/process/optimizePath.js +2 -2
- package/src/process/projection2d.js +2 -2
- package/src/process/reverseCurve.js +3 -3
- package/src/process/reversePath.js +4 -5
- package/src/process/roundPath.js +7 -6
- package/src/process/segmentToCubic.js +3 -3
- package/src/process/shortenSegment.js +3 -3
- package/src/process/splitCubic.js +1 -1
- package/src/process/splitPath.js +1 -1
- package/src/process/transformPath.js +8 -7
- package/src/svg-path-commander.js +60 -20
- package/src/util/getClosestPoint.js +1 -1
- package/src/util/getCubicSize.js +1 -1
- package/src/util/getDrawDirection.js +1 -1
- package/src/util/getPathArea.js +1 -1
- package/src/util/getPathBBox.js +2 -2
- package/src/util/getPathLength.js +1 -1
- package/src/util/getPointAtLength.js +1 -1
- package/src/util/getPropertiesAtLength.js +3 -3
- package/src/util/getPropertiesAtPoint.js +2 -2
- package/src/util/getSegmentAtLength.js +2 -2
- package/src/util/getSegmentOfPoint.js +2 -2
- package/src/util/getTotalLength.js +1 -1
- package/src/util/isAbsoluteArray.js +1 -1
- package/src/util/isCurveArray.js +1 -1
- package/src/util/isNormalizedArray.js +1 -1
- package/src/util/isPathArray.js +1 -1
- package/src/util/isPointInStroke.js +2 -2
- package/src/util/isRelativeArray.js +1 -1
- package/src/util/pathLengthFactory.js +3 -2
- package/src/util/segmentArcFactory.js +1 -1
- package/src/util/segmentCubicFactory.js +1 -1
- package/src/util/segmentLineFactory.js +1 -1
- package/src/util/segmentQuadFactory.js +1 -1
- package/src/util/shapeToPath.js +14 -14
- package/src/util/util.js +0 -2
- package/types/index.d.ts +1 -3
- package/types/more/modules.ts +0 -3
- package/types/more/svg.d.ts +11 -10
- package/types/svg-path-commander.d.ts +214 -226
- package/src/util/createPath.js +0 -17
- package/src/util/getPointAtPathLength.js +0 -15
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// SVGPathCommander v0.
|
|
2
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).SVGPathCommander=e()}(this,(function(){"use strict";var t={origin:[0,0,0],round:4},e={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0};function r(t){var r=t.pathValue[t.segmentStart],n=r.toLowerCase(),a=t.data;for("m"===n&&a.length>2&&(t.segments.push([r,a[0],a[1]]),a=a.slice(2),n="l",r="m"===r?"l":"L");a.length>=e[n]&&(t.segments.push([r].concat(a.splice(0,e[n]))),e[n]););}function n(t){var e=t.index,r=t.pathValue.charCodeAt(e);return 48===r?(t.param=0,void(t.index+=1)):49===r?(t.param=1,void(t.index+=1)):void(t.err='Invalid path value: invalid Arc flag "'+r+'", expecting 0 or 1 at index '+e)}function a(t){return t>=48&&t<=57}function i(t){var e,r=t.max,n=t.pathValue,i=t.index,o=i,s=!1,u=!1,c=!1,m=!1;if(o>=r)t.err="Invalid path value at "+o+": missing param "+n[o];else if(43!==(e=n.charCodeAt(o))&&45!==e||(e=(o+=1)<r?n.charCodeAt(o):0),a(e)||46===e){if(46!==e){if(s=48===e,e=(o+=1)<r?n.charCodeAt(o):0,s&&o<r&&e&&a(e))return void(t.err="Invalid path value at index "+i+": "+n[i]+" illegal number");for(;o<r&&a(n.charCodeAt(o));)o+=1,u=!0;e=o<r?n.charCodeAt(o):0}if(46===e){for(m=!0,o+=1;a(n.charCodeAt(o));)o+=1,c=!0;e=o<r?n.charCodeAt(o):0}if(101===e||69===e){if(m&&!u&&!c)return void(t.err="Invalid path value at index "+o+": "+n[o]+" invalid float exponent");if(43!==(e=(o+=1)<r?n.charCodeAt(o):0)&&45!==e||(o+=1),!(o<r&&a(n.charCodeAt(o))))return void(t.err="Invalid path value at index "+o+": "+n[o]+" invalid float exponent");for(;o<r&&a(n.charCodeAt(o));)o+=1}t.index=o,t.param=+t.pathValue.slice(i,o)}else t.err="Invalid path value at index "+o+": "+n[o]+" is not a number"}function o(t){for(var e,r=t.pathValue,n=t.max;t.index<n&&(10===(e=r.charCodeAt(t.index))||13===e||8232===e||8233===e||32===e||9===e||11===e||12===e||160===e||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(e)>=0);)t.index+=1}function s(t){return t>=48&&t<=57||43===t||45===t||46===t}function u(t){var a=t.max,u=t.pathValue,c=t.index,m=u.charCodeAt(c),f=e[u[c].toLowerCase()];if(t.segmentStart=c,function(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:return!0;default:return!1}}(m))if(t.index+=1,o(t),t.data=[],f){for(;;){for(var h=f;h>0;h-=1){if(97!=(32|m)||3!==h&&4!==h?i(t):n(t),t.err.length)return;t.data.push(t.param),o(t),t.index<a&&44===u.charCodeAt(t.index)&&(t.index+=1,o(t))}if(t.index>=t.max)break;if(!s(u.charCodeAt(t.index)))break}r(t)}else r(t);else t.err="Invalid path value: "+u[c]+" not a path command"}function c(t){return t.map((function(t){return Array.isArray(t)?[].concat(t):t}))}function m(t){this.segments=[],this.pathValue=t,this.max=t.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""}function f(t){return Array.isArray(t)&&t.every((function(t){var r=t[0].toLowerCase();return e[r]===t.length-1&&"achlmqstvz".includes(r)}))}function h(t){if(f(t))return c(t);var e=new m(t);for(o(e);e.index<e.max&&!e.err.length;)u(e);return e.err.length?e.segments=[]:e.segments.length&&("mM".includes(e.segments[0][0])?e.segments[0][0]="M":(e.err="Invalid path value: missing M/m",e.segments=[])),e.segments}function l(t){return f(t)&&t.every((function(t){return t[0]===t[0].toUpperCase()}))}function p(t){if(l(t))return c(t);var e=h(t),r=0,n=0,a=0,i=0;return e.map((function(t){var e,o=t.slice(1).map(Number),s=t[0],u=s.toUpperCase();if("M"===s)return r=(e=o)[0],n=e[1],a=r,i=n,["M",r,n];var c=[];if(s!==u)switch(u){case"A":c=[u,o[0],o[1],o[2],o[3],o[4],o[5]+r,o[6]+n];break;case"V":c=[u,o[0]+n];break;case"H":c=[u,o[0]+r];break;default:var m=o.map((function(t,e){return t+(e%2?n:r)}));c=[u].concat(m)}else c=[u].concat(o);var f=c.length;switch(u){case"Z":r=a,n=i;break;case"H":r=c[1];break;case"V":n=c[1];break;default:r=c[f-2],n=c[f-1],"M"===u&&(a=r,i=n)}return c}))}function y(t){return f(t)&&t.slice(1).every((function(t){return t[0]===t[0].toLowerCase()}))}function v(t){if(y(t))return c(t);var e=h(t),r=0,n=0,a=0,i=0;return e.map((function(t){var e,o,s=t.slice(1).map(Number),u=t[0],c=u.toLowerCase();if("M"===u)return r=(e=s)[0],n=e[1],a=r,i=n,["M",r,n];var m=[];if(u!==c)switch(c){case"a":m=[c,s[0],s[1],s[2],s[3],s[4],s[5]-r,s[6]-n];break;case"v":m=[c,s[0]-n];break;case"h":m=[c,s[0]-r];break;default:var f=s.map((function(t,e){return t-(e%2?n:r)}));m=[c].concat(f),"m"===c&&(r=(o=s)[0],n=o[1],a=r,i=n)}else"m"===u&&(a=s[0]+r,i=s[1]+n),m=[c].concat(s);var h=m.length;switch(c){case"z":r=a,n=i;break;case"h":r+=m[1];break;case"v":n+=m[1];break;default:r+=m[h-2],n+=m[h-1]}return m}))}function x(t,e,r){if(t[r].length>7){t[r].shift();for(var n=t[r],a=r;n.length;)e[r]="A",t.splice(a+=1,0,["C"].concat(n.splice(0,6)));t.splice(r,1)}}function d(t,e,r){var n=t[0],a=e.x1,i=e.y1,o=e.x2,s=e.y2,u=t.slice(1).map(Number),c=t;if("TQ".includes(n)||(e.qx=null,e.qy=null),"H"===n)c=["L",t[1],i];else if("V"===n)c=["L",a,t[1]];else if("S"===n){var m=function(t,e,r,n,a){return"CS".includes(a)?{x1:2*t-r,y1:2*e-n}:{x1:t,y1:e}}(a,i,o,s,r),f=m.x1,h=m.y1;e.x1=f,e.y1=h,c=["C",f,h].concat(u)}else if("T"===n){var l=function(t,e,r,n,a){return"QT".includes(a)?{qx:2*t-r,qy:2*e-n}:{qx:t,qy:e}}(a,i,e.qx,e.qy,r),p=l.qx,y=l.qy;e.qx=p,e.qy=y,c=["Q",p,y].concat(u)}else if("Q"===n){var v=u[0],x=u[1];e.qx=v,e.qy=x}return c}function g(t){return l(t)&&t.every((function(t){return"ACLMQZ".includes(t[0])}))}var M={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null};function b(t){if(g(t))return c(t);for(var e=p(t),r=Object.assign({},M),n=[],a=e.length,i="",o="",s=0;s<a;s+=1){i=e[s][0],n[s]=i,s&&(o=n[s-1]),e[s]=d(e[s],r,o);var u=e[s],m=u.length;r.x1=+u[m-2],r.y1=+u[m-1],r.x2=+u[m-4]||r.x1,r.y2=+u[m-3]||r.y1}return e}function w(t){var e=h(t),r=b(e),n=e.length,a="Z"===r.slice(-1)[0][0],i=a?n-2:n-1,o=r[0].slice(1),s=o[0],u=o[1],c=r[i].slice(-2),m=c[0],f=c[1];return a&&s===m&&u===f?e.slice(0,-1):e}function N(t){return f(t)&&t.every((function(t){return"MC".includes(t[0])}))}function A(t,e,r){return{x:t*Math.cos(r)-e*Math.sin(r),y:t*Math.sin(r)+e*Math.cos(r)}}function C(t,e,r,n,a,i,o,s,u,c){var m,f,h,l,p,y,v=t,x=e,d=r,g=n,M=s,b=u,w=120*Math.PI/180,N=Math.PI/180*(+a||0),S=[];if(c)h=(m=c)[0],l=m[1],p=m[2],y=m[3];else{v=(f=A(v,x,-N)).x,x=f.y;var k=(v-(M=(f=A(M,b,-N)).x))/2,P=(x-(b=f.y))/2,q=k*k/(d*d)+P*P/(g*g);q>1&&(d*=q=Math.sqrt(q),g*=q);var I=d*d,T=g*g,j=(i===o?-1:1)*Math.sqrt(Math.abs((I*T-I*P*P-T*k*k)/(I*P*P+T*k*k)));p=j*d*P/g+(v+M)/2,y=j*-g*k/d+(x+b)/2,h=(Math.asin((x-y)/g)*Math.pow(10,9)>>0)/Math.pow(10,9),l=(Math.asin((b-y)/g)*Math.pow(10,9)>>0)/Math.pow(10,9),h=v<p?Math.PI-h:h,l=M<p?Math.PI-l:l,h<0&&(h=2*Math.PI+h),l<0&&(l=2*Math.PI+l),o&&h>l&&(h-=2*Math.PI),!o&&l>h&&(l-=2*Math.PI)}var L=l-h;if(Math.abs(L)>w){var V=l,O=M,z=b;l=h+w*(o&&l>h?1:-1),S=C(M=p+d*Math.cos(l),b=y+g*Math.sin(l),d,g,a,0,o,O,z,[l,V,p,y])}L=l-h;var E=Math.cos(h),Z=Math.sin(h),Q=Math.cos(l),D=Math.sin(l),X=Math.tan(L/4),H=4/3*d*X,Y=4/3*g*X,F=[v,x],R=[v+H*Z,x-Y*E],B=[M+H*D,b-Y*Q],G=[M,b];if(R[0]=2*F[0]-R[0],R[1]=2*F[1]-R[1],c)return R.concat(B,G,S);for(var J=[],U=0,$=(S=R.concat(B,G,S)).length;U<$;U+=1)J[U]=U%2?A(S[U-1],S[U],N).y:A(S[U],S[U+1],N).x;return J}function S(t,e,r,n,a,i){return[1/3*t+2/3*r,1/3*e+2/3*n,1/3*a+2/3*r,1/3*i+2/3*n,a,i]}function k(t,e,r){var n=t[0],a=t[1];return[n+(e[0]-n)*r,a+(e[1]-a)*r]}function P(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}function q(t,e,r,n,a){var i=P([t,e],[r,n]);if("number"==typeof a){if(a<.001)return{x:t,y:e};if(a>i)return{x:r,y:n};var o=k([t,e],[r,n],a/i);return{x:o[0],y:o[1]}}return i}function I(t,e,r,n){var a=.5,i=[t,e],o=[r,n],s=k(i,o,a),u=k(o,s,a),c=k(s,u,a),m=k(u,c,a),f=k(c,m,a),h=i.concat(s,c,f,[a]),l=q.apply(void 0,h),p=f.concat(m,u,o,[0]),y=q.apply(void 0,p);return[l.x,l.y,y.x,y.y,r,n]}function T(t,e){var r,n=t[0],a=t.slice(1).map((function(t){return+t})),i=a[0],o=a[1],s=e.x1,u=e.y1,c=e.x,m=e.y;switch("TQ".includes(n)||(e.qx=null,e.qy=null),n){case"M":return e.x=i,e.y=o,t;case"A":return r=[s,u].concat(a),["C"].concat(C.apply(void 0,r));case"Q":return e.qx=i,e.qy=o,r=[s,u].concat(a),["C"].concat(S.apply(void 0,r));case"L":return["C"].concat(I(s,u,i,o));case"Z":return["C"].concat(I(s,u,c,m))}return t}function j(t){if(N(t))return c(t);for(var e=w(b(t)),r=Object.assign({},M),n=[],a="",i=e.length,o=0;o<i;o+=1){a=e[o][0],n[o]=a,e[o]=T(e[o],r),x(e,n,o),i=e.length;var s=e[o],u=s.length;r.x1=+s[u-2],r.y1=+s[u-1],r.x2=+s[u-4]||r.x1,r.y2=+s[u-3]||r.y1}return e}function L(e,r){var n=t.round;if(!1===r||!1===n)return c(e);var a=(n=r>=1?r:n)>=1?Math.pow(10,n):1;return e.map((function(t){var e=t.slice(1).map(Number).map((function(t){return t%1==0?t:Math.round(t*a)/a}));return[t[0]].concat(e)}))}function V(t,e){return L(t,e).map((function(t){return t[0]+t.slice(1).join(" ")})).join("")}function O(t){var e=p(t),r="Z"===e.slice(-1)[0][0],n=b(e).map((function(t,r){var n=t.slice(-2).map(Number),a=n[0],i=n[1];return{seg:e[r],n:t,c:e[r][0],x:a,y:i}})).map((function(t,e,n){var a=t.seg,i=t.n,o=e&&n[e-1],s=n[e+1]&&n[e+1],u=t.c,c=n.length,m=e?n[e-1].x:n[c-1].x,f=e?n[e-1].y:n[c-1].y,h=[];switch(u){case"M":h=r?["Z"]:[u,m,f];break;case"A":h=[u].concat(a.slice(1,-3),[1===a[5]?0:1],[m],[f]);break;case"C":h=s&&"S"===s.c?["S",a[1],a[2],m,f]:[u,a[3],a[4],a[1],a[2],m,f];break;case"S":h=o&&"CS".includes(o.c)&&(!s||s&&"S"!==s.c)?["C",i[3],i[4],i[1],i[2],m,f]:[u,i[1],i[2],m,f];break;case"Q":h=s&&"T"===s.c?["T",m,f]:[u].concat(a.slice(1,-2),[m],[f]);break;case"T":h=o&&"QT".includes(o.c)&&(!s||s&&"T"!==s.c)?["Q",i[1],i[2],m,f]:[u,m,f];break;case"Z":h=["M",m,f];break;case"H":h=[u,m];break;case"V":h=[u,f];break;default:h=[u].concat(a.slice(1,-2),[m],[f])}return h}));return r?n.reverse():[n[0]].concat(n.slice(1).reverse())}function z(t){return V(p(t),0).replace(/(m|M)/g,"|$1").split("|").map((function(t){return t.trim()})).filter((function(t){return t}))}function E(t,e,r,n){var a=t[0],i=function(t){return Math.round(t*Math.pow(10,4))/Math.pow(10,4)},o=t.slice(1).map((function(t){return+t})),s=e.slice(1).map((function(t){return+t})),u=r.x1,c=r.y1,m=r.x2,f=r.y2,h=r.x,l=r.y,p=t,y=s.slice(-2),v=y[0],x=y[1];if("TQ".includes(a)||(r.qx=null,r.qy=null),["V","H","S","T","Z"].includes(a))p=[a].concat(o);else if("L"===a)i(h)===i(v)?p=["V",x]:i(l)===i(x)&&(p=["H",v]);else if("C"===a){var d=s[0],g=s[1];"CS".includes(n)&&i(d)===i(2*u-m)&&i(g)===i(2*c-f)&&(p=["S"].concat(s.slice(-4))),r.x1=d,r.y1=g}else if("Q"===a){var M=s[0],b=s[1];r.qx=M,r.qy=b,"QT".includes(n)&&i(M)===i(2*u-m)&&i(b)===i(2*c-f)&&(p=["T"].concat(s.slice(-2)))}return p}function Z(t,e){for(var r,n=p(t),a=b(n),i=Object.assign({},M),o=[],s=n.length,u="",c="",m=0,f=0,h=0,l=0,y=0;y<s;y+=1){u=n[y][0],o[y]=u,y&&(c=o[y-1]),n[y]=E(n[y],a[y],i,c);var x=n[y],d=x.length;switch(i.x1=+x[d-2],i.y1=+x[d-1],i.x2=+x[d-4]||i.x1,i.y2=+x[d-3]||i.y1,u){case"Z":m=h,f=l;break;case"H":m=x[1];break;case"V":f=x[1];break;default:m=(r=x.slice(-2).map(Number))[0],f=r[1],"M"===u&&(h=m,l=f)}i.x=m,i.y=f}var g=L(n,e),w=L(v(n),e);return g.map((function(t,e){return e?t.join("").length<w[e].join("").length?t:w[e]:t}))}function Q(t){var e=new U,r=Array.from(t);if(!r.every((function(t){return!Number.isNaN(t)})))throw TypeError('CSSMatrix: "'+t+'" must only have numbers.');if(16===r.length){var n=r[0],a=r[1],i=r[2],o=r[3],s=r[4],u=r[5],c=r[6],m=r[7],f=r[8],h=r[9],l=r[10],p=r[11],y=r[12],v=r[13],x=r[14],d=r[15];e.m11=n,e.a=n,e.m21=s,e.c=s,e.m31=f,e.m41=y,e.e=y,e.m12=a,e.b=a,e.m22=u,e.d=u,e.m32=h,e.m42=v,e.f=v,e.m13=i,e.m23=c,e.m33=l,e.m43=x,e.m14=o,e.m24=m,e.m34=p,e.m44=d}else{if(6!==r.length)throw new TypeError("CSSMatrix: expecting an Array of 6/16 values.");var g=r[0],M=r[1],b=r[2],w=r[3],N=r[4],A=r[5];e.m11=g,e.a=g,e.m12=M,e.b=M,e.m21=b,e.c=b,e.m22=w,e.d=w,e.m41=N,e.e=N,e.m42=A,e.f=A}return e}function D(t){var e=Object.keys(new U);if("object"==typeof t&&e.every((function(e){return e in t})))return Q([t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44]);throw TypeError('CSSMatrix: "'+t+'" is not a DOMMatrix / CSSMatrix / JSON compatible object.')}function X(t){if("string"!=typeof t)throw TypeError('CSSMatrix: "'+t+'" is not a string.');var e=String(t).replace(/\s/g,""),r=new U,n='CSSMatrix: invalid transform string "'+t+'"';return e.split(")").filter((function(t){return t})).forEach((function(t){var e=t.split("("),a=e[0],i=e[1];if(!i)throw TypeError(n);var o=i.split(",").map((function(t){return t.includes("rad")?parseFloat(t)*(180/Math.PI):parseFloat(t)})),s=o[0],u=o[1],c=o[2],m=o[3],f=[s,u,c],h=[s,u,c,m];if("perspective"===a&&s&&[u,c].every((function(t){return void 0===t})))r.m34=-1/s;else if(a.includes("matrix")&&[6,16].includes(o.length)&&o.every((function(t){return!Number.isNaN(+t)}))){var l=o.map((function(t){return Math.abs(t)<1e-6?0:t}));r=r.multiply(Q(l))}else if("translate3d"===a&&f.every((function(t){return!Number.isNaN(+t)})))r=r.translate(s,u,c);else if("translate"===a&&s&&void 0===c)r=r.translate(s,u||0,0);else if("rotate3d"===a&&h.every((function(t){return!Number.isNaN(+t)}))&&m)r=r.rotateAxisAngle(s,u,c,m);else if("rotate"===a&&s&&[u,c].every((function(t){return void 0===t})))r=r.rotate(0,0,s);else if("scale3d"===a&&f.every((function(t){return!Number.isNaN(+t)}))&&f.some((function(t){return 1!==t})))r=r.scale(s,u,c);else if("scale"!==a||Number.isNaN(s)||1===s||void 0!==c)if("skew"===a&&s&&void 0===c)r=r.skewX(s),r=u?r.skewY(u):r;else{if(!(/[XYZ]/.test(a)&&s&&[u,c].every((function(t){return void 0===t}))&&["translate","rotate","scale","skew"].some((function(t){return a.includes(t)}))))throw TypeError(n);if(["skewX","skewY"].includes(a))r=r[a](s);else{var p=a.replace(/[XYZ]/,""),y=a.replace(p,""),v=["X","Y","Z"].indexOf(y),x=[0===v?s:0,1===v?s:0,2===v?s:0];r=r[p].apply(r,x)}}else{var d=Number.isNaN(+u)?s:u;r=r.scale(s,d,1)}})),r}function H(t,e,r){var n=new U;return n.m41=t,n.e=t,n.m42=e,n.f=e,n.m43=r,n}function Y(t,e,r){var n=new U,a=Math.PI/180,i=t*a,o=e*a,s=r*a,u=Math.cos(i),c=-Math.sin(i),m=Math.cos(o),f=-Math.sin(o),h=Math.cos(s),l=-Math.sin(s),p=m*h,y=-m*l;n.m11=p,n.a=p,n.m12=y,n.b=y,n.m13=f;var v=c*f*h+u*l;n.m21=v,n.c=v;var x=u*h-c*f*l;return n.m22=x,n.d=x,n.m23=-c*m,n.m31=c*l-u*f*h,n.m32=c*h+u*f*l,n.m33=u*m,n}function F(t,e,r,n){var a=new U,i=n*(Math.PI/360),o=Math.sin(i),s=Math.cos(i),u=o*o,c=Math.sqrt(t*t+e*e+r*r),m=t,f=e,h=r;0===c?(m=0,f=0,h=1):(m/=c,f/=c,h/=c);var l=m*m,p=f*f,y=h*h,v=1-2*(p+y)*u;a.m11=v,a.a=v;var x=2*(m*f*u+h*o*s);a.m12=x,a.b=x,a.m13=2*(m*h*u-f*o*s);var d=2*(f*m*u-h*o*s);a.m21=d,a.c=d;var g=1-2*(y+l)*u;return a.m22=g,a.d=g,a.m23=2*(f*h*u+m*o*s),a.m31=2*(h*m*u+f*o*s),a.m32=2*(h*f*u-m*o*s),a.m33=1-2*(l+p)*u,a}function R(t,e,r){var n=new U;return n.m11=t,n.a=t,n.m22=e,n.d=e,n.m33=r,n}function B(t){var e=new U,r=t*Math.PI/180,n=Math.tan(r);return e.m21=n,e.c=n,e}function G(t){var e=new U,r=t*Math.PI/180,n=Math.tan(r);return e.m12=n,e.b=n,e}function J(t,e){return Q([e.m11*t.m11+e.m12*t.m21+e.m13*t.m31+e.m14*t.m41,e.m11*t.m12+e.m12*t.m22+e.m13*t.m32+e.m14*t.m42,e.m11*t.m13+e.m12*t.m23+e.m13*t.m33+e.m14*t.m43,e.m11*t.m14+e.m12*t.m24+e.m13*t.m34+e.m14*t.m44,e.m21*t.m11+e.m22*t.m21+e.m23*t.m31+e.m24*t.m41,e.m21*t.m12+e.m22*t.m22+e.m23*t.m32+e.m24*t.m42,e.m21*t.m13+e.m22*t.m23+e.m23*t.m33+e.m24*t.m43,e.m21*t.m14+e.m22*t.m24+e.m23*t.m34+e.m24*t.m44,e.m31*t.m11+e.m32*t.m21+e.m33*t.m31+e.m34*t.m41,e.m31*t.m12+e.m32*t.m22+e.m33*t.m32+e.m34*t.m42,e.m31*t.m13+e.m32*t.m23+e.m33*t.m33+e.m34*t.m43,e.m31*t.m14+e.m32*t.m24+e.m33*t.m34+e.m34*t.m44,e.m41*t.m11+e.m42*t.m21+e.m43*t.m31+e.m44*t.m41,e.m41*t.m12+e.m42*t.m22+e.m43*t.m32+e.m44*t.m42,e.m41*t.m13+e.m42*t.m23+e.m43*t.m33+e.m44*t.m43,e.m41*t.m14+e.m42*t.m24+e.m43*t.m34+e.m44*t.m44])}var U=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var r=this;if(r.a=1,r.b=0,r.c=0,r.d=1,r.e=0,r.f=0,r.m11=1,r.m12=0,r.m13=0,r.m14=0,r.m21=0,r.m22=1,r.m23=0,r.m24=0,r.m31=0,r.m32=0,r.m33=1,r.m34=0,r.m41=0,r.m42=0,r.m43=0,r.m44=1,t&&t.length){var n=[16,6].some((function(e){return e===t.length}))?t:t[0];return r.setMatrixValue(n)}return r},$={isIdentity:{configurable:!0},is2D:{configurable:!0}};$.isIdentity.set=function(t){this.isIdentity=t},$.isIdentity.get=function(){var t=this;return 1===t.m11&&0===t.m12&&0===t.m13&&0===t.m14&&0===t.m21&&1===t.m22&&0===t.m23&&0===t.m24&&0===t.m31&&0===t.m32&&1===t.m33&&0===t.m34&&0===t.m41&&0===t.m42&&0===t.m43&&1===t.m44},$.is2D.get=function(){var t=this;return 0===t.m31&&0===t.m32&&1===t.m33&&0===t.m34&&0===t.m43&&1===t.m44},$.is2D.set=function(t){this.is2D=t},U.prototype.setMatrixValue=function(t){return[Array,Float64Array,Float32Array].some((function(e){return t instanceof e}))?Q(t):"string"==typeof t&&t.length&&"none"!==t?X(t):"object"==typeof t?D(t):this},U.prototype.toArray=function(){var t=this,e=Math.pow(10,6);return(t.is2D?[t.a,t.b,t.c,t.d,t.e,t.f]:[t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44]).map((function(t){return Math.abs(t)<1e-6?0:(t*e>>0)/e}))},U.prototype.toString=function(){var t=this.toArray();return(this.is2D?"matrix":"matrix3d")+"("+t+")"},U.prototype.toJSON=function(){var t=this,e=t.is2D,r=t.isIdentity;return Object.assign({},t,{is2D:e,isIdentity:r})},U.prototype.multiply=function(t){return J(this,t)},U.prototype.translate=function(t,e,r){var n=e,a=r;return void 0===a&&(a=0),void 0===n&&(n=0),J(this,H(t,n,a))},U.prototype.scale=function(t,e,r){var n=e,a=r;return void 0===n&&(n=t),void 0===a&&(a=1),J(this,R(t,n,a))},U.prototype.rotate=function(t,e,r){var n=t,a=e,i=r;return void 0===a&&(a=0),void 0===i&&(i=n,n=0),J(this,Y(n,a,i))},U.prototype.rotateAxisAngle=function(t,e,r,n){if([t,e,r,n].some((function(t){return Number.isNaN(t)})))throw new TypeError("CSSMatrix: expecting 4 values");return J(this,F(t,e,r,n))},U.prototype.skewX=function(t){return J(this,B(t))},U.prototype.skewY=function(t){return J(this,G(t))},U.prototype.transformPoint=function(t){var e=H(t.x,t.y,t.z);return e.m44=t.w||1,{x:(e=this.multiply(e)).m41,y:e.m42,z:e.m43,w:e.m44}},U.prototype.transform=function(t){var e=this,r=e.m11*t.x+e.m12*t.y+e.m13*t.z+e.m14*t.w,n=e.m21*t.x+e.m22*t.y+e.m23*t.z+e.m24*t.w,a=e.m31*t.x+e.m32*t.y+e.m33*t.z+e.m34*t.w,i=e.m41*t.x+e.m42*t.y+e.m43*t.z+e.m44*t.w;return{x:r/i,y:n/i,z:a/i,w:i}},Object.defineProperties(U.prototype,$),Object.assign(U,{Translate:H,Rotate:Y,RotateAxisAngle:F,Scale:R,SkewX:B,SkewY:G,Multiply:J,fromArray:Q,fromMatrix:D,fromString:X});function K(t,e,r){var n=e[0],a=e[1],i=r[0],o=r[1],s=r[2],u=t.transformPoint({x:n,y:a,z:0,w:1}),c=u.x-i,m=u.y-o,f=u.z-s;return[c*(Math.abs(s)/Math.abs(f))+i,m*(Math.abs(s)/Math.abs(f))+o]}function W(t,e){var r,n,a,i,o,s,u,m=0,f=0,h=p(t),l=b(h),y=function(t){var e=new U,r=t.origin,n=r[0],a=r[1],i=t.translate,o=t.rotate,s=t.skew,u=t.scale;return Array.isArray(i)&&i.every((function(t){return!Number.isNaN(+t)}))&&i.some((function(t){return 0!==t}))?e=e.translate(i[0]||0,i[1]||0,i[2]||0):"number"!=typeof i||Number.isNaN(+i)||(e=e.translate(i||0,0,0)),(o||s||u)&&(e=e.translate(n,a),Array.isArray(o)&&o.every((function(t){return!Number.isNaN(+t)}))&&o.some((function(t){return 0!==t}))?e=e.rotate(o[0],o[1],o[2]):"number"!=typeof o||Number.isNaN(+o)||(e=e.rotate(0,0,o)),Array.isArray(s)&&s.every((function(t){return!Number.isNaN(+t)}))&&s.some((function(t){return 0!==t}))?(e=s[0]?e.skewX(s[0]):e,e=s[1]?e.skewY(s[1]):e):"number"!=typeof s||Number.isNaN(+s)||(e=e.skewX(s||0)),Array.isArray(u)&&u.every((function(t){return!Number.isNaN(+t)}))&&u.some((function(t){return 1!==t}))?e=e.scale(u[0],u[1],u[2]):"number"!=typeof u||Number.isNaN(+u)||(e=e.scale(u||1,u||1,u||1)),e=e.translate(-n,-a)),e}(e),v=Object.keys(e),d=e.origin,g=[y.a,y.b,y.c,y.d,y.e,y.f],w=Object.assign({},M),N=[],A=0,C="",S=[],k=[];if(!y.isIdentity){for(r=0,a=h.length;r<a;r+=1){N=h[r],h[r]&&(C=N[0]),k[r]=C,"A"!==C||y.is2D&&["skewX","skewY"].find((function(t){return v.includes(t)}))||(N=T(l[r],w),h[r]=T(l[r],w),x(h,k,r),l[r]=T(l[r],w),x(l,k,r),a=Math.max(h.length,l.length)),A=(N=l[r]).length,w.x1=+N[A-2],w.y1=+N[A-1],w.x2=+N[A-4]||w.x1,w.y2=+N[A-3]||w.y1;var P={s:h[r],c:h[r][0],x:w.x1,y:w.y1};S=S.concat([P])}return S.map((function(t){var e,r,a;switch(C=t.c,N=t.s,C){case"A":return u=function(t,e,r,n){var a=Math.cos(n*Math.PI/180),i=Math.sin(n*Math.PI/180),o=[e*(t[0]*a+t[2]*i),e*(t[1]*a+t[3]*i),r*(-t[0]*i+t[2]*a),r*(-t[1]*i+t[3]*a)],s=o[0]*o[0]+o[2]*o[2],u=o[1]*o[1]+o[3]*o[3],c=((o[0]-o[3])*(o[0]-o[3])+(o[2]+o[1])*(o[2]+o[1]))*((o[0]+o[3])*(o[0]+o[3])+(o[2]-o[1])*(o[2]-o[1])),m=(s+u)/2;if(c<1e-9*m){var f=Math.sqrt(m);return{rx:f,ry:f,ax:0}}var h,l,p=o[0]*o[1]+o[2]*o[3],y=m+(c=Math.sqrt(c))/2,v=m-c/2,x=Math.abs(p)<1e-9&&Math.abs(y-u)<1e-9?90:Math.atan(Math.abs(p)>Math.abs(y-u)?(y-s)/p:p/(y-u)*180)/Math.PI;return x>=0?(h=Math.sqrt(y),l=Math.sqrt(v)):(x+=90,h=Math.sqrt(v),l=Math.sqrt(y)),{rx:h,ry:l,ax:x}}(g,N[1],N[2],N[3]),g[0]*g[3]-g[1]*g[2]<0&&(N[5]=N[5]?0:1),e=K(y,[+N[6],+N[7]],d),o=e[0],s=e[1],N=m===o&&f===s||u.rx<1e-9*u.ry||u.ry<1e-9*u.rx?["L",o,s]:[C,u.rx,u.ry,u.ax,N[4],N[5],o,s],m=o,f=s,N;case"L":case"H":case"V":return r=K(y,[t.x,t.y],d),o=r[0],s=r[1],m!==o&&f!==s?N=["L",o,s]:f===s?N=["H",o]:m===o&&(N=["V",s]),m=o,f=s,N;default:for(n=1,i=N.length;n<i;n+=2)a=K(y,[+N[n],+N[n+1]],d),m=a[0],f=a[1],N[n]=m,N[n+1]=f;return N}}))}return c(h)}function _(t,e,r,n,a,i,o,s,u){var c=1-u;return{x:Math.pow(c,3)*t+3*Math.pow(c,2)*u*r+3*c*Math.pow(u,2)*a+Math.pow(u,3)*o,y:Math.pow(c,3)*e+3*Math.pow(c,2)*u*n+3*c*Math.pow(u,2)*i+Math.pow(u,3)*s}}function tt(t,e,r,n,a,i,o,s,u){var c,m="number"==typeof u,f=t,h=e,l=0,p=[t,e,l],y=[t,e];if(m&&u<.001)return{x:f,y:h};for(var v=0;v<=100;v+=1){if(l+=P(y,[f=(c=_(t,e,r,n,a,i,o,s,v/100)).x,h=c.y]),y=[f,h],m&&l>=u){var x=(l-u)/(l-p[2]);return{x:y[0]*(1-x)+p[0]*x,y:y[1]*(1-x)+p[1]*x}}p=[f,h,l]}return m&&u>=l?{x:o,y:s}:l}function et(t,e,r,n,a,i,o,s){var u,c,m,f,h=a-2*r+t-(o-2*a+r),l=2*(r-t)-2*(a-r),p=t-r,y=(-l+Math.sqrt(l*l-4*h*p))/2/h,v=(-l-Math.sqrt(l*l-4*h*p))/2/h,x=[t,o],d=[e,s],g=0,M=0;return Math.abs(y)>1e12&&(y=.5),Math.abs(v)>1e12&&(v=.5),y>0&&y<1&&(g=(u=tt(t,e,r,n,a,i,o,s,y)).x,M=u.y,x.push(g),d.push(M)),v>0&&v<1&&(g=(c=tt(t,e,r,n,a,i,o,s,v)).x,M=c.y,x.push(g),d.push(M)),h=i-2*n+e-(s-2*i+n),p=e-n,y=(-(l=2*(n-e)-2*(i-n))+Math.sqrt(l*l-4*h*p))/2/h,v=(-l-Math.sqrt(l*l-4*h*p))/2/h,Math.abs(y)>1e12&&(y=.5),Math.abs(v)>1e12&&(v=.5),y>0&&y<1&&(g=(m=tt(t,e,r,n,a,i,o,s,y)).x,M=m.y,x.push(g),d.push(M)),v>0&&v<1&&(g=(f=tt(t,e,r,n,a,i,o,s,v)).x,M=f.y,x.push(g),d.push(M)),{min:{x:Math.min.apply(Math,x),y:Math.min.apply(Math,d)},max:{x:Math.max.apply(Math,x),y:Math.max.apply(Math,d)}}}function rt(t){if(!t)return{x:0,y:0,width:0,height:0,x2:0,y2:0,cx:0,cy:0,cz:0};var e=j(t),r=0,n=0,a=[],i=[];e.forEach((function(t){var e=t.slice(-2).map(Number),o=e[0],s=e[1];if("M"===t[0])r=o,n=s,a.push(o),i.push(s);else{var u=[r,n].concat(t.slice(1)),c=et.apply(void 0,u);a=a.concat([c.min.x],[c.max.x]),i=i.concat([c.min.y],[c.max.y]),r=o,n=s}}));var o=Math.min.apply(Math,a),s=Math.min.apply(Math,i),u=Math.max.apply(Math,a),c=Math.max.apply(Math,i),m=u-o,f=c-s;return{width:m,height:f,x:o,y:s,x2:u,y2:c,cx:o+m/2,cy:s+f/2,cz:Math.max(m,f)+Math.min(m,f)/2}}Object.assign(U,{Version:"0.0.24"});var nt=function(e,r){var n=r||{};this.segments=h(e);var a=rt(this.segments),i=a.width,o=a.height,s=a.cx,u=a.cy,c=a.cz,m=t.round,f=t.origin,l=n.round,p=n.origin;if("auto"===l){var y=(""+Math.floor(Math.max(i,o))).length;m=y>=4?0:4-y}else(Number.isInteger(l)&&l>=1||!1===l)&&(m=l);if(Array.isArray(p)&&p.length>=2){var v=p.map(Number),x=v[0],d=v[1],g=v[2];f=[Number.isNaN(x)?s:x,Number.isNaN(d)?u:d,g||c]}else f=[s,u,c];return this.round=m,this.origin=f,this};function at(t,e,r,n,a,i,o,s){return 3*((s-e)*(r+a)-(o-t)*(n+i)+n*(t-a)-r*(e-i)+s*(a+t/3)-o*(i+e/3))/20}function it(t){var e=0,r=0,n=0;return j(t).map((function(t){var a,i;switch(t[0]){case"M":return e=(a=t)[1],r=a[2],0;default:return n=at.apply(void 0,[e,r].concat(t.slice(1))),i=t.slice(-2),e=i[0],r=i[1],n}})).reduce((function(t,e){return t+e}),0)}function ot(t,e,r,n,a,i,o,s,u,c){var m,f=C(t,e,r,n,a,i,o,s,u),h="number"==typeof c,l=[t,e],p=l[0],y=l[1],v=0,x=[],d=[],g=0;if(h&&c<.001)return{x:p,y:y};for(var M=0,b=f.length;M<b;M+=6){if(x=f.slice(M,M+6),d=[p,y].concat(x),g=tt.apply(void 0,d),h&&v+g>=c)return tt.apply(void 0,d.concat([c-v]));v+=g,p=(m=x.slice(-2))[0],y=m[1]}return h&&c>=v?{x:s,y:u}:v}function st(t,e,r,n,a,i,o){var s=1-o;return{x:Math.pow(s,2)*t+2*s*o*r+Math.pow(o,2)*a,y:Math.pow(s,2)*e+2*s*o*n+Math.pow(o,2)*i}}function ut(t,e,r,n,a,i,o){var s,u="number"==typeof o,c=t,m=e,f=0,h=[t,e,f],l=[t,e];if(u&&o<.001)return{x:c,y:m};for(var p=0;p<=100;p+=1){if(f+=P(l,[c=(s=st(t,e,r,n,a,i,p/100)).x,m=s.y]),l=[c,m],u&&f>=o){var y=(f-o)/(f-h[2]);return{x:l[0]*(1-y)+h[0]*y,y:l[1]*(1-y)+h[1]*y}}h=[c,m,f]}return u&&o>=f?{x:a,y:i}:f}function ct(t,e){for(var r,n,a,i=w(b(t)),o="number"==typeof e,s=0,u=!0,c=[],m="M",f=0,h=0,l=0,p=0,y=0,v=0,x=i.length;v<x;v+=1){if(c=(u="M"===(m=(a=i[v])[0]))?c:[h,l].concat(a.slice(1)),u){if(p=(r=a)[1],y=r[2],o&&e<.001)return{x:p,y:y}}else if("L"===m){if(f=q.apply(void 0,c),o&&s+f>=e)return q.apply(void 0,c.concat([e-s]));s+=f}else if("A"===m){if(f=ot.apply(void 0,c),o&&s+f>=e)return ot.apply(void 0,c.concat([e-s]));s+=f}else if("C"===m){if(f=tt.apply(void 0,c),o&&s+f>=e)return tt.apply(void 0,c.concat([e-s]));s+=f}else if("Q"===m){if(f=ut.apply(void 0,c),o&&s+f>=e)return ut.apply(void 0,c.concat([e-s]));s+=f}else if("Z"===m){if(c=[h,l,p,y],f=q.apply(void 0,c),o&&s+f>=e)return q.apply(void 0,c.concat([e-s]));s+=f}h=(n="Z"!==m?a.slice(-2):[p,y])[0],l=n[1]}return o&&e>=s?{x:h,y:l}:s}function mt(t){return ct(t)}function ft(t,e){return ct(t,e)}function ht(t,e){var r=h(t),n=[],a=[].concat(r),i=mt(a),o=a.length-1,s=0,u=0,c=r[0],m=c.slice(-2),f={x:m[0],y:m[1]};if(o<=0||!e||!Number.isFinite(e))return{segment:c,index:0,length:u,point:f,lengthAtSegment:s};if(e>=i)return u=i-(s=mt(a=r.slice(0,-1))),{segment:r[o],index:o,length:u,lengthAtSegment:s};for(;o>0;)c=a[o],u=i-(s=mt(a=a.slice(0,-1))),i=s,n.push({segment:c,index:o,length:u,lengthAtSegment:s}),o-=1;return n.find((function(t){return t.lengthAtSegment<=e}))}function lt(t,e){for(var r=w(h(t)),n=b(r),a=mt(r),i=function(t){var r=t.x-e.x,n=t.y-e.y;return r*r+n*n},o=8,s={x:0,y:0},u=0,c=s,m=0,f=1/0,l=0;l<=a;l+=o)(u=i(s=ft(n,l)))<f&&(c=s,m=l,f=u);o/=2;for(var p={x:0,y:0},y=p,v=0,x=0,d=0,g=0;o>.5;)d=i(p=ft(n,v=m-o)),g=i(y=ft(n,x=m+o)),v>=0&&d<f?(c=p,m=v,f=d):x<=a&&g<f?(c=y,m=x,f=g):o/=2;var M=ht(r,m);return{closest:c,distance:Math.sqrt(f),segment:M}}nt.prototype.toAbsolute=function(){var t=this.segments;return this.segments=p(t),this},nt.prototype.toRelative=function(){var t=this.segments;return this.segments=v(t),this},nt.prototype.toCurve=function(){var t=this.segments;return this.segments=j(t),this},nt.prototype.reverse=function(t){this.toAbsolute();var e=this.segments,r=z(this.toString()),n=r.length>1?r:0,a=n&&c(n).map((function(e,r){return t?r?O(e):h(e):O(e)})),i=[];return i=n?a.flat(1):t?e:O(e),this.segments=c(i),this},nt.prototype.normalize=function(){var t=this.segments;return this.segments=b(t),this},nt.prototype.optimize=function(){var t=this.segments;return this.segments=Z(t,this.round),this},nt.prototype.transform=function(t){if(!t||"object"!=typeof t||"object"==typeof t&&!["translate","rotate","skew","scale"].some((function(e){return e in t})))return this;var e={};Object.keys(t).forEach((function(r){e[r]=Array.isArray(t[r])?[].concat(t[r]):Number(t[r])}));var r=this.segments,n=e.origin;if(n&&n.length>=2){var a=n.map(Number),i=a[0],o=a[1],s=a[2],u=this.origin,c=u[0],m=u[1],f=u[2];e.origin=[Number.isNaN(i)?c:i,Number.isNaN(o)?m:o,s||f]}else e.origin=Object.assign({},this.origin);return this.segments=W(r,e),this},nt.prototype.flipX=function(){return this.transform({rotate:[180,0,0]}),this},nt.prototype.flipY=function(){return this.transform({rotate:[0,180,0]}),this},nt.prototype.toString=function(){return V(this.segments,this.round)};var pt={circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],rect:["width","height","x","y","rx","ry"],polygon:["points"],polyline:["points"],glyph:[]};var yt={CSSMatrix:U,parsePathString:h,isPathArray:f,isCurveArray:N,isAbsoluteArray:l,isRelativeArray:y,isNormalizedArray:g,isValidPath:function(t){if("string"!=typeof t)return!1;var e=new m(t);for(o(e);e.index<e.max&&!e.err.length;)u(e);return!e.err.length&&"mM".includes(e.segments[0][0])},pathToAbsolute:p,pathToRelative:v,pathToCurve:j,pathToString:V,getDrawDirection:function(t){return it(j(t))>=0},getPathArea:it,getPathBBox:rt,getTotalLength:mt,getPathLength:function(t){var e=0;return j(t).forEach((function(t,r,n){var a="M"!==t[0]?n[r-1].slice(-2).concat(t.slice(1)):[];e+="M"===t[0]?0:tt.apply(void 0,a)})),e},getPointAtLength:ft,getPointAtPathLength:function(t,e){return ft(t,e)},getClosestPoint:function(t,e){return lt(t,e).closest},getSegmentOfPoint:function(t,e){var r=lt(t,e).segment;return void 0!==r?r.segment:null},getPropertiesAtPoint:lt,getPropertiesAtLength:ht,getSegmentAtLength:function(t,e){var r=ht(t,e);return(void 0!==r?r:{segment:null}).segment},isPointInStroke:function(t,e){var r=lt(t,e).distance;return Math.abs(r)<.01},clonePath:c,splitPath:z,fixPath:w,roundPath:L,optimizePath:Z,reverseCurve:function(t){var e=t.slice(1).map((function(e,r,n){return r?n[r-1].slice(-2).concat(e.slice(1)):t[0].slice(1).concat(e.slice(1))})).map((function(t){return t.map((function(e,r){return t[t.length-r-2*(1-r%2)]}))})).reverse();return[["M"].concat(e[0].slice(0,2))].concat(e.map((function(t){return["C"].concat(t.slice(2))})))},reversePath:O,normalizePath:b,transformPath:W,shapeToPath:function(e,r){var n=Object.keys(pt),a=e instanceof Element;if(a&&!n.some((function(t){return e.tagName===t})))throw TypeError('shapeToPath: "'+e+'" is not SVGElement');var i,o=document.createElementNS("http://www.w3.org/2000/svg","path"),s=a?e.tagName:e.type,u={};if(u.type=s,a){var c=pt[s];c.forEach((function(t){u[t]=e.getAttribute(t)})),Object.values(e.attributes).forEach((function(t){var e=t.name,r=t.value;c.includes(e)||o.setAttribute(e,r)}))}else Object.assign(u,e);var m,f,h,l,p=t.round;return"circle"===s?i=V((f=(m=u).cx,h=m.cy,l=m.r,[["M",f-l,h],["a",l,l,0,1,0,2*l,0],["a",l,l,0,1,0,-2*l,0]]),p):"ellipse"===s?i=V(function(t){var e=t.cx,r=t.cy,n=t.rx,a=t.ry;return[["M",e-n,r],["a",n,a,0,1,0,2*n,0],["a",n,a,0,1,0,-2*n,0]]}(u),p):["polyline","polygon"].includes(s)?i=V(function(t){for(var e=[],r=t.points.split(/[\s|,]/).map(Number),n=0;n<r.length;)e.push([n?"L":"M",r[n],r[n+1]]),n+=2;return"polygon"===t.type?e.concat([["z"]]):e}(u),p):"rect"===s?i=V(function(t){var e=+t.x||0,r=+t.y||0,n=+t.width,a=+t.height,i=+t.rx,o=+t.ry;return i||o?(i=i||o,o=o||i,2*i>n&&(i-=(2*i-n)/2),2*o>a&&(o-=(2*o-a)/2),[["M",e+i,r],["h",n-2*i],["s",i,0,i,o],["v",a-2*o],["s",0,o,-i,o],["h",2*i-n],["s",-i,0,-i,-o],["v",2*o-a],["s",0,-o,i,-o]]):[["M",e,r],["h",n],["v",a],["H",e],["Z"]]}(u),p):"line"===s?i=V(function(t){return[["M",t.x1,t.y1],["L",t.x2,t.y2]]}(u),p):"glyph"===s&&(i=a?e.getAttribute("d"):e.type),!!i&&(o.setAttribute("d",i),r&&a&&(e.before(o,e),e.remove()),o)},options:t};return Object.assign(nt,yt,{Version:"0.1.24"}),nt}));
|
|
1
|
+
// SVGPathCommander v0.2.0alpha2 | thednp © 2022 | MIT-License
|
|
2
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).SVGPathCommander=e()}(this,(function(){"use strict";const t={origin:[0,0,0],round:4},e={a:7,c:6,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,z:0};function n(t){let n=t.pathValue[t.segmentStart],r=n.toLowerCase(),{data:s}=t;for("m"===r&&s.length>2&&(t.segments.push([n,s[0],s[1]]),s=s.slice(2),r="l",n="m"===n?"l":"L");s.length>=e[r]&&(t.segments.push([n,...s.splice(0,e[r])]),e[r]););}const r="SVGPathCommander error";function s(t){const{index:e}=t,n=t.pathValue.charCodeAt(e);return 48===n?(t.param=0,void(t.index+=1)):49===n?(t.param=1,void(t.index+=1)):void(t.err=`${r}: invalid Arc flag "${n}", expecting 0 or 1 at index ${e}`)}function i(t){return t>=48&&t<=57}function a(t){const{max:e,pathValue:n,index:s}=t;let a,o=s,m=!1,c=!1,u=!1,l=!1;if(o>=e)t.err=`${r}: Invalid path value at index ${o}, "pathValue" is missing param`;else if(a=n.charCodeAt(o),43!==a&&45!==a||(o+=1,a=o<e?n.charCodeAt(o):0),i(a)||46===a){if(46!==a){if(m=48===a,o+=1,a=o<e?n.charCodeAt(o):0,m&&o<e&&a&&i(a))return void(t.err=`${r}: Invalid path value at index ${s}, "${n[s]}" illegal number`);for(;o<e&&i(n.charCodeAt(o));)o+=1,c=!0;a=o<e?n.charCodeAt(o):0}if(46===a){for(l=!0,o+=1;i(n.charCodeAt(o));)o+=1,u=!0;a=o<e?n.charCodeAt(o):0}if(101===a||69===a){if(l&&!c&&!u)return void(t.err=`${r}: Invalid path value at index ${o}, "${n[o]}" invalid float exponent`);if(o+=1,a=o<e?n.charCodeAt(o):0,43!==a&&45!==a||(o+=1),!(o<e&&i(n.charCodeAt(o))))return void(t.err=`${r}: Invalid path value at index ${o}: "${n[o]}" invalid float exponent`);for(;o<e&&i(n.charCodeAt(o));)o+=1}t.index=o,t.param=+t.pathValue.slice(s,o)}else t.err=`${r}: Invalid path value at index ${o}, "${n[o]}" is not a number`}function o(t){const{pathValue:e,max:n}=t;for(;t.index<n&&(10===(r=e.charCodeAt(t.index))||13===r||8232===r||8233===r||32===r||9===r||11===r||12===r||160===r||r>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].includes(r));)t.index+=1;var r}function m(t){return t>=48&&t<=57||43===t||45===t||46===t}function c(t){const{max:i,pathValue:c,index:u}=t,l=c.charCodeAt(u),h=e[c[u].toLowerCase()];if(t.segmentStart=u,function(t){switch(32|t){case 109:case 122:case 108:case 104:case 118:case 99:case 115:case 113:case 116:case 97:return!0;default:return!1}}(l))if(t.index+=1,o(t),t.data=[],h){for(;;){for(let e=h;e>0;e-=1){if(97!=(32|l)||3!==e&&4!==e?a(t):s(t),t.err.length)return;t.data.push(t.param),o(t),t.index<i&&44===c.charCodeAt(t.index)&&(t.index+=1,o(t))}if(t.index>=t.max)break;if(!m(c.charCodeAt(t.index)))break}n(t)}else n(t);else t.err=`${r}: Invalid path value "${c[u]}" is not a path command`}function u(t){return t.map(t=>Array.isArray(t)?[...t]:t)}function l(t){this.segments=[],this.pathValue=t,this.max=t.length,this.index=0,this.param=0,this.segmentStart=0,this.data=[],this.err=""}function h(t){return Array.isArray(t)&&t.every(t=>{const n=t[0].toLowerCase();return e[n]===t.length-1&&"achlmqstvz".includes(n)})}function f(t){if(h(t))return u(t);const e=new l(t);for(o(e);e.index<e.max&&!e.err.length;)c(e);return e.err.length||("mM".includes(e.segments[0][0])?e.segments[0][0]="M":e.err=r+": missing M/m"),e.err?e.err:e.segments}function y(t){return h(t)&&t.every(t=>t[0]===t[0].toUpperCase())}function x(t){if(y(t))return u(t);const e=f(t);let n=0,r=0,s=0,i=0;return e.map(t=>{const e=t.slice(1).map(Number),[a]=t,o=a.toUpperCase();if("M"===a)return[n,r]=e,s=n,i=r,["M",n,r];let m=[];if(a!==o)switch(o){case"A":m=[o,e[0],e[1],e[2],e[3],e[4],e[5]+n,e[6]+r];break;case"V":m=[o,e[0]+r];break;case"H":m=[o,e[0]+n];break;default:m=[o,...e.map((t,e)=>t+(e%2?r:n))]}else m=[o,...e];const c=m.length;switch(o){case"Z":n=s,r=i;break;case"H":[,n]=m;break;case"V":[,r]=m;break;default:n=m[c-2],r=m[c-1],"M"===o&&(s=n,i=r)}return m})}function g(t){return h(t)&&t.slice(1).every(t=>t[0]===t[0].toLowerCase())}function d(t){if(g(t))return u(t);const e=f(t);let n=0,r=0,s=0,i=0;return e.map(t=>{const e=t.slice(1).map(Number),[a]=t,o=a.toLowerCase();if("M"===a)return[n,r]=e,s=n,i=r,["M",n,r];let m=[];if(a!==o)switch(o){case"a":m=[o,e[0],e[1],e[2],e[3],e[4],e[5]-n,e[6]-r];break;case"v":m=[o,e[0]-r];break;case"h":m=[o,e[0]-n];break;default:m=[o,...e.map((t,e)=>t-(e%2?r:n))],"m"===o&&([n,r]=e,s=n,i=r)}else"m"===a&&(s=e[0]+n,i=e[1]+r),m=[o,...e];const c=m.length;switch(o){case"z":n=s,r=i;break;case"h":n+=m[1];break;case"v":r+=m[1];break;default:n+=m[c-2],r+=m[c-1]}return m})}function p(t,e,n){if(t[n].length>7){t[n].shift();const r=t[n];let s=n;for(;r.length;)e[n]="A",t.splice(s+=1,0,["C",...r.splice(0,6)]);t.splice(n,1)}}function M(t,e,n){const[r]=t,{x1:s,y1:i,x2:a,y2:o}=e,m=t.slice(1).map(Number);let c=t;if("TQ".includes(r)||(e.qx=null,e.qy=null),"H"===r)c=["L",t[1],i];else if("V"===r)c=["L",s,t[1]];else if("S"===r){const{x1:t,y1:r}=function(t,e,n,r,s){return"CS".includes(s)?{x1:2*t-n,y1:2*e-r}:{x1:t,y1:e}}(s,i,a,o,n);e.x1=t,e.y1=r,c=["C",t,r,...m]}else if("T"===r){const{qx:t,qy:r}=function(t,e,n,r,s){return"QT".includes(s)?{qx:2*t-n,qy:2*e-r}:{qx:t,qy:e}}(s,i,e.qx,e.qy,n);e.qx=t,e.qy=r,c=["Q",t,r,...m]}else if("Q"===r){const[t,n]=m;e.qx=t,e.qy=n}return c}function b(t){return y(t)&&t.every(t=>"ACLMQZ".includes(t[0]))}const v={x1:0,y1:0,x2:0,y2:0,x:0,y:0,qx:null,qy:null};function N(t){if(b(t))return u(t);const e=x(t),n={...v},r=[],s=e.length;let i="",a="";for(let t=0;t<s;t+=1){[i]=e[t],r[t]=i,t&&(a=r[t-1]),e[t]=M(e[t],n,a);const s=e[t],o=s.length;n.x1=+s[o-2],n.y1=+s[o-1],n.x2=+s[o-4]||n.x1,n.y2=+s[o-3]||n.y1}return e}function A(t){const e=f(t),n=N(e),{length:r}=e,s="Z"===n.slice(-1)[0][0],i=s?r-2:r-1,[a,o]=n[0].slice(1),[m,c]=n[i].slice(-2);return s&&a===m&&o===c?e.slice(0,-1):e}function w(t){return h(t)&&t.every(t=>"MC".includes(t[0]))}function C(t,e,n){return{x:t*Math.cos(n)-e*Math.sin(n),y:t*Math.sin(n)+e*Math.cos(n)}}function S(t,e,n,r,s,i,a,o,m,c){let u=t,l=e,h=n,f=r,y=o,x=m;const g=120*Math.PI/180,d=Math.PI/180*(+s||0);let p,M,b,v,N,A=[];if(c)[M,b,v,N]=c;else{p=C(u,l,-d),u=p.x,l=p.y,p=C(y,x,-d),y=p.x,x=p.y;const t=(u-y)/2,e=(l-x)/2;let n=t*t/(h*h)+e*e/(f*f);n>1&&(n=Math.sqrt(n),h*=n,f*=n);const r=h*h,s=f*f,o=(i===a?-1:1)*Math.sqrt(Math.abs((r*s-r*e*e-s*t*t)/(r*e*e+s*t*t)));v=o*h*e/f+(u+y)/2,N=o*-f*t/h+(l+x)/2,M=(Math.asin((l-N)/f)*10**9>>0)/10**9,b=(Math.asin((x-N)/f)*10**9>>0)/10**9,M=u<v?Math.PI-M:M,b=y<v?Math.PI-b:b,M<0&&(M=2*Math.PI+M),b<0&&(b=2*Math.PI+b),a&&M>b&&(M-=2*Math.PI),!a&&b>M&&(b-=2*Math.PI)}let w=b-M;if(Math.abs(w)>g){const t=b,e=y,n=x;b=M+g*(a&&b>M?1:-1),y=v+h*Math.cos(b),x=N+f*Math.sin(b),A=S(y,x,h,f,s,0,a,e,n,[b,t,v,N])}w=b-M;const k=Math.cos(M),P=Math.sin(M),q=Math.cos(b),T=Math.sin(b),I=Math.tan(w/4),$=4/3*h*I,V=4/3*f*I,L=[u,l],z=[u+$*P,l-V*k],j=[y+$*T,x-V*q],E=[y,x];if(z[0]=2*L[0]-z[0],z[1]=2*L[1]-z[1],c)return[...z,...j,...E,...A];A=[...z,...j,...E,...A];const Z=[];for(let t=0,e=A.length;t<e;t+=1)Z[t]=t%2?C(A[t-1],A[t],d).y:C(A[t],A[t+1],d).x;return Z}function k(t,e,n,r,s,i){return[1/3*t+2/3*n,1/3*e+2/3*r,1/3*s+2/3*n,1/3*i+2/3*r,s,i]}function P(t,e,n){const[r,s]=t,[i,a]=e;return[r+(i-r)*n,s+(a-s)*n]}function q(t,e){return Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1]))}function T(t,e,n,r,s){const i=q([t,e],[n,r]);if("number"==typeof s){if(s<.001)return{x:t,y:e};if(s>i)return{x:n,y:r};const[a,o]=P([t,e],[n,r],s/i);return{x:a,y:o}}return i}function I(t,e,n,r){const s=.5,i=[t,e],a=[n,r],o=P(i,a,s),m=P(a,o,s),c=P(o,m,s),u=P(m,c,s),l=P(c,u,s),h=T(...[...i,...o,...c,...l,s]),f=T(...[...l,...u,...m,...a,0]);return[h.x,h.y,f.x,f.y,n,r]}function $(t,e){const[n]=t,r=t.slice(1).map(t=>+t),[s,i]=r;let a;const{x1:o,y1:m,x:c,y:u}=e;switch("TQ".includes(n)||(e.qx=null,e.qy=null),n){case"M":return e.x=s,e.y=i,t;case"A":return a=[o,m,...r],["C",...S(...a)];case"Q":return e.qx=s,e.qy=i,a=[o,m,...r],["C",...k(...a)];case"L":return["C",...I(o,m,s,i)];case"Z":return["C",...I(o,m,c,u)]}return t}function V(t){if(w(t))return u(t);const e=A(N(t)),n={...v},r=[];let s="",i=e.length;for(let t=0;t<i;t+=1){[s]=e[t],r[t]=s,e[t]=$(e[t],n),p(e,r,t),i=e.length;const a=e[t],o=a.length;n.x1=+a[o-2],n.y1=+a[o-1],n.x2=+a[o-4]||n.x1,n.y2=+a[o-3]||n.y1}return e}function L(e,n){let{round:r}=t;if(!1===n||!1===r)return u(e);r=n>=0?n:r;const s=r>=1?10**r:1;return e.map(t=>{const e=t.slice(1).map(Number).map(t=>r?Math.round(t*s)/s:Math.round(t));return[t[0],...e]})}function z(t,e){return L(t,e).map(t=>t[0]+t.slice(1).join(" ")).join("")}function j(t){const e=x(t),n="Z"===e.slice(-1)[0][0],r=N(e).map((t,n)=>{const[r,s]=t.slice(-2).map(Number);return{seg:e[n],n:t,c:e[n][0],x:r,y:s}}).map((t,e,r)=>{const s=t.seg,i=t.n,a=e&&r[e-1],o=r[e+1]&&r[e+1],m=t.c,c=r.length,u=e?r[e-1].x:r[c-1].x,l=e?r[e-1].y:r[c-1].y;let h=[];switch(m){case"M":h=n?["Z"]:[m,u,l];break;case"A":h=[m,...s.slice(1,-3),1===s[5]?0:1,u,l];break;case"C":h=o&&"S"===o.c?["S",s[1],s[2],u,l]:[m,s[3],s[4],s[1],s[2],u,l];break;case"S":h=a&&"CS".includes(a.c)&&(!o||o&&"S"!==o.c)?["C",i[3],i[4],i[1],i[2],u,l]:[m,i[1],i[2],u,l];break;case"Q":h=o&&"T"===o.c?["T",u,l]:[m,...s.slice(1,-2),u,l];break;case"T":h=a&&"QT".includes(a.c)&&(!o||o&&"T"!==o.c)?["Q",i[1],i[2],u,l]:[m,u,l];break;case"Z":h=["M",u,l];break;case"H":h=[m,u];break;case"V":h=[m,l];break;default:h=[m,...s.slice(1,-2),u,l]}return h});return n?r.reverse():[r[0],...r.slice(1).reverse()]}function E(t){return z(x(t),0).replace(/(m|M)/g,"|$1").split("|").map(t=>t.trim()).filter(t=>t)}function Z(t,e,n,r){const[s]=t,i=t=>Math.round(1e4*t)/1e4,a=t.slice(1).map(t=>+t),o=e.slice(1).map(t=>+t),{x1:m,y1:c,x2:u,y2:l,x:h,y:f}=n;let y=t;const[x,g]=o.slice(-2);if("TQ".includes(s)||(n.qx=null,n.qy=null),["V","H","S","T","Z"].includes(s))y=[s,...a];else if("L"===s)i(h)===i(x)?y=["V",g]:i(f)===i(g)&&(y=["H",x]);else if("C"===s){const[t,e]=o;"CS".includes(r)&&i(t)===i(2*m-u)&&i(e)===i(2*c-l)&&(y=["S",...o.slice(-4)]),n.x1=t,n.y1=e}else if("Q"===s){const[t,e]=o;n.qx=t,n.qy=e,"QT".includes(r)&&i(t)===i(2*m-u)&&i(e)===i(2*c-l)&&(y=["T",...o.slice(-2)])}return y}function O(t,e){const n=x(t),r=N(n),s={...v},i=[],a=n.length;let o="",m="",c=0,u=0,l=0,h=0;for(let t=0;t<a;t+=1){[o]=n[t],i[t]=o,t&&(m=i[t-1]),n[t]=Z(n[t],r[t],s,m);const e=n[t],a=e.length;switch(s.x1=+e[a-2],s.y1=+e[a-1],s.x2=+e[a-4]||s.x1,s.y2=+e[a-3]||s.y1,o){case"Z":c=l,u=h;break;case"H":[,c]=e;break;case"V":[,u]=e;break;default:[c,u]=e.slice(-2).map(Number),"M"===o&&(l=c,h=u)}s.x=c,s.y=u}const f=L(n,e),y=L(d(n),e);return f.map((t,e)=>e?t.join("").length<y[e].join("").length?t:y[e]:t)}function Q(t){const e=new U,n=Array.from(t);if(!n.every(t=>!Number.isNaN(t)))throw TypeError(`CSSMatrix: "${t}" must only have numbers.`);if(16===n.length){const[t,r,s,i,a,o,m,c,u,l,h,f,y,x,g,d]=n;e.m11=t,e.a=t,e.m21=a,e.c=a,e.m31=u,e.m41=y,e.e=y,e.m12=r,e.b=r,e.m22=o,e.d=o,e.m32=l,e.m42=x,e.f=x,e.m13=s,e.m23=m,e.m33=h,e.m43=g,e.m14=i,e.m24=c,e.m34=f,e.m44=d}else{if(6!==n.length)throw new TypeError("CSSMatrix: expecting an Array of 6/16 values.");{const[t,r,s,i,a,o]=n;e.m11=t,e.a=t,e.m12=r,e.b=r,e.m21=s,e.c=s,e.m22=i,e.d=i,e.m41=a,e.e=a,e.m42=o,e.f=o}}return e}function D(t){const e=Object.keys(new U);if("object"==typeof t&&e.every(e=>e in t))return Q([t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44]);throw TypeError(`CSSMatrix: "${t}" is not a DOMMatrix / CSSMatrix / JSON compatible object.`)}function X(t){if("string"!=typeof t)throw TypeError(`CSSMatrix: "${t}" is not a string.`);const e=String(t).replace(/\s/g,"");let n=new U;const r=`CSSMatrix: invalid transform string "${t}"`;return e.split(")").filter(t=>t).forEach(t=>{const[e,s]=t.split("(");if(!s)throw TypeError(r);const i=s.split(",").map(t=>t.includes("rad")?parseFloat(t)*(180/Math.PI):parseFloat(t)),[a,o,m,c]=i,u=[a,o,m],l=[a,o,m,c];if("perspective"===e&&a&&[o,m].every(t=>void 0===t))n.m34=-1/a;else if(e.includes("matrix")&&[6,16].includes(i.length)&&i.every(t=>!Number.isNaN(+t))){const t=i.map(t=>Math.abs(t)<1e-6?0:t);n=n.multiply(Q(t))}else if("translate3d"===e&&u.every(t=>!Number.isNaN(+t)))n=n.translate(a,o,m);else if("translate"===e&&a&&void 0===m)n=n.translate(a,o||0,0);else if("rotate3d"===e&&l.every(t=>!Number.isNaN(+t))&&c)n=n.rotateAxisAngle(a,o,m,c);else if("rotate"===e&&a&&[o,m].every(t=>void 0===t))n=n.rotate(0,0,a);else if("scale3d"===e&&u.every(t=>!Number.isNaN(+t))&&u.some(t=>1!==t))n=n.scale(a,o,m);else if("scale"!==e||Number.isNaN(a)||1===a||void 0!==m)if("skew"===e&&a&&void 0===m)n=n.skewX(a),n=o?n.skewY(o):n;else{if(!(/[XYZ]/.test(e)&&a&&[o,m].every(t=>void 0===t)&&["translate","rotate","scale","skew"].some(t=>e.includes(t))))throw TypeError(r);if(["skewX","skewY"].includes(e))n=n[e](a);else{const t=e.replace(/[XYZ]/,""),r=e.replace(t,""),s=["X","Y","Z"].indexOf(r),i=[0===s?a:0,1===s?a:0,2===s?a:0];n=n[t](...i)}}else{const t=Number.isNaN(+o)?a:o;n=n.scale(a,t,1)}}),n}function H(t,e,n){const r=new U;return r.m41=t,r.e=t,r.m42=e,r.f=e,r.m43=n,r}function Y(t,e,n){const r=new U,s=Math.PI/180,i=t*s,a=e*s,o=n*s,m=Math.cos(i),c=-Math.sin(i),u=Math.cos(a),l=-Math.sin(a),h=Math.cos(o),f=-Math.sin(o),y=u*h,x=-u*f;r.m11=y,r.a=y,r.m12=x,r.b=x,r.m13=l;const g=c*l*h+m*f;r.m21=g,r.c=g;const d=m*h-c*l*f;return r.m22=d,r.d=d,r.m23=-c*u,r.m31=c*f-m*l*h,r.m32=c*h+m*l*f,r.m33=m*u,r}function B(t,e,n,r){const s=new U,i=r*(Math.PI/360),a=Math.sin(i),o=Math.cos(i),m=a*a,c=Math.sqrt(t*t+e*e+n*n);let u=t,l=e,h=n;0===c?(u=0,l=0,h=1):(u/=c,l/=c,h/=c);const f=u*u,y=l*l,x=h*h,g=1-2*(y+x)*m;s.m11=g,s.a=g;const d=2*(u*l*m+h*a*o);s.m12=d,s.b=d,s.m13=2*(u*h*m-l*a*o);const p=2*(l*u*m-h*a*o);s.m21=p,s.c=p;const M=1-2*(x+f)*m;return s.m22=M,s.d=M,s.m23=2*(l*h*m+u*a*o),s.m31=2*(h*u*m+l*a*o),s.m32=2*(h*l*m-u*a*o),s.m33=1-2*(f+y)*m,s}function F(t,e,n){const r=new U;return r.m11=t,r.a=t,r.m22=e,r.d=e,r.m33=n,r}function R(t){const e=new U,n=t*Math.PI/180,r=Math.tan(n);return e.m21=r,e.c=r,e}function G(t){const e=new U,n=t*Math.PI/180,r=Math.tan(n);return e.m12=r,e.b=r,e}function J(t,e){return Q([e.m11*t.m11+e.m12*t.m21+e.m13*t.m31+e.m14*t.m41,e.m11*t.m12+e.m12*t.m22+e.m13*t.m32+e.m14*t.m42,e.m11*t.m13+e.m12*t.m23+e.m13*t.m33+e.m14*t.m43,e.m11*t.m14+e.m12*t.m24+e.m13*t.m34+e.m14*t.m44,e.m21*t.m11+e.m22*t.m21+e.m23*t.m31+e.m24*t.m41,e.m21*t.m12+e.m22*t.m22+e.m23*t.m32+e.m24*t.m42,e.m21*t.m13+e.m22*t.m23+e.m23*t.m33+e.m24*t.m43,e.m21*t.m14+e.m22*t.m24+e.m23*t.m34+e.m24*t.m44,e.m31*t.m11+e.m32*t.m21+e.m33*t.m31+e.m34*t.m41,e.m31*t.m12+e.m32*t.m22+e.m33*t.m32+e.m34*t.m42,e.m31*t.m13+e.m32*t.m23+e.m33*t.m33+e.m34*t.m43,e.m31*t.m14+e.m32*t.m24+e.m33*t.m34+e.m34*t.m44,e.m41*t.m11+e.m42*t.m21+e.m43*t.m31+e.m44*t.m41,e.m41*t.m12+e.m42*t.m22+e.m43*t.m32+e.m44*t.m42,e.m41*t.m13+e.m42*t.m23+e.m43*t.m33+e.m44*t.m43,e.m41*t.m14+e.m42*t.m24+e.m43*t.m34+e.m44*t.m44])}class U{constructor(...t){const e=this;if(e.a=1,e.b=0,e.c=0,e.d=1,e.e=0,e.f=0,e.m11=1,e.m12=0,e.m13=0,e.m14=0,e.m21=0,e.m22=1,e.m23=0,e.m24=0,e.m31=0,e.m32=0,e.m33=1,e.m34=0,e.m41=0,e.m42=0,e.m43=0,e.m44=1,t&&t.length){const n=[16,6].some(e=>e===t.length)?t:t[0];return e.setMatrixValue(n)}return e}set isIdentity(t){this.isIdentity=t}get isIdentity(){const t=this;return 1===t.m11&&0===t.m12&&0===t.m13&&0===t.m14&&0===t.m21&&1===t.m22&&0===t.m23&&0===t.m24&&0===t.m31&&0===t.m32&&1===t.m33&&0===t.m34&&0===t.m41&&0===t.m42&&0===t.m43&&1===t.m44}get is2D(){const t=this;return 0===t.m31&&0===t.m32&&1===t.m33&&0===t.m34&&0===t.m43&&1===t.m44}set is2D(t){this.is2D=t}setMatrixValue(t){return[Array,Float64Array,Float32Array].some(e=>t instanceof e)?Q(t):"string"==typeof t&&t.length&&"none"!==t?X(t):"object"==typeof t?D(t):this}toArray(){const t=this;let e;return e=t.is2D?[t.a,t.b,t.c,t.d,t.e,t.f]:[t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44],e.map(t=>Math.abs(t)<1e-6?0:(t*10**6>>0)/10**6)}toString(){const t=this.toArray();return`${this.is2D?"matrix":"matrix3d"}(${t})`}toJSON(){const{is2D:t,isIdentity:e}=this;return{...this,is2D:t,isIdentity:e}}multiply(t){return J(this,t)}translate(t,e,n){let r=e,s=n;return void 0===s&&(s=0),void 0===r&&(r=0),J(this,H(t,r,s))}scale(t,e,n){let r=e,s=n;return void 0===r&&(r=t),void 0===s&&(s=1),J(this,F(t,r,s))}rotate(t,e,n){let r=t,s=e,i=n;return void 0===s&&(s=0),void 0===i&&(i=r,r=0),J(this,Y(r,s,i))}rotateAxisAngle(t,e,n,r){if([t,e,n,r].some(t=>Number.isNaN(t)))throw new TypeError("CSSMatrix: expecting 4 values");return J(this,B(t,e,n,r))}skewX(t){return J(this,R(t))}skewY(t){return J(this,G(t))}transformPoint(t){let e=H(t.x,t.y,t.z);return e.m44=t.w||1,e=this.multiply(e),{x:e.m41,y:e.m42,z:e.m43,w:e.m44}}transform(t){const e=this,n=e.m11*t.x+e.m12*t.y+e.m13*t.z+e.m14*t.w,r=e.m21*t.x+e.m22*t.y+e.m23*t.z+e.m24*t.w,s=e.m31*t.x+e.m32*t.y+e.m33*t.z+e.m34*t.w,i=e.m41*t.x+e.m42*t.y+e.m43*t.z+e.m44*t.w;return{x:n/i,y:r/i,z:s/i,w:i}}}Object.assign(U,{Translate:H,Rotate:Y,RotateAxisAngle:B,Scale:F,SkewX:R,SkewY:G,Multiply:J,fromArray:Q,fromMatrix:D,fromString:X});function K(t,e,n){const[r,s]=e,[i,a,o]=n,m=t.transformPoint({x:r,y:s,z:0,w:1}),c=m.x-i,u=m.y-a,l=m.z-o;return[c*(Math.abs(o)/Math.abs(l))+i,u*(Math.abs(o)/Math.abs(l))+a]}function W(t,e){let n,r,s,i,a,o,m,c=0,l=0;const h=x(t),f=N(h),y=function(t){let e=new U;const{origin:n}=t,[r,s]=n,{translate:i}=t,{rotate:a}=t,{skew:o}=t,{scale:m}=t;return Array.isArray(i)&&i.every(t=>!Number.isNaN(+t))&&i.some(t=>0!==t)?e=e.translate(i[0]||0,i[1]||0,i[2]||0):"number"!=typeof i||Number.isNaN(+i)||(e=e.translate(i||0,0,0)),(a||o||m)&&(e=e.translate(r,s),Array.isArray(a)&&a.every(t=>!Number.isNaN(+t))&&a.some(t=>0!==t)?e=e.rotate(a[0],a[1],a[2]):"number"!=typeof a||Number.isNaN(+a)||(e=e.rotate(0,0,a)),Array.isArray(o)&&o.every(t=>!Number.isNaN(+t))&&o.some(t=>0!==t)?(e=o[0]?e.skewX(o[0]):e,e=o[1]?e.skewY(o[1]):e):"number"!=typeof o||Number.isNaN(+o)||(e=e.skewX(o||0)),Array.isArray(m)&&m.every(t=>!Number.isNaN(+t))&&m.some(t=>1!==t)?e=e.scale(m[0],m[1],m[2]):"number"!=typeof m||Number.isNaN(+m)||(e=e.scale(m||1,m||1,m||1)),e=e.translate(-r,-s)),e}(e),g=Object.keys(e),{origin:d}=e,{a:M,b:b,c:A,d:w,e:C,f:S}=y,k=[M,b,A,w,C,S],P={...v};let q=[],T=0,I="",V=[];const L=[];if(!y.isIdentity){for(n=0,s=h.length;n<s;n+=1){q=h[n],h[n]&&([I]=q),L[n]=I,"A"!==I||y.is2D&&["skewX","skewY"].find(t=>g.includes(t))||(q=$(f[n],P),h[n]=$(f[n],P),p(h,L,n),f[n]=$(f[n],P),p(f,L,n),s=Math.max(h.length,f.length)),q=f[n],T=q.length,P.x1=+q[T-2],P.y1=+q[T-1],P.x2=+q[T-4]||P.x1,P.y2=+q[T-3]||P.y1;const t={s:h[n],c:h[n][0],x:P.x1,y:P.y1};V=[...V,t]}return V.map(t=>{switch(I=t.c,q=t.s,I){case"A":return m=function(t,e,n,r){const s=Math.cos(r*Math.PI/180),i=Math.sin(r*Math.PI/180),a=[e*(t[0]*s+t[2]*i),e*(t[1]*s+t[3]*i),n*(-t[0]*i+t[2]*s),n*(-t[1]*i+t[3]*s)],o=a[0]*a[0]+a[2]*a[2],m=a[1]*a[1]+a[3]*a[3];let c=((a[0]-a[3])*(a[0]-a[3])+(a[2]+a[1])*(a[2]+a[1]))*((a[0]+a[3])*(a[0]+a[3])+(a[2]-a[1])*(a[2]-a[1]));const u=(o+m)/2;if(c<1e-9*u){const t=Math.sqrt(u);return{rx:t,ry:t,ax:0}}const l=a[0]*a[1]+a[2]*a[3];c=Math.sqrt(c);const h=u+c/2,f=u-c/2;let y,x,g=Math.abs(l)<1e-9&&Math.abs(h-m)<1e-9?90:Math.atan(Math.abs(l)>Math.abs(h-m)?(h-o)/l:l/(h-m)*180)/Math.PI;return g>=0?(y=Math.sqrt(h),x=Math.sqrt(f)):(g+=90,y=Math.sqrt(f),x=Math.sqrt(h)),{rx:y,ry:x,ax:g}}(k,q[1],q[2],q[3]),k[0]*k[3]-k[1]*k[2]<0&&(q[5]=q[5]?0:1),[a,o]=K(y,[+q[6],+q[7]],d),q=c===a&&l===o||m.rx<1e-9*m.ry||m.ry<1e-9*m.rx?["L",a,o]:[I,m.rx,m.ry,m.ax,q[4],q[5],a,o],c=a,l=o,q;case"L":case"H":case"V":return[a,o]=K(y,[t.x,t.y],d),c!==a&&l!==o?q=["L",a,o]:l===o?q=["H",a]:c===a&&(q=["V",o]),c=a,l=o,q;default:for(r=1,i=q.length;r<i;r+=2)[c,l]=K(y,[+q[r],+q[r+1]],d),q[r]=c,q[r+1]=l;return q}})}return u(h)}function _(t,e,n,r,s,i,a,o,m){const c=1-m;return{x:c**3*t+3*c**2*m*n+3*c*m**2*s+m**3*a,y:c**3*e+3*c**2*m*r+3*c*m**2*i+m**3*o}}function tt(t,e,n,r,s,i,a,o,m){const c="number"==typeof m;let u=t,l=e,h=0,f=[t,e,h],y=[t,e],x=0;if(c&&m<.001)return{x:u,y:l};for(let g=0;g<=100;g+=1){if(x=g/100,({x:u,y:l}=_(t,e,n,r,s,i,a,o,x)),h+=q(y,[u,l]),y=[u,l],c&&h>=m){const t=(h-m)/(h-f[2]);return{x:y[0]*(1-t)+f[0]*t,y:y[1]*(1-t)+f[1]*t}}f=[u,l,h]}return c&&m>=h?{x:a,y:o}:h}function et(t){if(!t)return{x:0,y:0,width:0,height:0,x2:0,y2:0,cx:0,cy:0,cz:0};const e=V(t);let n=0,r=0,s=[],i=[];e.forEach(t=>{const[e,a]=t.slice(-2).map(Number);if("M"===t[0])n=e,r=a,s.push(e),i.push(a);else{const o=function(t,e,n,r,s,i,a,o){let m=s-2*n+t-(a-2*s+n),c=2*(n-t)-2*(s-n),u=t-n,l=(-c+Math.sqrt(c*c-4*m*u))/2/m,h=(-c-Math.sqrt(c*c-4*m*u))/2/m;const f=[t,a],y=[e,o];let x=0,g=0;return Math.abs(l)>1e12&&(l=.5),Math.abs(h)>1e12&&(h=.5),l>0&&l<1&&(({x:x,y:g}=tt(t,e,n,r,s,i,a,o,l)),f.push(x),y.push(g)),h>0&&h<1&&(({x:x,y:g}=tt(t,e,n,r,s,i,a,o,h)),f.push(x),y.push(g)),m=i-2*r+e-(o-2*i+r),c=2*(r-e)-2*(i-r),u=e-r,l=(-c+Math.sqrt(c*c-4*m*u))/2/m,h=(-c-Math.sqrt(c*c-4*m*u))/2/m,Math.abs(l)>1e12&&(l=.5),Math.abs(h)>1e12&&(h=.5),l>0&&l<1&&(({x:x,y:g}=tt(t,e,n,r,s,i,a,o,l)),f.push(x),y.push(g)),h>0&&h<1&&(({x:x,y:g}=tt(t,e,n,r,s,i,a,o,h)),f.push(x),y.push(g)),{min:{x:Math.min(...f),y:Math.min(...y)},max:{x:Math.max(...f),y:Math.max(...y)}}}(...[n,r,...t.slice(1)]);s=[...s,o.min.x,o.max.x],i=[...i,o.min.y,o.max.y],n=e,r=a}});const a=Math.min(...s),o=Math.min(...i),m=Math.max(...s),c=Math.max(...i),u=m-a,l=c-o;return{width:u,height:l,x:a,y:o,x2:m,y2:c,cx:a+u/2,cy:o+l/2,cz:Math.max(u,l)+Math.min(u,l)/2}}function nt(t,e,n,r,s,i,a,o,m,c){const u=S(t,e,n,r,s,i,a,o,m),l="number"==typeof c;let[h,f]=[t,e];let y=0,x=[],g=[],d=0;if(l&&c<.001)return{x:h,y:f};for(let t=0,e=u.length;t<e;t+=6){if(x=u.slice(t,t+6),g=[h,f,...x],d=tt(...g),l&&y+d>=c)return tt(...g,c-y);y+=d,[h,f]=x.slice(-2)}return l&&c>=y?{x:o,y:m}:y}function rt(t,e,n,r,s,i,a){const o=1-a;return{x:o**2*t+2*o*a*n+a**2*s,y:o**2*e+2*o*a*r+a**2*i}}function st(t,e,n,r,s,i,a){const o="number"==typeof a;let m=t,c=e,u=0,l=[t,e,u],h=[t,e],f=0;if(o&&a<.001)return{x:m,y:c};for(let y=0;y<=100;y+=1){if(f=y/100,({x:m,y:c}=rt(t,e,n,r,s,i,f)),u+=q(h,[m,c]),h=[m,c],o&&u>=a){const t=(u-a)/(u-l[2]);return{x:h[0]*(1-t)+l[0]*t,y:h[1]*(1-t)+l[1]*t}}l=[m,c,u]}return o&&a>=u?{x:s,y:i}:u}function it(t,e){const n=A(N(t)),r="number"==typeof e;let s,i=0,a=!0,o=[],m="M",c=0,u=0,l=0,h=0,f=0;for(let t=0,y=n.length;t<y;t+=1){if(s=n[t],[m]=s,a="M"===m,o=a?o:[u,l,...s.slice(1)],a){if([,h,f]=s,r&&e<.001)return{x:h,y:f}}else if("L"===m){if(c=T(...o),r&&i+c>=e)return T(...o,e-i);i+=c}else if("A"===m){if(c=nt(...o),r&&i+c>=e)return nt(...o,e-i);i+=c}else if("C"===m){if(c=tt(...o),r&&i+c>=e)return tt(...o,e-i);i+=c}else if("Q"===m){if(c=st(...o),r&&i+c>=e)return st(...o,e-i);i+=c}else if("Z"===m){if(o=[u,l,h,f],c=T(...o),r&&i+c>=e)return T(...o,e-i);i+=c}[u,l]="Z"!==m?s.slice(-2):[h,f]}return r&&e>=i?{x:u,y:l}:i}function at(t){return it(t)}function ot(t,e){return it(t,e)}Object.assign(U,{Version:"0.0.24"});class mt{constructor(e,n){const s=n||{},i=void 0===e;if(i||!e.length)throw TypeError(`${r}: "pathValue" is ${i?"undefined":"empty"}`);const a=f(e);if("string"==typeof a)throw TypeError(a);this.segments=a;const{width:o,height:m,cx:c,cy:u,cz:l}=this.getBBox();let{round:h,origin:y}=t;const{round:x,origin:g}=s;if("auto"===x){const t=(""+Math.floor(Math.max(o,m))).length;h=t>=4?0:4-t}else(Number.isInteger(x)||!1===x)&&(h=x);if(Array.isArray(g)&&g.length>=2){const[t,e,n]=g.map(Number);y=[Number.isNaN(t)?c:t,Number.isNaN(e)?u:e,Number.isNaN(n)?l:n]}else y=[c,u,l];return this.round=h,this.origin=y,this}getBBox(){return et(this.segments)}getTotalLength(){return at(this.segments)}getPointAtLength(t){return ot(this.segments,t)}toAbsolute(){const{segments:t}=this;return this.segments=x(t),this}toRelative(){const{segments:t}=this;return this.segments=d(t),this}toCurve(){const{segments:t}=this;return this.segments=V(t),this}reverse(t){this.toAbsolute();const{segments:e}=this,n=E(this.toString()),r=n.length>1?n:0,s=r&&u(r).map((e,n)=>t?n?j(e):f(e):j(e));let i=[];return i=r?s.flat(1):t?e:j(e),this.segments=u(i),this}normalize(){const{segments:t}=this;return this.segments=N(t),this}optimize(){const{segments:t}=this;return this.segments=O(t,this.round),this}transform(t){if(!t||"object"!=typeof t||"object"==typeof t&&!["translate","rotate","skew","scale"].some(e=>e in t))return this;const e={};Object.keys(t).forEach(n=>{e[n]=Array.isArray(t[n])?[...t[n]]:Number(t[n])});const{segments:n}=this,[r,s,i]=this.origin,{origin:a}=e;if(Array.isArray(a)&&a.length>=2){const[t,n,o]=a.map(Number);e.origin=[Number.isNaN(t)?r:t,Number.isNaN(n)?s:n,o||i]}else e.origin=[r,s,i];return this.segments=W(n,e),this}flipX(){return this.transform({rotate:[180,0,0]}),this}flipY(){return this.transform({rotate:[0,180,0]}),this}toString(){return z(this.segments,this.round)}}function ct(t){let e=0,n=0,r=0;return V(t).map(t=>{switch(t[0]){case"M":return[,e,n]=t,0;default:return r=function(t,e,n,r,s,i,a,o){return 3*((o-e)*(n+s)-(a-t)*(r+i)+r*(t-s)-n*(e-i)+o*(s+t/3)-a*(i+e/3))/20}(e,n,...t.slice(1)),[e,n]=t.slice(-2),r}}).reduce((t,e)=>t+e,0)}function ut(t,e){const n=f(t),r=[];let s=[...n],i=at(s),a=s.length-1,o=0,m=0,c=n[0];const[u,l]=c.slice(-2),h={x:u,y:l};if(a<=0||!e||!Number.isFinite(e))return{segment:c,index:0,length:m,point:h,lengthAtSegment:o};if(e>=i)return s=n.slice(0,-1),o=at(s),m=i-o,{segment:n[a],index:a,length:m,lengthAtSegment:o};for(;a>0;)c=s[a],s=s.slice(0,-1),o=at(s),m=i-o,i=o,r.push({segment:c,index:a,length:m,lengthAtSegment:o}),a-=1;return r.find(({lengthAtSegment:t})=>t<=e)}function lt(t,e){const n=A(f(t)),r=N(n),s=at(n),i=t=>{const n=t.x-e.x,r=t.y-e.y;return n*n+r*r};let a=8,o={x:0,y:0},m=0,c=o,u=0,l=1/0;for(let t=0;t<=s;t+=a)o=ot(r,t),m=i(o),m<l&&(c=o,u=t,l=m);a/=2;let h={x:0,y:0},y=h,x=0,g=0,d=0,p=0;for(;a>.5;)x=u-a,h=ot(r,x),d=i(h),g=u+a,y=ot(r,g),p=i(y),x>=0&&d<l?(c=h,u=x,l=d):g<=s&&p<l?(c=y,u=g,l=p):a/=2;const M=ut(n,u);return{closest:c,distance:Math.sqrt(l),segment:M}}const ht={circle:["cx","cy","r"],ellipse:["cx","cy","rx","ry"],rect:["width","height","x","y","rx","ry"],polygon:["points"],polyline:["points"],glyph:[]};const ft={CSSMatrix:U,parsePathString:f,isPathArray:h,isCurveArray:w,isAbsoluteArray:y,isRelativeArray:g,isNormalizedArray:b,isValidPath:function(t){if("string"!=typeof t)return!1;const e=new l(t);for(o(e);e.index<e.max&&!e.err.length;)c(e);return!e.err.length&&"mM".includes(e.segments[0][0])},pathToAbsolute:x,pathToRelative:d,pathToCurve:V,pathToString:z,getDrawDirection:function(t){return ct(V(t))>=0},getPathArea:ct,getPathBBox:et,getTotalLength:at,getPathLength:function(t){let e=0;return V(t).forEach((t,n,r)=>{const s="M"!==t[0]?[...r[n-1].slice(-2),...t.slice(1)]:[];e+="M"===t[0]?0:tt(...s)}),e},getPointAtLength:ot,getClosestPoint:function(t,e){return lt(t,e).closest},getSegmentOfPoint:function(t,e){const n=lt(t,e),{segment:r}=n;return void 0!==r?r.segment:null},getPropertiesAtPoint:lt,getPropertiesAtLength:ut,getSegmentAtLength:function(t,e){const n=ut(t,e),{segment:r}=void 0!==n?n:{segment:null};return r},isPointInStroke:function(t,e){const{distance:n}=lt(t,e);return Math.abs(n)<.01},clonePath:u,splitPath:E,fixPath:A,roundPath:L,optimizePath:O,reverseCurve:function(t){const e=t.slice(1).map((e,n,r)=>n?[...r[n-1].slice(-2),...e.slice(1)]:[...t[0].slice(1),...e.slice(1)]).map(t=>t.map((e,n)=>t[t.length-n-2*(1-n%2)])).reverse();return[["M",...e[0].slice(0,2)],...e.map(t=>["C",...t.slice(2)])]},reversePath:j,normalizePath:N,transformPath:W,shapeToPath:function(e,n){const r=Object.keys(ht),s=e instanceof Element;if(s&&!r.some(t=>e.tagName===t))throw TypeError(`shapeToPath: "${e}" is not SVGElement`);const i=document.createElementNS("http://www.w3.org/2000/svg","path"),a=s?e.tagName:e.type,o={};if(o.type=a,s){const t=ht[a];t.forEach(t=>{o[t]=e.getAttribute(t)}),Object.values(e.attributes).forEach(({name:e,value:n})=>{t.includes(e)||i.setAttribute(e,n)})}else Object.assign(o,e);let m;const{round:c}=t;return"circle"===a?m=z(function(t){const{cx:e,cy:n,r:r}=t;return[["M",e-r,n],["a",r,r,0,1,0,2*r,0],["a",r,r,0,1,0,-2*r,0]]}(o),c):"ellipse"===a?m=z(function(t){const{cx:e,cy:n,rx:r,ry:s}=t;return[["M",e-r,n],["a",r,s,0,1,0,2*r,0],["a",r,s,0,1,0,-2*r,0]]}(o),c):["polyline","polygon"].includes(a)?m=z(function(t){const e=[],n=t.points.trim().split(/[\s|,]/).map(Number);let r=0;for(;r<n.length;)e.push([r?"L":"M",n[r],n[r+1]]),r+=2;return"polygon"===t.type?[...e,["z"]]:e}(o),c):"rect"===a?m=z(function(t){const e=+t.x||0,n=+t.y||0,r=+t.width,s=+t.height;let i=+t.rx,a=+t.ry;return i||a?(i=i||a,a=a||i,2*i>r&&(i-=(2*i-r)/2),2*a>s&&(a-=(2*a-s)/2),[["M",e+i,n],["h",r-2*i],["s",i,0,i,a],["v",s-2*a],["s",0,a,-i,a],["h",2*i-r],["s",-i,0,-i,-a],["v",2*a-s],["s",0,-a,i,-a]]):[["M",e,n],["h",r],["v",s],["H",e],["Z"]]}(o),c):"line"===a?m=z(function(t){const{x1:e,y1:n,x2:r,y2:s}=t;return[["M",e,n],["L",r,s]]}(o),c):"glyph"===a&&(m=s?e.getAttribute("d"):e.type),!!m&&(i.setAttribute("d",m),n&&s&&(e.before(i,e),e.remove()),i)},options:t};return Object.assign(mt,ft,{Version:"0.2.0alpha2"}),mt}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svg-path-commander",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0alpha2",
|
|
4
4
|
"description": "ES6+ JavaScript tools for SVG processing and converting path data",
|
|
5
5
|
"main": "dist/svg-path-commander.min.js",
|
|
6
6
|
"module": "dist/svg-path-commander.esm.js",
|
|
@@ -12,14 +12,21 @@
|
|
|
12
12
|
"src"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
|
-
"
|
|
15
|
+
"instrument": "npx nyc instrument --compact=false src cypress/instrumented",
|
|
16
|
+
"test": "npm run instrument && npx cypress run",
|
|
17
|
+
"cypress": "npm run instrument && npx cypress open",
|
|
18
|
+
"coverage:report": "npx nyc report --include=src/*.js --reporter=lcov --reporter=json --reporter=text --reporter=json-summary",
|
|
19
|
+
"coverage:badge": "npx --check-coverage update-badge",
|
|
16
20
|
"build": "npm run lint:js && npm-run-all --parallel build-*",
|
|
17
21
|
"custom-build": "rollup -c --environment",
|
|
18
22
|
"fix:js": "eslint src/ --config .eslintrc --fix",
|
|
19
23
|
"lint:js": "eslint src/ --config .eslintrc",
|
|
20
24
|
"build:ts": "tsc -d",
|
|
21
25
|
"build-js": "rollup --environment FORMAT:umd,MIN:false -c",
|
|
26
|
+
"build-js-es5": "rollup --environment FORMAT:umd,MIN:false,ES:es5 -c",
|
|
27
|
+
"build-copy": "rollup --environment FORMAT:umd,MIN:false,OUTPUTFILE:docs/svg-path-commander.js -c",
|
|
22
28
|
"build-js-min": "rollup --environment FORMAT:umd,MIN:true -c",
|
|
29
|
+
"build-js-es5-min": "rollup --environment FORMAT:umd,MIN:true,ES:es5 -c",
|
|
23
30
|
"build-esm": "rollup --environment FORMAT:esm,MIN:false -c",
|
|
24
31
|
"build-esm-min": "rollup --environment FORMAT:esm,MIN:true -c"
|
|
25
32
|
},
|
|
@@ -46,9 +53,15 @@
|
|
|
46
53
|
},
|
|
47
54
|
"homepage": "http://thednp.github.io/svg-path-commander",
|
|
48
55
|
"devDependencies": {
|
|
56
|
+
"@bahmutov/cypress-esbuild-preprocessor": "^2.1.3",
|
|
57
|
+
"@cypress/code-coverage": "^3.9.12",
|
|
49
58
|
"@rollup/plugin-buble": "^0.21.3",
|
|
50
59
|
"@rollup/plugin-json": "^4.1.0",
|
|
51
60
|
"@rollup/plugin-node-resolve": "^7.1.3",
|
|
61
|
+
"babel-plugin-istanbul": "^6.1.1",
|
|
62
|
+
"check-code-coverage": "^1.10.0",
|
|
63
|
+
"cypress": "^9.5.4",
|
|
64
|
+
"esbuild": "^0.14.30",
|
|
52
65
|
"eslint": "^7.22.0",
|
|
53
66
|
"eslint-config-airbnb-base": "^14.2.1",
|
|
54
67
|
"eslint-plugin-import": "^2.22.1",
|
|
@@ -5,8 +5,8 @@ import isAbsoluteArray from '../util/isAbsoluteArray';
|
|
|
5
5
|
* Parses a path string value or object and returns an array
|
|
6
6
|
* of segments, all converted to absolute values.
|
|
7
7
|
*
|
|
8
|
-
* @param {string |
|
|
9
|
-
* @returns {
|
|
8
|
+
* @param {string | SVGPath.pathArray} pathInput the path string | object
|
|
9
|
+
* @returns {SVGPath.absoluteArray} the resulted `pathArray` with absolute values
|
|
10
10
|
*/
|
|
11
11
|
export default function pathToAbsolute(pathInput) {
|
|
12
12
|
if (isAbsoluteArray(pathInput)) {
|
|
@@ -22,7 +22,7 @@ export default function pathToAbsolute(pathInput) {
|
|
|
22
22
|
return path.map((segment) => {
|
|
23
23
|
const values = segment.slice(1).map(Number);
|
|
24
24
|
const [pathCommand] = segment;
|
|
25
|
-
/** @type {
|
|
25
|
+
/** @type {SVGPath.absoluteCommand} */
|
|
26
26
|
// @ts-ignore
|
|
27
27
|
const absCommand = pathCommand.toUpperCase();
|
|
28
28
|
|
|
@@ -32,7 +32,7 @@ export default function pathToAbsolute(pathInput) {
|
|
|
32
32
|
my = y;
|
|
33
33
|
return ['M', x, y];
|
|
34
34
|
}
|
|
35
|
-
/** @type {
|
|
35
|
+
/** @type {SVGPath.absoluteSegment} */
|
|
36
36
|
// @ts-ignore
|
|
37
37
|
let absoluteSegment = [];
|
|
38
38
|
|
|
@@ -13,8 +13,8 @@ import paramsParser from '../parser/paramsParser';
|
|
|
13
13
|
* In addition, un-necessary `Z` segment is removed if previous segment
|
|
14
14
|
* extends to the `M` segment.
|
|
15
15
|
*
|
|
16
|
-
* @param {string |
|
|
17
|
-
* @returns {
|
|
16
|
+
* @param {string | SVGPath.pathArray} pathInput the string to be parsed or 'pathArray'
|
|
17
|
+
* @returns {SVGPath.curveArray} the resulted `pathArray` converted to cubic-bezier
|
|
18
18
|
*/
|
|
19
19
|
export default function pathToCurve(pathInput) {
|
|
20
20
|
if (isCurveArray(pathInput)) {
|
|
@@ -6,8 +6,8 @@ import isRelativeArray from '../util/isRelativeArray';
|
|
|
6
6
|
* Parses a path string value or object and returns an array
|
|
7
7
|
* of segments, all converted to relative values.
|
|
8
8
|
*
|
|
9
|
-
* @param {string |
|
|
10
|
-
* @returns {
|
|
9
|
+
* @param {string | SVGPath.pathArray} pathInput the path string | object
|
|
10
|
+
* @returns {SVGPath.relativeArray} the resulted `pathArray` with relative values
|
|
11
11
|
*/
|
|
12
12
|
export default function pathToRelative(pathInput) {
|
|
13
13
|
if (isRelativeArray(pathInput)) {
|
|
@@ -23,7 +23,7 @@ export default function pathToRelative(pathInput) {
|
|
|
23
23
|
return path.map((segment) => {
|
|
24
24
|
const values = segment.slice(1).map(Number);
|
|
25
25
|
const [pathCommand] = segment;
|
|
26
|
-
/** @type {
|
|
26
|
+
/** @type {SVGPath.relativeCommand} */
|
|
27
27
|
// @ts-ignore
|
|
28
28
|
const relativeCommand = pathCommand.toLowerCase();
|
|
29
29
|
|
|
@@ -34,7 +34,7 @@ export default function pathToRelative(pathInput) {
|
|
|
34
34
|
return ['M', x, y];
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
/** @type {
|
|
37
|
+
/** @type {SVGPath.relativeSegment} */
|
|
38
38
|
// @ts-ignore -- trust me DON'T CHANGE
|
|
39
39
|
let relativeSegment = [];
|
|
40
40
|
|
|
@@ -4,8 +4,8 @@ import roundPath from '../process/roundPath';
|
|
|
4
4
|
* Returns a valid `d` attribute string value created
|
|
5
5
|
* by rounding values and concatenating the `pathArray` segments.
|
|
6
6
|
*
|
|
7
|
-
* @param {
|
|
8
|
-
* @param {
|
|
7
|
+
* @param {SVGPath.pathArray} path the `pathArray` object
|
|
8
|
+
* @param {number | false} round amount of decimals to round values to
|
|
9
9
|
* @returns {string} the concatenated path string
|
|
10
10
|
*/
|
|
11
11
|
export default function pathToString(path, round) {
|
|
@@ -6,13 +6,12 @@ import distanceSquareRoot from './distanceSquareRoot';
|
|
|
6
6
|
*
|
|
7
7
|
* Returns the perimeter of a polygon.
|
|
8
8
|
*
|
|
9
|
-
* @param {number
|
|
9
|
+
* @param {[number,number][]} polygon an array of coordinates
|
|
10
10
|
* @returns {number} the polygon length
|
|
11
11
|
*/
|
|
12
12
|
export default function polygonLength(polygon) {
|
|
13
13
|
return polygon.reduce((length, point, i) => {
|
|
14
14
|
if (i) {
|
|
15
|
-
// @ts-ignore
|
|
16
15
|
return length + distanceSquareRoot(polygon[i - 1], point);
|
|
17
16
|
}
|
|
18
17
|
return 0;
|
package/src/options/options.js
CHANGED
|
@@ -3,7 +3,7 @@ import paramsCount from './paramsCount';
|
|
|
3
3
|
/**
|
|
4
4
|
* Breaks the parsing of a pathString once a segment is finalized.
|
|
5
5
|
*
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {SVGPath.PathParser} path the `PathParser` instance
|
|
7
7
|
*/
|
|
8
8
|
export default function finalizeSegment(path) {
|
|
9
9
|
let pathCommand = path.pathValue[path.segmentStart];
|
package/src/parser/isSpace.js
CHANGED
|
@@ -11,5 +11,5 @@ export default function isSpace(ch) {
|
|
|
11
11
|
return (ch === 0x0A) || (ch === 0x0D) || (ch === 0x2028) || (ch === 0x2029) // Line terminators
|
|
12
12
|
// White spaces
|
|
13
13
|
|| (ch === 0x20) || (ch === 0x09) || (ch === 0x0B) || (ch === 0x0C) || (ch === 0xA0)
|
|
14
|
-
|| (ch >= 0x1680 && specialSpaces.
|
|
14
|
+
|| (ch >= 0x1680 && specialSpaces.includes(ch));
|
|
15
15
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import scanSegment from './scanSegment';
|
|
2
2
|
import skipSpaces from './skipSpaces';
|
|
3
|
-
import
|
|
3
|
+
import error from './error';
|
|
4
4
|
import clonePath from '../process/clonePath';
|
|
5
5
|
import PathParser from './pathParser';
|
|
6
6
|
import isPathArray from '../util/isPathArray';
|
|
@@ -9,8 +9,8 @@ import isPathArray from '../util/isPathArray';
|
|
|
9
9
|
* Parses a path string value and returns an array
|
|
10
10
|
* of segments we like to call `pathArray`.
|
|
11
11
|
*
|
|
12
|
-
* @param {
|
|
13
|
-
* @returns {
|
|
12
|
+
* @param {SVGPath.pathArray | string} pathInput the string to be parsed
|
|
13
|
+
* @returns {SVGPath.pathArray | string} the resulted `pathArray`
|
|
14
14
|
*/
|
|
15
15
|
export default function parsePathString(pathInput) {
|
|
16
16
|
if (isPathArray(pathInput)) {
|
|
@@ -27,18 +27,13 @@ export default function parsePathString(pathInput) {
|
|
|
27
27
|
scanSegment(path);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
if (path.err.length) {
|
|
31
|
-
// @ts-ignore
|
|
32
|
-
path.segments = [];
|
|
33
|
-
} else if (path.segments.length) {
|
|
30
|
+
if (!path.err.length) {
|
|
34
31
|
if (!'mM'.includes(path.segments[0][0])) {
|
|
35
|
-
path.err = `${
|
|
36
|
-
// @ts-ignore
|
|
37
|
-
path.segments = [];
|
|
32
|
+
path.err = `${error}: missing M/m`;
|
|
38
33
|
} else {
|
|
39
34
|
path.segments[0][0] = 'M';
|
|
40
35
|
}
|
|
41
36
|
}
|
|
42
37
|
|
|
43
|
-
return path.segments;
|
|
38
|
+
return path.err ? path.err : path.segments;
|
|
44
39
|
}
|
package/src/parser/pathParser.js
CHANGED
package/src/parser/scanFlag.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import error from './error';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Validates an A (arc-to) specific path command value.
|
|
5
5
|
* Usually a `large-arc-flag` or `sweep-flag`.
|
|
6
6
|
*
|
|
7
|
-
* @param {
|
|
7
|
+
* @param {SVGPath.PathParser} path the `PathParser` instance
|
|
8
8
|
*/
|
|
9
9
|
export default function scanFlag(path) {
|
|
10
10
|
const { index } = path;
|
|
@@ -22,5 +22,5 @@ export default function scanFlag(path) {
|
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
path.err = `${
|
|
25
|
+
path.err = `${error}: invalid Arc flag "${ch}", expecting 0 or 1 at index ${index}`;
|
|
26
26
|
}
|
package/src/parser/scanParam.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import isDigit from './isDigit';
|
|
2
2
|
import invalidPathValue from './invalidPathValue';
|
|
3
|
+
import error from './error';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Validates every character of the path string,
|
|
6
7
|
* every path command, negative numbers or floating point numbers.
|
|
7
8
|
*
|
|
8
|
-
* @param {
|
|
9
|
+
* @param {SVGPath.PathParser} path the `PathParser` instance
|
|
9
10
|
*/
|
|
10
11
|
export default function scanParam(path) {
|
|
11
12
|
const { max, pathValue, index: start } = path;
|
|
@@ -18,7 +19,7 @@ export default function scanParam(path) {
|
|
|
18
19
|
|
|
19
20
|
if (index >= max) {
|
|
20
21
|
// path.err = 'SvgPath: missed param (at pos ' + index + ')';
|
|
21
|
-
path.err = `${invalidPathValue} at ${index}
|
|
22
|
+
path.err = `${error}: ${invalidPathValue} at index ${index}, "pathValue" is missing param`;
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
25
|
ch = pathValue.charCodeAt(index);
|
|
@@ -32,7 +33,7 @@ export default function scanParam(path) {
|
|
|
32
33
|
// https://github.com/ariya/esprimas
|
|
33
34
|
if (!isDigit(ch) && ch !== 0x2E/* . */) {
|
|
34
35
|
// path.err = 'SvgPath: param should start with 0..9 or `.` (at pos ' + index + ')';
|
|
35
|
-
path.err = `${invalidPathValue} at index ${index}
|
|
36
|
+
path.err = `${error}: ${invalidPathValue} at index ${index}, "${pathValue[index]}" is not a number`;
|
|
36
37
|
return;
|
|
37
38
|
}
|
|
38
39
|
|
|
@@ -47,7 +48,7 @@ export default function scanParam(path) {
|
|
|
47
48
|
if (ch && isDigit(ch)) {
|
|
48
49
|
// path.err = 'SvgPath: numbers started with `0` such as `09`
|
|
49
50
|
// are illegal (at pos ' + start + ')';
|
|
50
|
-
path.err = `${invalidPathValue} at index ${start}
|
|
51
|
+
path.err = `${error}: ${invalidPathValue} at index ${start}, "${pathValue[start]}" illegal number`;
|
|
51
52
|
return;
|
|
52
53
|
}
|
|
53
54
|
}
|
|
@@ -71,7 +72,7 @@ export default function scanParam(path) {
|
|
|
71
72
|
|
|
72
73
|
if (ch === 0x65/* e */ || ch === 0x45/* E */) {
|
|
73
74
|
if (hasDot && !hasCeiling && !hasDecimal) {
|
|
74
|
-
path.err = `${invalidPathValue} at index ${index}
|
|
75
|
+
path.err = `${error}: ${invalidPathValue} at index ${index}, "${pathValue[index]}" invalid float exponent`;
|
|
75
76
|
return;
|
|
76
77
|
}
|
|
77
78
|
|
|
@@ -87,7 +88,7 @@ export default function scanParam(path) {
|
|
|
87
88
|
}
|
|
88
89
|
} else {
|
|
89
90
|
// path.err = 'SvgPath: invalid float exponent (at pos ' + index + ')';
|
|
90
|
-
path.err = `${invalidPathValue} at index ${index}: ${pathValue[index]} invalid float exponent`;
|
|
91
|
+
path.err = `${error}: ${invalidPathValue} at index ${index}: "${pathValue[index]}" invalid float exponent`;
|
|
91
92
|
return;
|
|
92
93
|
}
|
|
93
94
|
}
|
|
@@ -7,12 +7,13 @@ import isPathCommand from './isPathCommand';
|
|
|
7
7
|
import isDigitStart from './isDigitStart';
|
|
8
8
|
import isArcCommand from './isArcCommand';
|
|
9
9
|
import invalidPathValue from './invalidPathValue';
|
|
10
|
+
import error from './error';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Scans every character in the path string to determine
|
|
13
14
|
* where a segment starts and where it ends.
|
|
14
15
|
*
|
|
15
|
-
* @param {
|
|
16
|
+
* @param {SVGPath.PathParser} path the `PathParser` instance
|
|
16
17
|
*/
|
|
17
18
|
export default function scanSegment(path) {
|
|
18
19
|
const { max, pathValue, index } = path;
|
|
@@ -22,7 +23,7 @@ export default function scanSegment(path) {
|
|
|
22
23
|
path.segmentStart = index;
|
|
23
24
|
|
|
24
25
|
if (!isPathCommand(cmdCode)) {
|
|
25
|
-
path.err = `${
|
|
26
|
+
path.err = `${error}: ${invalidPathValue} "${pathValue[index]}" is not a path command`;
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
28
29
|
|
package/src/parser/skipSpaces.js
CHANGED
|
@@ -5,7 +5,7 @@ import isSpace from './isSpace';
|
|
|
5
5
|
* path string every time it encounters any kind of
|
|
6
6
|
* space character.
|
|
7
7
|
*
|
|
8
|
-
* @param {
|
|
8
|
+
* @param {SVGPath.PathParser} path the `PathParser` instance
|
|
9
9
|
*/
|
|
10
10
|
export default function skipSpaces(path) {
|
|
11
11
|
const { pathValue, max } = path;
|
package/src/process/clonePath.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns a clone of an existing `pathArray`.
|
|
3
3
|
*
|
|
4
|
-
* @param {
|
|
4
|
+
* @param {SVGPath.pathArray | SVGPath.pathSegment} path the source `pathArray`
|
|
5
5
|
* @returns {any} the cloned `pathArray`
|
|
6
6
|
*/
|
|
7
7
|
export default function clonePath(path) {
|
package/src/process/fixArc.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Splits an extended A (arc-to) segment into two cubic-bezier segments.
|
|
3
3
|
*
|
|
4
|
-
* @param {
|
|
4
|
+
* @param {SVGPath.pathArray} path the `pathArray` this segment belongs to
|
|
5
5
|
* @param {string[]} allPathCommands all previous path commands
|
|
6
6
|
* @param {number} i the segment index
|
|
7
7
|
*/
|
package/src/process/fixPath.js
CHANGED
|
@@ -10,8 +10,8 @@ import normalizePath from './normalizePath';
|
|
|
10
10
|
* use `splitPath` first and apply this utility on each
|
|
11
11
|
* sub-path separately.
|
|
12
12
|
*
|
|
13
|
-
* @param {
|
|
14
|
-
* @return {
|
|
13
|
+
* @param {SVGPath.pathArray | string} pathInput the `pathArray` source
|
|
14
|
+
* @return {SVGPath.pathArray} a fixed `pathArray`
|
|
15
15
|
*/
|
|
16
16
|
export default function fixPath(pathInput) {
|
|
17
17
|
const pathArray = parsePathString(pathInput);
|
|
@@ -3,14 +3,15 @@ import CSSMatrix from 'dommatrix';
|
|
|
3
3
|
/**
|
|
4
4
|
* Returns a transformation matrix to apply to `<path>` elements.
|
|
5
5
|
*
|
|
6
|
-
* @see
|
|
6
|
+
* @see SVGPath.transformObject
|
|
7
7
|
*
|
|
8
|
-
* @param {
|
|
8
|
+
* @param {SVGPath.transformObject} transform the `transformObject`
|
|
9
9
|
* @returns {CSSMatrix} a new transformation matrix
|
|
10
10
|
*/
|
|
11
11
|
export default function getSVGMatrix(transform) {
|
|
12
12
|
let matrix = new CSSMatrix();
|
|
13
13
|
const { origin } = transform;
|
|
14
|
+
// @ts-ignore -- at this point the origin is surely defined
|
|
14
15
|
const [originX, originY] = origin;
|
|
15
16
|
const { translate } = transform;
|
|
16
17
|
const { rotate } = transform;
|
|
@@ -9,8 +9,8 @@ import paramsParser from '../parser/paramsParser';
|
|
|
9
9
|
* * convert segments to absolute values
|
|
10
10
|
* * convert shorthand path commands to their non-shorthand notation
|
|
11
11
|
*
|
|
12
|
-
* @param {string |
|
|
13
|
-
* @returns {
|
|
12
|
+
* @param {string | SVGPath.pathArray} pathInput the string to be parsed or 'pathArray'
|
|
13
|
+
* @returns {SVGPath.normalArray} the normalized `pathArray`
|
|
14
14
|
*/
|
|
15
15
|
export default function normalizePath(pathInput) {
|
|
16
16
|
if (isNormalizedArray(pathInput)) {
|
|
@@ -18,7 +18,7 @@ export default function normalizePath(pathInput) {
|
|
|
18
18
|
return clonePath(pathInput);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
/** @type {
|
|
21
|
+
/** @type {SVGPath.normalArray} */
|
|
22
22
|
// @ts-ignore -- `absoluteArray` will become a `normalArray`
|
|
23
23
|
const path = pathToAbsolute(pathInput);
|
|
24
24
|
const params = { ...paramsParser };
|
|
@@ -4,10 +4,10 @@ import shorthandToCubic from './shorthandToCubic';
|
|
|
4
4
|
/**
|
|
5
5
|
* Normalizes a single segment of a `pathArray` object.
|
|
6
6
|
*
|
|
7
|
-
* @param {
|
|
7
|
+
* @param {SVGPath.pathSegment} segment the segment object
|
|
8
8
|
* @param {any} params the coordinates of the previous segment
|
|
9
9
|
* @param {string} prevCommand the path command of the previous segment
|
|
10
|
-
* @returns {
|
|
10
|
+
* @returns {SVGPath.normalSegment} the normalized segment
|
|
11
11
|
*/
|
|
12
12
|
export default function normalizeSegment(segment, params, prevCommand) {
|
|
13
13
|
const [pathCommand] = segment;
|
|
@@ -14,9 +14,9 @@ import normalizePath from './normalizePath';
|
|
|
14
14
|
* * implement `auto` for rounding values based on pathBBox
|
|
15
15
|
* * also revers path check if it's smaller string, maybe?
|
|
16
16
|
*
|
|
17
|
-
* @param {
|
|
17
|
+
* @param {SVGPath.pathArray} pathInput a string or `pathArray`
|
|
18
18
|
* @param {number | boolean} round the amount of decimals to round values to
|
|
19
|
-
* @returns {
|
|
19
|
+
* @returns {SVGPath.pathArray} the optimized `pathArray`
|
|
20
20
|
*/
|
|
21
21
|
export default function optimizePath(pathInput, round) {
|
|
22
22
|
const path = pathToAbsolute(pathInput);
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* Details =>
|
|
8
8
|
* https://stackoverflow.com/questions/23792505/predicted-rendering-of-css-3d-transformed-pixel
|
|
9
9
|
*
|
|
10
|
-
* @param {
|
|
10
|
+
* @param {SVGPath.CSSMatrix} m the transformation matrix
|
|
11
11
|
* @param {[number, number]} point2D the initial [x,y] coordinates
|
|
12
|
-
* @param {number[]} origin the
|
|
12
|
+
* @param {number[]} origin the [x,y,z] transform origin
|
|
13
13
|
* @returns {[number, number]} the projected [x,y] coordinates
|
|
14
14
|
*/
|
|
15
15
|
export default function projection2d(m, point2D, origin) {
|