svg-path-commander 2.1.3 → 2.1.6
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 +4 -4
- package/dist/svg-path-commander.cjs +1 -1
- package/dist/svg-path-commander.cjs.map +1 -1
- package/dist/svg-path-commander.d.ts +755 -830
- package/dist/svg-path-commander.js +1 -1
- package/dist/svg-path-commander.js.map +1 -1
- package/dist/svg-path-commander.mjs +670 -395
- package/dist/svg-path-commander.mjs.map +1 -1
- package/package.json +16 -24
- package/.eslintrc.cjs +0 -225
- package/.lgtm.yml +0 -9
- package/.prettierrc.json +0 -15
- package/dts.config.ts +0 -15
- package/src/convert/pathToAbsolute.ts +0 -18
- package/src/convert/pathToCurve.ts +0 -43
- package/src/convert/pathToRelative.ts +0 -18
- package/src/convert/pathToString.ts +0 -50
- package/src/index.ts +0 -454
- package/src/interface.ts +0 -130
- package/src/math/arcTools.ts +0 -388
- package/src/math/bezier.ts +0 -261
- package/src/math/cubicTools.ts +0 -123
- package/src/math/distanceSquareRoot.ts +0 -15
- package/src/math/lineTools.ts +0 -61
- package/src/math/midPoint.ts +0 -18
- package/src/math/polygonTools.ts +0 -48
- package/src/math/quadTools.ts +0 -98
- package/src/math/rotateVector.ts +0 -17
- package/src/math/roundTo.ts +0 -7
- package/src/options/options.ts +0 -9
- package/src/parser/error.ts +0 -2
- package/src/parser/finalizeSegment.ts +0 -35
- package/src/parser/invalidPathValue.ts +0 -2
- package/src/parser/isArcCommand.ts +0 -11
- package/src/parser/isDigit.ts +0 -12
- package/src/parser/isDigitStart.ts +0 -14
- package/src/parser/isMoveCommand.ts +0 -17
- package/src/parser/isPathCommand.ts +0 -28
- package/src/parser/isSpace.ts +0 -23
- package/src/parser/paramsCount.ts +0 -16
- package/src/parser/paramsParser.ts +0 -14
- package/src/parser/parsePathString.ts +0 -33
- package/src/parser/pathParser.ts +0 -29
- package/src/parser/scanFlag.ts +0 -29
- package/src/parser/scanParam.ts +0 -102
- package/src/parser/scanSegment.ts +0 -84
- package/src/parser/skipSpaces.ts +0 -17
- package/src/process/absolutizeSegment.ts +0 -67
- package/src/process/arcToCubic.ts +0 -128
- package/src/process/getSVGMatrix.ts +0 -70
- package/src/process/iterate.ts +0 -58
- package/src/process/lineToCubic.ts +0 -17
- package/src/process/normalizePath.ts +0 -33
- package/src/process/normalizeSegment.ts +0 -84
- package/src/process/optimizePath.ts +0 -62
- package/src/process/projection2d.ts +0 -52
- package/src/process/quadToCubic.ts +0 -31
- package/src/process/relativizeSegment.ts +0 -63
- package/src/process/reverseCurve.ts +0 -24
- package/src/process/reversePath.ts +0 -114
- package/src/process/roundPath.ts +0 -33
- package/src/process/roundSegment.ts +0 -9
- package/src/process/segmentToCubic.ts +0 -48
- package/src/process/shortenSegment.ts +0 -71
- package/src/process/splitCubic.ts +0 -29
- package/src/process/splitPath.ts +0 -63
- package/src/process/transformPath.ts +0 -114
- package/src/types.ts +0 -228
- package/src/util/distanceEpsilon.ts +0 -3
- package/src/util/getClosestPoint.ts +0 -15
- package/src/util/getDrawDirection.ts +0 -16
- package/src/util/getPathArea.ts +0 -70
- package/src/util/getPathBBox.ts +0 -171
- package/src/util/getPointAtLength.ts +0 -110
- package/src/util/getPropertiesAtLength.ts +0 -67
- package/src/util/getPropertiesAtPoint.ts +0 -84
- package/src/util/getSegmentAtLength.ts +0 -15
- package/src/util/getSegmentOfPoint.ts +0 -18
- package/src/util/getTotalLength.ts +0 -133
- package/src/util/isAbsoluteArray.ts +0 -18
- package/src/util/isCurveArray.ts +0 -15
- package/src/util/isNormalizedArray.ts +0 -16
- package/src/util/isPathArray.ts +0 -24
- package/src/util/isPointInStroke.ts +0 -16
- package/src/util/isRelativeArray.ts +0 -18
- package/src/util/isValidPath.ts +0 -27
- package/src/util/shapeParams.ts +0 -16
- package/src/util/shapeToPath.ts +0 -86
- package/src/util/shapeToPathArray.ts +0 -183
- package/test/class.test.ts +0 -506
- package/test/fixtures/getMarkup.ts +0 -17
- package/test/fixtures/shapeObjects.ts +0 -11
- package/test/fixtures/shapes.js +0 -104
- package/test/fixtures/simpleShapes.js +0 -87
- package/test/static.test.ts +0 -330
- package/tsconfig.json +0 -34
- package/vite.config.mts +0 -41
- package/vitest.config-ui.mts +0 -31
- package/vitest.config.mts +0 -31
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
const
|
|
1
|
+
var Qe = Object.defineProperty;
|
|
2
|
+
var Ze = (e, t, s) => t in e ? Qe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
|
3
|
+
var b = (e, t, s) => Ze(e, typeof t != "symbol" ? t + "" : t, s);
|
|
4
|
+
var De = Object.defineProperty, Oe = (e, t, s) => t in e ? De(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, j = (e, t, s) => Oe(e, typeof t != "symbol" ? t + "" : t, s);
|
|
5
|
+
const Be = {
|
|
6
6
|
a: 1,
|
|
7
7
|
b: 0,
|
|
8
8
|
c: 0,
|
|
@@ -27,13 +27,32 @@ const Oe = {
|
|
|
27
27
|
m44: 1,
|
|
28
28
|
is2D: !0,
|
|
29
29
|
isIdentity: !0
|
|
30
|
-
}, Gt = (e) => (e instanceof Float64Array || e instanceof Float32Array || Array.isArray(e) && e.every((t) => typeof t == "number")) && [6, 16].some((t) => e.length === t), te = (e) => e instanceof DOMMatrix || e instanceof
|
|
31
|
-
const t = new
|
|
30
|
+
}, Gt = (e) => (e instanceof Float64Array || e instanceof Float32Array || Array.isArray(e) && e.every((t) => typeof t == "number")) && [6, 16].some((t) => e.length === t), te = (e) => e instanceof DOMMatrix || e instanceof C || typeof e == "object" && Object.keys(Be).every((t) => e && t in e), lt = (e) => {
|
|
31
|
+
const t = new C(), s = Array.from(e);
|
|
32
32
|
if (!Gt(s))
|
|
33
|
-
throw TypeError(
|
|
33
|
+
throw TypeError(
|
|
34
|
+
`CSSMatrix: "${s.join(",")}" must be an array with 6/16 numbers.`
|
|
35
|
+
);
|
|
34
36
|
if (s.length === 16) {
|
|
35
|
-
const [
|
|
36
|
-
|
|
37
|
+
const [
|
|
38
|
+
r,
|
|
39
|
+
n,
|
|
40
|
+
i,
|
|
41
|
+
o,
|
|
42
|
+
l,
|
|
43
|
+
c,
|
|
44
|
+
a,
|
|
45
|
+
u,
|
|
46
|
+
f,
|
|
47
|
+
h,
|
|
48
|
+
y,
|
|
49
|
+
m,
|
|
50
|
+
g,
|
|
51
|
+
d,
|
|
52
|
+
M,
|
|
53
|
+
w
|
|
54
|
+
] = s;
|
|
55
|
+
t.m11 = r, t.a = r, t.m21 = l, t.c = l, t.m31 = f, t.m41 = g, t.e = g, t.m12 = n, t.b = n, t.m22 = c, t.d = c, t.m32 = h, t.m42 = d, t.f = d, t.m13 = i, t.m23 = a, t.m33 = y, t.m43 = M, t.m14 = o, t.m24 = u, t.m34 = m, t.m44 = w;
|
|
37
56
|
} else if (s.length === 6) {
|
|
38
57
|
const [r, n, i, o, l, c] = s;
|
|
39
58
|
t.m11 = r, t.a = r, t.m12 = n, t.b = n, t.m21 = i, t.c = i, t.m22 = o, t.d = o, t.m41 = l, t.e = l, t.m42 = c, t.f = c;
|
|
@@ -59,43 +78,53 @@ const Oe = {
|
|
|
59
78
|
e.m43,
|
|
60
79
|
e.m44
|
|
61
80
|
]);
|
|
62
|
-
throw TypeError(
|
|
81
|
+
throw TypeError(
|
|
82
|
+
`CSSMatrix: "${JSON.stringify(e)}" is not a DOMMatrix / CSSMatrix / JSON compatible object.`
|
|
83
|
+
);
|
|
63
84
|
}, ne = (e) => {
|
|
64
85
|
if (typeof e != "string")
|
|
65
86
|
throw TypeError(`CSSMatrix: "${JSON.stringify(e)}" is not a string.`);
|
|
66
87
|
const t = String(e).replace(/\s/g, "");
|
|
67
|
-
let s = new
|
|
88
|
+
let s = new C();
|
|
68
89
|
const r = `CSSMatrix: invalid transform string "${e}"`;
|
|
69
90
|
return t.split(")").filter((n) => n).forEach((n) => {
|
|
70
91
|
const [i, o] = n.split("(");
|
|
71
92
|
if (!o) throw TypeError(r);
|
|
72
|
-
const l = o.split(",").map(
|
|
73
|
-
|
|
93
|
+
const l = o.split(",").map(
|
|
94
|
+
(m) => m.includes("rad") ? parseFloat(m) * (180 / Math.PI) : parseFloat(m)
|
|
95
|
+
), [c, a, u, f] = l, h = [c, a, u], y = [c, a, u, f];
|
|
96
|
+
if (i === "perspective" && c && [a, u].every((m) => m === void 0))
|
|
74
97
|
s.m34 = -1 / c;
|
|
75
|
-
else if (i.includes("matrix") && [6, 16].includes(l.length) && l.every((
|
|
76
|
-
const
|
|
77
|
-
s = s.multiply(lt(
|
|
78
|
-
} else if (i === "translate3d" && h.every((
|
|
98
|
+
else if (i.includes("matrix") && [6, 16].includes(l.length) && l.every((m) => !Number.isNaN(+m))) {
|
|
99
|
+
const m = l.map((g) => Math.abs(g) < 1e-6 ? 0 : g);
|
|
100
|
+
s = s.multiply(lt(m));
|
|
101
|
+
} else if (i === "translate3d" && h.every((m) => !Number.isNaN(+m)))
|
|
79
102
|
s = s.translate(c, a, u);
|
|
80
103
|
else if (i === "translate" && c && u === void 0)
|
|
81
104
|
s = s.translate(c, a || 0, 0);
|
|
82
|
-
else if (i === "rotate3d" &&
|
|
83
|
-
s = s.rotateAxisAngle(c, a, u,
|
|
84
|
-
else if (i === "rotate" && c && [a, u].every((
|
|
105
|
+
else if (i === "rotate3d" && y.every((m) => !Number.isNaN(+m)) && f)
|
|
106
|
+
s = s.rotateAxisAngle(c, a, u, f);
|
|
107
|
+
else if (i === "rotate" && c && [a, u].every((m) => m === void 0))
|
|
85
108
|
s = s.rotate(0, 0, c);
|
|
86
|
-
else if (i === "scale3d" && h.every((
|
|
109
|
+
else if (i === "scale3d" && h.every((m) => !Number.isNaN(+m)) && h.some((m) => m !== 1))
|
|
87
110
|
s = s.scale(c, a, u);
|
|
88
111
|
else if (i === "scale" && !Number.isNaN(c) && c !== 1 && u === void 0) {
|
|
89
|
-
const
|
|
90
|
-
s = s.scale(c,
|
|
112
|
+
const m = Number.isNaN(+a) ? c : a;
|
|
113
|
+
s = s.scale(c, m, 1);
|
|
91
114
|
} else if (i === "skew" && (c || !Number.isNaN(c) && a) && u === void 0)
|
|
92
115
|
s = s.skew(c, a || 0);
|
|
93
|
-
else if (["translate", "rotate", "scale", "skew"].some(
|
|
116
|
+
else if (["translate", "rotate", "scale", "skew"].some(
|
|
117
|
+
(m) => i.includes(m)
|
|
118
|
+
) && /[XYZ]/.test(i) && c && [a, u].every((m) => m === void 0))
|
|
94
119
|
if (i === "skewX" || i === "skewY")
|
|
95
120
|
s = s[i](c);
|
|
96
121
|
else {
|
|
97
|
-
const
|
|
98
|
-
|
|
122
|
+
const m = i.replace(/[XYZ]/, ""), g = i.replace(m, ""), d = ["X", "Y", "Z"].indexOf(g), M = m === "scale" ? 1 : 0, w = [
|
|
123
|
+
d === 0 ? c : M,
|
|
124
|
+
d === 1 ? c : M,
|
|
125
|
+
d === 2 ? c : M
|
|
126
|
+
];
|
|
127
|
+
s = s[m](...w);
|
|
99
128
|
}
|
|
100
129
|
else
|
|
101
130
|
throw TypeError(r);
|
|
@@ -118,32 +147,32 @@ const Oe = {
|
|
|
118
147
|
e.m43,
|
|
119
148
|
e.m44
|
|
120
149
|
], se = (e, t, s) => {
|
|
121
|
-
const r = new
|
|
150
|
+
const r = new C();
|
|
122
151
|
return r.m41 = e, r.e = e, r.m42 = t, r.f = t, r.m43 = s, r;
|
|
123
152
|
}, re = (e, t, s) => {
|
|
124
|
-
const r = new
|
|
125
|
-
r.m11 =
|
|
126
|
-
const
|
|
127
|
-
r.m21 =
|
|
128
|
-
const M = c * h - a *
|
|
129
|
-
return r.m22 = M, r.d = M, r.m23 = -a * u, r.m31 = a *
|
|
153
|
+
const r = new C(), n = Math.PI / 180, i = e * n, o = t * n, l = s * n, c = Math.cos(i), a = -Math.sin(i), u = Math.cos(o), f = -Math.sin(o), h = Math.cos(l), y = -Math.sin(l), m = u * h, g = -u * y;
|
|
154
|
+
r.m11 = m, r.a = m, r.m12 = g, r.b = g, r.m13 = f;
|
|
155
|
+
const d = a * f * h + c * y;
|
|
156
|
+
r.m21 = d, r.c = d;
|
|
157
|
+
const M = c * h - a * f * y;
|
|
158
|
+
return r.m22 = M, r.d = M, r.m23 = -a * u, r.m31 = a * y - c * f * h, r.m32 = a * h + c * f * y, r.m33 = c * u, r;
|
|
130
159
|
}, ie = (e, t, s, r) => {
|
|
131
|
-
const n = new
|
|
160
|
+
const n = new C(), i = Math.sqrt(e * e + t * t + s * s);
|
|
132
161
|
if (i === 0)
|
|
133
162
|
return n;
|
|
134
|
-
const o = e / i, l = t / i, c = s / i, a = r * (Math.PI / 360), u = Math.sin(a),
|
|
135
|
-
n.m11 =
|
|
136
|
-
const M = 2 * (o * l * h + c * u *
|
|
137
|
-
n.m12 = M, n.b = M, n.m13 = 2 * (o * c * h - l * u *
|
|
138
|
-
const
|
|
139
|
-
n.m21 =
|
|
140
|
-
const x = 1 - 2 * (
|
|
141
|
-
return n.m22 = x, n.d = x, n.m23 = 2 * (l * c * h + o * u *
|
|
163
|
+
const o = e / i, l = t / i, c = s / i, a = r * (Math.PI / 360), u = Math.sin(a), f = Math.cos(a), h = u * u, y = o * o, m = l * l, g = c * c, d = 1 - 2 * (m + g) * h;
|
|
164
|
+
n.m11 = d, n.a = d;
|
|
165
|
+
const M = 2 * (o * l * h + c * u * f);
|
|
166
|
+
n.m12 = M, n.b = M, n.m13 = 2 * (o * c * h - l * u * f);
|
|
167
|
+
const w = 2 * (l * o * h - c * u * f);
|
|
168
|
+
n.m21 = w, n.c = w;
|
|
169
|
+
const x = 1 - 2 * (g + y) * h;
|
|
170
|
+
return n.m22 = x, n.d = x, n.m23 = 2 * (l * c * h + o * u * f), n.m31 = 2 * (c * o * h + l * u * f), n.m32 = 2 * (c * l * h - o * u * f), n.m33 = 1 - 2 * (y + m) * h, n;
|
|
142
171
|
}, oe = (e, t, s) => {
|
|
143
|
-
const r = new
|
|
172
|
+
const r = new C();
|
|
144
173
|
return r.m11 = e, r.a = e, r.m22 = t, r.d = t, r.m33 = s, r;
|
|
145
174
|
}, At = (e, t) => {
|
|
146
|
-
const s = new
|
|
175
|
+
const s = new C();
|
|
147
176
|
if (e) {
|
|
148
177
|
const r = e * Math.PI / 180, n = Math.tan(r);
|
|
149
178
|
s.m21 = n, s.c = n;
|
|
@@ -154,10 +183,27 @@ const Oe = {
|
|
|
154
183
|
}
|
|
155
184
|
return s;
|
|
156
185
|
}, ce = (e) => At(e, 0), le = (e) => At(0, e), _ = (e, t) => {
|
|
157
|
-
const s = t.m11 * e.m11 + t.m12 * e.m21 + t.m13 * e.m31 + t.m14 * e.m41, r = t.m11 * e.m12 + t.m12 * e.m22 + t.m13 * e.m32 + t.m14 * e.m42, n = t.m11 * e.m13 + t.m12 * e.m23 + t.m13 * e.m33 + t.m14 * e.m43, i = t.m11 * e.m14 + t.m12 * e.m24 + t.m13 * e.m34 + t.m14 * e.m44, o = t.m21 * e.m11 + t.m22 * e.m21 + t.m23 * e.m31 + t.m24 * e.m41, l = t.m21 * e.m12 + t.m22 * e.m22 + t.m23 * e.m32 + t.m24 * e.m42, c = t.m21 * e.m13 + t.m22 * e.m23 + t.m23 * e.m33 + t.m24 * e.m43, a = t.m21 * e.m14 + t.m22 * e.m24 + t.m23 * e.m34 + t.m24 * e.m44, u = t.m31 * e.m11 + t.m32 * e.m21 + t.m33 * e.m31 + t.m34 * e.m41,
|
|
158
|
-
return lt([
|
|
186
|
+
const s = t.m11 * e.m11 + t.m12 * e.m21 + t.m13 * e.m31 + t.m14 * e.m41, r = t.m11 * e.m12 + t.m12 * e.m22 + t.m13 * e.m32 + t.m14 * e.m42, n = t.m11 * e.m13 + t.m12 * e.m23 + t.m13 * e.m33 + t.m14 * e.m43, i = t.m11 * e.m14 + t.m12 * e.m24 + t.m13 * e.m34 + t.m14 * e.m44, o = t.m21 * e.m11 + t.m22 * e.m21 + t.m23 * e.m31 + t.m24 * e.m41, l = t.m21 * e.m12 + t.m22 * e.m22 + t.m23 * e.m32 + t.m24 * e.m42, c = t.m21 * e.m13 + t.m22 * e.m23 + t.m23 * e.m33 + t.m24 * e.m43, a = t.m21 * e.m14 + t.m22 * e.m24 + t.m23 * e.m34 + t.m24 * e.m44, u = t.m31 * e.m11 + t.m32 * e.m21 + t.m33 * e.m31 + t.m34 * e.m41, f = t.m31 * e.m12 + t.m32 * e.m22 + t.m33 * e.m32 + t.m34 * e.m42, h = t.m31 * e.m13 + t.m32 * e.m23 + t.m33 * e.m33 + t.m34 * e.m43, y = t.m31 * e.m14 + t.m32 * e.m24 + t.m33 * e.m34 + t.m34 * e.m44, m = t.m41 * e.m11 + t.m42 * e.m21 + t.m43 * e.m31 + t.m44 * e.m41, g = t.m41 * e.m12 + t.m42 * e.m22 + t.m43 * e.m32 + t.m44 * e.m42, d = t.m41 * e.m13 + t.m42 * e.m23 + t.m43 * e.m33 + t.m44 * e.m43, M = t.m41 * e.m14 + t.m42 * e.m24 + t.m43 * e.m34 + t.m44 * e.m44;
|
|
187
|
+
return lt([
|
|
188
|
+
s,
|
|
189
|
+
r,
|
|
190
|
+
n,
|
|
191
|
+
i,
|
|
192
|
+
o,
|
|
193
|
+
l,
|
|
194
|
+
c,
|
|
195
|
+
a,
|
|
196
|
+
u,
|
|
197
|
+
f,
|
|
198
|
+
h,
|
|
199
|
+
y,
|
|
200
|
+
m,
|
|
201
|
+
g,
|
|
202
|
+
d,
|
|
203
|
+
M
|
|
204
|
+
]);
|
|
159
205
|
};
|
|
160
|
-
class
|
|
206
|
+
class C {
|
|
161
207
|
/**
|
|
162
208
|
* @constructor
|
|
163
209
|
* @param init accepts all parameter configurations:
|
|
@@ -381,7 +427,7 @@ class T {
|
|
|
381
427
|
};
|
|
382
428
|
}
|
|
383
429
|
}
|
|
384
|
-
|
|
430
|
+
j(C, "Translate", se), j(C, "Rotate", re), j(C, "RotateAxisAngle", ie), j(C, "Scale", oe), j(C, "SkewX", ce), j(C, "SkewY", le), j(C, "Skew", At), j(C, "Multiply", _), j(C, "fromArray", lt), j(C, "fromMatrix", ee), j(C, "fromString", ne), j(C, "toArray", zt), j(C, "isCompatibleArray", Gt), j(C, "isCompatibleObject", te);
|
|
385
431
|
const V = {
|
|
386
432
|
origin: [0, 0, 0],
|
|
387
433
|
round: 4
|
|
@@ -400,13 +446,17 @@ const V = {
|
|
|
400
446
|
}, qt = (e) => {
|
|
401
447
|
let t = e.pathValue[e.segmentStart], s = t.toLowerCase();
|
|
402
448
|
const { data: r } = e;
|
|
403
|
-
for (; r.length >= tt[s] && (s === "m" && r.length > 2 ? (e.segments.push(
|
|
449
|
+
for (; r.length >= tt[s] && (s === "m" && r.length > 2 ? (e.segments.push(
|
|
450
|
+
[t].concat(
|
|
451
|
+
r.splice(0, 2)
|
|
452
|
+
)
|
|
453
|
+
), s = "l", t = t === "m" ? "l" : "L") : e.segments.push(
|
|
404
454
|
[t].concat(
|
|
405
455
|
r.splice(0, tt[s])
|
|
406
456
|
)
|
|
407
457
|
), !!tt[s]); )
|
|
408
458
|
;
|
|
409
|
-
},
|
|
459
|
+
}, S = "SVGPathCommander Error", ae = (e) => {
|
|
410
460
|
const { index: t, pathValue: s } = e, r = s.charCodeAt(t);
|
|
411
461
|
if (r === 48) {
|
|
412
462
|
e.param = 0, e.index += 1;
|
|
@@ -416,21 +466,21 @@ const V = {
|
|
|
416
466
|
e.param = 1, e.index += 1;
|
|
417
467
|
return;
|
|
418
468
|
}
|
|
419
|
-
e.err = `${
|
|
469
|
+
e.err = `${S}: invalid Arc flag "${s[t]}", expecting 0 or 1 at index ${t}`;
|
|
420
470
|
}, U = (e) => e >= 48 && e <= 57, J = "Invalid path value", ue = (e) => {
|
|
421
471
|
const { max: t, pathValue: s, index: r } = e;
|
|
422
472
|
let n = r, i = !1, o = !1, l = !1, c = !1, a;
|
|
423
473
|
if (n >= t) {
|
|
424
|
-
e.err = `${
|
|
474
|
+
e.err = `${S}: ${J} at index ${n}, "pathValue" is missing param`;
|
|
425
475
|
return;
|
|
426
476
|
}
|
|
427
477
|
if (a = s.charCodeAt(n), (a === 43 || a === 45) && (n += 1, a = s.charCodeAt(n)), !U(a) && a !== 46) {
|
|
428
|
-
e.err = `${
|
|
478
|
+
e.err = `${S}: ${J} at index ${n}, "${s[n]}" is not a number`;
|
|
429
479
|
return;
|
|
430
480
|
}
|
|
431
481
|
if (a !== 46) {
|
|
432
482
|
if (i = a === 48, n += 1, a = s.charCodeAt(n), i && n < t && a && U(a)) {
|
|
433
|
-
e.err = `${
|
|
483
|
+
e.err = `${S}: ${J} at index ${r}, "${s[r]}" illegal number`;
|
|
434
484
|
return;
|
|
435
485
|
}
|
|
436
486
|
for (; n < t && U(s.charCodeAt(n)); )
|
|
@@ -444,14 +494,14 @@ const V = {
|
|
|
444
494
|
}
|
|
445
495
|
if (a === 101 || a === 69) {
|
|
446
496
|
if (c && !o && !l) {
|
|
447
|
-
e.err = `${
|
|
497
|
+
e.err = `${S}: ${J} at index ${n}, "${s[n]}" invalid float exponent`;
|
|
448
498
|
return;
|
|
449
499
|
}
|
|
450
500
|
if (n += 1, a = s.charCodeAt(n), (a === 43 || a === 45) && (n += 1), n < t && U(s.charCodeAt(n)))
|
|
451
501
|
for (; n < t && U(s.charCodeAt(n)); )
|
|
452
502
|
n += 1;
|
|
453
503
|
else {
|
|
454
|
-
e.err = `${
|
|
504
|
+
e.err = `${S}: ${J} at index ${n}, "${s[n]}" invalid integer exponent`;
|
|
455
505
|
return;
|
|
456
506
|
}
|
|
457
507
|
}
|
|
@@ -518,12 +568,12 @@ const V = {
|
|
|
518
568
|
var c;
|
|
519
569
|
const { max: t, pathValue: s, index: r, segments: n } = e, i = s.charCodeAt(r), o = tt[s[r].toLowerCase()];
|
|
520
570
|
if (e.segmentStart = r, !fe(i)) {
|
|
521
|
-
e.err = `${
|
|
571
|
+
e.err = `${S}: ${J} "${s[r]}" is not a path command at index ${r}`;
|
|
522
572
|
return;
|
|
523
573
|
}
|
|
524
574
|
const l = n[n.length - 1];
|
|
525
575
|
if (!ge(i) && ((c = l == null ? void 0 : l[0]) == null ? void 0 : c.toLocaleLowerCase()) === "z") {
|
|
526
|
-
e.err = `${
|
|
576
|
+
e.err = `${S}: ${J} "${s[r]}" is not a MoveTo path command at index ${r}`;
|
|
527
577
|
return;
|
|
528
578
|
}
|
|
529
579
|
if (e.index += 1, et(e), e.data = [], !o) {
|
|
@@ -574,7 +624,11 @@ const Q = (e) => {
|
|
|
574
624
|
if (i === "H")
|
|
575
625
|
return [i, e[1] + s];
|
|
576
626
|
if (i === "L")
|
|
577
|
-
return [
|
|
627
|
+
return [
|
|
628
|
+
i,
|
|
629
|
+
e[1] + s,
|
|
630
|
+
e[2] + r
|
|
631
|
+
];
|
|
578
632
|
{
|
|
579
633
|
const l = [], c = e.length;
|
|
580
634
|
for (let a = 1; a < c; a += 1)
|
|
@@ -582,13 +636,13 @@ const Q = (e) => {
|
|
|
582
636
|
return [i].concat(l);
|
|
583
637
|
}
|
|
584
638
|
}, Z = (e, t) => {
|
|
585
|
-
let s = e.length, r, n = "M", i = "M", o = !1, l = 0, c = 0, a = 0, u = 0,
|
|
639
|
+
let s = e.length, r, n = "M", i = "M", o = !1, l = 0, c = 0, a = 0, u = 0, f = 0;
|
|
586
640
|
for (let h = 0; h < s; h += 1) {
|
|
587
|
-
r = e[h], [n] = r,
|
|
588
|
-
const
|
|
589
|
-
if (
|
|
641
|
+
r = e[h], [n] = r, f = r.length, i = n.toUpperCase(), o = i !== n;
|
|
642
|
+
const y = t(r, h, l, c);
|
|
643
|
+
if (y === !1)
|
|
590
644
|
break;
|
|
591
|
-
i === "Z" ? (l = a, c = u) : i === "H" ? l = r[1] + (o ? l : 0) : i === "V" ? c = r[1] + (o ? c : 0) : (l = r[
|
|
645
|
+
i === "Z" ? (l = a, c = u) : i === "H" ? l = r[1] + (o ? l : 0) : i === "V" ? c = r[1] + (o ? c : 0) : (l = r[f - 2] + (o ? l : 0), c = r[f - 1] + (o ? c : 0), i === "M" && (a = l, u = c)), y && (e[h] = y, y[0] === "C" && (s = e.length));
|
|
592
646
|
}
|
|
593
647
|
return e;
|
|
594
648
|
}, ht = (e) => {
|
|
@@ -613,7 +667,11 @@ const Q = (e) => {
|
|
|
613
667
|
if (i === "h")
|
|
614
668
|
return [i, e[1] - s];
|
|
615
669
|
if (i === "l")
|
|
616
|
-
return [
|
|
670
|
+
return [
|
|
671
|
+
i,
|
|
672
|
+
e[1] - s,
|
|
673
|
+
e[2] - r
|
|
674
|
+
];
|
|
617
675
|
{
|
|
618
676
|
const l = [], c = e.length;
|
|
619
677
|
for (let a = 1; a < c; a += 1)
|
|
@@ -627,32 +685,41 @@ const Q = (e) => {
|
|
|
627
685
|
const { sin: r, cos: n } = Math, i = e * n(s) - t * r(s), o = e * r(s) + t * n(s);
|
|
628
686
|
return { x: i, y: o };
|
|
629
687
|
}, Mt = (e, t, s, r, n, i, o, l, c, a) => {
|
|
630
|
-
let u = e,
|
|
631
|
-
const
|
|
632
|
-
let
|
|
688
|
+
let u = e, f = t, h = s, y = r, m = l, g = c;
|
|
689
|
+
const d = Math.PI * 120 / 180, M = Math.PI / 180 * (+n || 0);
|
|
690
|
+
let w = [], x, p, L, T, I;
|
|
633
691
|
if (a)
|
|
634
|
-
[
|
|
692
|
+
[p, L, T, I] = a;
|
|
635
693
|
else {
|
|
636
|
-
x = st(u,
|
|
637
|
-
const v = (u -
|
|
638
|
-
let X = v * v / (h * h) + O * O / (
|
|
639
|
-
X > 1 && (X = Math.sqrt(X), h *= X,
|
|
640
|
-
const
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
R
|
|
649
|
-
|
|
694
|
+
x = st(u, f, -M), u = x.x, f = x.y, x = st(m, g, -M), m = x.x, g = x.y;
|
|
695
|
+
const v = (u - m) / 2, O = (f - g) / 2;
|
|
696
|
+
let X = v * v / (h * h) + O * O / (y * y);
|
|
697
|
+
X > 1 && (X = Math.sqrt(X), h *= X, y *= X);
|
|
698
|
+
const Ct = h * h, $t = y * y, Jt = (i === o ? -1 : 1) * Math.sqrt(
|
|
699
|
+
Math.abs(
|
|
700
|
+
(Ct * $t - Ct * O * O - $t * v * v) / (Ct * O * O + $t * v * v)
|
|
701
|
+
)
|
|
702
|
+
);
|
|
703
|
+
T = Jt * h * O / y + (u + m) / 2, I = Jt * -y * v / h + (f + g) / 2, p = Math.asin(((f - I) / y * 10 ** 9 >> 0) / 10 ** 9), L = Math.asin(((g - I) / y * 10 ** 9 >> 0) / 10 ** 9), p = u < T ? Math.PI - p : p, L = m < T ? Math.PI - L : L, p < 0 && (p = Math.PI * 2 + p), L < 0 && (L = Math.PI * 2 + L), o && p > L && (p -= Math.PI * 2), !o && L > p && (L -= Math.PI * 2);
|
|
704
|
+
}
|
|
705
|
+
let R = L - p;
|
|
706
|
+
if (Math.abs(R) > d) {
|
|
707
|
+
const v = L, O = m, X = g;
|
|
708
|
+
L = p + d * (o && L > p ? 1 : -1), m = T + h * Math.cos(L), g = I + y * Math.sin(L), w = Mt(m, g, h, y, n, 0, o, O, X, [
|
|
709
|
+
L,
|
|
710
|
+
v,
|
|
711
|
+
T,
|
|
712
|
+
I
|
|
713
|
+
]);
|
|
714
|
+
}
|
|
715
|
+
R = L - p;
|
|
716
|
+
const P = Math.cos(p), z = Math.sin(p), D = Math.cos(L), K = Math.sin(L), q = Math.tan(R / 4), N = 4 / 3 * h * q, $ = 4 / 3 * y * q, E = [u, f], B = [u + N * z, f - $ * P], F = [m + N * K, g - $ * D], G = [m, g];
|
|
650
717
|
if (B[0] = 2 * E[0] - B[0], B[1] = 2 * E[1] - B[1], a)
|
|
651
|
-
return [B[0], B[1], F[0], F[1], G[0], G[1]].concat(
|
|
652
|
-
|
|
718
|
+
return [B[0], B[1], F[0], F[1], G[0], G[1]].concat(w);
|
|
719
|
+
w = [B[0], B[1], F[0], F[1], G[0], G[1]].concat(w);
|
|
653
720
|
const W = [];
|
|
654
|
-
for (let v = 0, O =
|
|
655
|
-
W[v] = v % 2 ? st(
|
|
721
|
+
for (let v = 0, O = w.length; v < O; v += 1)
|
|
722
|
+
W[v] = v % 2 ? st(w[v - 1], w[v], M).y : st(w[v], w[v + 1], M).x;
|
|
656
723
|
return W;
|
|
657
724
|
}, xe = (e, t, s, r, n, i) => {
|
|
658
725
|
const o = 0.3333333333333333, l = 2 / 3;
|
|
@@ -678,19 +745,44 @@ const Q = (e) => {
|
|
|
678
745
|
}, pe = (e, t) => {
|
|
679
746
|
const [s] = e, r = e.slice(1).map(Number), [n, i] = r, { x1: o, y1: l, x: c, y: a } = t;
|
|
680
747
|
return "TQ".includes(s) || (t.qx = null, t.qy = null), s === "M" ? (t.x = n, t.y = i, e) : s === "A" ? ["C"].concat(
|
|
681
|
-
Mt(
|
|
748
|
+
Mt(
|
|
749
|
+
o,
|
|
750
|
+
l,
|
|
751
|
+
r[0],
|
|
752
|
+
r[1],
|
|
753
|
+
r[2],
|
|
754
|
+
r[3],
|
|
755
|
+
r[4],
|
|
756
|
+
r[5],
|
|
757
|
+
r[6]
|
|
758
|
+
)
|
|
682
759
|
) : s === "Q" ? (t.qx = n, t.qy = i, ["C"].concat(
|
|
683
760
|
xe(o, l, r[0], r[1], r[2], r[3])
|
|
684
|
-
)) : s === "L" ? ["C"].concat(
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
761
|
+
)) : s === "L" ? ["C"].concat(
|
|
762
|
+
Pt(o, l, n, i)
|
|
763
|
+
) : s === "Z" ? ["C"].concat(
|
|
764
|
+
Pt(o, l, c, a)
|
|
765
|
+
) : e;
|
|
766
|
+
}, Nt = (e, t) => {
|
|
767
|
+
const [s] = e, r = s.toUpperCase(), n = s !== r, { x1: i, y1: o, x2: l, y2: c, x: a, y: u } = t, f = e.slice(1);
|
|
768
|
+
let h = f.map((y, m) => y + (n ? m % 2 ? u : a : 0));
|
|
688
769
|
if ("TQ".includes(r) || (t.qx = null, t.qy = null), r === "A")
|
|
689
|
-
return h =
|
|
770
|
+
return h = f.slice(0, -2).concat(
|
|
771
|
+
f[5] + (n ? a : 0),
|
|
772
|
+
f[6] + (n ? u : 0)
|
|
773
|
+
), ["A"].concat(h);
|
|
690
774
|
if (r === "H")
|
|
691
|
-
return [
|
|
775
|
+
return [
|
|
776
|
+
"L",
|
|
777
|
+
e[1] + (n ? a : 0),
|
|
778
|
+
o
|
|
779
|
+
];
|
|
692
780
|
if (r === "V")
|
|
693
|
-
return [
|
|
781
|
+
return [
|
|
782
|
+
"L",
|
|
783
|
+
i,
|
|
784
|
+
e[1] + (n ? u : 0)
|
|
785
|
+
];
|
|
694
786
|
if (r === "L")
|
|
695
787
|
return [
|
|
696
788
|
"L",
|
|
@@ -706,20 +798,20 @@ const Q = (e) => {
|
|
|
706
798
|
if (r === "C")
|
|
707
799
|
return ["C"].concat(h);
|
|
708
800
|
if (r === "S") {
|
|
709
|
-
const
|
|
710
|
-
return t.x1 =
|
|
801
|
+
const y = i * 2 - l, m = o * 2 - c;
|
|
802
|
+
return t.x1 = y, t.y1 = m, ["C", y, m].concat(h);
|
|
711
803
|
} else if (r === "T") {
|
|
712
|
-
const
|
|
804
|
+
const y = i * 2 - (t.qx ? t.qx : (
|
|
713
805
|
/* istanbul ignore next */
|
|
714
806
|
0
|
|
715
|
-
)),
|
|
807
|
+
)), m = o * 2 - (t.qy ? t.qy : (
|
|
716
808
|
/* istanbul ignore next */
|
|
717
809
|
0
|
|
718
810
|
));
|
|
719
|
-
return t.qx =
|
|
811
|
+
return t.qx = y, t.qy = m, ["Q", y, m].concat(h);
|
|
720
812
|
} else if (r === "Q") {
|
|
721
|
-
const [
|
|
722
|
-
return t.qx =
|
|
813
|
+
const [y, m] = h;
|
|
814
|
+
return t.qx = y, t.qy = m, ["Q"].concat(h);
|
|
723
815
|
} else if (r === "Z")
|
|
724
816
|
return ["Z"];
|
|
725
817
|
return e;
|
|
@@ -736,9 +828,13 @@ const Q = (e) => {
|
|
|
736
828
|
const t = { ...ut }, s = Q(e);
|
|
737
829
|
return Z(s, (r, n, i, o) => {
|
|
738
830
|
t.x = i, t.y = o;
|
|
739
|
-
const l =
|
|
831
|
+
const l = Nt(r, t);
|
|
740
832
|
let c = pe(l, t);
|
|
741
|
-
c[0] === "C" && c.length > 7 && (s.splice(
|
|
833
|
+
c[0] === "C" && c.length > 7 && (s.splice(
|
|
834
|
+
n + 1,
|
|
835
|
+
0,
|
|
836
|
+
["C"].concat(c.slice(7))
|
|
837
|
+
), c = c.slice(0, 7));
|
|
742
838
|
const u = c.length;
|
|
743
839
|
return t.x1 = +c[u - 2], t.y1 = +c[u - 1], t.x2 = +c[u - 4] || t.x1, t.y2 = +c[u - 3] || t.y1, c;
|
|
744
840
|
});
|
|
@@ -765,10 +861,12 @@ const Q = (e) => {
|
|
|
765
861
|
}
|
|
766
862
|
}
|
|
767
863
|
return i;
|
|
768
|
-
},
|
|
864
|
+
}, wt = (e, t) => Math.sqrt(
|
|
865
|
+
(e[0] - t[0]) * (e[0] - t[0]) + (e[1] - t[1]) * (e[1] - t[1])
|
|
866
|
+
), it = (e, t, s, r) => wt([e, t], [s, r]), Ht = (e, t, s, r, n) => {
|
|
769
867
|
let i = { x: e, y: t };
|
|
770
868
|
if (typeof n == "number") {
|
|
771
|
-
const o =
|
|
869
|
+
const o = wt([e, t], [s, r]);
|
|
772
870
|
if (n <= 0)
|
|
773
871
|
i = { x: e, y: t };
|
|
774
872
|
else if (n >= o)
|
|
@@ -786,109 +884,139 @@ const Q = (e) => {
|
|
|
786
884
|
const r = s / 2, n = Math.sin(r), i = Math.cos(r), o = e ** 2 * n ** 2, l = t ** 2 * i ** 2, c = Math.sqrt(o + l) * s;
|
|
787
885
|
return Math.abs(c);
|
|
788
886
|
}, Y = (e, t, s, r, n, i) => {
|
|
789
|
-
const { sin: o, cos: l } = Math, c = l(n), a = o(n), u = s * l(i),
|
|
790
|
-
return [e + c * u - a *
|
|
887
|
+
const { sin: o, cos: l } = Math, c = l(n), a = o(n), u = s * l(i), f = r * o(i);
|
|
888
|
+
return [e + c * u - a * f, t + a * u + c * f];
|
|
791
889
|
}, Et = (e, t) => {
|
|
792
890
|
const { x: s, y: r } = e, { x: n, y: i } = t, o = s * n + r * i, l = Math.sqrt((s ** 2 + r ** 2) * (n ** 2 + i ** 2));
|
|
793
891
|
return (s * i - r * n < 0 ? -1 : 1) * Math.acos(o / l);
|
|
794
892
|
}, Lt = (e, t, s, r, n, i, o, l, c) => {
|
|
795
|
-
const { abs: a, sin: u, cos:
|
|
796
|
-
let
|
|
797
|
-
const M = (n % 360 + 360) % 360 * (
|
|
893
|
+
const { abs: a, sin: u, cos: f, sqrt: h, PI: y } = Math;
|
|
894
|
+
let m = a(s), g = a(r);
|
|
895
|
+
const M = (n % 360 + 360) % 360 * (y / 180);
|
|
798
896
|
if (e === l && t === c)
|
|
799
897
|
return {
|
|
800
|
-
rx:
|
|
801
|
-
ry:
|
|
898
|
+
rx: m,
|
|
899
|
+
ry: g,
|
|
802
900
|
startAngle: 0,
|
|
803
901
|
endAngle: 0,
|
|
804
902
|
center: { x: l, y: c }
|
|
805
903
|
};
|
|
806
|
-
if (
|
|
904
|
+
if (m === 0 || g === 0)
|
|
807
905
|
return {
|
|
808
|
-
rx:
|
|
809
|
-
ry:
|
|
906
|
+
rx: m,
|
|
907
|
+
ry: g,
|
|
810
908
|
startAngle: 0,
|
|
811
909
|
endAngle: 0,
|
|
812
910
|
center: { x: (l + e) / 2, y: (c + t) / 2 }
|
|
813
911
|
};
|
|
814
|
-
const
|
|
815
|
-
x:
|
|
816
|
-
y: -u(M) *
|
|
817
|
-
}, L =
|
|
818
|
-
L > 1 && (
|
|
819
|
-
const
|
|
820
|
-
let R =
|
|
912
|
+
const w = (e - l) / 2, x = (t - c) / 2, p = {
|
|
913
|
+
x: f(M) * w + u(M) * x,
|
|
914
|
+
y: -u(M) * w + f(M) * x
|
|
915
|
+
}, L = p.x ** 2 / m ** 2 + p.y ** 2 / g ** 2;
|
|
916
|
+
L > 1 && (m *= h(L), g *= h(L));
|
|
917
|
+
const T = m ** 2 * g ** 2 - m ** 2 * p.y ** 2 - g ** 2 * p.x ** 2, I = m ** 2 * p.y ** 2 + g ** 2 * p.x ** 2;
|
|
918
|
+
let R = T / I;
|
|
821
919
|
R = R < 0 ? 0 : R;
|
|
822
920
|
const P = (i !== o ? 1 : -1) * h(R), z = {
|
|
823
|
-
x: P * (
|
|
824
|
-
y: P * (-(
|
|
921
|
+
x: P * (m * p.y / g),
|
|
922
|
+
y: P * (-(g * p.x) / m)
|
|
825
923
|
}, D = {
|
|
826
|
-
x:
|
|
827
|
-
y: u(M) * z.x +
|
|
924
|
+
x: f(M) * z.x - u(M) * z.y + (e + l) / 2,
|
|
925
|
+
y: u(M) * z.x + f(M) * z.y + (t + c) / 2
|
|
828
926
|
}, K = {
|
|
829
|
-
x: (
|
|
830
|
-
y: (
|
|
831
|
-
}, q = Et({ x: 1, y: 0 }, K),
|
|
832
|
-
x: (-
|
|
833
|
-
y: (-
|
|
927
|
+
x: (p.x - z.x) / m,
|
|
928
|
+
y: (p.y - z.y) / g
|
|
929
|
+
}, q = Et({ x: 1, y: 0 }, K), N = {
|
|
930
|
+
x: (-p.x - z.x) / m,
|
|
931
|
+
y: (-p.y - z.y) / g
|
|
834
932
|
};
|
|
835
|
-
let $ = Et(K,
|
|
836
|
-
!o && $ > 0 ? $ -= 2 *
|
|
933
|
+
let $ = Et(K, N);
|
|
934
|
+
!o && $ > 0 ? $ -= 2 * y : o && $ < 0 && ($ += 2 * y), $ %= 2 * y;
|
|
837
935
|
const E = q + $;
|
|
838
936
|
return {
|
|
839
937
|
center: D,
|
|
840
938
|
startAngle: q,
|
|
841
939
|
endAngle: E,
|
|
842
|
-
rx:
|
|
843
|
-
ry:
|
|
940
|
+
rx: m,
|
|
941
|
+
ry: g
|
|
844
942
|
};
|
|
845
943
|
}, _t = (e, t, s, r, n, i, o, l, c) => {
|
|
846
|
-
const { rx: a, ry: u, startAngle:
|
|
847
|
-
|
|
944
|
+
const { rx: a, ry: u, startAngle: f, endAngle: h } = Lt(
|
|
945
|
+
e,
|
|
946
|
+
t,
|
|
947
|
+
s,
|
|
948
|
+
r,
|
|
949
|
+
n,
|
|
950
|
+
i,
|
|
951
|
+
o,
|
|
952
|
+
l,
|
|
953
|
+
c
|
|
954
|
+
);
|
|
955
|
+
return Ft(a, u, h - f);
|
|
848
956
|
}, be = (e, t, s, r, n, i, o, l, c, a) => {
|
|
849
957
|
let u = { x: e, y: t };
|
|
850
|
-
const { center:
|
|
958
|
+
const { center: f, rx: h, ry: y, startAngle: m, endAngle: g } = Lt(
|
|
959
|
+
e,
|
|
960
|
+
t,
|
|
961
|
+
s,
|
|
962
|
+
r,
|
|
963
|
+
n,
|
|
964
|
+
i,
|
|
965
|
+
o,
|
|
966
|
+
l,
|
|
967
|
+
c
|
|
968
|
+
);
|
|
851
969
|
if (typeof a == "number") {
|
|
852
|
-
const
|
|
970
|
+
const d = Ft(h, y, g - m);
|
|
853
971
|
if (a <= 0)
|
|
854
972
|
u = { x: e, y: t };
|
|
855
|
-
else if (a >=
|
|
973
|
+
else if (a >= d)
|
|
856
974
|
u = { x: l, y: c };
|
|
857
975
|
else {
|
|
858
976
|
if (e === l && t === c)
|
|
859
977
|
return { x: l, y: c };
|
|
860
|
-
if (h === 0 ||
|
|
978
|
+
if (h === 0 || y === 0)
|
|
861
979
|
return Ht(e, t, l, c, a);
|
|
862
|
-
const { PI: M, cos:
|
|
980
|
+
const { PI: M, cos: w, sin: x } = Math, p = g - m, T = (n % 360 + 360) % 360 * (M / 180), I = m + p * (a / d), R = h * w(I), P = y * x(I);
|
|
863
981
|
u = {
|
|
864
|
-
x:
|
|
865
|
-
y: x(
|
|
982
|
+
x: w(T) * R - x(T) * P + f.x,
|
|
983
|
+
y: x(T) * R + w(T) * P + f.y
|
|
866
984
|
};
|
|
867
985
|
}
|
|
868
986
|
}
|
|
869
987
|
return u;
|
|
870
988
|
}, de = (e, t, s, r, n, i, o, l, c) => {
|
|
871
|
-
const { center: a, rx: u, ry:
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
989
|
+
const { center: a, rx: u, ry: f, startAngle: h, endAngle: y } = Lt(
|
|
990
|
+
e,
|
|
991
|
+
t,
|
|
992
|
+
s,
|
|
993
|
+
r,
|
|
994
|
+
n,
|
|
995
|
+
i,
|
|
996
|
+
o,
|
|
997
|
+
l,
|
|
998
|
+
c
|
|
999
|
+
), m = y - h, { min: g, max: d, tan: M, atan2: w, PI: x } = Math, { x: p, y: L } = a, T = n * x / 180, I = M(T), R = w(-f * I, u), P = R, z = R + x, D = w(f, u * I), K = D + x;
|
|
1000
|
+
let q = g(e, l), N = d(e, l), $ = g(t, c), E = d(t, c);
|
|
1001
|
+
const B = y - m * 1e-3, F = Y(p, L, u, f, T, B), G = y - m * 0.999, W = Y(p, L, u, f, T, G);
|
|
1002
|
+
if (F[0] > N || W[0] > N) {
|
|
1003
|
+
const v = Y(p, L, u, f, T, P);
|
|
1004
|
+
q = g(q, v[0]), $ = g($, v[1]), N = d(N, v[0]), E = d(E, v[1]);
|
|
877
1005
|
}
|
|
878
1006
|
if (F[0] < q || W[0] < q) {
|
|
879
|
-
const v = Y(
|
|
880
|
-
q =
|
|
1007
|
+
const v = Y(p, L, u, f, T, z);
|
|
1008
|
+
q = g(q, v[0]), $ = g($, v[1]), N = d(N, v[0]), E = d(E, v[1]);
|
|
881
1009
|
}
|
|
882
1010
|
if (F[1] < $ || W[1] < $) {
|
|
883
|
-
const v = Y(
|
|
884
|
-
q =
|
|
1011
|
+
const v = Y(p, L, u, f, T, K);
|
|
1012
|
+
q = g(q, v[0]), $ = g($, v[1]), N = d(N, v[0]), E = d(E, v[1]);
|
|
885
1013
|
}
|
|
886
1014
|
if (F[1] > E || W[1] > E) {
|
|
887
|
-
const v = Y(
|
|
888
|
-
q =
|
|
1015
|
+
const v = Y(p, L, u, f, T, D);
|
|
1016
|
+
q = g(q, v[0]), $ = g($, v[1]), N = d(N, v[0]), E = d(E, v[1]);
|
|
889
1017
|
}
|
|
890
|
-
return [q, $,
|
|
891
|
-
},
|
|
1018
|
+
return [q, $, N, E];
|
|
1019
|
+
}, He = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
892
1020
|
__proto__: null,
|
|
893
1021
|
angleBetween: Et,
|
|
894
1022
|
arcLength: Ft,
|
|
@@ -960,7 +1088,7 @@ const Q = (e) => {
|
|
|
960
1088
|
t.push(i), s = i;
|
|
961
1089
|
}
|
|
962
1090
|
return t;
|
|
963
|
-
},
|
|
1091
|
+
}, Ne = (e, t) => {
|
|
964
1092
|
if (t === 0)
|
|
965
1093
|
return e[0].t = 0, e[0];
|
|
966
1094
|
const s = e.length - 1;
|
|
@@ -983,14 +1111,14 @@ const Q = (e) => {
|
|
|
983
1111
|
y: l * n[0].y + c * n[1].y + a * n[2].y + u * n[3].y,
|
|
984
1112
|
t
|
|
985
1113
|
};
|
|
986
|
-
},
|
|
1114
|
+
}, we = (e, t) => {
|
|
987
1115
|
const s = e(t), r = s.x * s.x + s.y * s.y;
|
|
988
1116
|
return Math.sqrt(r);
|
|
989
1117
|
}, Le = (e) => {
|
|
990
1118
|
const s = Rt.length;
|
|
991
1119
|
let r = 0;
|
|
992
1120
|
for (let n = 0, i; n < s; n++)
|
|
993
|
-
i = 0.5 * Rt[n] + 0.5, r += Ae[n] *
|
|
1121
|
+
i = 0.5 * Rt[n] + 0.5, r += Ae[n] * we(e, i);
|
|
994
1122
|
return 0.5 * r;
|
|
995
1123
|
}, mt = (e) => {
|
|
996
1124
|
const t = [];
|
|
@@ -1000,14 +1128,14 @@ const Q = (e) => {
|
|
|
1000
1128
|
y: e[r + 1]
|
|
1001
1129
|
});
|
|
1002
1130
|
const s = Me(t);
|
|
1003
|
-
return Le((r) =>
|
|
1131
|
+
return Le((r) => Ne(s[0], r));
|
|
1004
1132
|
}, ve = 1e-8, gt = ([e, t, s]) => {
|
|
1005
1133
|
const r = Math.min(e, s), n = Math.max(e, s);
|
|
1006
1134
|
if (t >= e ? s >= t : s <= t)
|
|
1007
1135
|
return [r, n];
|
|
1008
1136
|
const i = (e * s - t * t) / (e - 2 * t + s);
|
|
1009
1137
|
return i < r ? [i, n] : [r, i];
|
|
1010
|
-
},
|
|
1138
|
+
}, jt = ([e, t, s, r]) => {
|
|
1011
1139
|
const n = e - 3 * t + 3 * s - r;
|
|
1012
1140
|
if (Math.abs(n) < ve)
|
|
1013
1141
|
return e === r && e === t ? [e, r] : gt([e, -0.5 * e + 1.5 * t, e - 3 * t + 3 * s]);
|
|
@@ -1017,28 +1145,31 @@ const Q = (e) => {
|
|
|
1017
1145
|
const o = Math.sqrt(i);
|
|
1018
1146
|
let l = Math.min(e, r), c = Math.max(e, r);
|
|
1019
1147
|
const a = e - 2 * t + s;
|
|
1020
|
-
for (let u = (a + o) / n,
|
|
1148
|
+
for (let u = (a + o) / n, f = 1; f <= 2; u = (a - o) / n, f++)
|
|
1021
1149
|
if (u > 0 && u < 1) {
|
|
1022
1150
|
const h = e * (1 - u) * (1 - u) * (1 - u) + t * 3 * (1 - u) * (1 - u) * u + s * 3 * (1 - u) * u * u + r * u * u * u;
|
|
1023
1151
|
h < l && (l = h), h > c && (c = h);
|
|
1024
1152
|
}
|
|
1025
1153
|
return [l, c];
|
|
1026
|
-
},
|
|
1154
|
+
}, Te = ([e, t, s, r, n, i, o, l], c) => {
|
|
1027
1155
|
const a = 1 - c;
|
|
1028
1156
|
return {
|
|
1029
1157
|
x: a ** 3 * e + 3 * a ** 2 * c * s + 3 * a * c ** 2 * n + c ** 3 * o,
|
|
1030
1158
|
y: a ** 3 * t + 3 * a ** 2 * c * r + 3 * a * c ** 2 * i + c ** 3 * l
|
|
1031
1159
|
};
|
|
1032
|
-
}, xt = (e, t, s, r, n, i, o, l) => mt([e, t, s, r, n, i, o, l]),
|
|
1160
|
+
}, xt = (e, t, s, r, n, i, o, l) => mt([e, t, s, r, n, i, o, l]), Ce = (e, t, s, r, n, i, o, l, c) => {
|
|
1033
1161
|
const a = typeof c == "number";
|
|
1034
1162
|
let u = { x: e, y: t };
|
|
1035
1163
|
if (a) {
|
|
1036
|
-
const
|
|
1037
|
-
c <= 0 || (c >=
|
|
1164
|
+
const f = mt([e, t, s, r, n, i, o, l]);
|
|
1165
|
+
c <= 0 || (c >= f ? u = { x: o, y: l } : u = Te(
|
|
1166
|
+
[e, t, s, r, n, i, o, l],
|
|
1167
|
+
c / f
|
|
1168
|
+
));
|
|
1038
1169
|
}
|
|
1039
1170
|
return u;
|
|
1040
|
-
},
|
|
1041
|
-
const c =
|
|
1171
|
+
}, St = (e, t, s, r, n, i, o, l) => {
|
|
1172
|
+
const c = jt([e, s, n, o]), a = jt([t, r, i, l]);
|
|
1042
1173
|
return [c[0], a[0], c[1], a[1]];
|
|
1043
1174
|
}, $e = ([e, t, s, r, n, i], o) => {
|
|
1044
1175
|
const l = 1 - o;
|
|
@@ -1051,32 +1182,41 @@ const Q = (e) => {
|
|
|
1051
1182
|
let c = { x: e, y: t };
|
|
1052
1183
|
if (l) {
|
|
1053
1184
|
const a = mt([e, t, s, r, n, i]);
|
|
1054
|
-
o <= 0 || (o >= a ? c = { x: n, y: i } : c = $e(
|
|
1185
|
+
o <= 0 || (o >= a ? c = { x: n, y: i } : c = $e(
|
|
1186
|
+
[e, t, s, r, n, i],
|
|
1187
|
+
o / a
|
|
1188
|
+
));
|
|
1055
1189
|
}
|
|
1056
1190
|
return c;
|
|
1057
1191
|
}, Qt = (e, t, s, r, n, i) => {
|
|
1058
1192
|
const o = gt([e, s, n]), l = gt([t, r, i]);
|
|
1059
1193
|
return [o[0], l[0], o[1], l[1]];
|
|
1060
|
-
},
|
|
1194
|
+
}, Fe = (e) => {
|
|
1061
1195
|
const t = e.length;
|
|
1062
1196
|
let s = -1, r, n = e[t - 1], i = 0;
|
|
1063
1197
|
for (; ++s < t; )
|
|
1064
1198
|
r = n, n = e[s], i += r[1] * n[0] - r[0] * n[1];
|
|
1065
1199
|
return i / 2;
|
|
1066
|
-
},
|
|
1200
|
+
}, _e = (e) => e.reduce((t, s, r) => r ? t + wt(e[r - 1], s) : 0, 0), bt = 1e-5, ot = (e) => {
|
|
1067
1201
|
const t = Q(e), s = { ...ut };
|
|
1068
1202
|
return Z(t, (r, n, i, o) => {
|
|
1069
1203
|
s.x = i, s.y = o;
|
|
1070
|
-
const l =
|
|
1204
|
+
const l = Nt(r, s), c = l.length;
|
|
1071
1205
|
return s.x1 = +l[c - 2], s.y1 = +l[c - 1], s.x2 = +l[c - 4] || s.x1, s.y2 = +l[c - 3] || s.y1, l;
|
|
1072
1206
|
});
|
|
1073
1207
|
}, rt = (e, t) => {
|
|
1074
1208
|
const s = ot(e);
|
|
1075
1209
|
let r = !1, n = [], i = "M", o = 0, l = 0, [c, a] = s[0].slice(1);
|
|
1076
1210
|
const u = typeof t == "number";
|
|
1077
|
-
let
|
|
1078
|
-
return !u || t < bt ?
|
|
1079
|
-
if ([i] =
|
|
1211
|
+
let f = { x: c, y: a }, h = 0, y = f, m = 0;
|
|
1212
|
+
return !u || t < bt ? f : (Z(s, (g, d, M, w) => {
|
|
1213
|
+
if ([i] = g, r = i === "M", n = r ? n : [M, w].concat(g.slice(1)), r ? ([, c, a] = g, f = { x: c, y: a }, h = 0) : i === "L" ? (f = Ht(
|
|
1214
|
+
n[0],
|
|
1215
|
+
n[1],
|
|
1216
|
+
n[2],
|
|
1217
|
+
n[3],
|
|
1218
|
+
t - m
|
|
1219
|
+
), h = it(n[0], n[1], n[2], n[3])) : i === "A" ? (f = be(
|
|
1080
1220
|
n[0],
|
|
1081
1221
|
n[1],
|
|
1082
1222
|
n[2],
|
|
@@ -1086,8 +1226,8 @@ const Q = (e) => {
|
|
|
1086
1226
|
n[6],
|
|
1087
1227
|
n[7],
|
|
1088
1228
|
n[8],
|
|
1089
|
-
t -
|
|
1090
|
-
), h = _t(
|
|
1229
|
+
t - m
|
|
1230
|
+
), h = _t(
|
|
1091
1231
|
n[0],
|
|
1092
1232
|
n[1],
|
|
1093
1233
|
n[2],
|
|
@@ -1096,27 +1236,66 @@ const Q = (e) => {
|
|
|
1096
1236
|
n[5],
|
|
1097
1237
|
n[6],
|
|
1098
1238
|
n[7],
|
|
1099
|
-
|
|
1100
|
-
)
|
|
1101
|
-
|
|
1239
|
+
n[8]
|
|
1240
|
+
)) : i === "C" ? (f = Ce(
|
|
1241
|
+
n[0],
|
|
1242
|
+
n[1],
|
|
1243
|
+
n[2],
|
|
1244
|
+
n[3],
|
|
1245
|
+
n[4],
|
|
1246
|
+
n[5],
|
|
1247
|
+
n[6],
|
|
1248
|
+
n[7],
|
|
1249
|
+
t - m
|
|
1250
|
+
), h = xt(
|
|
1251
|
+
n[0],
|
|
1252
|
+
n[1],
|
|
1253
|
+
n[2],
|
|
1254
|
+
n[3],
|
|
1255
|
+
n[4],
|
|
1256
|
+
n[5],
|
|
1257
|
+
n[6],
|
|
1258
|
+
n[7]
|
|
1259
|
+
)) : i === "Q" ? (f = ze(
|
|
1260
|
+
n[0],
|
|
1261
|
+
n[1],
|
|
1262
|
+
n[2],
|
|
1263
|
+
n[3],
|
|
1264
|
+
n[4],
|
|
1265
|
+
n[5],
|
|
1266
|
+
t - m
|
|
1267
|
+
), h = pt(
|
|
1268
|
+
n[0],
|
|
1269
|
+
n[1],
|
|
1270
|
+
n[2],
|
|
1271
|
+
n[3],
|
|
1272
|
+
n[4],
|
|
1273
|
+
n[5]
|
|
1274
|
+
)) : i === "Z" && (n = [M, w, c, a], f = { x: c, y: a }, h = it(n[0], n[1], n[2], n[3])), [o, l] = n.slice(-2), m < t)
|
|
1275
|
+
y = f;
|
|
1102
1276
|
else
|
|
1103
1277
|
return !1;
|
|
1104
|
-
|
|
1105
|
-
}), t >
|
|
1278
|
+
m += h;
|
|
1279
|
+
}), t > m - bt ? { x: o, y: l } : y);
|
|
1106
1280
|
}, nt = (e) => {
|
|
1107
1281
|
const t = Q(e);
|
|
1108
|
-
let s = 0, r = 0, n = 0, i = 0, o = 0, l = 0, c = "M", a = 0, u = 0,
|
|
1109
|
-
return Z(t, (h,
|
|
1282
|
+
let s = 0, r = 0, n = 0, i = 0, o = 0, l = 0, c = "M", a = 0, u = 0, f = 0;
|
|
1283
|
+
return Z(t, (h, y, m, g) => {
|
|
1110
1284
|
[c] = h;
|
|
1111
|
-
const
|
|
1112
|
-
if ([c] = x, "TQ".includes(
|
|
1285
|
+
const d = c.toUpperCase(), w = d !== c ? at(h, y, m, g) : h.slice(0), x = d === "V" ? ["L", m, w[1]] : d === "H" ? ["L", w[1], g] : w;
|
|
1286
|
+
if ([c] = x, "TQ".includes(d) || (o = 0, l = 0), c === "M")
|
|
1113
1287
|
[, a, u] = x;
|
|
1114
1288
|
else if (c === "L")
|
|
1115
|
-
|
|
1289
|
+
f += it(
|
|
1290
|
+
m,
|
|
1291
|
+
g,
|
|
1292
|
+
x[1],
|
|
1293
|
+
x[2]
|
|
1294
|
+
);
|
|
1116
1295
|
else if (c === "A")
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1296
|
+
f += _t(
|
|
1297
|
+
m,
|
|
1298
|
+
g,
|
|
1120
1299
|
x[1],
|
|
1121
1300
|
x[2],
|
|
1122
1301
|
x[3],
|
|
@@ -1126,43 +1305,43 @@ const Q = (e) => {
|
|
|
1126
1305
|
x[7]
|
|
1127
1306
|
);
|
|
1128
1307
|
else if (c === "S") {
|
|
1129
|
-
const
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1308
|
+
const p = s * 2 - n, L = r * 2 - i;
|
|
1309
|
+
f += xt(
|
|
1310
|
+
m,
|
|
1311
|
+
g,
|
|
1312
|
+
p,
|
|
1134
1313
|
L,
|
|
1135
1314
|
x[1],
|
|
1136
1315
|
x[2],
|
|
1137
1316
|
x[3],
|
|
1138
1317
|
x[4]
|
|
1139
1318
|
);
|
|
1140
|
-
} else c === "C" ?
|
|
1141
|
-
|
|
1142
|
-
|
|
1319
|
+
} else c === "C" ? f += xt(
|
|
1320
|
+
m,
|
|
1321
|
+
g,
|
|
1143
1322
|
x[1],
|
|
1144
1323
|
x[2],
|
|
1145
1324
|
x[3],
|
|
1146
1325
|
x[4],
|
|
1147
1326
|
x[5],
|
|
1148
1327
|
x[6]
|
|
1149
|
-
) : c === "T" ? (o = s * 2 - o, l = r * 2 - l,
|
|
1150
|
-
|
|
1151
|
-
|
|
1328
|
+
) : c === "T" ? (o = s * 2 - o, l = r * 2 - l, f += pt(
|
|
1329
|
+
m,
|
|
1330
|
+
g,
|
|
1152
1331
|
o,
|
|
1153
1332
|
l,
|
|
1154
1333
|
x[1],
|
|
1155
1334
|
x[2]
|
|
1156
|
-
)) : c === "Q" ? (o = x[1], l = x[2],
|
|
1157
|
-
|
|
1158
|
-
|
|
1335
|
+
)) : c === "Q" ? (o = x[1], l = x[2], f += pt(
|
|
1336
|
+
m,
|
|
1337
|
+
g,
|
|
1159
1338
|
x[1],
|
|
1160
1339
|
x[2],
|
|
1161
1340
|
x[3],
|
|
1162
1341
|
x[4]
|
|
1163
|
-
)) : c === "Z" && (
|
|
1342
|
+
)) : c === "Z" && (f += it(m, g, a, u));
|
|
1164
1343
|
[s, r] = c === "Z" ? [a, u] : x.slice(-2), [n, i] = c === "C" ? [x[3], x[4]] : c === "S" ? [x[1], x[2]] : [s, r];
|
|
1165
|
-
}),
|
|
1344
|
+
}), f;
|
|
1166
1345
|
}, Ut = (e, t) => {
|
|
1167
1346
|
const s = Q(e);
|
|
1168
1347
|
let r = s.slice(0), n = nt(r), i = r.length - 1, o = 0, l = 0, c = s[0];
|
|
@@ -1188,32 +1367,43 @@ const Q = (e) => {
|
|
|
1188
1367
|
length: l,
|
|
1189
1368
|
lengthAtSegment: o
|
|
1190
1369
|
}), i -= 1;
|
|
1191
|
-
return a.find(
|
|
1370
|
+
return a.find(
|
|
1371
|
+
({ lengthAtSegment: u }) => u <= t
|
|
1372
|
+
);
|
|
1192
1373
|
}, vt = (e, t) => {
|
|
1193
|
-
const s = Q(e), r = ot(s), n = nt(r), i = (
|
|
1194
|
-
const L =
|
|
1195
|
-
return L * L +
|
|
1374
|
+
const s = Q(e), r = ot(s), n = nt(r), i = (p) => {
|
|
1375
|
+
const L = p.x - t.x, T = p.y - t.y;
|
|
1376
|
+
return L * L + T * T;
|
|
1196
1377
|
};
|
|
1197
|
-
let o = 8, l, c = { x: 0, y: 0 }, a = 0, u = 0,
|
|
1198
|
-
for (let
|
|
1199
|
-
l = rt(r,
|
|
1378
|
+
let o = 8, l, c = { x: 0, y: 0 }, a = 0, u = 0, f = 1 / 0;
|
|
1379
|
+
for (let p = 0; p <= n; p += o)
|
|
1380
|
+
l = rt(r, p), a = i(l), a < f && (c = l, u = p, f = a);
|
|
1200
1381
|
o /= 2;
|
|
1201
|
-
let h,
|
|
1202
|
-
for (; o > 1e-6 && (
|
|
1382
|
+
let h, y, m = 0, g = 0, d = 0, M = 0;
|
|
1383
|
+
for (; o > 1e-6 && (m = u - o, h = rt(r, m), d = i(h), g = u + o, y = rt(r, g), M = i(y), m >= 0 && d < f ? (c = h, u = m, f = d) : g <= n && M < f ? (c = y, u = g, f = M) : o /= 2, !(o < 1e-5)); )
|
|
1203
1384
|
;
|
|
1204
|
-
const
|
|
1205
|
-
return { closest: c, distance: x, segment:
|
|
1206
|
-
},
|
|
1385
|
+
const w = Ut(s, u), x = Math.sqrt(f);
|
|
1386
|
+
return { closest: c, distance: x, segment: w };
|
|
1387
|
+
}, Ue = (e, t) => vt(e, t).closest, Je = (e, t, s, r, n, i, o, l) => 3 * ((l - t) * (s + n) - (o - e) * (r + i) + r * (e - n) - s * (t - i) + l * (n + e / 3) - o * (i + t / 3)) / 20, qe = (e) => {
|
|
1207
1388
|
let t = 0, s = 0, r = 0;
|
|
1208
1389
|
return yt(e).map((n) => {
|
|
1209
1390
|
switch (n[0]) {
|
|
1210
1391
|
case "M":
|
|
1211
1392
|
return [, t, s] = n, 0;
|
|
1212
1393
|
default:
|
|
1213
|
-
return r =
|
|
1394
|
+
return r = Je(
|
|
1395
|
+
t,
|
|
1396
|
+
s,
|
|
1397
|
+
n[1],
|
|
1398
|
+
n[2],
|
|
1399
|
+
n[3],
|
|
1400
|
+
n[4],
|
|
1401
|
+
n[5],
|
|
1402
|
+
n[6]
|
|
1403
|
+
), [t, s] = n.slice(-2), r;
|
|
1214
1404
|
}
|
|
1215
1405
|
}).reduce((n, i) => n + i, 0);
|
|
1216
|
-
},
|
|
1406
|
+
}, Ke = (e) => qe(yt(e)) >= 0, Wt = (e) => {
|
|
1217
1407
|
if (!e)
|
|
1218
1408
|
return {
|
|
1219
1409
|
x: 0,
|
|
@@ -1229,85 +1419,90 @@ const Q = (e) => {
|
|
|
1229
1419
|
const t = Q(e);
|
|
1230
1420
|
let s = "M", r = 0, n = 0;
|
|
1231
1421
|
const { max: i, min: o } = Math;
|
|
1232
|
-
let l = 1 / 0, c = 1 / 0, a = -1 / 0, u = -1 / 0,
|
|
1422
|
+
let l = 1 / 0, c = 1 / 0, a = -1 / 0, u = -1 / 0, f = 0, h = 0, y = 0, m = 0, g = 0, d = 0, M = 0, w = 0, x = 0, p = 0;
|
|
1233
1423
|
Z(t, (I, R, P, z) => {
|
|
1234
1424
|
[s] = I;
|
|
1235
|
-
const D = s.toUpperCase(), q = D !== s ? at(I, R, P, z) : I.slice(0),
|
|
1236
|
-
if ([s] =
|
|
1237
|
-
[, r, n] =
|
|
1425
|
+
const D = s.toUpperCase(), q = D !== s ? at(I, R, P, z) : I.slice(0), N = D === "V" ? ["L", P, q[1]] : D === "H" ? ["L", q[1], z] : q;
|
|
1426
|
+
if ([s] = N, "TQ".includes(D) || (x = 0, p = 0), s === "M")
|
|
1427
|
+
[, r, n] = N, f = r, h = n, y = r, m = n;
|
|
1238
1428
|
else if (s === "L")
|
|
1239
|
-
[
|
|
1429
|
+
[f, h, y, m] = It(
|
|
1430
|
+
P,
|
|
1431
|
+
z,
|
|
1432
|
+
N[1],
|
|
1433
|
+
N[2]
|
|
1434
|
+
);
|
|
1240
1435
|
else if (s === "A")
|
|
1241
|
-
[
|
|
1436
|
+
[f, h, y, m] = de(
|
|
1242
1437
|
P,
|
|
1243
1438
|
z,
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1439
|
+
N[1],
|
|
1440
|
+
N[2],
|
|
1441
|
+
N[3],
|
|
1442
|
+
N[4],
|
|
1443
|
+
N[5],
|
|
1444
|
+
N[6],
|
|
1445
|
+
N[7]
|
|
1251
1446
|
);
|
|
1252
1447
|
else if (s === "S") {
|
|
1253
|
-
const $ =
|
|
1254
|
-
[
|
|
1448
|
+
const $ = g * 2 - M, E = d * 2 - w;
|
|
1449
|
+
[f, h, y, m] = St(
|
|
1255
1450
|
P,
|
|
1256
1451
|
z,
|
|
1257
1452
|
$,
|
|
1258
1453
|
E,
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1454
|
+
N[1],
|
|
1455
|
+
N[2],
|
|
1456
|
+
N[3],
|
|
1457
|
+
N[4]
|
|
1263
1458
|
);
|
|
1264
|
-
} else s === "C" ? [
|
|
1459
|
+
} else s === "C" ? [f, h, y, m] = St(
|
|
1265
1460
|
P,
|
|
1266
1461
|
z,
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
) : s === "T" ? (x =
|
|
1462
|
+
N[1],
|
|
1463
|
+
N[2],
|
|
1464
|
+
N[3],
|
|
1465
|
+
N[4],
|
|
1466
|
+
N[5],
|
|
1467
|
+
N[6]
|
|
1468
|
+
) : s === "T" ? (x = g * 2 - x, p = d * 2 - p, [f, h, y, m] = Qt(
|
|
1274
1469
|
P,
|
|
1275
1470
|
z,
|
|
1276
1471
|
x,
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
)) : s === "Q" ? (x =
|
|
1472
|
+
p,
|
|
1473
|
+
N[1],
|
|
1474
|
+
N[2]
|
|
1475
|
+
)) : s === "Q" ? (x = N[1], p = N[2], [f, h, y, m] = Qt(
|
|
1281
1476
|
P,
|
|
1282
1477
|
z,
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
)) : s === "Z" && ([
|
|
1288
|
-
l = o(
|
|
1478
|
+
N[1],
|
|
1479
|
+
N[2],
|
|
1480
|
+
N[3],
|
|
1481
|
+
N[4]
|
|
1482
|
+
)) : s === "Z" && ([f, h, y, m] = It(P, z, r, n));
|
|
1483
|
+
l = o(f, l), c = o(h, c), a = i(y, a), u = i(m, u), [g, d] = s === "Z" ? [r, n] : N.slice(-2), [M, w] = s === "C" ? [N[3], N[4]] : s === "S" ? [N[1], N[2]] : [g, d];
|
|
1289
1484
|
});
|
|
1290
|
-
const L = a - l,
|
|
1485
|
+
const L = a - l, T = u - c;
|
|
1291
1486
|
return {
|
|
1292
1487
|
width: L,
|
|
1293
|
-
height:
|
|
1488
|
+
height: T,
|
|
1294
1489
|
x: l,
|
|
1295
1490
|
y: c,
|
|
1296
1491
|
x2: a,
|
|
1297
1492
|
y2: u,
|
|
1298
1493
|
cx: l + L / 2,
|
|
1299
|
-
cy: c +
|
|
1494
|
+
cy: c + T / 2,
|
|
1300
1495
|
// an estimated guess
|
|
1301
|
-
cz: Math.max(L,
|
|
1496
|
+
cz: Math.max(L, T) + Math.min(L, T) / 2
|
|
1302
1497
|
};
|
|
1303
|
-
},
|
|
1498
|
+
}, We = (e, t) => Ut(e, t).segment, Xe = (e, t) => vt(e, t).segment, Tt = (e) => Array.isArray(e) && e.every((t) => {
|
|
1304
1499
|
const s = t[0].toLowerCase();
|
|
1305
1500
|
return tt[s] === t.length - 1 && "achlmqstvz".includes(s) && t.slice(1).every(Number.isFinite);
|
|
1306
|
-
}) && e.length > 0, Pe = (e) =>
|
|
1307
|
-
e.every(([t]) => t === t.toUpperCase()), ke = (e) => Pe(e) && e.every(([t]) => "ACLMQZ".includes(t)),
|
|
1501
|
+
}) && e.length > 0, Pe = (e) => Tt(e) && // `isPathArray` also checks if it's `Array`
|
|
1502
|
+
e.every(([t]) => t === t.toUpperCase()), ke = (e) => Pe(e) && e.every(([t]) => "ACLMQZ".includes(t)), Ye = (e) => ke(e) && e.every(([t]) => "MC".includes(t)), Ve = (e, t) => {
|
|
1308
1503
|
const { distance: s } = vt(e, t);
|
|
1309
1504
|
return Math.abs(s) < bt;
|
|
1310
|
-
},
|
|
1505
|
+
}, Ge = (e) => Tt(e) && // `isPathArray` checks if it's `Array`
|
|
1311
1506
|
e.slice(1).every(([t]) => t === t.toLowerCase()), Ie = (e) => {
|
|
1312
1507
|
if (typeof e != "string" || !e.length)
|
|
1313
1508
|
return !1;
|
|
@@ -1323,33 +1518,33 @@ e.slice(1).every(([t]) => t === t.toLowerCase()), Ie = (e) => {
|
|
|
1323
1518
|
polygon: ["points"],
|
|
1324
1519
|
polyline: ["points"],
|
|
1325
1520
|
glyph: ["d"]
|
|
1326
|
-
},
|
|
1521
|
+
}, Ee = (e) => e != null && typeof e == "object" && e.nodeType === 1, tn = (e) => {
|
|
1327
1522
|
let { x1: t, y1: s, x2: r, y2: n } = e;
|
|
1328
1523
|
return [t, s, r, n] = [t, s, r, n].map((i) => +i), [
|
|
1329
1524
|
["M", t, s],
|
|
1330
1525
|
["L", r, n]
|
|
1331
1526
|
];
|
|
1332
|
-
},
|
|
1527
|
+
}, en = (e) => {
|
|
1333
1528
|
const t = [], s = (e.points || "").trim().split(/[\s|,]/).map((n) => +n);
|
|
1334
1529
|
let r = 0;
|
|
1335
1530
|
for (; r < s.length; )
|
|
1336
1531
|
t.push([r ? "L" : "M", s[r], s[r + 1]]), r += 2;
|
|
1337
1532
|
return e.type === "polygon" ? [...t, ["z"]] : t;
|
|
1338
|
-
},
|
|
1533
|
+
}, nn = (e) => {
|
|
1339
1534
|
let { cx: t, cy: s, r } = e;
|
|
1340
1535
|
return [t, s, r] = [t, s, r].map((n) => +n), [
|
|
1341
1536
|
["M", t - r, s],
|
|
1342
1537
|
["a", r, r, 0, 1, 0, 2 * r, 0],
|
|
1343
1538
|
["a", r, r, 0, 1, 0, -2 * r, 0]
|
|
1344
1539
|
];
|
|
1345
|
-
},
|
|
1540
|
+
}, sn = (e) => {
|
|
1346
1541
|
let { cx: t, cy: s } = e, r = e.rx || 0, n = e.ry || r;
|
|
1347
1542
|
return [t, s, r, n] = [t, s, r, n].map((i) => +i), [
|
|
1348
1543
|
["M", t - r, s],
|
|
1349
1544
|
["a", r, n, 0, 1, 0, 2 * r, 0],
|
|
1350
1545
|
["a", r, n, 0, 1, 0, -2 * r, 0]
|
|
1351
1546
|
];
|
|
1352
|
-
},
|
|
1547
|
+
}, rn = (e) => {
|
|
1353
1548
|
const t = +e.x || 0, s = +e.y || 0, r = +e.width, n = +e.height;
|
|
1354
1549
|
let i = +(e.rx || 0), o = +(e.ry || i);
|
|
1355
1550
|
return i || o ? (i * 2 > r && (i -= (i * 2 - r) / 2), o * 2 > n && (o -= (o * 2 - n) / 2), [
|
|
@@ -1363,62 +1558,74 @@ e.slice(1).every(([t]) => t === t.toLowerCase()), Ie = (e) => {
|
|
|
1363
1558
|
["v", -n + o * 2],
|
|
1364
1559
|
["s", 0, -o, i, -o]
|
|
1365
1560
|
]) : [["M", t, s], ["h", r], ["v", n], ["H", t], ["Z"]];
|
|
1366
|
-
},
|
|
1367
|
-
const
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
i ? e.getAttribute("d") || /* istanbul ignore next @preserve */
|
|
1561
|
+
}, Re = (e) => {
|
|
1562
|
+
const t = Object.keys(ct), s = Ee(e), r = s ? e.tagName : null;
|
|
1563
|
+
if (r && [...t, "path"].every((c) => r !== c))
|
|
1564
|
+
throw TypeError(`${S}: "${r}" is not SVGElement`);
|
|
1565
|
+
const n = s ? r : e.type, i = ct[n], o = { type: n };
|
|
1566
|
+
s ? i.forEach((c) => {
|
|
1567
|
+
o[c] = e.getAttribute(c);
|
|
1568
|
+
}) : Object.assign(o, e);
|
|
1569
|
+
let l = [];
|
|
1570
|
+
return n === "circle" ? l = nn(o) : n === "ellipse" ? l = sn(o) : ["polyline", "polygon"].includes(n) ? l = en(o) : n === "rect" ? l = rn(o) : n === "line" ? l = tn(o) : ["glyph", "path"].includes(n) && (l = Q(
|
|
1571
|
+
s ? e.getAttribute("d") || /* istanbul ignore next @preserve */
|
|
1378
1572
|
"" : e.d || ""
|
|
1379
|
-
)),
|
|
1380
|
-
},
|
|
1381
|
-
const r = s || document, n =
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
if (
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
m[
|
|
1573
|
+
)), Tt(l) && l.length ? l : !1;
|
|
1574
|
+
}, on = (e, t, s) => {
|
|
1575
|
+
const r = s || document, n = Object.keys(ct), i = Ee(e), o = i ? e.tagName : null;
|
|
1576
|
+
if (o === "path")
|
|
1577
|
+
throw TypeError(`${S}: "${o}" is already SVGPathElement`);
|
|
1578
|
+
if (o && n.every((m) => o !== m))
|
|
1579
|
+
throw TypeError(`${S}: "${o}" is not SVGElement`);
|
|
1580
|
+
const l = r.createElementNS("http://www.w3.org/2000/svg", "path"), c = i ? o : e.type, a = ct[c], u = { type: c }, f = V.round, h = Re(e), y = h && h.length ? kt(h, f) : "";
|
|
1581
|
+
return i ? (a.forEach((m) => {
|
|
1582
|
+
u[m] = e.getAttribute(m);
|
|
1583
|
+
}), Object.values(e.attributes).forEach(({ name: m, value: g }) => {
|
|
1584
|
+
a.includes(m) || l.setAttribute(m, g);
|
|
1585
|
+
})) : (Object.assign(u, e), Object.keys(u).forEach((m) => {
|
|
1586
|
+
!a.includes(m) && m !== "type" && l.setAttribute(
|
|
1587
|
+
m.replace(/[A-Z]/g, (g) => `-${g.toLowerCase()}`),
|
|
1588
|
+
u[m]
|
|
1394
1589
|
);
|
|
1395
|
-
})), Ie(
|
|
1396
|
-
},
|
|
1397
|
-
let t = new
|
|
1590
|
+
})), Ie(y) ? (l.setAttribute("d", y), t && i && (e.before(l, e), e.remove()), l) : !1;
|
|
1591
|
+
}, je = (e) => {
|
|
1592
|
+
let t = new C();
|
|
1398
1593
|
const { origin: s } = e, [r, n] = s, { translate: i } = e, { rotate: o } = e, { skew: l } = e, { scale: c } = e;
|
|
1399
|
-
return Array.isArray(i) && i.length >= 2 && i.every((a) => !Number.isNaN(+a)) && i.some((a) => a !== 0) ? t = t.translate(...i) : typeof i == "number" && !Number.isNaN(i) && (t = t.translate(i)), (o || l || c) && (t = t.translate(r, n), Array.isArray(o) && o.length >= 2 && o.every((a) => !Number.isNaN(+a)) && o.some((a) => a !== 0) ? t = t.rotate(...o) : typeof o == "number" && !Number.isNaN(o) && (t = t.rotate(o)), Array.isArray(l) && l.length === 2 && l.every(
|
|
1594
|
+
return Array.isArray(i) && i.length >= 2 && i.every((a) => !Number.isNaN(+a)) && i.some((a) => a !== 0) ? t = t.translate(...i) : typeof i == "number" && !Number.isNaN(i) && (t = t.translate(i)), (o || l || c) && (t = t.translate(r, n), Array.isArray(o) && o.length >= 2 && o.every((a) => !Number.isNaN(+a)) && o.some((a) => a !== 0) ? t = t.rotate(...o) : typeof o == "number" && !Number.isNaN(o) && (t = t.rotate(o)), Array.isArray(l) && l.length === 2 && l.every(
|
|
1595
|
+
(a) => !Number.isNaN(+a)
|
|
1596
|
+
) && l.some((a) => a !== 0) ? (t = l[0] ? t.skewX(l[0]) : t, t = l[1] ? t.skewY(l[1]) : t) : typeof l == "number" && !Number.isNaN(l) && (t = t.skewX(l)), Array.isArray(c) && c.length >= 2 && c.every(
|
|
1597
|
+
(a) => !Number.isNaN(+a)
|
|
1598
|
+
) && c.some((a) => a !== 1) ? t = t.scale(...c) : typeof c == "number" && !Number.isNaN(c) && (t = t.scale(c)), t = t.translate(-r, -n)), t;
|
|
1400
1599
|
}, Se = (e, t, s, r) => {
|
|
1401
1600
|
const [n] = e, { round: i } = V, o = typeof i == "number" ? i : (
|
|
1402
1601
|
/* istanbul ignore next */
|
|
1403
1602
|
4
|
|
1404
|
-
), l = t.slice(1), { x1: c, y1: a, x2: u, y2:
|
|
1603
|
+
), l = t.slice(1), { x1: c, y1: a, x2: u, y2: f, x: h, y } = s, [m, g] = l.slice(-2), d = e;
|
|
1405
1604
|
if ("TQ".includes(n) || (s.qx = null, s.qy = null), n === "L") {
|
|
1406
|
-
if (k(h, o) === k(
|
|
1407
|
-
return ["V",
|
|
1408
|
-
if (k(
|
|
1409
|
-
return ["H",
|
|
1605
|
+
if (k(h, o) === k(m, o))
|
|
1606
|
+
return ["V", g];
|
|
1607
|
+
if (k(y, o) === k(g, o))
|
|
1608
|
+
return ["H", m];
|
|
1410
1609
|
} else if (n === "C") {
|
|
1411
|
-
const [M,
|
|
1412
|
-
if (s.x1 = M, s.y1 =
|
|
1413
|
-
return [
|
|
1610
|
+
const [M, w] = l;
|
|
1611
|
+
if (s.x1 = M, s.y1 = w, "CS".includes(r) && (k(M, o) === k(c * 2 - u, o) && k(w, o) === k(a * 2 - f, o) || k(c, o) === k(u * 2 - h, o) && k(a, o) === k(f * 2 - y, o)))
|
|
1612
|
+
return [
|
|
1613
|
+
"S",
|
|
1614
|
+
l[2],
|
|
1615
|
+
l[3],
|
|
1616
|
+
l[4],
|
|
1617
|
+
l[5]
|
|
1618
|
+
];
|
|
1414
1619
|
} else if (n === "Q") {
|
|
1415
|
-
const [M,
|
|
1416
|
-
if (s.qx = M, s.qy =
|
|
1620
|
+
const [M, w] = l;
|
|
1621
|
+
if (s.qx = M, s.qy = w, "QT".includes(r) && k(M, o) === k(c * 2 - u, o) && k(w, o) === k(a * 2 - f, o))
|
|
1417
1622
|
return ["T", l[2], l[3]];
|
|
1418
1623
|
}
|
|
1419
|
-
return
|
|
1624
|
+
return d;
|
|
1420
1625
|
}, dt = (e, t) => {
|
|
1421
|
-
const s = e.slice(1).map(
|
|
1626
|
+
const s = e.slice(1).map(
|
|
1627
|
+
(r) => k(r, t)
|
|
1628
|
+
);
|
|
1422
1629
|
return [e[0]].concat(s);
|
|
1423
1630
|
}, Xt = (e, t) => {
|
|
1424
1631
|
const s = ht(e), r = typeof t == "number" && t >= 0 ? t : (
|
|
@@ -1426,29 +1633,34 @@ e.slice(1).every(([t]) => t === t.toLowerCase()), Ie = (e) => {
|
|
|
1426
1633
|
2
|
|
1427
1634
|
), n = { ...ut }, i = [];
|
|
1428
1635
|
let o = "M", l = "Z";
|
|
1429
|
-
return Z(s, (c, a, u,
|
|
1430
|
-
n.x = u, n.y =
|
|
1431
|
-
const h =
|
|
1432
|
-
let
|
|
1636
|
+
return Z(s, (c, a, u, f) => {
|
|
1637
|
+
n.x = u, n.y = f;
|
|
1638
|
+
const h = Nt(c, n);
|
|
1639
|
+
let y = c;
|
|
1433
1640
|
if ([o] = c, i[a] = o, a) {
|
|
1434
1641
|
l = i[a - 1];
|
|
1435
|
-
const
|
|
1436
|
-
|
|
1642
|
+
const g = Se(
|
|
1643
|
+
c,
|
|
1644
|
+
h,
|
|
1645
|
+
n,
|
|
1646
|
+
l
|
|
1647
|
+
), d = dt(g, r), M = d.join(""), w = Bt(g, a, u, f), x = dt(w, r), p = x.join("");
|
|
1648
|
+
y = M.length < p.length ? d : x;
|
|
1437
1649
|
}
|
|
1438
|
-
const
|
|
1439
|
-
return n.x1 = +h[
|
|
1650
|
+
const m = h.length;
|
|
1651
|
+
return n.x1 = +h[m - 2], n.y1 = +h[m - 1], n.x2 = +h[m - 4] || n.x1, n.y2 = +h[m - 3] || n.y1, y;
|
|
1440
1652
|
});
|
|
1441
|
-
},
|
|
1442
|
-
let s =
|
|
1653
|
+
}, cn = (e, t) => {
|
|
1654
|
+
let s = C.Translate(t[0], t[1], t[2]);
|
|
1443
1655
|
return [, , , s.m44] = t, s = e.multiply(s), [s.m41, s.m42, s.m43, s.m44];
|
|
1444
1656
|
}, Zt = (e, t, s) => {
|
|
1445
|
-
const [r, n, i] = s, [o, l, c] =
|
|
1657
|
+
const [r, n, i] = s, [o, l, c] = cn(e, [t[0], t[1], 0, 1]), a = o - r, u = l - n, f = c - i;
|
|
1446
1658
|
return [
|
|
1447
1659
|
// protect against division by ZERO
|
|
1448
|
-
a * (Math.abs(i) / Math.abs(
|
|
1449
|
-
u * (Math.abs(i) / Math.abs(
|
|
1660
|
+
a * (Math.abs(i) / Math.abs(f) || 1) + r,
|
|
1661
|
+
u * (Math.abs(i) / Math.abs(f) || 1) + n
|
|
1450
1662
|
];
|
|
1451
|
-
},
|
|
1663
|
+
}, ln = (e) => {
|
|
1452
1664
|
const t = e.slice(1).map(
|
|
1453
1665
|
(s, r, n) => r ? n[r - 1].slice(-2).concat(s.slice(1)) : e[0].slice(1).concat(s.slice(1))
|
|
1454
1666
|
).map((s) => s.map((r, n) => s[s.length - n - 2 * (1 - n % 2)])).reverse();
|
|
@@ -1457,118 +1669,153 @@ e.slice(1).every(([t]) => t === t.toLowerCase()), Ie = (e) => {
|
|
|
1457
1669
|
);
|
|
1458
1670
|
}, ft = (e) => {
|
|
1459
1671
|
const t = ht(e), s = ot(t), r = t.length, n = t[r - 1][0] === "Z", i = Z(t, (o, l) => {
|
|
1460
|
-
const c = s[l], a = l && t[l - 1], u = a && a[0],
|
|
1461
|
-
let
|
|
1462
|
-
switch (
|
|
1672
|
+
const c = s[l], a = l && t[l - 1], u = a && a[0], f = t[l + 1], h = f && f[0], [y] = o, [m, g] = s[l ? l - 1 : r - 1].slice(-2);
|
|
1673
|
+
let d = o;
|
|
1674
|
+
switch (y) {
|
|
1463
1675
|
case "M":
|
|
1464
|
-
|
|
1676
|
+
d = n ? ["Z"] : [y, m, g];
|
|
1465
1677
|
break;
|
|
1466
1678
|
case "A":
|
|
1467
|
-
|
|
1468
|
-
|
|
1679
|
+
d = [
|
|
1680
|
+
y,
|
|
1469
1681
|
o[1],
|
|
1470
1682
|
o[2],
|
|
1471
1683
|
o[3],
|
|
1472
1684
|
o[4],
|
|
1473
1685
|
o[5] === 1 ? 0 : 1,
|
|
1474
|
-
|
|
1475
|
-
|
|
1686
|
+
m,
|
|
1687
|
+
g
|
|
1476
1688
|
];
|
|
1477
1689
|
break;
|
|
1478
1690
|
case "C":
|
|
1479
|
-
|
|
1691
|
+
f && h === "S" ? d = ["S", o[1], o[2], m, g] : d = [
|
|
1692
|
+
y,
|
|
1693
|
+
o[3],
|
|
1694
|
+
o[4],
|
|
1695
|
+
o[1],
|
|
1696
|
+
o[2],
|
|
1697
|
+
m,
|
|
1698
|
+
g
|
|
1699
|
+
];
|
|
1480
1700
|
break;
|
|
1481
1701
|
case "S":
|
|
1482
|
-
u && "CS".includes(u) && (!
|
|
1702
|
+
u && "CS".includes(u) && (!f || h !== "S") ? d = [
|
|
1483
1703
|
"C",
|
|
1484
1704
|
c[3],
|
|
1485
1705
|
c[4],
|
|
1486
1706
|
c[1],
|
|
1487
1707
|
c[2],
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
] :
|
|
1708
|
+
m,
|
|
1709
|
+
g
|
|
1710
|
+
] : d = [
|
|
1711
|
+
y,
|
|
1712
|
+
c[1],
|
|
1713
|
+
c[2],
|
|
1714
|
+
m,
|
|
1715
|
+
g
|
|
1716
|
+
];
|
|
1491
1717
|
break;
|
|
1492
1718
|
case "Q":
|
|
1493
|
-
|
|
1719
|
+
f && h === "T" ? d = ["T", m, g] : d = [y, o[1], o[2], m, g];
|
|
1494
1720
|
break;
|
|
1495
1721
|
case "T":
|
|
1496
|
-
u && "QT".includes(u) && (!
|
|
1722
|
+
u && "QT".includes(u) && (!f || h !== "T") ? d = [
|
|
1723
|
+
"Q",
|
|
1724
|
+
c[1],
|
|
1725
|
+
c[2],
|
|
1726
|
+
m,
|
|
1727
|
+
g
|
|
1728
|
+
] : d = [y, m, g];
|
|
1497
1729
|
break;
|
|
1498
1730
|
case "Z":
|
|
1499
|
-
|
|
1731
|
+
d = ["M", m, g];
|
|
1500
1732
|
break;
|
|
1501
1733
|
case "H":
|
|
1502
|
-
|
|
1734
|
+
d = [y, m];
|
|
1503
1735
|
break;
|
|
1504
1736
|
case "V":
|
|
1505
|
-
|
|
1737
|
+
d = [y, g];
|
|
1506
1738
|
break;
|
|
1507
1739
|
default:
|
|
1508
|
-
|
|
1740
|
+
d = [y].concat(
|
|
1741
|
+
o.slice(1, -2),
|
|
1742
|
+
m,
|
|
1743
|
+
g
|
|
1744
|
+
);
|
|
1509
1745
|
}
|
|
1510
|
-
return
|
|
1746
|
+
return d;
|
|
1511
1747
|
});
|
|
1512
1748
|
return n ? i.reverse() : [i[0]].concat(i.slice(1).reverse());
|
|
1513
|
-
},
|
|
1749
|
+
}, an = (e, t) => {
|
|
1514
1750
|
let { round: s } = V;
|
|
1515
1751
|
return s = t === "off" || typeof t == "number" && t >= 0 ? t : typeof s == "number" && s >= 0 ? s : (
|
|
1516
1752
|
/* istanbul ignore next @preserve */
|
|
1517
1753
|
"off"
|
|
1518
1754
|
), s === "off" ? e.slice(0) : Z(e, (r) => dt(r, s));
|
|
1519
|
-
},
|
|
1520
|
-
const s = t, r = e.slice(0, 2), n = e.slice(2, 4), i = e.slice(4, 6), o = e.slice(6, 8), l = H(r, n, s), c = H(n, i, s), a = H(i, o, s), u = H(l, c, s),
|
|
1755
|
+
}, un = (e, t = 0.5) => {
|
|
1756
|
+
const s = t, r = e.slice(0, 2), n = e.slice(2, 4), i = e.slice(4, 6), o = e.slice(6, 8), l = H(r, n, s), c = H(n, i, s), a = H(i, o, s), u = H(l, c, s), f = H(c, a, s), h = H(u, f, s);
|
|
1521
1757
|
return [
|
|
1522
1758
|
["C", l[0], l[1], u[0], u[1], h[0], h[1]],
|
|
1523
|
-
["C",
|
|
1759
|
+
["C", f[0], f[1], a[0], a[1], o[0], o[1]]
|
|
1524
1760
|
];
|
|
1525
1761
|
}, Yt = (e) => {
|
|
1526
1762
|
const t = [];
|
|
1527
1763
|
let s, r = -1, n = 0, i = 0, o = 0, l = 0;
|
|
1528
1764
|
const c = { ...ut };
|
|
1529
1765
|
return e.forEach((a) => {
|
|
1530
|
-
const [u] = a,
|
|
1531
|
-
|
|
1766
|
+
const [u] = a, f = u.toUpperCase(), h = u.toLowerCase(), y = u === h, m = a.slice(1);
|
|
1767
|
+
f === "M" ? (r += 1, [n, i] = m, n += y ? c.x : 0, i += y ? c.y : 0, o = n, l = i, s = [y ? [f, o, l] : a]) : (f === "Z" ? (n = o, i = l) : f === "H" ? ([, n] = a, n += y ? c.x : (
|
|
1532
1768
|
/* istanbul ignore next @preserve */
|
|
1533
1769
|
0
|
|
1534
|
-
)) :
|
|
1770
|
+
)) : f === "V" ? ([, i] = a, i += y ? c.y : (
|
|
1535
1771
|
/* istanbul ignore next @preserve */
|
|
1536
1772
|
0
|
|
1537
|
-
)) : ([n, i] = a.slice(-2), n +=
|
|
1773
|
+
)) : ([n, i] = a.slice(-2), n += y ? c.x : 0, i += y ? c.y : 0), s.push(a)), c.x = n, c.y = i, t[r] = s;
|
|
1538
1774
|
}), t;
|
|
1539
1775
|
}, Vt = (e, t) => {
|
|
1540
1776
|
let s = 0, r = 0, n = 0, i = 0, o = 0, l = 0, c = "M";
|
|
1541
1777
|
const a = Q(e), u = t && Object.keys(t);
|
|
1542
|
-
if (!t || u && !u.length)
|
|
1778
|
+
if (!t || u && !u.length)
|
|
1779
|
+
return a.slice(0);
|
|
1543
1780
|
t.origin || Object.assign(t, { origin: V.origin });
|
|
1544
|
-
const
|
|
1545
|
-
return h.isIdentity ? a.slice(0) : Z(a, (
|
|
1546
|
-
[c] =
|
|
1547
|
-
const M = c.toUpperCase(), x = M !== c ? at(
|
|
1548
|
-
let
|
|
1549
|
-
|
|
1781
|
+
const f = t.origin, h = je(t);
|
|
1782
|
+
return h.isIdentity ? a.slice(0) : Z(a, (y, m, g, d) => {
|
|
1783
|
+
[c] = y;
|
|
1784
|
+
const M = c.toUpperCase(), x = M !== c ? at(y, m, g, d) : y.slice(0);
|
|
1785
|
+
let p = M === "A" ? ["C"].concat(
|
|
1786
|
+
Mt(
|
|
1787
|
+
g,
|
|
1788
|
+
d,
|
|
1789
|
+
x[1],
|
|
1790
|
+
x[2],
|
|
1791
|
+
x[3],
|
|
1792
|
+
x[4],
|
|
1793
|
+
x[5],
|
|
1794
|
+
x[6],
|
|
1795
|
+
x[7]
|
|
1796
|
+
)
|
|
1797
|
+
) : M === "V" ? ["L", g, x[1]] : M === "H" ? ["L", x[1], d] : x;
|
|
1798
|
+
c = p[0];
|
|
1799
|
+
const L = c === "C" && p.length > 7, T = L ? p.slice(0, 7) : p.slice(0);
|
|
1800
|
+
if (L && (a.splice(
|
|
1801
|
+
m + 1,
|
|
1802
|
+
0,
|
|
1550
1803
|
["C"].concat(
|
|
1551
|
-
|
|
1552
|
-
y,
|
|
1553
|
-
p,
|
|
1554
|
-
x[1],
|
|
1555
|
-
x[2],
|
|
1556
|
-
x[3],
|
|
1557
|
-
x[4],
|
|
1558
|
-
x[5],
|
|
1559
|
-
x[6],
|
|
1560
|
-
x[7]
|
|
1561
|
-
)
|
|
1804
|
+
p.slice(7)
|
|
1562
1805
|
)
|
|
1563
|
-
)
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1806
|
+
), p = T), c === "L")
|
|
1807
|
+
[n, i] = Zt(h, [
|
|
1808
|
+
p[1],
|
|
1809
|
+
p[2]
|
|
1810
|
+
], f), s !== n && r !== i ? p = ["L", n, i] : r === i ? p = ["H", n] : s === n && (p = ["V", i]);
|
|
1568
1811
|
else
|
|
1569
|
-
for (o = 1, l =
|
|
1570
|
-
[n, i] = Zt(
|
|
1571
|
-
|
|
1812
|
+
for (o = 1, l = p.length; o < l; o += 2)
|
|
1813
|
+
[n, i] = Zt(
|
|
1814
|
+
h,
|
|
1815
|
+
[+p[o], +p[o + 1]],
|
|
1816
|
+
f
|
|
1817
|
+
), p[o] = n, p[o + 1] = i;
|
|
1818
|
+
return s = n, r = i, p;
|
|
1572
1819
|
});
|
|
1573
1820
|
};
|
|
1574
1821
|
class A {
|
|
@@ -1580,18 +1827,20 @@ class A {
|
|
|
1580
1827
|
constructor(t, s) {
|
|
1581
1828
|
const r = s || {}, n = typeof t > "u";
|
|
1582
1829
|
if (n || !t.length)
|
|
1583
|
-
throw TypeError(
|
|
1830
|
+
throw TypeError(
|
|
1831
|
+
`${S}: "pathValue" is ${n ? "undefined" : "empty"}`
|
|
1832
|
+
);
|
|
1584
1833
|
this.segments = Q(t);
|
|
1585
1834
|
const { round: i, origin: o } = r;
|
|
1586
1835
|
let l;
|
|
1587
1836
|
Number.isInteger(i) || i === "off" ? l = i : l = V.round;
|
|
1588
1837
|
let c = V.origin;
|
|
1589
1838
|
if (Array.isArray(o) && o.length >= 2) {
|
|
1590
|
-
const [a, u,
|
|
1839
|
+
const [a, u, f] = o.map(Number);
|
|
1591
1840
|
c = [
|
|
1592
1841
|
Number.isNaN(a) ? 0 : a,
|
|
1593
1842
|
Number.isNaN(u) ? 0 : u,
|
|
1594
|
-
Number.isNaN(
|
|
1843
|
+
Number.isNaN(f) ? 0 : f
|
|
1595
1844
|
];
|
|
1596
1845
|
}
|
|
1597
1846
|
return this.round = l, this.origin = c, this;
|
|
@@ -1666,7 +1915,6 @@ class A {
|
|
|
1666
1915
|
* @public
|
|
1667
1916
|
*/
|
|
1668
1917
|
reverse(t) {
|
|
1669
|
-
this.toAbsolute();
|
|
1670
1918
|
const { segments: s } = this, r = Yt(s), n = r.length > 1 ? r : !1, i = n ? n.map((l, c) => t ? c ? ft(l) : l.slice(0) : ft(l)) : s.slice(0);
|
|
1671
1919
|
let o = [];
|
|
1672
1920
|
return n ? o = i.flat(1) : o = t ? s : ft(s), this.segments = o.slice(0), this;
|
|
@@ -1714,7 +1962,11 @@ class A {
|
|
|
1714
1962
|
const { origin: l } = o;
|
|
1715
1963
|
if (Array.isArray(l) && l.length >= 2) {
|
|
1716
1964
|
const [c, a, u] = l.map(Number);
|
|
1717
|
-
o.origin = [
|
|
1965
|
+
o.origin = [
|
|
1966
|
+
Number.isNaN(c) ? r : c,
|
|
1967
|
+
Number.isNaN(a) ? n : a,
|
|
1968
|
+
u || i
|
|
1969
|
+
];
|
|
1718
1970
|
} else
|
|
1719
1971
|
o.origin = [r, n, i];
|
|
1720
1972
|
return this.segments = Vt(s, o), this;
|
|
@@ -1747,19 +1999,42 @@ class A {
|
|
|
1747
1999
|
toString() {
|
|
1748
2000
|
return kt(this.segments, this.round);
|
|
1749
2001
|
}
|
|
2002
|
+
/**
|
|
2003
|
+
* Remove the instance.
|
|
2004
|
+
*
|
|
2005
|
+
* @public
|
|
2006
|
+
* @return void
|
|
2007
|
+
*/
|
|
2008
|
+
dispose() {
|
|
2009
|
+
Object.keys(this).forEach((t) => delete this[t]);
|
|
2010
|
+
}
|
|
1750
2011
|
}
|
|
1751
|
-
|
|
2012
|
+
b(A, "CSSMatrix", C), b(A, "pathToAbsolute", ht), b(A, "pathToRelative", Kt), b(A, "pathToCurve", yt), b(A, "pathToString", kt), b(A, "arcTools", He), b(A, "bezierTools", {
|
|
1752
2013
|
Cvalues: Ae,
|
|
1753
2014
|
Tvalues: Rt,
|
|
1754
|
-
minmaxC:
|
|
2015
|
+
minmaxC: jt,
|
|
1755
2016
|
minmaxQ: gt,
|
|
1756
2017
|
getBezierLength: mt,
|
|
1757
2018
|
bezierLength: Le,
|
|
1758
|
-
calculateBezier:
|
|
1759
|
-
computeBezier:
|
|
2019
|
+
calculateBezier: we,
|
|
2020
|
+
computeBezier: Ne,
|
|
1760
2021
|
deriveBezier: Me,
|
|
1761
2022
|
CBEZIER_MINMAX_EPSILON: ve
|
|
1762
|
-
}),
|
|
2023
|
+
}), b(A, "cubicTools", {
|
|
2024
|
+
getCubicLength: xt,
|
|
2025
|
+
getCubicBBox: St,
|
|
2026
|
+
getPointAtCubicLength: Ce,
|
|
2027
|
+
getPointAtCubicSegmentLength: Te
|
|
2028
|
+
}), b(A, "lineTools", {
|
|
2029
|
+
getPointAtLineLength: Ht,
|
|
2030
|
+
getLineBBox: It,
|
|
2031
|
+
getLineLength: it
|
|
2032
|
+
}), b(A, "quadTools", {
|
|
2033
|
+
getPointAtQuadSegmentLength: $e,
|
|
2034
|
+
getQuadLength: pt,
|
|
2035
|
+
getQuadBBox: Qt,
|
|
2036
|
+
getPointAtQuadLength: ze
|
|
2037
|
+
}), b(A, "polygonTools", { polygonArea: Fe, polygonLength: _e }), b(A, "distanceSquareRoot", wt), b(A, "distanceEpsilon", bt), b(A, "midPoint", H), b(A, "rotateVector", st), b(A, "roundTo", k), b(A, "finalizeSegment", qt), b(A, "invalidPathValue", J), b(A, "isArcCommand", ye), b(A, "isDigit", U), b(A, "isDigitStart", he), b(A, "isMoveCommand", ge), b(A, "isPathCommand", fe), b(A, "isSpace", me), b(A, "paramsCount", tt), b(A, "paramsParser", ut), b(A, "pathParser", Ot), b(A, "scanFlag", ae), b(A, "scanParam", ue), b(A, "scanSegment", Dt), b(A, "skipSpaces", et), b(A, "getPathBBox", Wt), b(A, "getPathArea", qe), b(A, "getTotalLength", nt), b(A, "getDrawDirection", Ke), b(A, "getPointAtLength", rt), b(A, "getPropertiesAtLength", Ut), b(A, "getPropertiesAtPoint", vt), b(A, "getClosestPoint", Ue), b(A, "getSegmentOfPoint", Xe), b(A, "getSegmentAtLength", We), b(A, "isPointInStroke", Ve), b(A, "isValidPath", Ie), b(A, "isPathArray", Tt), b(A, "isAbsoluteArray", Pe), b(A, "isRelativeArray", Ge), b(A, "isCurveArray", Ye), b(A, "isNormalizedArray", ke), b(A, "shapeToPath", on), b(A, "shapeToPathArray", Re), b(A, "shapeParams", ct), b(A, "parsePathString", Q), b(A, "absolutizeSegment", at), b(A, "arcToCubic", Mt), b(A, "getSVGMatrix", je), b(A, "iterate", Z), b(A, "lineToCubic", Pt), b(A, "normalizePath", ot), b(A, "normalizeSegment", Nt), b(A, "optimizePath", Xt), b(A, "projection2d", Zt), b(A, "quadToCubic", xe), b(A, "relativizeSegment", Bt), b(A, "reverseCurve", ln), b(A, "reversePath", ft), b(A, "roundPath", an), b(A, "roundSegment", dt), b(A, "segmentToCubic", pe), b(A, "shortenSegment", Se), b(A, "splitCubic", un), b(A, "splitPath", Yt), b(A, "transformPath", Vt);
|
|
1763
2038
|
export {
|
|
1764
2039
|
A as default
|
|
1765
2040
|
};
|