svg-path-commander 2.1.1 → 2.1.2
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 +2 -2
- package/dist/svg-path-commander.cjs +1 -1
- package/dist/svg-path-commander.cjs.map +1 -1
- package/dist/svg-path-commander.d.ts +207 -19
- package/dist/svg-path-commander.js +1 -1
- package/dist/svg-path-commander.js.map +1 -1
- package/dist/svg-path-commander.mjs +1052 -969
- package/dist/svg-path-commander.mjs.map +1 -1
- package/package.json +7 -7
- package/src/convert/pathToAbsolute.ts +2 -31
- package/src/convert/pathToCurve.ts +13 -27
- package/src/convert/pathToRelative.ts +2 -47
- package/src/convert/pathToString.ts +40 -7
- package/src/index.ts +132 -39
- package/src/interface.ts +2 -1
- package/src/math/arcTools.ts +53 -51
- package/src/math/bezier.ts +41 -33
- package/src/math/cubicTools.ts +10 -8
- package/src/math/distanceSquareRoot.ts +1 -1
- package/src/math/lineTools.ts +6 -4
- package/src/math/polygonTools.ts +48 -0
- package/src/math/quadTools.ts +8 -6
- package/src/math/rotateVector.ts +3 -2
- package/src/math/roundTo.ts +7 -0
- package/src/parser/finalizeSegment.ts +11 -7
- package/src/parser/parsePathString.ts +2 -3
- package/src/parser/pathParser.ts +1 -1
- package/src/process/absolutizeSegment.ts +35 -30
- package/src/process/arcToCubic.ts +2 -2
- package/src/process/iterate.ts +41 -16
- package/src/process/lineToCubic.ts +1 -1
- package/src/process/normalizePath.ts +14 -31
- package/src/process/normalizeSegment.ts +53 -15
- package/src/process/optimizePath.ts +40 -60
- package/src/process/projection2d.ts +2 -2
- package/src/process/relativizeSegment.ts +33 -35
- package/src/process/reverseCurve.ts +8 -5
- package/src/process/reversePath.ts +87 -74
- package/src/process/roundPath.ts +14 -8
- package/src/process/roundSegment.ts +9 -0
- package/src/process/segmentToCubic.ts +9 -7
- package/src/process/shortenSegment.ts +24 -32
- package/src/process/splitCubic.ts +2 -2
- package/src/process/transformPath.ts +35 -40
- package/src/types.ts +7 -11
- package/src/util/getPathArea.ts +2 -2
- package/src/util/getPathBBox.ts +25 -42
- package/src/util/getPointAtLength.ts +51 -49
- package/src/util/getPropertiesAtLength.ts +4 -5
- package/src/util/getPropertiesAtPoint.ts +5 -5
- package/src/util/getTotalLength.ts +23 -38
- package/test/class.test.ts +2 -0
- package/test/fixtures/shapes.js +5 -5
- package/test/static.test.ts +18 -12
- package/src/math/polygonArea.ts +0 -29
- package/src/math/polygonLength.ts +0 -22
|
@@ -1,184 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
round: 4
|
|
7
|
-
}, E = "SVGPathCommander Error", tt = {
|
|
8
|
-
a: 7,
|
|
9
|
-
c: 6,
|
|
10
|
-
h: 1,
|
|
11
|
-
l: 2,
|
|
12
|
-
m: 2,
|
|
13
|
-
r: 4,
|
|
14
|
-
q: 4,
|
|
15
|
-
s: 4,
|
|
16
|
-
t: 2,
|
|
17
|
-
v: 1,
|
|
18
|
-
z: 0
|
|
19
|
-
}, $t = (e) => {
|
|
20
|
-
let t = e.pathValue[e.segmentStart], n = t.toLowerCase();
|
|
21
|
-
const { data: r } = e;
|
|
22
|
-
for (; r.length >= tt[n] && (n === "m" && r.length > 2 ? (e.segments.push([t, ...r.splice(0, 2)]), n = "l", t = t === "m" ? "l" : "L") : e.segments.push([t, ...r.splice(0, tt[n])]), !!tt[n]); )
|
|
23
|
-
;
|
|
24
|
-
}, ye = (e) => {
|
|
25
|
-
const { index: t, pathValue: n } = e, r = n.charCodeAt(t);
|
|
26
|
-
if (r === 48) {
|
|
27
|
-
e.param = 0, e.index += 1;
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
if (r === 49) {
|
|
31
|
-
e.param = 1, e.index += 1;
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
e.err = `${E}: invalid Arc flag "${n[t]}", expecting 0 or 1 at index ${t}`;
|
|
35
|
-
}, F = (e) => e >= 48 && e <= 57, U = "Invalid path value", ge = (e) => {
|
|
36
|
-
const { max: t, pathValue: n, index: r } = e;
|
|
37
|
-
let s = r, i = !1, o = !1, c = !1, l = !1, a;
|
|
38
|
-
if (s >= t) {
|
|
39
|
-
e.err = `${E}: ${U} at index ${s}, "pathValue" is missing param`;
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (a = n.charCodeAt(s), (a === 43 || a === 45) && (s += 1, a = n.charCodeAt(s)), !F(a) && a !== 46) {
|
|
43
|
-
e.err = `${E}: ${U} at index ${s}, "${n[s]}" is not a number`;
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
if (a !== 46) {
|
|
47
|
-
if (i = a === 48, s += 1, a = n.charCodeAt(s), i && s < t && a && F(a)) {
|
|
48
|
-
e.err = `${E}: ${U} at index ${r}, "${n[r]}" illegal number`;
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
for (; s < t && F(n.charCodeAt(s)); )
|
|
52
|
-
s += 1, o = !0;
|
|
53
|
-
a = n.charCodeAt(s);
|
|
54
|
-
}
|
|
55
|
-
if (a === 46) {
|
|
56
|
-
for (l = !0, s += 1; F(n.charCodeAt(s)); )
|
|
57
|
-
s += 1, c = !0;
|
|
58
|
-
a = n.charCodeAt(s);
|
|
59
|
-
}
|
|
60
|
-
if (a === 101 || a === 69) {
|
|
61
|
-
if (l && !o && !c) {
|
|
62
|
-
e.err = `${E}: ${U} at index ${s}, "${n[s]}" invalid float exponent`;
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (s += 1, a = n.charCodeAt(s), (a === 43 || a === 45) && (s += 1), s < t && F(n.charCodeAt(s)))
|
|
66
|
-
for (; s < t && F(n.charCodeAt(s)); )
|
|
67
|
-
s += 1;
|
|
68
|
-
else {
|
|
69
|
-
e.err = `${E}: ${U} at index ${s}, "${n[s]}" invalid integer exponent`;
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
e.index = s, e.param = +e.pathValue.slice(r, s);
|
|
74
|
-
}, xe = (e) => [
|
|
75
|
-
// Special spaces
|
|
76
|
-
5760,
|
|
77
|
-
6158,
|
|
78
|
-
8192,
|
|
79
|
-
8193,
|
|
80
|
-
8194,
|
|
81
|
-
8195,
|
|
82
|
-
8196,
|
|
83
|
-
8197,
|
|
84
|
-
8198,
|
|
85
|
-
8199,
|
|
86
|
-
8200,
|
|
87
|
-
8201,
|
|
88
|
-
8202,
|
|
89
|
-
8239,
|
|
90
|
-
8287,
|
|
91
|
-
12288,
|
|
92
|
-
65279,
|
|
93
|
-
// Line terminators
|
|
94
|
-
10,
|
|
95
|
-
13,
|
|
96
|
-
8232,
|
|
97
|
-
8233,
|
|
98
|
-
// White spaces
|
|
99
|
-
32,
|
|
100
|
-
9,
|
|
101
|
-
11,
|
|
102
|
-
12,
|
|
103
|
-
160
|
|
104
|
-
].includes(e), et = (e) => {
|
|
105
|
-
const { pathValue: t, max: n } = e;
|
|
106
|
-
for (; e.index < n && xe(t.charCodeAt(e.index)); )
|
|
107
|
-
e.index += 1;
|
|
108
|
-
}, pe = (e) => {
|
|
109
|
-
switch (e | 32) {
|
|
110
|
-
case 109:
|
|
111
|
-
case 122:
|
|
112
|
-
case 108:
|
|
113
|
-
case 104:
|
|
114
|
-
case 118:
|
|
115
|
-
case 99:
|
|
116
|
-
case 115:
|
|
117
|
-
case 113:
|
|
118
|
-
case 116:
|
|
119
|
-
case 97:
|
|
120
|
-
return !0;
|
|
121
|
-
default:
|
|
122
|
-
return !1;
|
|
123
|
-
}
|
|
124
|
-
}, de = (e) => F(e) || e === 43 || e === 45 || e === 46, Me = (e) => (e | 32) === 97, be = (e) => {
|
|
125
|
-
switch (e | 32) {
|
|
126
|
-
case 109:
|
|
127
|
-
case 77:
|
|
128
|
-
return !0;
|
|
129
|
-
default:
|
|
130
|
-
return !1;
|
|
131
|
-
}
|
|
132
|
-
}, Qt = (e) => {
|
|
133
|
-
var l;
|
|
134
|
-
const { max: t, pathValue: n, index: r, segments: s } = e, i = n.charCodeAt(r), o = tt[n[r].toLowerCase()];
|
|
135
|
-
if (e.segmentStart = r, !pe(i)) {
|
|
136
|
-
e.err = `${E}: ${U} "${n[r]}" is not a path command at index ${r}`;
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
const c = s[s.length - 1];
|
|
140
|
-
if (!be(i) && ((l = c == null ? void 0 : c[0]) == null ? void 0 : l.toLocaleLowerCase()) === "z") {
|
|
141
|
-
e.err = `${E}: ${U} "${n[r]}" is not a MoveTo path command at index ${r}`;
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
if (e.index += 1, et(e), e.data = [], !o) {
|
|
145
|
-
$t(e);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
for (; ; ) {
|
|
149
|
-
for (let a = o; a > 0; a -= 1) {
|
|
150
|
-
if (Me(i) && (a === 3 || a === 4) ? ye(e) : ge(e), e.err.length)
|
|
151
|
-
return;
|
|
152
|
-
e.data.push(e.param), et(e), e.index < t && n.charCodeAt(e.index) === 44 && (e.index += 1, et(e));
|
|
153
|
-
}
|
|
154
|
-
if (e.index >= e.max || !de(n.charCodeAt(e.index)))
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
$t(e);
|
|
158
|
-
};
|
|
159
|
-
class Xt {
|
|
160
|
-
constructor(t) {
|
|
161
|
-
this.segments = [], this.pathValue = t, this.max = t.length, this.index = 0, this.param = 0, this.segmentStart = 0, this.data = [], this.err = "";
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
const q = (e) => {
|
|
165
|
-
if (typeof e != "string")
|
|
166
|
-
return e.slice(0);
|
|
167
|
-
const t = new Xt(e);
|
|
168
|
-
for (et(t); t.index < t.max && !t.err.length; )
|
|
169
|
-
Qt(t);
|
|
170
|
-
if (t != null && t.err.length)
|
|
171
|
-
throw TypeError(t.err);
|
|
172
|
-
return t.segments;
|
|
173
|
-
}, we = (e) => {
|
|
174
|
-
const t = e.length;
|
|
175
|
-
let n = -1, r, s = e[t - 1], i = 0;
|
|
176
|
-
for (; ++n < t; )
|
|
177
|
-
r = s, s = e[n], i += r[1] * s[0] - r[0] * s[1];
|
|
178
|
-
return i / 2;
|
|
179
|
-
}, Pt = (e, t) => Math.sqrt((e[0] - t[0]) * (e[0] - t[0]) + (e[1] - t[1]) * (e[1] - t[1])), Ne = (e) => e.reduce((t, n, r) => r ? t + Pt(e[r - 1], n) : 0, 0);
|
|
180
|
-
var Ae = Object.defineProperty, Ce = (e, t, n) => t in e ? Ae(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, k = (e, t, n) => Ce(e, typeof t != "symbol" ? t + "" : t, n);
|
|
181
|
-
const ve = {
|
|
1
|
+
var Se = Object.defineProperty;
|
|
2
|
+
var De = (e, t, s) => t in e ? Se(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
|
3
|
+
var g = (e, t, s) => De(e, typeof t != "symbol" ? t + "" : t, s);
|
|
4
|
+
var Ze = Object.defineProperty, Oe = (e, t, s) => t in e ? Ze(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, q = (e, t, s) => Oe(e, typeof t != "symbol" ? t + "" : t, s);
|
|
5
|
+
const Qe = {
|
|
182
6
|
a: 1,
|
|
183
7
|
b: 0,
|
|
184
8
|
c: 0,
|
|
@@ -203,21 +27,21 @@ const ve = {
|
|
|
203
27
|
m44: 1,
|
|
204
28
|
is2D: !0,
|
|
205
29
|
isIdentity: !0
|
|
206
|
-
},
|
|
207
|
-
const t = new
|
|
208
|
-
if (!
|
|
209
|
-
throw TypeError(`CSSMatrix: "${
|
|
210
|
-
if (
|
|
211
|
-
const [r,
|
|
212
|
-
t.m11 = r, t.a = r, t.m21 =
|
|
213
|
-
} else if (
|
|
214
|
-
const [r,
|
|
215
|
-
t.m11 = r, t.a = r, t.m12 =
|
|
30
|
+
}, Vt = (e) => (e instanceof Float64Array || e instanceof Float32Array || Array.isArray(e) && e.every((t) => typeof t == "number")) && [6, 16].some((t) => e.length === t), Gt = (e) => e instanceof DOMMatrix || e instanceof C || typeof e == "object" && Object.keys(Qe).every((t) => e && t in e), ht = (e) => {
|
|
31
|
+
const t = new C(), s = Array.from(e);
|
|
32
|
+
if (!Vt(s))
|
|
33
|
+
throw TypeError(`CSSMatrix: "${s.join(",")}" must be an array with 6/16 numbers.`);
|
|
34
|
+
if (s.length === 16) {
|
|
35
|
+
const [r, n, i, o, a, c, l, u, m, f, y, h, x, b, A, w] = s;
|
|
36
|
+
t.m11 = r, t.a = r, t.m21 = a, t.c = a, t.m31 = m, t.m41 = x, t.e = x, t.m12 = n, t.b = n, t.m22 = c, t.d = c, t.m32 = f, t.m42 = b, t.f = b, t.m13 = i, t.m23 = l, t.m33 = y, t.m43 = A, t.m14 = o, t.m24 = u, t.m34 = h, t.m44 = w;
|
|
37
|
+
} else if (s.length === 6) {
|
|
38
|
+
const [r, n, i, o, a, c] = s;
|
|
39
|
+
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 = a, t.e = a, t.m42 = c, t.f = c;
|
|
216
40
|
}
|
|
217
41
|
return t;
|
|
218
|
-
},
|
|
219
|
-
if (
|
|
220
|
-
return
|
|
42
|
+
}, te = (e) => {
|
|
43
|
+
if (Gt(e))
|
|
44
|
+
return ht([
|
|
221
45
|
e.m11,
|
|
222
46
|
e.m12,
|
|
223
47
|
e.m13,
|
|
@@ -236,47 +60,47 @@ const ve = {
|
|
|
236
60
|
e.m44
|
|
237
61
|
]);
|
|
238
62
|
throw TypeError(`CSSMatrix: "${JSON.stringify(e)}" is not a DOMMatrix / CSSMatrix / JSON compatible object.`);
|
|
239
|
-
},
|
|
63
|
+
}, ee = (e) => {
|
|
240
64
|
if (typeof e != "string")
|
|
241
65
|
throw TypeError(`CSSMatrix: "${JSON.stringify(e)}" is not a string.`);
|
|
242
66
|
const t = String(e).replace(/\s/g, "");
|
|
243
|
-
let
|
|
67
|
+
let s = new C();
|
|
244
68
|
const r = `CSSMatrix: invalid transform string "${e}"`;
|
|
245
|
-
return t.split(")").filter((
|
|
246
|
-
const [i, o] =
|
|
69
|
+
return t.split(")").filter((n) => n).forEach((n) => {
|
|
70
|
+
const [i, o] = n.split("(");
|
|
247
71
|
if (!o) throw TypeError(r);
|
|
248
|
-
const
|
|
249
|
-
if (i === "perspective" &&
|
|
250
|
-
|
|
251
|
-
else if (i.includes("matrix") && [6, 16].includes(
|
|
252
|
-
const h =
|
|
253
|
-
|
|
254
|
-
} else if (i === "translate3d" &&
|
|
255
|
-
|
|
256
|
-
else if (i === "translate" &&
|
|
257
|
-
|
|
258
|
-
else if (i === "rotate3d" &&
|
|
259
|
-
|
|
260
|
-
else if (i === "rotate" &&
|
|
261
|
-
|
|
262
|
-
else if (i === "scale3d" &&
|
|
263
|
-
|
|
264
|
-
else if (i === "scale" && !Number.isNaN(
|
|
265
|
-
const h = Number.isNaN(+
|
|
266
|
-
|
|
267
|
-
} else if (i === "skew" && (
|
|
268
|
-
|
|
269
|
-
else if (["translate", "rotate", "scale", "skew"].some((h) => i.includes(h)) && /[XYZ]/.test(i) &&
|
|
72
|
+
const a = o.split(",").map((h) => h.includes("rad") ? parseFloat(h) * (180 / Math.PI) : parseFloat(h)), [c, l, u, m] = a, f = [c, l, u], y = [c, l, u, m];
|
|
73
|
+
if (i === "perspective" && c && [l, u].every((h) => h === void 0))
|
|
74
|
+
s.m34 = -1 / c;
|
|
75
|
+
else if (i.includes("matrix") && [6, 16].includes(a.length) && a.every((h) => !Number.isNaN(+h))) {
|
|
76
|
+
const h = a.map((x) => Math.abs(x) < 1e-6 ? 0 : x);
|
|
77
|
+
s = s.multiply(ht(h));
|
|
78
|
+
} else if (i === "translate3d" && f.every((h) => !Number.isNaN(+h)))
|
|
79
|
+
s = s.translate(c, l, u);
|
|
80
|
+
else if (i === "translate" && c && u === void 0)
|
|
81
|
+
s = s.translate(c, l || 0, 0);
|
|
82
|
+
else if (i === "rotate3d" && y.every((h) => !Number.isNaN(+h)) && m)
|
|
83
|
+
s = s.rotateAxisAngle(c, l, u, m);
|
|
84
|
+
else if (i === "rotate" && c && [l, u].every((h) => h === void 0))
|
|
85
|
+
s = s.rotate(0, 0, c);
|
|
86
|
+
else if (i === "scale3d" && f.every((h) => !Number.isNaN(+h)) && f.some((h) => h !== 1))
|
|
87
|
+
s = s.scale(c, l, u);
|
|
88
|
+
else if (i === "scale" && !Number.isNaN(c) && c !== 1 && u === void 0) {
|
|
89
|
+
const h = Number.isNaN(+l) ? c : l;
|
|
90
|
+
s = s.scale(c, h, 1);
|
|
91
|
+
} else if (i === "skew" && (c || !Number.isNaN(c) && l) && u === void 0)
|
|
92
|
+
s = s.skew(c, l || 0);
|
|
93
|
+
else if (["translate", "rotate", "scale", "skew"].some((h) => i.includes(h)) && /[XYZ]/.test(i) && c && [l, u].every((h) => h === void 0))
|
|
270
94
|
if (i === "skewX" || i === "skewY")
|
|
271
|
-
|
|
95
|
+
s = s[i](c);
|
|
272
96
|
else {
|
|
273
|
-
const h = i.replace(/[XYZ]/, ""),
|
|
274
|
-
|
|
97
|
+
const h = i.replace(/[XYZ]/, ""), x = i.replace(h, ""), b = ["X", "Y", "Z"].indexOf(x), A = h === "scale" ? 1 : 0, w = [b === 0 ? c : A, b === 1 ? c : A, b === 2 ? c : A];
|
|
98
|
+
s = s[h](...w);
|
|
275
99
|
}
|
|
276
100
|
else
|
|
277
101
|
throw TypeError(r);
|
|
278
|
-
}),
|
|
279
|
-
},
|
|
102
|
+
}), s;
|
|
103
|
+
}, vt = (e, t) => t ? [e.a, e.b, e.c, e.d, e.e, e.f] : [
|
|
280
104
|
e.m11,
|
|
281
105
|
e.m12,
|
|
282
106
|
e.m13,
|
|
@@ -293,47 +117,47 @@ const ve = {
|
|
|
293
117
|
e.m42,
|
|
294
118
|
e.m43,
|
|
295
119
|
e.m44
|
|
296
|
-
],
|
|
297
|
-
const r = new
|
|
298
|
-
return r.m41 = e, r.e = e, r.m42 = t, r.f = t, r.m43 =
|
|
299
|
-
},
|
|
300
|
-
const r = new
|
|
301
|
-
r.m11 = h, r.a = h, r.m12 =
|
|
302
|
-
const
|
|
303
|
-
r.m21 =
|
|
304
|
-
const
|
|
305
|
-
return r.m22 =
|
|
306
|
-
},
|
|
307
|
-
const
|
|
120
|
+
], ne = (e, t, s) => {
|
|
121
|
+
const r = new C();
|
|
122
|
+
return r.m41 = e, r.e = e, r.m42 = t, r.f = t, r.m43 = s, r;
|
|
123
|
+
}, se = (e, t, s) => {
|
|
124
|
+
const r = new C(), n = Math.PI / 180, i = e * n, o = t * n, a = s * n, c = Math.cos(i), l = -Math.sin(i), u = Math.cos(o), m = -Math.sin(o), f = Math.cos(a), y = -Math.sin(a), h = u * f, x = -u * y;
|
|
125
|
+
r.m11 = h, r.a = h, r.m12 = x, r.b = x, r.m13 = m;
|
|
126
|
+
const b = l * m * f + c * y;
|
|
127
|
+
r.m21 = b, r.c = b;
|
|
128
|
+
const A = c * f - l * m * y;
|
|
129
|
+
return r.m22 = A, r.d = A, r.m23 = -l * u, r.m31 = l * y - c * m * f, r.m32 = l * f + c * m * y, r.m33 = c * u, r;
|
|
130
|
+
}, re = (e, t, s, r) => {
|
|
131
|
+
const n = new C(), i = Math.sqrt(e * e + t * t + s * s);
|
|
308
132
|
if (i === 0)
|
|
309
|
-
return
|
|
310
|
-
const o = e / i,
|
|
311
|
-
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
const
|
|
317
|
-
return
|
|
318
|
-
},
|
|
319
|
-
const r = new
|
|
320
|
-
return r.m11 = e, r.a = e, r.m22 = t, r.d = t, r.m33 =
|
|
321
|
-
},
|
|
322
|
-
const
|
|
133
|
+
return n;
|
|
134
|
+
const o = e / i, a = t / i, c = s / i, l = r * (Math.PI / 360), u = Math.sin(l), m = Math.cos(l), f = u * u, y = o * o, h = a * a, x = c * c, b = 1 - 2 * (h + x) * f;
|
|
135
|
+
n.m11 = b, n.a = b;
|
|
136
|
+
const A = 2 * (o * a * f + c * u * m);
|
|
137
|
+
n.m12 = A, n.b = A, n.m13 = 2 * (o * c * f - a * u * m);
|
|
138
|
+
const w = 2 * (a * o * f - c * u * m);
|
|
139
|
+
n.m21 = w, n.c = w;
|
|
140
|
+
const N = 1 - 2 * (x + y) * f;
|
|
141
|
+
return n.m22 = N, n.d = N, n.m23 = 2 * (a * c * f + o * u * m), n.m31 = 2 * (c * o * f + a * u * m), n.m32 = 2 * (c * a * f - o * u * m), n.m33 = 1 - 2 * (y + h) * f, n;
|
|
142
|
+
}, ie = (e, t, s) => {
|
|
143
|
+
const r = new C();
|
|
144
|
+
return r.m11 = e, r.a = e, r.m22 = t, r.d = t, r.m33 = s, r;
|
|
145
|
+
}, At = (e, t) => {
|
|
146
|
+
const s = new C();
|
|
323
147
|
if (e) {
|
|
324
|
-
const r = e * Math.PI / 180,
|
|
325
|
-
|
|
148
|
+
const r = e * Math.PI / 180, n = Math.tan(r);
|
|
149
|
+
s.m21 = n, s.c = n;
|
|
326
150
|
}
|
|
327
151
|
if (t) {
|
|
328
|
-
const r = t * Math.PI / 180,
|
|
329
|
-
|
|
152
|
+
const r = t * Math.PI / 180, n = Math.tan(r);
|
|
153
|
+
s.m12 = n, s.b = n;
|
|
330
154
|
}
|
|
331
|
-
return
|
|
332
|
-
},
|
|
333
|
-
const
|
|
334
|
-
return
|
|
155
|
+
return s;
|
|
156
|
+
}, oe = (e) => At(e, 0), ce = (e) => At(0, e), B = (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, a = 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, l = 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, m = t.m31 * e.m12 + t.m32 * e.m22 + t.m33 * e.m32 + t.m34 * e.m42, f = 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, h = t.m41 * e.m11 + t.m42 * e.m21 + t.m43 * e.m31 + t.m44 * e.m41, x = t.m41 * e.m12 + t.m42 * e.m22 + t.m43 * e.m32 + t.m44 * e.m42, b = t.m41 * e.m13 + t.m42 * e.m23 + t.m43 * e.m33 + t.m44 * e.m43, A = t.m41 * e.m14 + t.m42 * e.m24 + t.m43 * e.m34 + t.m44 * e.m44;
|
|
158
|
+
return ht([s, r, n, i, o, a, c, l, u, m, f, y, h, x, b, A]);
|
|
335
159
|
};
|
|
336
|
-
class
|
|
160
|
+
class C {
|
|
337
161
|
/**
|
|
338
162
|
* @constructor
|
|
339
163
|
* @param init accepts all parameter configurations:
|
|
@@ -378,7 +202,7 @@ class v {
|
|
|
378
202
|
* @return the matrix instance
|
|
379
203
|
*/
|
|
380
204
|
setMatrixValue(t) {
|
|
381
|
-
return typeof t == "string" && t.length && t !== "none" ?
|
|
205
|
+
return typeof t == "string" && t.length && t !== "none" ? ee(t) : Array.isArray(t) || t instanceof Float64Array || t instanceof Float32Array ? ht(t) : typeof t == "object" ? te(t) : this;
|
|
382
206
|
}
|
|
383
207
|
/**
|
|
384
208
|
* Returns a *Float32Array* containing elements which comprise the matrix.
|
|
@@ -389,7 +213,7 @@ class v {
|
|
|
389
213
|
* @return an *Array* representation of the matrix
|
|
390
214
|
*/
|
|
391
215
|
toFloat32Array(t) {
|
|
392
|
-
return Float32Array.from(
|
|
216
|
+
return Float32Array.from(vt(this, t));
|
|
393
217
|
}
|
|
394
218
|
/**
|
|
395
219
|
* Returns a *Float64Array* containing elements which comprise the matrix.
|
|
@@ -400,7 +224,7 @@ class v {
|
|
|
400
224
|
* @return an *Array* representation of the matrix
|
|
401
225
|
*/
|
|
402
226
|
toFloat64Array(t) {
|
|
403
|
-
return Float64Array.from(
|
|
227
|
+
return Float64Array.from(vt(this, t));
|
|
404
228
|
}
|
|
405
229
|
/**
|
|
406
230
|
* Creates and returns a string representation of the matrix in `CSS` matrix syntax,
|
|
@@ -412,8 +236,8 @@ class v {
|
|
|
412
236
|
* @return a string representation of the matrix
|
|
413
237
|
*/
|
|
414
238
|
toString() {
|
|
415
|
-
const { is2D: t } = this,
|
|
416
|
-
return `${t ? "matrix" : "matrix3d"}(${
|
|
239
|
+
const { is2D: t } = this, s = this.toFloat64Array(t).join(", ");
|
|
240
|
+
return `${t ? "matrix" : "matrix3d"}(${s})`;
|
|
417
241
|
}
|
|
418
242
|
/**
|
|
419
243
|
* Returns a JSON representation of the `CSSMatrix` instance, a standard *Object*
|
|
@@ -426,8 +250,8 @@ class v {
|
|
|
426
250
|
* @return an *Object* with all matrix values.
|
|
427
251
|
*/
|
|
428
252
|
toJSON() {
|
|
429
|
-
const { is2D: t, isIdentity:
|
|
430
|
-
return { ...this, is2D: t, isIdentity:
|
|
253
|
+
const { is2D: t, isIdentity: s } = this;
|
|
254
|
+
return { ...this, is2D: t, isIdentity: s };
|
|
431
255
|
}
|
|
432
256
|
/**
|
|
433
257
|
* The Multiply method returns a new CSSMatrix which is the result of this
|
|
@@ -438,7 +262,7 @@ class v {
|
|
|
438
262
|
* @return The resulted matrix.
|
|
439
263
|
*/
|
|
440
264
|
multiply(t) {
|
|
441
|
-
return
|
|
265
|
+
return B(this, t);
|
|
442
266
|
}
|
|
443
267
|
/**
|
|
444
268
|
* The translate method returns a new matrix which is this matrix post
|
|
@@ -451,10 +275,10 @@ class v {
|
|
|
451
275
|
* @param z Z component of the translation value.
|
|
452
276
|
* @return The resulted matrix
|
|
453
277
|
*/
|
|
454
|
-
translate(t,
|
|
455
|
-
const
|
|
456
|
-
let i =
|
|
457
|
-
return typeof i > "u" && (i = 0), typeof o > "u" && (o = 0),
|
|
278
|
+
translate(t, s, r) {
|
|
279
|
+
const n = t;
|
|
280
|
+
let i = s, o = r;
|
|
281
|
+
return typeof i > "u" && (i = 0), typeof o > "u" && (o = 0), B(this, ne(n, i, o));
|
|
458
282
|
}
|
|
459
283
|
/**
|
|
460
284
|
* The scale method returns a new matrix which is this matrix post multiplied by
|
|
@@ -467,10 +291,10 @@ class v {
|
|
|
467
291
|
* @param z The Z component of the scale value.
|
|
468
292
|
* @return The resulted matrix
|
|
469
293
|
*/
|
|
470
|
-
scale(t,
|
|
471
|
-
const
|
|
472
|
-
let i =
|
|
473
|
-
return typeof i > "u" && (i = t), typeof o > "u" && (o = 1),
|
|
294
|
+
scale(t, s, r) {
|
|
295
|
+
const n = t;
|
|
296
|
+
let i = s, o = r;
|
|
297
|
+
return typeof i > "u" && (i = t), typeof o > "u" && (o = 1), B(this, ie(n, i, o));
|
|
474
298
|
}
|
|
475
299
|
/**
|
|
476
300
|
* The rotate method returns a new matrix which is this matrix post multiplied
|
|
@@ -484,9 +308,9 @@ class v {
|
|
|
484
308
|
* @param rz The (optional) Z component of the rotation value.
|
|
485
309
|
* @return The resulted matrix
|
|
486
310
|
*/
|
|
487
|
-
rotate(t,
|
|
488
|
-
let
|
|
489
|
-
return typeof t == "number" && typeof
|
|
311
|
+
rotate(t, s, r) {
|
|
312
|
+
let n = t, i = s || 0, o = r || 0;
|
|
313
|
+
return typeof t == "number" && typeof s > "u" && typeof r > "u" && (o = n, n = 0, i = 0), B(this, se(n, i, o));
|
|
490
314
|
}
|
|
491
315
|
/**
|
|
492
316
|
* The rotateAxisAngle method returns a new matrix which is this matrix post
|
|
@@ -500,10 +324,10 @@ class v {
|
|
|
500
324
|
* @param angle The angle of rotation about the axis vector, in degrees.
|
|
501
325
|
* @return The resulted matrix
|
|
502
326
|
*/
|
|
503
|
-
rotateAxisAngle(t,
|
|
504
|
-
if ([t,
|
|
327
|
+
rotateAxisAngle(t, s, r, n) {
|
|
328
|
+
if ([t, s, r, n].some((i) => Number.isNaN(+i)))
|
|
505
329
|
throw new TypeError("CSSMatrix: expecting 4 values");
|
|
506
|
-
return
|
|
330
|
+
return B(this, re(t, s, r, n));
|
|
507
331
|
}
|
|
508
332
|
/**
|
|
509
333
|
* Specifies a skew transformation along the `x-axis` by the given angle.
|
|
@@ -513,7 +337,7 @@ class v {
|
|
|
513
337
|
* @return The resulted matrix
|
|
514
338
|
*/
|
|
515
339
|
skewX(t) {
|
|
516
|
-
return
|
|
340
|
+
return B(this, oe(t));
|
|
517
341
|
}
|
|
518
342
|
/**
|
|
519
343
|
* Specifies a skew transformation along the `y-axis` by the given angle.
|
|
@@ -523,7 +347,7 @@ class v {
|
|
|
523
347
|
* @return The resulted matrix
|
|
524
348
|
*/
|
|
525
349
|
skewY(t) {
|
|
526
|
-
return
|
|
350
|
+
return B(this, ce(t));
|
|
527
351
|
}
|
|
528
352
|
/**
|
|
529
353
|
* Specifies a skew transformation along both the `x-axis` and `y-axis`.
|
|
@@ -533,8 +357,8 @@ class v {
|
|
|
533
357
|
* @param angleY The angle amount in degrees to skew.
|
|
534
358
|
* @return The resulted matrix
|
|
535
359
|
*/
|
|
536
|
-
skew(t,
|
|
537
|
-
return
|
|
360
|
+
skew(t, s) {
|
|
361
|
+
return B(this, At(t, s));
|
|
538
362
|
}
|
|
539
363
|
/**
|
|
540
364
|
* Transforms a specified vector using the matrix, returning a new
|
|
@@ -548,210 +372,531 @@ class v {
|
|
|
548
372
|
* @return the resulting Tuple
|
|
549
373
|
*/
|
|
550
374
|
transformPoint(t) {
|
|
551
|
-
const
|
|
552
|
-
return t instanceof DOMPoint ? new DOMPoint(
|
|
553
|
-
x:
|
|
375
|
+
const s = this.m11 * t.x + this.m21 * t.y + this.m31 * t.z + this.m41 * t.w, r = this.m12 * t.x + this.m22 * t.y + this.m32 * t.z + this.m42 * t.w, n = this.m13 * t.x + this.m23 * t.y + this.m33 * t.z + this.m43 * t.w, i = this.m14 * t.x + this.m24 * t.y + this.m34 * t.z + this.m44 * t.w;
|
|
376
|
+
return t instanceof DOMPoint ? new DOMPoint(s, r, n, i) : {
|
|
377
|
+
x: s,
|
|
554
378
|
y: r,
|
|
555
|
-
z:
|
|
379
|
+
z: n,
|
|
556
380
|
w: i
|
|
557
381
|
};
|
|
558
382
|
}
|
|
559
383
|
}
|
|
560
|
-
|
|
561
|
-
const
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
384
|
+
q(C, "Translate", ne), q(C, "Rotate", se), q(C, "RotateAxisAngle", re), q(C, "Scale", ie), q(C, "SkewX", oe), q(C, "SkewY", ce), q(C, "Skew", At), q(C, "Multiply", B), q(C, "fromArray", ht), q(C, "fromMatrix", te), q(C, "fromString", ee), q(C, "toArray", vt), q(C, "isCompatibleArray", Vt), q(C, "isCompatibleObject", Gt);
|
|
385
|
+
const V = {
|
|
386
|
+
origin: [0, 0, 0],
|
|
387
|
+
round: 4
|
|
388
|
+
}, nt = {
|
|
389
|
+
a: 7,
|
|
390
|
+
c: 6,
|
|
391
|
+
h: 1,
|
|
392
|
+
l: 2,
|
|
393
|
+
m: 2,
|
|
394
|
+
r: 4,
|
|
395
|
+
q: 4,
|
|
396
|
+
s: 4,
|
|
397
|
+
t: 2,
|
|
398
|
+
v: 1,
|
|
399
|
+
z: 0
|
|
400
|
+
}, Tt = (e) => {
|
|
401
|
+
let t = e.pathValue[e.segmentStart], s = t.toLowerCase();
|
|
402
|
+
const { data: r } = e;
|
|
403
|
+
for (; r.length >= nt[s] && (s === "m" && r.length > 2 ? (e.segments.push([t].concat(r.splice(0, 2))), s = "l", t = t === "m" ? "l" : "L") : e.segments.push(
|
|
404
|
+
[t].concat(
|
|
405
|
+
r.splice(0, nt[s])
|
|
406
|
+
)
|
|
407
|
+
), !!nt[s]); )
|
|
408
|
+
;
|
|
409
|
+
}, E = "SVGPathCommander Error", ae = (e) => {
|
|
410
|
+
const { index: t, pathValue: s } = e, r = s.charCodeAt(t);
|
|
411
|
+
if (r === 48) {
|
|
412
|
+
e.param = 0, e.index += 1;
|
|
413
|
+
return;
|
|
579
414
|
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
if (
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
415
|
+
if (r === 49) {
|
|
416
|
+
e.param = 1, e.index += 1;
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
e.err = `${E}: invalid Arc flag "${s[t]}", expecting 0 or 1 at index ${t}`;
|
|
420
|
+
}, H = (e) => e >= 48 && e <= 57, U = "Invalid path value", le = (e) => {
|
|
421
|
+
const { max: t, pathValue: s, index: r } = e;
|
|
422
|
+
let n = r, i = !1, o = !1, a = !1, c = !1, l;
|
|
423
|
+
if (n >= t) {
|
|
424
|
+
e.err = `${E}: ${U} at index ${n}, "pathValue" is missing param`;
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
if (l = s.charCodeAt(n), (l === 43 || l === 45) && (n += 1, l = s.charCodeAt(n)), !H(l) && l !== 46) {
|
|
428
|
+
e.err = `${E}: ${U} at index ${n}, "${s[n]}" is not a number`;
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
if (l !== 46) {
|
|
432
|
+
if (i = l === 48, n += 1, l = s.charCodeAt(n), i && n < t && l && H(l)) {
|
|
433
|
+
e.err = `${E}: ${U} at index ${r}, "${s[r]}" illegal number`;
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
for (; n < t && H(s.charCodeAt(n)); )
|
|
437
|
+
n += 1, o = !0;
|
|
438
|
+
l = s.charCodeAt(n);
|
|
439
|
+
}
|
|
440
|
+
if (l === 46) {
|
|
441
|
+
for (c = !0, n += 1; H(s.charCodeAt(n)); )
|
|
442
|
+
n += 1, a = !0;
|
|
443
|
+
l = s.charCodeAt(n);
|
|
444
|
+
}
|
|
445
|
+
if (l === 101 || l === 69) {
|
|
446
|
+
if (c && !o && !a) {
|
|
447
|
+
e.err = `${E}: ${U} at index ${n}, "${s[n]}" invalid float exponent`;
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
if (n += 1, l = s.charCodeAt(n), (l === 43 || l === 45) && (n += 1), n < t && H(s.charCodeAt(n)))
|
|
451
|
+
for (; n < t && H(s.charCodeAt(n)); )
|
|
452
|
+
n += 1;
|
|
453
|
+
else {
|
|
454
|
+
e.err = `${E}: ${U} at index ${n}, "${s[n]}" invalid integer exponent`;
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
e.index = n, e.param = +e.pathValue.slice(r, n);
|
|
459
|
+
}, ue = (e) => [
|
|
460
|
+
// Special spaces
|
|
461
|
+
5760,
|
|
462
|
+
6158,
|
|
463
|
+
8192,
|
|
464
|
+
8193,
|
|
465
|
+
8194,
|
|
466
|
+
8195,
|
|
467
|
+
8196,
|
|
468
|
+
8197,
|
|
469
|
+
8198,
|
|
470
|
+
8199,
|
|
471
|
+
8200,
|
|
472
|
+
8201,
|
|
473
|
+
8202,
|
|
474
|
+
8239,
|
|
475
|
+
8287,
|
|
476
|
+
12288,
|
|
477
|
+
65279,
|
|
478
|
+
// Line terminators
|
|
479
|
+
10,
|
|
480
|
+
13,
|
|
481
|
+
8232,
|
|
482
|
+
8233,
|
|
483
|
+
// White spaces
|
|
484
|
+
32,
|
|
485
|
+
9,
|
|
486
|
+
11,
|
|
487
|
+
12,
|
|
488
|
+
160
|
|
489
|
+
].includes(e), st = (e) => {
|
|
490
|
+
const { pathValue: t, max: s } = e;
|
|
491
|
+
for (; e.index < s && ue(t.charCodeAt(e.index)); )
|
|
492
|
+
e.index += 1;
|
|
493
|
+
}, me = (e) => {
|
|
494
|
+
switch (e | 32) {
|
|
495
|
+
case 109:
|
|
496
|
+
case 122:
|
|
497
|
+
case 108:
|
|
498
|
+
case 104:
|
|
499
|
+
case 118:
|
|
500
|
+
case 99:
|
|
501
|
+
case 115:
|
|
502
|
+
case 113:
|
|
503
|
+
case 116:
|
|
504
|
+
case 97:
|
|
505
|
+
return !0;
|
|
506
|
+
default:
|
|
507
|
+
return !1;
|
|
508
|
+
}
|
|
509
|
+
}, he = (e) => H(e) || e === 43 || e === 45 || e === 46, fe = (e) => (e | 32) === 97, ye = (e) => {
|
|
510
|
+
switch (e | 32) {
|
|
511
|
+
case 109:
|
|
512
|
+
case 77:
|
|
513
|
+
return !0;
|
|
514
|
+
default:
|
|
515
|
+
return !1;
|
|
516
|
+
}
|
|
517
|
+
}, Et = (e) => {
|
|
518
|
+
var c;
|
|
519
|
+
const { max: t, pathValue: s, index: r, segments: n } = e, i = s.charCodeAt(r), o = nt[s[r].toLowerCase()];
|
|
520
|
+
if (e.segmentStart = r, !me(i)) {
|
|
521
|
+
e.err = `${E}: ${U} "${s[r]}" is not a path command at index ${r}`;
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
const a = n[n.length - 1];
|
|
525
|
+
if (!ye(i) && ((c = a == null ? void 0 : a[0]) == null ? void 0 : c.toLocaleLowerCase()) === "z") {
|
|
526
|
+
e.err = `${E}: ${U} "${s[r]}" is not a MoveTo path command at index ${r}`;
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
if (e.index += 1, st(e), e.data = [], !o) {
|
|
530
|
+
Tt(e);
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
for (; ; ) {
|
|
534
|
+
for (let l = o; l > 0; l -= 1) {
|
|
535
|
+
if (fe(i) && (l === 3 || l === 4) ? ae(e) : le(e), e.err.length)
|
|
536
|
+
return;
|
|
537
|
+
e.data.push(e.param), st(e), e.index < t && s.charCodeAt(e.index) === 44 && (e.index += 1, st(e));
|
|
602
538
|
}
|
|
539
|
+
if (e.index >= e.max || !he(s.charCodeAt(e.index)))
|
|
540
|
+
break;
|
|
541
|
+
}
|
|
542
|
+
Tt(e);
|
|
543
|
+
};
|
|
544
|
+
class Rt {
|
|
545
|
+
constructor(t) {
|
|
546
|
+
this.segments = [], this.pathValue = t, this.max = t.length, this.index = 0, this.param = 0, this.segmentStart = 0, this.data = [], this.err = "";
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
const R = (e) => {
|
|
550
|
+
if (typeof e != "string")
|
|
551
|
+
return e.slice(0);
|
|
552
|
+
const t = new Rt(e);
|
|
553
|
+
for (st(t); t.index < t.max && !t.err.length; )
|
|
554
|
+
Et(t);
|
|
555
|
+
if (t != null && t.err.length)
|
|
556
|
+
throw TypeError(t.err);
|
|
557
|
+
return t.segments;
|
|
558
|
+
}, jt = (e, t, s, r) => {
|
|
559
|
+
const [n] = e, i = n.toUpperCase();
|
|
560
|
+
if (t === 0 || i === n) return e;
|
|
561
|
+
if (i === "A")
|
|
562
|
+
return [
|
|
563
|
+
i,
|
|
564
|
+
e[1],
|
|
565
|
+
e[2],
|
|
566
|
+
e[3],
|
|
567
|
+
e[4],
|
|
568
|
+
e[5],
|
|
569
|
+
e[6] + s,
|
|
570
|
+
e[7] + r
|
|
571
|
+
];
|
|
572
|
+
if (i === "V")
|
|
573
|
+
return [i, e[1] + r];
|
|
574
|
+
if (i === "H")
|
|
575
|
+
return [i, e[1] + s];
|
|
576
|
+
if (i === "L")
|
|
577
|
+
return [i, e[1] + s, e[2] + r];
|
|
578
|
+
{
|
|
579
|
+
const a = e.slice(1).map((c, l) => c + (l % 2 ? r : s));
|
|
580
|
+
return [i].concat(a);
|
|
581
|
+
}
|
|
582
|
+
}, j = (e, t) => {
|
|
583
|
+
let s = e.length, r, n = "M", i = "M", o = !1, a = 0, c = 0, l = 0, u = 0, m = 0;
|
|
584
|
+
for (let f = 0; f < s; f += 1) {
|
|
585
|
+
r = e[f], [n] = r, m = r.length, i = n.toUpperCase(), o = i !== n;
|
|
586
|
+
const y = t(r, f, a, c);
|
|
587
|
+
if (y === !1)
|
|
588
|
+
break;
|
|
589
|
+
i === "Z" ? (a = l, c = u) : i === "H" ? a = r[1] + (o ? a : 0) : i === "V" ? c = r[1] + (o ? c : 0) : (a = r[m - 2] + (o ? a : 0), c = r[m - 1] + (o ? c : 0), i === "M" && (l = a, u = c)), y && (e[f] = y, y[0] === "C" && (s = e.length));
|
|
603
590
|
}
|
|
604
591
|
return e;
|
|
592
|
+
}, xt = (e) => {
|
|
593
|
+
const t = R(e);
|
|
594
|
+
return j(t, jt);
|
|
595
|
+
}, St = (e, t, s, r) => {
|
|
596
|
+
const [n] = e, i = n.toLowerCase();
|
|
597
|
+
if (t === 0 || n === i) return e;
|
|
598
|
+
if (i === "a")
|
|
599
|
+
return [
|
|
600
|
+
i,
|
|
601
|
+
e[1],
|
|
602
|
+
e[2],
|
|
603
|
+
e[3],
|
|
604
|
+
e[4],
|
|
605
|
+
e[5],
|
|
606
|
+
e[6] - s,
|
|
607
|
+
e[7] - r
|
|
608
|
+
];
|
|
609
|
+
if (i === "v")
|
|
610
|
+
return [i, e[1] - r];
|
|
611
|
+
if (i === "h")
|
|
612
|
+
return [i, e[1] - s];
|
|
613
|
+
if (i === "l")
|
|
614
|
+
return [i, e[1] - s, e[2] - r];
|
|
615
|
+
{
|
|
616
|
+
const a = e.slice(1).map((c, l) => c - (l % 2 ? r : s));
|
|
617
|
+
return [i].concat(a);
|
|
618
|
+
}
|
|
619
|
+
}, Xt = (e) => {
|
|
620
|
+
const t = R(e);
|
|
621
|
+
return j(t, St);
|
|
622
|
+
}, ct = (e, t, s) => {
|
|
623
|
+
const { sin: r, cos: n } = Math, i = e * n(s) - t * r(s), o = e * r(s) + t * n(s);
|
|
624
|
+
return { x: i, y: o };
|
|
625
|
+
}, Dt = (e, t, s, r, n, i, o, a, c, l) => {
|
|
626
|
+
let u = e, m = t, f = s, y = r, h = a, x = c;
|
|
627
|
+
const b = Math.PI * 120 / 180, A = Math.PI / 180 * (+n || 0);
|
|
628
|
+
let w = [], N, M, d, v, L;
|
|
629
|
+
if (l)
|
|
630
|
+
[M, d, v, L] = l;
|
|
631
|
+
else {
|
|
632
|
+
N = ct(u, m, -A), u = N.x, m = N.y, N = ct(h, x, -A), h = N.x, x = N.y;
|
|
633
|
+
const $ = (u - h) / 2, P = (m - x) / 2;
|
|
634
|
+
let Q = $ * $ / (f * f) + P * P / (y * y);
|
|
635
|
+
Q > 1 && (Q = Math.sqrt(Q), f *= Q, y *= Q);
|
|
636
|
+
const F = f * f, D = y * y, Ut = (i === o ? -1 : 1) * Math.sqrt(Math.abs((F * D - F * P * P - D * $ * $) / (F * P * P + D * $ * $)));
|
|
637
|
+
v = Ut * f * P / y + (u + h) / 2, L = Ut * -y * $ / f + (m + x) / 2, M = Math.asin(((m - L) / y * 10 ** 9 >> 0) / 10 ** 9), d = Math.asin(((x - L) / y * 10 ** 9 >> 0) / 10 ** 9), M = u < v ? Math.PI - M : M, d = h < v ? Math.PI - d : d, M < 0 && (M = Math.PI * 2 + M), d < 0 && (d = Math.PI * 2 + d), o && M > d && (M -= Math.PI * 2), !o && d > M && (d -= Math.PI * 2);
|
|
638
|
+
}
|
|
639
|
+
let T = d - M;
|
|
640
|
+
if (Math.abs(T) > b) {
|
|
641
|
+
const $ = d, P = h, Q = x;
|
|
642
|
+
d = M + b * (o && d > M ? 1 : -1), h = v + f * Math.cos(d), x = L + y * Math.sin(d), w = Dt(h, x, f, y, n, 0, o, P, Q, [d, $, v, L]);
|
|
643
|
+
}
|
|
644
|
+
T = d - M;
|
|
645
|
+
const Z = Math.cos(M), k = Math.sin(M), it = Math.cos(d), tt = Math.sin(d), _ = Math.tan(T / 4), et = 4 / 3 * f * _, I = 4 / 3 * y * _, J = [u, m], S = [u + et * k, m - I * Z], Y = [h + et * tt, x - I * it], K = [h, x];
|
|
646
|
+
if (S[0] = 2 * J[0] - S[0], S[1] = 2 * J[1] - S[1], l)
|
|
647
|
+
return [S[0], S[1], Y[0], Y[1], K[0], K[1]].concat(w);
|
|
648
|
+
w = [S[0], S[1], Y[0], Y[1], K[0], K[1]].concat(w);
|
|
649
|
+
const ot = [];
|
|
650
|
+
for (let $ = 0, P = w.length; $ < P; $ += 1)
|
|
651
|
+
ot[$] = $ % 2 ? ct(w[$ - 1], w[$], A).y : ct(w[$], w[$ + 1], A).x;
|
|
652
|
+
return ot;
|
|
653
|
+
}, xe = (e, t, s, r, n, i) => {
|
|
654
|
+
const o = 0.3333333333333333, a = 2 / 3;
|
|
655
|
+
return [
|
|
656
|
+
o * e + a * s,
|
|
657
|
+
// cpx1
|
|
658
|
+
o * t + a * r,
|
|
659
|
+
// cpy1
|
|
660
|
+
o * n + a * s,
|
|
661
|
+
// cpx2
|
|
662
|
+
o * i + a * r,
|
|
663
|
+
// cpy2
|
|
664
|
+
n,
|
|
665
|
+
i
|
|
666
|
+
// x,y
|
|
667
|
+
];
|
|
668
|
+
}, O = (e, t, s) => {
|
|
669
|
+
const [r, n] = e, [i, o] = t;
|
|
670
|
+
return [r + (i - r) * s, n + (o - n) * s];
|
|
671
|
+
}, Ct = (e, t, s, r) => {
|
|
672
|
+
const n = O([e, t], [s, r], 0.3333333333333333), i = O([e, t], [s, r], 2 / 3);
|
|
673
|
+
return [n[0], n[1], i[0], i[1], s, r];
|
|
674
|
+
}, Zt = (e, t) => {
|
|
675
|
+
const [s] = e, r = e.slice(1).map(Number), [n, i] = r, { x1: o, y1: a, x: c, y: l } = t;
|
|
676
|
+
return "TQ".includes(s) || (t.qx = null, t.qy = null), s === "M" ? (t.x = n, t.y = i, e) : s === "A" ? ["C"].concat(
|
|
677
|
+
Dt(o, a, r[0], r[1], r[2], r[3], r[4], r[5], r[6])
|
|
678
|
+
) : s === "Q" ? (t.qx = n, t.qy = i, ["C"].concat(
|
|
679
|
+
xe(o, a, r[0], r[1], r[2], r[3])
|
|
680
|
+
)) : s === "L" ? ["C"].concat(Ct(o, a, n, i)) : s === "Z" ? ["C"].concat(Ct(o, a, c, l)) : e;
|
|
605
681
|
}, G = (e, t) => {
|
|
606
|
-
const [
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
return
|
|
614
|
-
|
|
615
|
-
|
|
682
|
+
const [s] = e, r = s.toUpperCase(), n = s !== r, { x1: i, y1: o, x2: a, y2: c, x: l, y: u } = t, m = e.slice(1);
|
|
683
|
+
let f = m.map((y, h) => y + (n ? h % 2 ? u : l : 0));
|
|
684
|
+
if ("TQ".includes(r) || (t.qx = null, t.qy = null), r === "A")
|
|
685
|
+
return f = m.slice(0, -2).concat(m[5] + (n ? l : 0), m[6] + (n ? u : 0)), ["A"].concat(f);
|
|
686
|
+
if (r === "H")
|
|
687
|
+
return ["L", e[1] + (n ? l : 0), o];
|
|
688
|
+
if (r === "V")
|
|
689
|
+
return ["L", i, e[1] + (n ? u : 0)];
|
|
690
|
+
if (r === "L")
|
|
691
|
+
return [
|
|
692
|
+
"L",
|
|
693
|
+
e[1] + (n ? l : 0),
|
|
694
|
+
e[2] + (n ? u : 0)
|
|
695
|
+
];
|
|
696
|
+
if (r === "M")
|
|
697
|
+
return [
|
|
698
|
+
"M",
|
|
699
|
+
e[1] + (n ? l : 0),
|
|
700
|
+
e[2] + (n ? u : 0)
|
|
701
|
+
];
|
|
702
|
+
if (r === "C")
|
|
703
|
+
return ["C"].concat(f);
|
|
704
|
+
if (r === "S") {
|
|
705
|
+
const y = i * 2 - a, h = o * 2 - c;
|
|
706
|
+
return t.x1 = y, t.y1 = h, ["C", y, h].concat(f);
|
|
707
|
+
} else if (r === "T") {
|
|
708
|
+
const y = i * 2 - (t.qx ? t.qx : (
|
|
616
709
|
/* istanbul ignore next */
|
|
617
710
|
0
|
|
618
|
-
)),
|
|
711
|
+
)), h = o * 2 - (t.qy ? t.qy : (
|
|
619
712
|
/* istanbul ignore next */
|
|
620
713
|
0
|
|
621
714
|
));
|
|
622
|
-
return t.qx =
|
|
623
|
-
} else if (
|
|
624
|
-
const [
|
|
625
|
-
t.qx =
|
|
626
|
-
}
|
|
715
|
+
return t.qx = y, t.qy = h, ["Q", y, h].concat(f);
|
|
716
|
+
} else if (r === "Q") {
|
|
717
|
+
const [y, h] = f;
|
|
718
|
+
return t.qx = y, t.qy = h, ["Q"].concat(f);
|
|
719
|
+
} else if (r === "Z")
|
|
720
|
+
return ["Z"];
|
|
627
721
|
return e;
|
|
628
|
-
},
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
722
|
+
}, X = {
|
|
723
|
+
x1: 0,
|
|
724
|
+
y1: 0,
|
|
725
|
+
x2: 0,
|
|
726
|
+
y2: 0,
|
|
727
|
+
x: 0,
|
|
728
|
+
y: 0,
|
|
729
|
+
qx: null,
|
|
730
|
+
qy: null
|
|
731
|
+
}, gt = (e) => {
|
|
732
|
+
const t = { ...X }, s = R(e);
|
|
733
|
+
return j(s, (r, n, i, o) => {
|
|
734
|
+
t.x = i, t.y = o;
|
|
735
|
+
const a = G(r, t);
|
|
736
|
+
let c = Zt(a, t);
|
|
737
|
+
c[0] === "C" && c.length > 7 && (s.splice(n + 1, 0, ["C"].concat(c.slice(7))), c = c.slice(0, 7));
|
|
738
|
+
const u = c.length;
|
|
739
|
+
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;
|
|
740
|
+
});
|
|
741
|
+
}, z = (e, t) => {
|
|
742
|
+
const s = t >= 1 ? 10 ** t : 1;
|
|
743
|
+
return t > 0 ? Math.round(e * s) / s : Math.round(e);
|
|
744
|
+
}, $t = (e, t) => {
|
|
745
|
+
const s = e.length;
|
|
746
|
+
let { round: r } = V, n = e[0], i = "";
|
|
747
|
+
r = t === "off" || typeof t == "number" && t >= 0 ? t : typeof r == "number" && r >= 0 ? r : (
|
|
748
|
+
/* istanbul ignore next @preserve */
|
|
749
|
+
"off"
|
|
750
|
+
);
|
|
751
|
+
for (let o = 0; o < s; o += 1) {
|
|
752
|
+
n = e[o];
|
|
753
|
+
const [a] = n, c = n.slice(1);
|
|
754
|
+
if (i += a, r === "off")
|
|
755
|
+
i += c.join(" ");
|
|
639
756
|
else {
|
|
640
|
-
|
|
641
|
-
|
|
757
|
+
let l = 0;
|
|
758
|
+
const u = c.length;
|
|
759
|
+
for (; l < u; )
|
|
760
|
+
i += z(c[l], r), l !== u - 1 && (i += " "), l += 1;
|
|
642
761
|
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
762
|
+
}
|
|
763
|
+
return i;
|
|
764
|
+
}, Mt = (e, t) => Math.sqrt((e[0] - t[0]) * (e[0] - t[0]) + (e[1] - t[1]) * (e[1] - t[1])), lt = (e, t, s, r) => Mt([e, t], [s, r]), Ot = (e, t, s, r, n) => {
|
|
765
|
+
let i = { x: e, y: t };
|
|
766
|
+
if (typeof n == "number") {
|
|
767
|
+
const o = Mt([e, t], [s, r]);
|
|
768
|
+
if (n <= 0)
|
|
769
|
+
i = { x: e, y: t };
|
|
770
|
+
else if (n >= o)
|
|
771
|
+
i = { x: s, y: r };
|
|
772
|
+
else {
|
|
773
|
+
const [a, c] = O([e, t], [s, r], n / o);
|
|
774
|
+
i = { x: a, y: c };
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
return i;
|
|
778
|
+
}, zt = (e, t, s, r) => {
|
|
779
|
+
const { min: n, max: i } = Math;
|
|
646
780
|
return {
|
|
647
781
|
min: {
|
|
648
|
-
x:
|
|
649
|
-
y:
|
|
782
|
+
x: n(e, s),
|
|
783
|
+
y: n(t, r)
|
|
650
784
|
},
|
|
651
785
|
max: {
|
|
652
|
-
x: i(e,
|
|
786
|
+
x: i(e, s),
|
|
653
787
|
y: i(t, r)
|
|
654
788
|
}
|
|
655
789
|
};
|
|
656
|
-
},
|
|
657
|
-
const r =
|
|
658
|
-
return Math.abs(
|
|
659
|
-
},
|
|
660
|
-
const o = Math
|
|
790
|
+
}, Qt = (e, t, s) => {
|
|
791
|
+
const r = s / 2, n = Math.sin(r), i = Math.cos(r), o = e ** 2 * n ** 2, a = t ** 2 * i ** 2, c = Math.sqrt(o + a) * s;
|
|
792
|
+
return Math.abs(c);
|
|
793
|
+
}, W = (e, t, s, r, n, i) => {
|
|
794
|
+
const { sin: o, cos: a } = Math, c = a(n), l = o(n), u = s * a(i), m = r * o(i);
|
|
661
795
|
return {
|
|
662
|
-
x:
|
|
663
|
-
y:
|
|
796
|
+
x: e + c * u - l * m,
|
|
797
|
+
y: t + l * u + c * m
|
|
664
798
|
};
|
|
665
|
-
},
|
|
666
|
-
const { x:
|
|
667
|
-
return (
|
|
668
|
-
},
|
|
669
|
-
const { abs:
|
|
670
|
-
let h =
|
|
671
|
-
const
|
|
672
|
-
if (e ===
|
|
799
|
+
}, Pt = (e, t) => {
|
|
800
|
+
const { x: s, y: r } = e, { x: n, y: i } = t, o = s * n + r * i, a = Math.sqrt((s ** 2 + r ** 2) * (n ** 2 + i ** 2));
|
|
801
|
+
return (s * i - r * n < 0 ? -1 : 1) * Math.acos(o / a);
|
|
802
|
+
}, wt = (e, t, s, r, n, i, o, a, c) => {
|
|
803
|
+
const { abs: l, sin: u, cos: m, sqrt: f, PI: y } = Math;
|
|
804
|
+
let h = l(s), x = l(r);
|
|
805
|
+
const A = (n % 360 + 360) % 360 * (y / 180);
|
|
806
|
+
if (e === a && t === c)
|
|
673
807
|
return {
|
|
674
808
|
rx: h,
|
|
675
|
-
ry:
|
|
809
|
+
ry: x,
|
|
676
810
|
startAngle: 0,
|
|
677
811
|
endAngle: 0,
|
|
678
|
-
center: { x:
|
|
812
|
+
center: { x: a, y: c }
|
|
679
813
|
};
|
|
680
|
-
if (h === 0 ||
|
|
814
|
+
if (h === 0 || x === 0)
|
|
681
815
|
return {
|
|
682
816
|
rx: h,
|
|
683
|
-
ry:
|
|
817
|
+
ry: x,
|
|
684
818
|
startAngle: 0,
|
|
685
819
|
endAngle: 0,
|
|
686
|
-
center: { x:
|
|
820
|
+
center: { x: (a + e) / 2, y: (c + t) / 2 }
|
|
687
821
|
};
|
|
688
|
-
const
|
|
689
|
-
x:
|
|
690
|
-
y: -
|
|
691
|
-
},
|
|
692
|
-
|
|
693
|
-
const
|
|
694
|
-
let
|
|
695
|
-
|
|
696
|
-
const
|
|
697
|
-
x:
|
|
698
|
-
y:
|
|
699
|
-
},
|
|
700
|
-
x:
|
|
701
|
-
y:
|
|
702
|
-
},
|
|
703
|
-
x: (M.x -
|
|
704
|
-
y: (M.y -
|
|
705
|
-
},
|
|
706
|
-
x: (-M.x -
|
|
707
|
-
y: (-M.y -
|
|
822
|
+
const w = (e - a) / 2, N = (t - c) / 2, M = {
|
|
823
|
+
x: m(A) * w + u(A) * N,
|
|
824
|
+
y: -u(A) * w + m(A) * N
|
|
825
|
+
}, d = M.x ** 2 / h ** 2 + M.y ** 2 / x ** 2;
|
|
826
|
+
d > 1 && (h *= f(d), x *= f(d));
|
|
827
|
+
const v = h ** 2 * x ** 2 - h ** 2 * M.y ** 2 - x ** 2 * M.x ** 2, L = h ** 2 * M.y ** 2 + x ** 2 * M.x ** 2;
|
|
828
|
+
let T = v / L;
|
|
829
|
+
T = T < 0 ? 0 : T;
|
|
830
|
+
const Z = (i !== o ? 1 : -1) * f(T), k = {
|
|
831
|
+
x: Z * (h * M.y / x),
|
|
832
|
+
y: Z * (-(x * M.x) / h)
|
|
833
|
+
}, it = {
|
|
834
|
+
x: m(A) * k.x - u(A) * k.y + (e + a) / 2,
|
|
835
|
+
y: u(A) * k.x + m(A) * k.y + (t + c) / 2
|
|
836
|
+
}, tt = {
|
|
837
|
+
x: (M.x - k.x) / h,
|
|
838
|
+
y: (M.y - k.y) / x
|
|
839
|
+
}, _ = Pt({ x: 1, y: 0 }, tt), et = {
|
|
840
|
+
x: (-M.x - k.x) / h,
|
|
841
|
+
y: (-M.y - k.y) / x
|
|
708
842
|
};
|
|
709
|
-
let I =
|
|
710
|
-
!o && I > 0 ? I -= 2 *
|
|
711
|
-
const J =
|
|
843
|
+
let I = Pt(tt, et);
|
|
844
|
+
!o && I > 0 ? I -= 2 * y : o && I < 0 && (I += 2 * y), I %= 2 * y;
|
|
845
|
+
const J = _ + I;
|
|
712
846
|
return {
|
|
713
|
-
center:
|
|
714
|
-
startAngle:
|
|
847
|
+
center: it,
|
|
848
|
+
startAngle: _,
|
|
715
849
|
endAngle: J,
|
|
716
850
|
rx: h,
|
|
717
|
-
ry:
|
|
851
|
+
ry: x
|
|
718
852
|
};
|
|
719
|
-
},
|
|
720
|
-
const { rx:
|
|
721
|
-
return
|
|
722
|
-
},
|
|
723
|
-
let
|
|
724
|
-
const { center:
|
|
725
|
-
if (typeof
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
853
|
+
}, Bt = (e, t, s, r, n, i, o, a, c) => {
|
|
854
|
+
const { rx: l, ry: u, startAngle: m, endAngle: f } = wt(e, t, s, r, n, i, o, a, c);
|
|
855
|
+
return Qt(l, u, f - m);
|
|
856
|
+
}, ge = (e, t, s, r, n, i, o, a, c, l) => {
|
|
857
|
+
let u = { x: e, y: t };
|
|
858
|
+
const { center: m, rx: f, ry: y, startAngle: h, endAngle: x } = wt(e, t, s, r, n, i, o, a, c);
|
|
859
|
+
if (typeof l == "number") {
|
|
860
|
+
const b = Qt(f, y, x - h);
|
|
861
|
+
if (l <= 0)
|
|
862
|
+
u = { x: e, y: t };
|
|
863
|
+
else if (l >= b)
|
|
864
|
+
u = { x: a, y: c };
|
|
730
865
|
else {
|
|
731
|
-
if (e ===
|
|
732
|
-
return { x:
|
|
733
|
-
if (
|
|
734
|
-
return
|
|
735
|
-
const { PI:
|
|
736
|
-
|
|
737
|
-
x:
|
|
738
|
-
y:
|
|
866
|
+
if (e === a && t === c)
|
|
867
|
+
return { x: a, y: c };
|
|
868
|
+
if (f === 0 || y === 0)
|
|
869
|
+
return Ot(e, t, a, c, l);
|
|
870
|
+
const { PI: A, cos: w, sin: N } = Math, M = x - h, v = (n % 360 + 360) % 360 * (A / 180), L = h + M * (l / b), T = f * w(L), Z = y * N(L);
|
|
871
|
+
u = {
|
|
872
|
+
x: w(v) * T - N(v) * Z + m.x,
|
|
873
|
+
y: N(v) * T + w(v) * Z + m.y
|
|
739
874
|
};
|
|
740
875
|
}
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
876
|
+
}
|
|
877
|
+
return u;
|
|
878
|
+
}, pe = (e, t, s, r, n, i, o, a, c) => {
|
|
879
|
+
const { center: l, rx: u, ry: m, startAngle: f, endAngle: y } = wt(e, t, s, r, n, i, o, a, c), h = y - f, { min: x, max: b, tan: A, atan2: w, PI: N } = Math, M = { x: a, y: c }, { x: d, y: v } = l, L = [M], T = n * N / 180, Z = A(T), k = w(-m * Z, u), it = k, tt = k + N, _ = w(m, u * Z), et = _ + N, I = [e, a], J = [t, c], S = x(...I), Y = b(...I), K = x(...J), ot = b(...J), $ = y - h * 1e-3, P = W(d, v, u, m, T, $), Q = y - h * 0.999, F = W(d, v, u, m, T, Q);
|
|
880
|
+
return (P.x > Y || F.x > Y) && L.push(W(d, v, u, m, T, it)), (P.x < S || F.x < S) && L.push(W(d, v, u, m, T, tt)), (P.y < K || F.y < K) && L.push(W(d, v, u, m, T, et)), (P.y > ot || F.y > ot) && L.push(W(d, v, u, m, T, _)), {
|
|
745
881
|
min: {
|
|
746
|
-
x:
|
|
747
|
-
y:
|
|
882
|
+
x: x(...L.map((D) => D.x)),
|
|
883
|
+
y: x(...L.map((D) => D.y))
|
|
748
884
|
},
|
|
749
885
|
max: {
|
|
750
|
-
x:
|
|
751
|
-
y:
|
|
886
|
+
x: b(...L.map((D) => D.x)),
|
|
887
|
+
y: b(...L.map((D) => D.y))
|
|
752
888
|
}
|
|
753
889
|
};
|
|
754
|
-
},
|
|
890
|
+
}, Be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
891
|
+
__proto__: null,
|
|
892
|
+
angleBetween: Pt,
|
|
893
|
+
arcLength: Qt,
|
|
894
|
+
arcPoint: W,
|
|
895
|
+
getArcBBox: pe,
|
|
896
|
+
getArcLength: Bt,
|
|
897
|
+
getArcProps: wt,
|
|
898
|
+
getPointAtArcLength: ge
|
|
899
|
+
}, Symbol.toStringTag, { value: "Module" })), qt = [
|
|
755
900
|
-0.06405689286260563,
|
|
756
901
|
0.06405689286260563,
|
|
757
902
|
-0.1911188674736163,
|
|
@@ -776,7 +921,7 @@ const gt = {
|
|
|
776
921
|
0.9747285559713095,
|
|
777
922
|
-0.9951872199970213,
|
|
778
923
|
0.9951872199970213
|
|
779
|
-
],
|
|
924
|
+
], be = [
|
|
780
925
|
0.12793819534675216,
|
|
781
926
|
0.12793819534675216,
|
|
782
927
|
0.1258374563468283,
|
|
@@ -801,312 +946,284 @@ const gt = {
|
|
|
801
946
|
0.028531388628933663,
|
|
802
947
|
0.0123412297999872,
|
|
803
948
|
0.0123412297999872
|
|
804
|
-
],
|
|
949
|
+
], de = (e) => {
|
|
805
950
|
const t = [];
|
|
806
|
-
for (let
|
|
951
|
+
for (let s = e, r = s.length, n = r - 1; r > 1; r -= 1, n -= 1) {
|
|
807
952
|
const i = [];
|
|
808
|
-
for (let o = 0; o <
|
|
953
|
+
for (let o = 0; o < n; o += 1)
|
|
809
954
|
i.push({
|
|
810
|
-
x:
|
|
811
|
-
y:
|
|
955
|
+
x: n * (s[o + 1].x - s[o].x),
|
|
956
|
+
y: n * (s[o + 1].y - s[o].y),
|
|
812
957
|
t: 0
|
|
813
958
|
});
|
|
814
|
-
t.push(i),
|
|
959
|
+
t.push(i), s = i;
|
|
815
960
|
}
|
|
816
961
|
return t;
|
|
817
|
-
},
|
|
962
|
+
}, Ae = (e, t) => {
|
|
818
963
|
if (t === 0)
|
|
819
964
|
return e[0].t = 0, e[0];
|
|
820
|
-
const
|
|
965
|
+
const s = e.length - 1;
|
|
821
966
|
if (t === 1)
|
|
822
|
-
return e[
|
|
967
|
+
return e[s].t = 1, e[s];
|
|
823
968
|
const r = 1 - t;
|
|
824
|
-
let
|
|
825
|
-
if (
|
|
969
|
+
let n = e;
|
|
970
|
+
if (s === 0)
|
|
826
971
|
return e[0].t = t, e[0];
|
|
827
|
-
if (
|
|
972
|
+
if (s === 1)
|
|
828
973
|
return {
|
|
829
|
-
x: r *
|
|
830
|
-
y: r *
|
|
974
|
+
x: r * n[0].x + t * n[1].x,
|
|
975
|
+
y: r * n[0].y + t * n[1].y,
|
|
831
976
|
t
|
|
832
977
|
};
|
|
833
978
|
const i = r * r, o = t * t;
|
|
834
|
-
let
|
|
835
|
-
return
|
|
836
|
-
x:
|
|
837
|
-
y:
|
|
979
|
+
let a = 0, c = 0, l = 0, u = 0;
|
|
980
|
+
return s === 2 ? (n = [n[0], n[1], n[2], { x: 0, y: 0 }], a = i, c = r * t * 2, l = o) : s === 3 && (a = i * r, c = i * t * 3, l = r * o * 3, u = t * o), {
|
|
981
|
+
x: a * n[0].x + c * n[1].x + l * n[2].x + u * n[3].x,
|
|
982
|
+
y: a * n[0].y + c * n[1].y + l * n[2].y + u * n[3].y,
|
|
838
983
|
t
|
|
839
984
|
};
|
|
840
|
-
},
|
|
841
|
-
const
|
|
985
|
+
}, Me = (e, t) => {
|
|
986
|
+
const s = e(t), r = s.x * s.x + s.y * s.y;
|
|
842
987
|
return Math.sqrt(r);
|
|
843
|
-
},
|
|
844
|
-
const
|
|
988
|
+
}, we = (e) => {
|
|
989
|
+
const s = qt.length;
|
|
845
990
|
let r = 0;
|
|
846
|
-
for (let
|
|
847
|
-
i = 0.5 *
|
|
991
|
+
for (let n = 0, i; n < s; n++)
|
|
992
|
+
i = 0.5 * qt[n] + 0.5, r += be[n] * Me(e, i);
|
|
848
993
|
return 0.5 * r;
|
|
849
|
-
},
|
|
994
|
+
}, ft = (e) => {
|
|
850
995
|
const t = [];
|
|
851
|
-
for (let r = 0,
|
|
996
|
+
for (let r = 0, n = e.length, i = 2; r < n; r += i)
|
|
852
997
|
t.push({
|
|
853
998
|
x: e[r],
|
|
854
999
|
y: e[r + 1]
|
|
855
1000
|
});
|
|
856
|
-
const
|
|
857
|
-
return
|
|
858
|
-
},
|
|
859
|
-
const
|
|
860
|
-
if (
|
|
861
|
-
return [
|
|
862
|
-
const
|
|
863
|
-
return
|
|
864
|
-
},
|
|
865
|
-
const
|
|
866
|
-
if (Math.abs(
|
|
867
|
-
return e
|
|
868
|
-
const
|
|
869
|
-
if (
|
|
870
|
-
return [Math.min(e
|
|
871
|
-
const
|
|
872
|
-
let
|
|
873
|
-
const
|
|
874
|
-
for (let
|
|
875
|
-
if (
|
|
876
|
-
const
|
|
877
|
-
|
|
1001
|
+
const s = de(t);
|
|
1002
|
+
return we((r) => Ae(s[0], r));
|
|
1003
|
+
}, Ne = 1e-8, pt = ([e, t, s]) => {
|
|
1004
|
+
const r = Math.min(e, s), n = Math.max(e, s);
|
|
1005
|
+
if (t >= e ? s >= t : s <= t)
|
|
1006
|
+
return [r, n];
|
|
1007
|
+
const i = (e * s - t * t) / (e - 2 * t + s);
|
|
1008
|
+
return i < r ? [i, n] : [r, i];
|
|
1009
|
+
}, kt = ([e, t, s, r]) => {
|
|
1010
|
+
const n = e - 3 * t + 3 * s - r;
|
|
1011
|
+
if (Math.abs(n) < Ne)
|
|
1012
|
+
return e === r && e === t ? [e, r] : pt([e, -0.5 * e + 1.5 * t, e - 3 * t + 3 * s]);
|
|
1013
|
+
const i = -e * s + e * r - t * s - t * r + t * t + s * s;
|
|
1014
|
+
if (i <= 0)
|
|
1015
|
+
return [Math.min(e, r), Math.max(e, r)];
|
|
1016
|
+
const o = Math.sqrt(i);
|
|
1017
|
+
let a = Math.min(e, r), c = Math.max(e, r);
|
|
1018
|
+
const l = e - 2 * t + s;
|
|
1019
|
+
for (let u = (l + o) / n, m = 1; m <= 2; u = (l - o) / n, m++)
|
|
1020
|
+
if (u > 0 && u < 1) {
|
|
1021
|
+
const f = e * (1 - u) * (1 - u) * (1 - u) + t * 3 * (1 - u) * (1 - u) * u + s * 3 * (1 - u) * u * u + r * u * u * u;
|
|
1022
|
+
f < a && (a = f), f > c && (c = f);
|
|
878
1023
|
}
|
|
879
|
-
return [
|
|
880
|
-
},
|
|
881
|
-
const
|
|
1024
|
+
return [a, c];
|
|
1025
|
+
}, Le = ([e, t, s, r, n, i, o, a], c) => {
|
|
1026
|
+
const l = 1 - c;
|
|
882
1027
|
return {
|
|
883
|
-
x:
|
|
884
|
-
y:
|
|
1028
|
+
x: l ** 3 * e + 3 * l ** 2 * c * s + 3 * l * c ** 2 * n + c ** 3 * o,
|
|
1029
|
+
y: l ** 3 * t + 3 * l ** 2 * c * r + 3 * l * c ** 2 * i + c ** 3 * a
|
|
885
1030
|
};
|
|
886
|
-
},
|
|
887
|
-
const
|
|
888
|
-
let
|
|
889
|
-
if (
|
|
890
|
-
const
|
|
891
|
-
|
|
1031
|
+
}, _t = (e, t, s, r, n, i, o, a) => ft([e, t, s, r, n, i, o, a]), ve = (e, t, s, r, n, i, o, a, c) => {
|
|
1032
|
+
const l = typeof c == "number";
|
|
1033
|
+
let u = { x: e, y: t };
|
|
1034
|
+
if (l) {
|
|
1035
|
+
const m = ft([e, t, s, r, n, i, o, a]);
|
|
1036
|
+
c <= 0 || (c >= m ? u = { x: o, y: a } : u = Le([e, t, s, r, n, i, o, a], c / m));
|
|
892
1037
|
}
|
|
893
|
-
return
|
|
894
|
-
},
|
|
895
|
-
const
|
|
1038
|
+
return u;
|
|
1039
|
+
}, Te = (e, t, s, r, n, i, o, a) => {
|
|
1040
|
+
const c = kt([e, s, n, o]), l = kt([t, r, i, a]);
|
|
896
1041
|
return {
|
|
897
|
-
min: { x:
|
|
898
|
-
max: { x:
|
|
1042
|
+
min: { x: c[0], y: l[0] },
|
|
1043
|
+
max: { x: c[1], y: l[1] }
|
|
899
1044
|
};
|
|
900
|
-
},
|
|
901
|
-
const
|
|
1045
|
+
}, Ce = ([e, t, s, r, n, i], o) => {
|
|
1046
|
+
const a = 1 - o;
|
|
902
1047
|
return {
|
|
903
|
-
x:
|
|
904
|
-
y:
|
|
1048
|
+
x: a ** 2 * e + 2 * a * o * s + o ** 2 * n,
|
|
1049
|
+
y: a ** 2 * t + 2 * a * o * r + o ** 2 * i
|
|
905
1050
|
};
|
|
906
|
-
},
|
|
907
|
-
const
|
|
908
|
-
let
|
|
909
|
-
if (
|
|
910
|
-
const
|
|
911
|
-
o <= 0 || (o >=
|
|
1051
|
+
}, Ft = (e, t, s, r, n, i) => ft([e, t, s, r, n, i]), $e = (e, t, s, r, n, i, o) => {
|
|
1052
|
+
const a = typeof o == "number";
|
|
1053
|
+
let c = { x: e, y: t };
|
|
1054
|
+
if (a) {
|
|
1055
|
+
const l = ft([e, t, s, r, n, i]);
|
|
1056
|
+
o <= 0 || (o >= l ? c = { x: n, y: i } : c = Ce([e, t, s, r, n, i], o / l));
|
|
912
1057
|
}
|
|
913
|
-
return
|
|
914
|
-
},
|
|
915
|
-
const o =
|
|
916
|
-
return {
|
|
917
|
-
min: { x: o[0], y: c[0] },
|
|
918
|
-
max: { x: o[1], y: c[1] }
|
|
919
|
-
};
|
|
920
|
-
}, zt = (e) => {
|
|
921
|
-
if (!e)
|
|
922
|
-
return {
|
|
923
|
-
x: 0,
|
|
924
|
-
y: 0,
|
|
925
|
-
width: 0,
|
|
926
|
-
height: 0,
|
|
927
|
-
x2: 0,
|
|
928
|
-
y2: 0,
|
|
929
|
-
cx: 0,
|
|
930
|
-
cy: 0,
|
|
931
|
-
cz: 0
|
|
932
|
-
};
|
|
933
|
-
const t = q(e);
|
|
934
|
-
let n = [], r = "M", s = 0, i = 0, o = 0, c = 0;
|
|
935
|
-
const l = [], a = [];
|
|
936
|
-
let m = { x: s, y: i }, u = { x: s, y: i };
|
|
937
|
-
D(t, (d, C) => {
|
|
938
|
-
const M = V(d, C), b = G(M, C);
|
|
939
|
-
return [r] = b, n = [s, i, ...b.slice(1)], r === "M" ? ([, o, c] = b, m = { x: o, y: c }, u = { x: o, y: c }) : r === "L" ? { min: m, max: u } = kt(...n) : r === "A" ? { min: m, max: u } = Le(...n) : r === "C" ? { min: m, max: u } = Oe(...n) : r === "Q" ? { min: m, max: u } = De(...n) : r === "Z" && (n = [s, i, o, c], { min: m, max: u } = kt(...n)), l.push(m), a.push(u), r === "Z" ? (s = o, i = c) : ([s, i] = b.slice(-2), r === "M" && (o = s, c = i)), C.x = s, C.y = i, b;
|
|
940
|
-
});
|
|
941
|
-
const g = Math.min(...l.map((d) => d.x)), f = Math.max(...a.map((d) => d.x)), h = Math.min(...l.map((d) => d.y)), y = Math.max(...a.map((d) => d.y)), x = f - g, p = y - h;
|
|
1058
|
+
return c;
|
|
1059
|
+
}, ze = (e, t, s, r, n, i) => {
|
|
1060
|
+
const o = pt([e, s, n]), a = pt([t, r, i]);
|
|
942
1061
|
return {
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
x: g,
|
|
946
|
-
y: h,
|
|
947
|
-
x2: f,
|
|
948
|
-
y2: y,
|
|
949
|
-
cx: g + x / 2,
|
|
950
|
-
cy: h + p / 2,
|
|
951
|
-
// an estimated guess
|
|
952
|
-
cz: Math.max(x, p) + Math.min(x, p) / 2
|
|
1062
|
+
min: { x: o[0], y: a[0] },
|
|
1063
|
+
max: { x: o[1], y: a[1] }
|
|
953
1064
|
};
|
|
954
|
-
},
|
|
955
|
-
const
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
let H = L * L / (g * g) + Z * Z / (f * f);
|
|
967
|
-
H > 1 && (H = Math.sqrt(H), g *= H, f *= H);
|
|
968
|
-
const Mt = g * g, bt = f * f, St = (i === o ? -1 : 1) * Math.sqrt(Math.abs((Mt * bt - Mt * Z * Z - bt * L * L) / (Mt * Z * Z + bt * L * L)));
|
|
969
|
-
w = St * g * Z / f + (m + h) / 2, T = St * -f * L / g + (u + y) / 2, M = Math.asin(((u - T) / f * 10 ** 9 >> 0) / 10 ** 9), b = Math.asin(((y - T) / f * 10 ** 9 >> 0) / 10 ** 9), M = m < w ? Math.PI - M : M, b = h < w ? Math.PI - b : b, M < 0 && (M = Math.PI * 2 + M), b < 0 && (b = Math.PI * 2 + b), o && M > b && (M -= Math.PI * 2), !o && b > M && (b -= Math.PI * 2);
|
|
970
|
-
}
|
|
971
|
-
let P = b - M;
|
|
972
|
-
if (Math.abs(P) > x) {
|
|
973
|
-
const L = b, Z = h, H = y;
|
|
974
|
-
b = M + x * (o && b > M ? 1 : -1), h = w + g * Math.cos(b), y = T + f * Math.sin(b), d = re(h, y, g, f, s, 0, o, Z, H, [b, L, w, T]);
|
|
975
|
-
}
|
|
976
|
-
P = b - M;
|
|
977
|
-
const $ = Math.cos(M), S = Math.sin(M), _ = Math.cos(b), X = Math.sin(b), Q = Math.tan(P / 4), B = 4 / 3 * g * Q, I = 4 / 3 * f * Q, J = [m, u], z = [m + B * S, u - I * $], ot = [h + B * X, y - I * _], Y = [h, y];
|
|
978
|
-
if (z[0] = 2 * J[0] - z[0], z[1] = 2 * J[1] - z[1], a)
|
|
979
|
-
return [...z, ...ot, ...Y, ...d];
|
|
980
|
-
d = [...z, ...ot, ...Y, ...d];
|
|
981
|
-
const O = [];
|
|
982
|
-
for (let L = 0, Z = d.length; L < Z; L += 1)
|
|
983
|
-
O[L] = L % 2 ? ct(d[L - 1], d[L], p).y : ct(d[L], d[L + 1], p).x;
|
|
984
|
-
return O;
|
|
985
|
-
}, Qe = (e, t, n, r, s, i) => {
|
|
986
|
-
const o = 0.3333333333333333, c = 2 / 3;
|
|
987
|
-
return [
|
|
988
|
-
o * e + c * n,
|
|
989
|
-
// cpx1
|
|
990
|
-
o * t + c * r,
|
|
991
|
-
// cpy1
|
|
992
|
-
o * s + c * n,
|
|
993
|
-
// cpx2
|
|
994
|
-
o * i + c * r,
|
|
995
|
-
// cpy2
|
|
996
|
-
s,
|
|
997
|
-
i
|
|
998
|
-
// x,y
|
|
999
|
-
];
|
|
1000
|
-
}, Zt = (e, t, n, r) => {
|
|
1001
|
-
const s = R([e, t], [n, r], 0.3333333333333333), i = R([e, t], [n, r], 2 / 3);
|
|
1002
|
-
return [...s, ...i, n, r];
|
|
1003
|
-
}, ie = (e, t) => {
|
|
1004
|
-
const [n] = e, r = e.slice(1).map(Number), [s, i] = r;
|
|
1005
|
-
let o;
|
|
1006
|
-
const { x1: c, y1: l, x: a, y: m } = t;
|
|
1007
|
-
return "TQ".includes(n) || (t.qx = null, t.qy = null), n === "M" ? (t.x = s, t.y = i, e) : n === "A" ? (o = [c, l, ...r], ["C", ...re(...o)]) : n === "Q" ? (t.qx = s, t.qy = i, o = [c, l, ...r], ["C", ...Qe(...o)]) : n === "L" ? ["C", ...Zt(c, l, s, i)] : n === "Z" ? ["C", ...Zt(c, l, a, m)] : e;
|
|
1008
|
-
}, mt = (e) => {
|
|
1009
|
-
let t = 0, n = 0, r = 0, s = 0, i = "M";
|
|
1010
|
-
const o = q(e);
|
|
1011
|
-
return D(o, (c, l, a) => {
|
|
1012
|
-
const m = V(c, l);
|
|
1013
|
-
[i] = m;
|
|
1014
|
-
const u = i.toUpperCase(), g = G(m, l);
|
|
1015
|
-
let f = ie(g, l);
|
|
1016
|
-
return f[0] === "C" && f.length > 7 && (o.splice(a + 1, 0, ["C", ...f.slice(7)]), f = f.slice(0, 7)), u === "Z" ? (t = r, n = s) : ([t, n] = f.slice(-2), u === "M" && (r = t, s = n)), l.x = t, l.y = n, f;
|
|
1065
|
+
}, _e = (e) => {
|
|
1066
|
+
const t = e.length;
|
|
1067
|
+
let s = -1, r, n = e[t - 1], i = 0;
|
|
1068
|
+
for (; ++s < t; )
|
|
1069
|
+
r = n, n = e[s], i += r[1] * n[0] - r[0] * n[1];
|
|
1070
|
+
return i / 2;
|
|
1071
|
+
}, Fe = (e) => e.reduce((t, s, r) => r ? t + Mt(e[r - 1], s) : 0, 0), bt = 1e-5, ut = (e) => {
|
|
1072
|
+
const t = R(e), s = { ...X };
|
|
1073
|
+
return j(t, (r, n, i, o) => {
|
|
1074
|
+
s.x = i, s.y = o;
|
|
1075
|
+
const a = G(r, s), c = a.length;
|
|
1076
|
+
return s.x1 = +a[c - 2], s.y1 = +a[c - 1], s.x2 = +a[c - 4] || s.x1, s.y2 = +a[c - 3] || s.y1, a;
|
|
1017
1077
|
});
|
|
1018
|
-
},
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1078
|
+
}, at = (e, t) => {
|
|
1079
|
+
const s = ut(e);
|
|
1080
|
+
let r = !1, n = [], i = "M", o = 0, a = 0, [c, l] = s[0].slice(1);
|
|
1081
|
+
const u = typeof t == "number";
|
|
1082
|
+
let m = { x: c, y: l }, f = 0, y = m, h = 0;
|
|
1083
|
+
return !u || t < bt ? m : (j(s, (x, b, A, w) => {
|
|
1084
|
+
if ([i] = x, r = i === "M", n = r ? n : [A, w].concat(x.slice(1)), r ? ([, c, l] = x, m = { x: c, y: l }, f = 0) : i === "L" ? (m = Ot(n[0], n[1], n[2], n[3], t - h), f = lt(n[0], n[1], n[2], n[3])) : i === "A" ? (m = ge(
|
|
1085
|
+
n[0],
|
|
1086
|
+
n[1],
|
|
1087
|
+
n[2],
|
|
1088
|
+
n[3],
|
|
1089
|
+
n[4],
|
|
1090
|
+
n[5],
|
|
1091
|
+
n[6],
|
|
1092
|
+
n[7],
|
|
1093
|
+
n[8],
|
|
1094
|
+
t - h
|
|
1095
|
+
), f = Bt(n[0], n[1], n[2], n[3], n[4], n[5], n[6], n[7], n[8])) : i === "C" ? (m = ve(
|
|
1096
|
+
n[0],
|
|
1097
|
+
n[1],
|
|
1098
|
+
n[2],
|
|
1099
|
+
n[3],
|
|
1100
|
+
n[4],
|
|
1101
|
+
n[5],
|
|
1102
|
+
n[6],
|
|
1103
|
+
n[7],
|
|
1104
|
+
t - h
|
|
1105
|
+
), f = _t(n[0], n[1], n[2], n[3], n[4], n[5], n[6], n[7])) : i === "Q" ? (m = $e(n[0], n[1], n[2], n[3], n[4], n[5], t - h), f = Ft(n[0], n[1], n[2], n[3], n[4], n[5])) : i === "Z" && (n = [A, w, c, l], m = { x: c, y: l }, f = lt(n[0], n[1], n[2], n[3])), [o, a] = n.slice(-2), h < t)
|
|
1106
|
+
y = m;
|
|
1107
|
+
else
|
|
1108
|
+
return !1;
|
|
1109
|
+
h += f;
|
|
1110
|
+
}), t > h - bt ? { x: o, y: a } : y);
|
|
1111
|
+
}, rt = (e) => {
|
|
1112
|
+
const t = R(e), s = { ...X };
|
|
1113
|
+
let r = !1, n = [], i = "M", o = 0, a = 0, c = 0;
|
|
1114
|
+
return j(t, (l, u, m, f) => {
|
|
1115
|
+
s.x = m, s.y = f;
|
|
1116
|
+
const y = G(l, s);
|
|
1117
|
+
[i] = y, r = i === "M", n = r ? n : [m, f].concat(y.slice(1)), r ? [, o, a] = y : i === "L" ? c += lt(n[0], n[1], n[2], n[3]) : i === "A" ? c += Bt(n[0], n[1], n[2], n[3], n[4], n[5], n[6], n[7], n[8]) : i === "C" ? c += _t(n[0], n[1], n[2], n[3], n[4], n[5], n[6], n[7]) : i === "Q" ? c += Ft(n[0], n[1], n[2], n[3], n[4], n[5]) : i === "Z" && (n = [m, f, o, a], c += lt(n[0], n[1], n[2], n[3]));
|
|
1118
|
+
const h = y.length;
|
|
1119
|
+
s.x1 = +y[h - 2], s.y1 = +y[h - 1], s.x2 = +y[h - 4] || s.x1, s.y2 = +y[h - 3] || s.y1;
|
|
1120
|
+
}), c;
|
|
1121
|
+
}, Ht = (e, t) => {
|
|
1122
|
+
const s = R(e);
|
|
1123
|
+
let r = s.slice(0), n = rt(r), i = r.length - 1, o = 0, a = 0, c = s[0];
|
|
1048
1124
|
if (i <= 0 || !t || !Number.isFinite(t))
|
|
1049
1125
|
return {
|
|
1050
|
-
segment:
|
|
1126
|
+
segment: c,
|
|
1051
1127
|
index: 0,
|
|
1052
|
-
length:
|
|
1053
|
-
point: u,
|
|
1128
|
+
length: a,
|
|
1054
1129
|
lengthAtSegment: o
|
|
1055
1130
|
};
|
|
1056
|
-
if (t >=
|
|
1057
|
-
return r =
|
|
1058
|
-
segment:
|
|
1131
|
+
if (t >= n)
|
|
1132
|
+
return r = s.slice(0, -1), o = rt(r), a = n - o, c = s[i], {
|
|
1133
|
+
segment: c,
|
|
1059
1134
|
index: i,
|
|
1060
|
-
length:
|
|
1135
|
+
length: a,
|
|
1061
1136
|
lengthAtSegment: o
|
|
1062
1137
|
};
|
|
1063
|
-
const
|
|
1138
|
+
const l = [];
|
|
1064
1139
|
for (; i > 0; )
|
|
1065
|
-
|
|
1066
|
-
segment:
|
|
1140
|
+
c = r[i], r = r.slice(0, -1), o = rt(r), a = n - o, n = o, l.push({
|
|
1141
|
+
segment: c,
|
|
1067
1142
|
index: i,
|
|
1068
|
-
length:
|
|
1143
|
+
length: a,
|
|
1069
1144
|
lengthAtSegment: o
|
|
1070
1145
|
}), i -= 1;
|
|
1071
|
-
return
|
|
1072
|
-
},
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
[i] = a;
|
|
1077
|
-
const m = i.toUpperCase();
|
|
1078
|
-
return m === "Z" ? (t = r, n = s) : ([t, n] = a.slice(-2), m === "M" && (r = t, s = n)), c.x = t, c.y = n, a;
|
|
1079
|
-
});
|
|
1080
|
-
}, pt = (e, t) => {
|
|
1081
|
-
const n = q(e), r = rt(n), s = W(n), i = (M) => {
|
|
1082
|
-
const b = M.x - t.x, w = M.y - t.y;
|
|
1083
|
-
return b * b + w * w;
|
|
1146
|
+
return l.find(({ lengthAtSegment: u }) => u <= t);
|
|
1147
|
+
}, Nt = (e, t) => {
|
|
1148
|
+
const s = R(e), r = ut(s), n = rt(r), i = (M) => {
|
|
1149
|
+
const d = M.x - t.x, v = M.y - t.y;
|
|
1150
|
+
return d * d + v * v;
|
|
1084
1151
|
};
|
|
1085
|
-
let o = 8,
|
|
1086
|
-
for (let M = 0; M <=
|
|
1087
|
-
|
|
1152
|
+
let o = 8, a, c = { x: 0, y: 0 }, l = 0, u = 0, m = 1 / 0;
|
|
1153
|
+
for (let M = 0; M <= n; M += o)
|
|
1154
|
+
a = at(r, M), l = i(a), l < m && (c = a, u = M, m = l);
|
|
1088
1155
|
o /= 2;
|
|
1089
|
-
let
|
|
1090
|
-
for (; o > 1e-6 && (h =
|
|
1156
|
+
let f, y, h = 0, x = 0, b = 0, A = 0;
|
|
1157
|
+
for (; o > 1e-6 && (h = u - o, f = at(r, h), b = i(f), x = u + o, y = at(r, x), A = i(y), h >= 0 && b < m ? (c = f, u = h, m = b) : x <= n && A < m ? (c = y, u = x, m = A) : o /= 2, !(o < 1e-5)); )
|
|
1091
1158
|
;
|
|
1092
|
-
const
|
|
1093
|
-
return { closest:
|
|
1094
|
-
},
|
|
1095
|
-
|
|
1096
|
-
return
|
|
1097
|
-
|
|
1159
|
+
const w = Ht(s, u), N = Math.sqrt(m);
|
|
1160
|
+
return { closest: c, distance: N, segment: w };
|
|
1161
|
+
}, He = (e, t) => Nt(e, t).closest, Ue = (e, t, s, r, n, i, o, a) => 3 * ((a - t) * (s + n) - (o - e) * (r + i) + r * (e - n) - s * (t - i) + a * (n + e / 3) - o * (i + t / 3)) / 20, Pe = (e) => {
|
|
1162
|
+
let t = 0, s = 0, r = 0;
|
|
1163
|
+
return gt(e).map((n) => {
|
|
1164
|
+
switch (n[0]) {
|
|
1165
|
+
case "M":
|
|
1166
|
+
return [, t, s] = n, 0;
|
|
1167
|
+
default:
|
|
1168
|
+
return r = Ue(t, s, n[1], n[2], n[3], n[4], n[5], n[6]), [t, s] = n.slice(-2), r;
|
|
1169
|
+
}
|
|
1170
|
+
}).reduce((n, i) => n + i, 0);
|
|
1171
|
+
}, Xe = (e) => Pe(gt(e)) >= 0, Jt = (e) => {
|
|
1172
|
+
if (!e)
|
|
1173
|
+
return {
|
|
1174
|
+
x: 0,
|
|
1175
|
+
y: 0,
|
|
1176
|
+
width: 0,
|
|
1177
|
+
height: 0,
|
|
1178
|
+
x2: 0,
|
|
1179
|
+
y2: 0,
|
|
1180
|
+
cx: 0,
|
|
1181
|
+
cy: 0,
|
|
1182
|
+
cz: 0
|
|
1183
|
+
};
|
|
1184
|
+
const t = R(e);
|
|
1185
|
+
let s = [], r = "M";
|
|
1186
|
+
const n = 0, i = 0;
|
|
1187
|
+
let o = 0, a = 0;
|
|
1188
|
+
const c = [], l = [];
|
|
1189
|
+
let u = { x: n, y: i }, m = { x: n, y: i };
|
|
1190
|
+
const f = { ...X };
|
|
1191
|
+
j(t, (N, M, d, v) => {
|
|
1192
|
+
f.x = d, f.y = v;
|
|
1193
|
+
const L = G(N, f);
|
|
1194
|
+
[r] = L, s = [d, v].concat(L.slice(1)), r === "M" ? ([, o, a] = L, u = { x: o, y: a }, m = { x: o, y: a }) : r === "L" ? { min: u, max: m } = zt(s[0], s[1], s[2], s[3]) : r === "A" ? { min: u, max: m } = pe(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8]) : r === "C" ? { min: u, max: m } = Te(s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7]) : r === "Q" ? { min: u, max: m } = ze(s[0], s[1], s[2], s[3], s[4], s[5]) : r === "Z" && (s = [d, v, o, a], { min: u, max: m } = zt(s[0], s[1], s[2], s[3])), c.push(u), l.push(m);
|
|
1195
|
+
const T = L.length;
|
|
1196
|
+
f.x1 = +L[T - 2], f.y1 = +L[T - 1], f.x2 = +L[T - 4] || f.x1, f.y2 = +L[T - 3] || f.y1;
|
|
1197
|
+
});
|
|
1198
|
+
const y = Math.min(...c.map((N) => N.x)), h = Math.max(...l.map((N) => N.x)), x = Math.min(...c.map((N) => N.y)), b = Math.max(...l.map((N) => N.y)), A = h - y, w = b - x;
|
|
1199
|
+
return {
|
|
1200
|
+
width: A,
|
|
1201
|
+
height: w,
|
|
1202
|
+
x: y,
|
|
1203
|
+
y: x,
|
|
1204
|
+
x2: h,
|
|
1205
|
+
y2: b,
|
|
1206
|
+
cx: y + A / 2,
|
|
1207
|
+
cy: x + w / 2,
|
|
1208
|
+
// an estimated guess
|
|
1209
|
+
cz: Math.max(A, w) + Math.min(A, w) / 2
|
|
1210
|
+
};
|
|
1211
|
+
}, Je = (e, t) => Ht(e, t).segment, Ye = (e, t) => Nt(e, t).segment, Lt = (e) => Array.isArray(e) && e.every((t) => {
|
|
1212
|
+
const s = t[0].toLowerCase();
|
|
1213
|
+
return nt[s] === t.length - 1 && "achlmqstvz".includes(s) && t.slice(1).every(Number.isFinite);
|
|
1214
|
+
}) && e.length > 0, qe = (e) => Lt(e) && // `isPathArray` also checks if it's `Array`
|
|
1215
|
+
e.every(([t]) => t === t.toUpperCase()), ke = (e) => qe(e) && e.every(([t]) => "ACLMQZ".includes(t)), Ke = (e) => ke(e) && e.every(([t]) => "MC".includes(t)), We = (e, t) => {
|
|
1216
|
+
const { distance: s } = Nt(e, t);
|
|
1217
|
+
return Math.abs(s) < bt;
|
|
1218
|
+
}, Ve = (e) => Lt(e) && // `isPathArray` checks if it's `Array`
|
|
1219
|
+
e.slice(1).every(([t]) => t === t.toLowerCase()), Ie = (e) => {
|
|
1098
1220
|
if (typeof e != "string" || !e.length)
|
|
1099
1221
|
return !1;
|
|
1100
|
-
const t = new
|
|
1101
|
-
for (
|
|
1102
|
-
|
|
1222
|
+
const t = new Rt(e);
|
|
1223
|
+
for (st(t); t.index < t.max && !t.err.length; )
|
|
1224
|
+
Et(t);
|
|
1103
1225
|
return !t.err.length && "mM".includes(t.segments[0][0]);
|
|
1104
|
-
},
|
|
1105
|
-
const n = t[0].toLowerCase();
|
|
1106
|
-
return tt[n] === t.length - 1 && "achlmqstvz".includes(n) && t.slice(1).every(Number.isFinite);
|
|
1107
|
-
}) && e.length > 0, le = (e) => dt(e) && // `isPathArray` also checks if it's `Array`
|
|
1108
|
-
e.every(([t]) => t === t.toUpperCase()), Ve = (e) => dt(e) && // `isPathArray` checks if it's `Array`
|
|
1109
|
-
e.slice(1).every(([t]) => t === t.toLowerCase()), ae = (e) => le(e) && e.every(([t]) => "ACLMQZ".includes(t)), _e = (e) => ae(e) && e.every(([t]) => "MC".includes(t)), ut = {
|
|
1226
|
+
}, mt = {
|
|
1110
1227
|
line: ["x1", "y1", "x2", "y2"],
|
|
1111
1228
|
circle: ["cx", "cy", "r"],
|
|
1112
1229
|
ellipse: ["cx", "cy", "rx", "ry"],
|
|
@@ -1114,316 +1231,271 @@ e.slice(1).every(([t]) => t === t.toLowerCase()), ae = (e) => le(e) && e.every((
|
|
|
1114
1231
|
polygon: ["points"],
|
|
1115
1232
|
polyline: ["points"],
|
|
1116
1233
|
glyph: ["d"]
|
|
1117
|
-
},
|
|
1118
|
-
let { x1: t, y1:
|
|
1119
|
-
return [t,
|
|
1120
|
-
["M", t,
|
|
1121
|
-
["L", r,
|
|
1234
|
+
}, Ge = (e) => {
|
|
1235
|
+
let { x1: t, y1: s, x2: r, y2: n } = e;
|
|
1236
|
+
return [t, s, r, n] = [t, s, r, n].map((i) => +i), [
|
|
1237
|
+
["M", t, s],
|
|
1238
|
+
["L", r, n]
|
|
1122
1239
|
];
|
|
1123
|
-
},
|
|
1124
|
-
const t = [],
|
|
1240
|
+
}, tn = (e) => {
|
|
1241
|
+
const t = [], s = (e.points || "").trim().split(/[\s|,]/).map((n) => +n);
|
|
1125
1242
|
let r = 0;
|
|
1126
|
-
for (; r <
|
|
1127
|
-
t.push([r ? "L" : "M",
|
|
1243
|
+
for (; r < s.length; )
|
|
1244
|
+
t.push([r ? "L" : "M", s[r], s[r + 1]]), r += 2;
|
|
1128
1245
|
return e.type === "polygon" ? [...t, ["z"]] : t;
|
|
1129
|
-
},
|
|
1130
|
-
let { cx: t, cy:
|
|
1131
|
-
return [t,
|
|
1132
|
-
["M", t - r,
|
|
1246
|
+
}, en = (e) => {
|
|
1247
|
+
let { cx: t, cy: s, r } = e;
|
|
1248
|
+
return [t, s, r] = [t, s, r].map((n) => +n), [
|
|
1249
|
+
["M", t - r, s],
|
|
1133
1250
|
["a", r, r, 0, 1, 0, 2 * r, 0],
|
|
1134
1251
|
["a", r, r, 0, 1, 0, -2 * r, 0]
|
|
1135
1252
|
];
|
|
1136
|
-
},
|
|
1137
|
-
let { cx: t, cy:
|
|
1138
|
-
return [t,
|
|
1139
|
-
["M", t - r,
|
|
1140
|
-
["a", r,
|
|
1141
|
-
["a", r,
|
|
1253
|
+
}, nn = (e) => {
|
|
1254
|
+
let { cx: t, cy: s } = e, r = e.rx || 0, n = e.ry || r;
|
|
1255
|
+
return [t, s, r, n] = [t, s, r, n].map((i) => +i), [
|
|
1256
|
+
["M", t - r, s],
|
|
1257
|
+
["a", r, n, 0, 1, 0, 2 * r, 0],
|
|
1258
|
+
["a", r, n, 0, 1, 0, -2 * r, 0]
|
|
1142
1259
|
];
|
|
1143
|
-
},
|
|
1144
|
-
const t = +e.x || 0,
|
|
1260
|
+
}, sn = (e) => {
|
|
1261
|
+
const t = +e.x || 0, s = +e.y || 0, r = +e.width, n = +e.height;
|
|
1145
1262
|
let i = +(e.rx || 0), o = +(e.ry || i);
|
|
1146
|
-
return i || o ? (i * 2 > r && (i -= (i * 2 - r) / 2), o * 2 >
|
|
1147
|
-
["M", t + i,
|
|
1263
|
+
return i || o ? (i * 2 > r && (i -= (i * 2 - r) / 2), o * 2 > n && (o -= (o * 2 - n) / 2), [
|
|
1264
|
+
["M", t + i, s],
|
|
1148
1265
|
["h", r - i * 2],
|
|
1149
1266
|
["s", i, 0, i, o],
|
|
1150
|
-
["v",
|
|
1267
|
+
["v", n - o * 2],
|
|
1151
1268
|
["s", 0, o, -i, o],
|
|
1152
1269
|
["h", -r + i * 2],
|
|
1153
1270
|
["s", -i, 0, -i, -o],
|
|
1154
|
-
["v", -
|
|
1271
|
+
["v", -n + o * 2],
|
|
1155
1272
|
["s", 0, -o, i, -o]
|
|
1156
|
-
]) : [["M", t,
|
|
1157
|
-
},
|
|
1273
|
+
]) : [["M", t, s], ["h", r], ["v", n], ["H", t], ["Z"]];
|
|
1274
|
+
}, Ee = (e, t) => {
|
|
1158
1275
|
const r = (t || document).defaultView || /* istanbul ignore next */
|
|
1159
|
-
window,
|
|
1160
|
-
if (o && [...
|
|
1276
|
+
window, n = Object.keys(mt), i = e instanceof r.SVGElement, o = i ? e.tagName : null;
|
|
1277
|
+
if (o && [...n, "path"].every((m) => o !== m))
|
|
1161
1278
|
throw TypeError(`${E}: "${o}" is not SVGElement`);
|
|
1162
|
-
const
|
|
1163
|
-
i ?
|
|
1164
|
-
|
|
1165
|
-
}) : Object.assign(
|
|
1166
|
-
let
|
|
1167
|
-
return
|
|
1279
|
+
const a = i ? o : e.type, c = mt[a], l = { type: a };
|
|
1280
|
+
i ? c.forEach((m) => {
|
|
1281
|
+
l[m] = e.getAttribute(m);
|
|
1282
|
+
}) : Object.assign(l, e);
|
|
1283
|
+
let u = [];
|
|
1284
|
+
return a === "circle" ? u = en(l) : a === "ellipse" ? u = nn(l) : ["polyline", "polygon"].includes(a) ? u = tn(l) : a === "rect" ? u = sn(l) : a === "line" ? u = Ge(l) : ["glyph", "path"].includes(a) && (u = R(
|
|
1168
1285
|
i ? e.getAttribute("d") || /* istanbul ignore next @preserve */
|
|
1169
1286
|
"" : e.d || ""
|
|
1170
|
-
)),
|
|
1171
|
-
},
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
})
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
const l = r.createElementNS("http://www.w3.org/2000/svg", "path"), a = o ? c : e.type, m = ut[a], u = { type: a }, g = st.round, f = me(e, r), h = f && f.length ? Ct(f, g) : "";
|
|
1186
|
-
return o ? (m.forEach((y) => {
|
|
1187
|
-
u[y] = e.getAttribute(y);
|
|
1188
|
-
}), Object.values(e.attributes).forEach(({ name: y, value: x }) => {
|
|
1189
|
-
m.includes(y) || l.setAttribute(y, x);
|
|
1190
|
-
})) : (Object.assign(u, e), Object.keys(u).forEach((y) => {
|
|
1191
|
-
!m.includes(y) && y !== "type" && l.setAttribute(
|
|
1192
|
-
y.replace(/[A-Z]/g, (x) => `-${x.toLowerCase()}`),
|
|
1193
|
-
u[y]
|
|
1287
|
+
)), Lt(u) && u.length ? u : !1;
|
|
1288
|
+
}, rn = (e, t, s) => {
|
|
1289
|
+
const r = s || document, n = r.defaultView || /* istanbul ignore next */
|
|
1290
|
+
window, i = Object.keys(mt), o = e instanceof n.SVGElement, a = o ? e.tagName : null;
|
|
1291
|
+
if (a === "path") throw TypeError(`${E}: "${a}" is already SVGPathElement`);
|
|
1292
|
+
if (a && i.every((x) => a !== x)) throw TypeError(`${E}: "${a}" is not SVGElement`);
|
|
1293
|
+
const c = r.createElementNS("http://www.w3.org/2000/svg", "path"), l = o ? a : e.type, u = mt[l], m = { type: l }, f = V.round, y = Ee(e, r), h = y && y.length ? $t(y, f) : "";
|
|
1294
|
+
return o ? (u.forEach((x) => {
|
|
1295
|
+
m[x] = e.getAttribute(x);
|
|
1296
|
+
}), Object.values(e.attributes).forEach(({ name: x, value: b }) => {
|
|
1297
|
+
u.includes(x) || c.setAttribute(x, b);
|
|
1298
|
+
})) : (Object.assign(m, e), Object.keys(m).forEach((x) => {
|
|
1299
|
+
!u.includes(x) && x !== "type" && c.setAttribute(
|
|
1300
|
+
x.replace(/[A-Z]/g, (b) => `-${b.toLowerCase()}`),
|
|
1301
|
+
m[x]
|
|
1194
1302
|
);
|
|
1195
|
-
})),
|
|
1196
|
-
},
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
[i] = c;
|
|
1219
|
-
const a = V(c, l), m = i.toUpperCase();
|
|
1220
|
-
return m === "Z" ? (t = r, n = s) : m === "H" ? [, t] = a : m === "V" ? [, n] = a : ([t, n] = a.slice(-2), m === "M" && (r = t, s = n)), l.x = t, l.y = n, a;
|
|
1221
|
-
});
|
|
1222
|
-
}, nn = (e, t, n) => {
|
|
1223
|
-
const [r] = e, { x: s, y: i } = t, o = e.slice(1).map(Number), c = r.toLowerCase();
|
|
1224
|
-
if (n === 0 && r === "M")
|
|
1225
|
-
return e;
|
|
1226
|
-
if (r !== c) {
|
|
1227
|
-
if (c === "a")
|
|
1228
|
-
return [
|
|
1229
|
-
c,
|
|
1230
|
-
o[0],
|
|
1231
|
-
o[1],
|
|
1232
|
-
o[2],
|
|
1233
|
-
o[3],
|
|
1234
|
-
o[4],
|
|
1235
|
-
o[5] - s,
|
|
1236
|
-
o[6] - i
|
|
1237
|
-
];
|
|
1238
|
-
if (c === "v")
|
|
1239
|
-
return [c, o[0] - i];
|
|
1240
|
-
if (c === "h")
|
|
1241
|
-
return [c, o[0] - s];
|
|
1242
|
-
{
|
|
1243
|
-
const l = o.map((a, m) => a - (m % 2 ? i : s));
|
|
1244
|
-
return [c, ...l];
|
|
1245
|
-
}
|
|
1246
|
-
}
|
|
1247
|
-
return e;
|
|
1248
|
-
}, vt = (e) => {
|
|
1249
|
-
let t = 0, n = 0, r = 0, s = 0, i = "M";
|
|
1250
|
-
const o = q(e);
|
|
1251
|
-
return D(o, (c, l, a) => {
|
|
1252
|
-
[i] = c;
|
|
1253
|
-
const m = nn(c, l, a), [u] = m, g = i.toUpperCase(), f = i.toLowerCase(), h = u === f;
|
|
1254
|
-
return g === "Z" ? (t = r, n = s) : g === "H" ? ([, t] = m, t += h ? l.x : (
|
|
1255
|
-
/* istanbul ignore next @preserve */
|
|
1256
|
-
0
|
|
1257
|
-
)) : g === "V" ? ([, n] = m, n += h ? l.y : (
|
|
1258
|
-
/* istanbul ignore next @preserve */
|
|
1259
|
-
0
|
|
1260
|
-
)) : ([t, n] = m.slice(-2), t += h ? l.x : 0, n += h ? l.y : 0, g === "M" && (r = t, s = n)), l.x = t, l.y = n, m;
|
|
1261
|
-
});
|
|
1262
|
-
}, sn = (e, t, n, r) => {
|
|
1263
|
-
const [s] = e, i = (p) => Math.round(p * 10 ** 4) / 10 ** 4, o = e.slice(1), c = t.slice(1), { x1: l, y1: a, x2: m, y2: u, x: g, y: f } = n;
|
|
1264
|
-
let h = e;
|
|
1265
|
-
const [y, x] = c.slice(-2);
|
|
1266
|
-
if ("TQ".includes(s) || (n.qx = null, n.qy = null), ["V", "H", "S", "T", "Z"].includes(s))
|
|
1267
|
-
h = [s, ...o];
|
|
1268
|
-
else if (s === "L")
|
|
1269
|
-
i(g) === i(y) ? h = ["V", x] : i(f) === i(x) && (h = ["H", y]);
|
|
1270
|
-
else if (s === "C") {
|
|
1271
|
-
const [p, d] = c;
|
|
1272
|
-
"CS".includes(r) && (i(p) === i(l * 2 - m) && i(d) === i(a * 2 - u) || i(l) === i(m * 2 - g) && i(a) === i(u * 2 - f)) && (h = ["S", ...c.slice(-4)]), n.x1 = p, n.y1 = d;
|
|
1273
|
-
} else if (s === "Q") {
|
|
1274
|
-
const [p, d] = c;
|
|
1275
|
-
n.qx = p, n.qy = d, "QT".includes(r) && (i(p) === i(l * 2 - m) && i(d) === i(a * 2 - u) || i(l) === i(m * 2 - g) && i(a) === i(u * 2 - f)) && (h = ["T", ...c.slice(-2)]);
|
|
1303
|
+
})), Ie(h) ? (c.setAttribute("d", h), t && o && (e.before(c, e), e.remove()), c) : !1;
|
|
1304
|
+
}, Re = (e) => {
|
|
1305
|
+
let t = new C();
|
|
1306
|
+
const { origin: s } = e, [r, n] = s, { translate: i } = e, { rotate: o } = e, { skew: a } = e, { scale: c } = e;
|
|
1307
|
+
return Array.isArray(i) && i.length >= 2 && i.every((l) => !Number.isNaN(+l)) && i.some((l) => l !== 0) ? t = t.translate(...i) : typeof i == "number" && !Number.isNaN(i) && (t = t.translate(i)), (o || a || c) && (t = t.translate(r, n), Array.isArray(o) && o.length >= 2 && o.every((l) => !Number.isNaN(+l)) && o.some((l) => l !== 0) ? t = t.rotate(...o) : typeof o == "number" && !Number.isNaN(o) && (t = t.rotate(o)), Array.isArray(a) && a.length === 2 && a.every((l) => !Number.isNaN(+l)) && a.some((l) => l !== 0) ? (t = a[0] ? t.skewX(a[0]) : t, t = a[1] ? t.skewY(a[1]) : t) : typeof a == "number" && !Number.isNaN(a) && (t = t.skewX(a)), Array.isArray(c) && c.length >= 2 && c.every((l) => !Number.isNaN(+l)) && c.some((l) => l !== 1) ? t = t.scale(...c) : typeof c == "number" && !Number.isNaN(c) && (t = t.scale(c)), t = t.translate(-r, -n)), t;
|
|
1308
|
+
}, je = (e, t, s, r) => {
|
|
1309
|
+
const [n] = e, { round: i } = V, o = typeof i == "number" ? i : (
|
|
1310
|
+
/* istanbul ignore next */
|
|
1311
|
+
4
|
|
1312
|
+
), a = t.slice(1), { x1: c, y1: l, x2: u, y2: m, x: f, y } = s, [h, x] = a.slice(-2), b = e;
|
|
1313
|
+
if ("TQ".includes(n) || (s.qx = null, s.qy = null), n === "L") {
|
|
1314
|
+
if (z(f, o) === z(h, o))
|
|
1315
|
+
return ["V", x];
|
|
1316
|
+
if (z(y, o) === z(x, o))
|
|
1317
|
+
return ["H", h];
|
|
1318
|
+
} else if (n === "C") {
|
|
1319
|
+
const [A, w] = a;
|
|
1320
|
+
if (s.x1 = A, s.y1 = w, "CS".includes(r) && (z(A, o) === z(c * 2 - u, o) && z(w, o) === z(l * 2 - m, o) || z(c, o) === z(u * 2 - f, o) && z(l, o) === z(m * 2 - y, o)))
|
|
1321
|
+
return ["S", a[2], a[3], a[4], a[5]];
|
|
1322
|
+
} else if (n === "Q") {
|
|
1323
|
+
const [A, w] = a;
|
|
1324
|
+
if (s.qx = A, s.qy = w, "QT".includes(r) && z(A, o) === z(c * 2 - u, o) && z(w, o) === z(l * 2 - m, o))
|
|
1325
|
+
return ["T", a[2], a[3]];
|
|
1276
1326
|
}
|
|
1277
|
-
return
|
|
1278
|
-
},
|
|
1279
|
-
const
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
[a, m] = x.slice(-2).map(Number), c === "M" && (u = a, g = m);
|
|
1327
|
+
return b;
|
|
1328
|
+
}, dt = (e, t) => {
|
|
1329
|
+
const s = e.slice(1).map((r) => z(r, t));
|
|
1330
|
+
return [e[0]].concat(s);
|
|
1331
|
+
}, Yt = (e, t) => {
|
|
1332
|
+
const s = xt(e), r = typeof t == "number" && t >= 0 ? t : (
|
|
1333
|
+
/* istanbul ignore next @preserve */
|
|
1334
|
+
2
|
|
1335
|
+
), n = { ...X }, i = [];
|
|
1336
|
+
let o = "M", a = "Z";
|
|
1337
|
+
return j(s, (c, l, u, m) => {
|
|
1338
|
+
n.x = u, n.y = m;
|
|
1339
|
+
const f = G(c, n);
|
|
1340
|
+
let y = c;
|
|
1341
|
+
if ([o] = c, i[l] = o, l) {
|
|
1342
|
+
a = i[l - 1];
|
|
1343
|
+
const x = je(c, f, n, a), b = dt(x, r), A = b.join(""), w = St(x, l, u, m), N = dt(w, r), M = N.join("");
|
|
1344
|
+
y = A.length < M.length ? b : N;
|
|
1296
1345
|
}
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1346
|
+
const h = f.length;
|
|
1347
|
+
return n.x1 = +f[h - 2], n.y1 = +f[h - 1], n.x2 = +f[h - 4] || n.x1, n.y2 = +f[h - 3] || n.y1, y;
|
|
1348
|
+
});
|
|
1349
|
+
}, on = (e, t) => {
|
|
1350
|
+
let s = C.Translate(t[0], t[1], t[2]);
|
|
1351
|
+
return [, , , s.m44] = t, s = e.multiply(s), [s.m41, s.m42, s.m43, s.m44];
|
|
1352
|
+
}, It = (e, t, s) => {
|
|
1353
|
+
const [r, n, i] = s, [o, a, c] = on(e, [t[0], t[1], 0, 1]), l = o - r, u = a - n, m = c - i;
|
|
1354
|
+
return [
|
|
1355
|
+
// protect against division by ZERO
|
|
1356
|
+
l * (Math.abs(i) / Math.abs(m) || 1) + r,
|
|
1357
|
+
u * (Math.abs(i) / Math.abs(m) || 1) + n
|
|
1358
|
+
];
|
|
1359
|
+
}, cn = (e) => {
|
|
1302
1360
|
const t = e.slice(1).map(
|
|
1303
|
-
(
|
|
1304
|
-
).map((
|
|
1305
|
-
return [["M"
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
// normalized
|
|
1314
|
-
c: t[i][0],
|
|
1315
|
-
// pathCommand
|
|
1316
|
-
x: o,
|
|
1317
|
-
// x
|
|
1318
|
-
y: c
|
|
1319
|
-
// y
|
|
1320
|
-
};
|
|
1321
|
-
}).map((s, i, o) => {
|
|
1322
|
-
const c = s.seg, l = s.n, a = i && o[i - 1], m = o[i + 1], u = s.c, g = o.length, f = i ? o[i - 1].x : o[g - 1].x, h = i ? o[i - 1].y : o[g - 1].y;
|
|
1323
|
-
let y = [];
|
|
1324
|
-
switch (u) {
|
|
1361
|
+
(s, r, n) => r ? n[r - 1].slice(-2).concat(s.slice(1)) : e[0].slice(1).concat(s.slice(1))
|
|
1362
|
+
).map((s) => s.map((r, n) => s[s.length - n - 2 * (1 - n % 2)])).reverse();
|
|
1363
|
+
return [["M"].concat(t[0].slice(0, 2))].concat(
|
|
1364
|
+
t.map((s) => ["C"].concat(s.slice(2)))
|
|
1365
|
+
);
|
|
1366
|
+
}, yt = (e) => {
|
|
1367
|
+
const t = xt(e), s = ut(t), r = t.length, n = t[r - 1][0] === "Z", i = j(t, (o, a) => {
|
|
1368
|
+
const c = s[a], l = a && t[a - 1], u = l && l[0], m = t[a + 1], f = m && m[0], [y] = o, [h, x] = s[a ? a - 1 : r - 1].slice(-2);
|
|
1369
|
+
let b = o;
|
|
1370
|
+
switch (y) {
|
|
1325
1371
|
case "M":
|
|
1326
|
-
|
|
1372
|
+
b = n ? ["Z"] : [y, h, x];
|
|
1327
1373
|
break;
|
|
1328
1374
|
case "A":
|
|
1329
|
-
|
|
1375
|
+
b = [
|
|
1376
|
+
y,
|
|
1377
|
+
o[1],
|
|
1378
|
+
o[2],
|
|
1379
|
+
o[3],
|
|
1380
|
+
o[4],
|
|
1381
|
+
o[5] === 1 ? 0 : 1,
|
|
1382
|
+
h,
|
|
1383
|
+
x
|
|
1384
|
+
];
|
|
1330
1385
|
break;
|
|
1331
1386
|
case "C":
|
|
1332
|
-
m &&
|
|
1387
|
+
m && f === "S" ? b = ["S", o[1], o[2], h, x] : b = [y, o[3], o[4], o[1], o[2], h, x];
|
|
1333
1388
|
break;
|
|
1334
1389
|
case "S":
|
|
1335
|
-
|
|
1390
|
+
u && "CS".includes(u) && (!m || f !== "S") ? b = [
|
|
1391
|
+
"C",
|
|
1392
|
+
c[3],
|
|
1393
|
+
c[4],
|
|
1394
|
+
c[1],
|
|
1395
|
+
c[2],
|
|
1396
|
+
h,
|
|
1397
|
+
x
|
|
1398
|
+
] : b = [y, c[1], c[2], h, x];
|
|
1336
1399
|
break;
|
|
1337
1400
|
case "Q":
|
|
1338
|
-
m &&
|
|
1401
|
+
m && f === "T" ? b = ["T", h, x] : b = [y, o[1], o[2], h, x];
|
|
1339
1402
|
break;
|
|
1340
1403
|
case "T":
|
|
1341
|
-
|
|
1404
|
+
u && "QT".includes(u) && (!m || f !== "T") ? b = ["Q", c[1], c[2], h, x] : b = [y, h, x];
|
|
1342
1405
|
break;
|
|
1343
1406
|
case "Z":
|
|
1344
|
-
|
|
1407
|
+
b = ["M", h, x];
|
|
1345
1408
|
break;
|
|
1346
1409
|
case "H":
|
|
1347
|
-
|
|
1410
|
+
b = [y, h];
|
|
1348
1411
|
break;
|
|
1349
1412
|
case "V":
|
|
1350
|
-
|
|
1413
|
+
b = [y, x];
|
|
1351
1414
|
break;
|
|
1352
1415
|
default:
|
|
1353
|
-
|
|
1416
|
+
b = [y].concat(o.slice(1, -2), h, x);
|
|
1354
1417
|
}
|
|
1355
|
-
return
|
|
1418
|
+
return b;
|
|
1356
1419
|
});
|
|
1357
|
-
return n ?
|
|
1358
|
-
},
|
|
1359
|
-
let
|
|
1360
|
-
return
|
|
1361
|
-
|
|
1362
|
-
|
|
1420
|
+
return n ? i.reverse() : [i[0]].concat(i.slice(1).reverse());
|
|
1421
|
+
}, an = (e, t) => {
|
|
1422
|
+
let { round: s } = V;
|
|
1423
|
+
return s = t === "off" || typeof t == "number" && t >= 0 ? t : typeof s == "number" && s >= 0 ? s : (
|
|
1424
|
+
/* istanbul ignore next @preserve */
|
|
1425
|
+
"off"
|
|
1426
|
+
), s === "off" ? e.slice(0) : j(e, (r) => dt(r, s));
|
|
1427
|
+
}, ln = (e, t = 0.5) => {
|
|
1428
|
+
const s = t, r = e.slice(0, 2), n = e.slice(2, 4), i = e.slice(4, 6), o = e.slice(6, 8), a = O(r, n, s), c = O(n, i, s), l = O(i, o, s), u = O(a, c, s), m = O(c, l, s), f = O(u, m, s);
|
|
1363
1429
|
return [
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
m * (Math.abs(i) / Math.abs(u) || 1) + s
|
|
1430
|
+
["C", a[0], a[1], u[0], u[1], f[0], f[1]],
|
|
1431
|
+
["C", m[0], m[1], l[0], l[1], o[0], o[1]]
|
|
1367
1432
|
];
|
|
1368
|
-
},
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1433
|
+
}, Kt = (e) => {
|
|
1434
|
+
const t = [];
|
|
1435
|
+
let s, r = -1, n = 0, i = 0, o = 0, a = 0;
|
|
1436
|
+
const c = { ...X };
|
|
1437
|
+
return e.forEach((l) => {
|
|
1438
|
+
const [u] = l, m = u.toUpperCase(), f = u.toLowerCase(), y = u === f, h = l.slice(1);
|
|
1439
|
+
m === "M" ? (r += 1, [n, i] = h, n += y ? c.x : 0, i += y ? c.y : 0, o = n, a = i, s = [y ? [m, o, a] : l]) : (m === "Z" ? (n = o, i = a) : m === "H" ? ([, n] = l, n += y ? c.x : (
|
|
1440
|
+
/* istanbul ignore next @preserve */
|
|
1441
|
+
0
|
|
1442
|
+
)) : m === "V" ? ([, i] = l, i += y ? c.y : (
|
|
1443
|
+
/* istanbul ignore next @preserve */
|
|
1444
|
+
0
|
|
1445
|
+
)) : ([n, i] = l.slice(-2), n += y ? c.x : 0, i += y ? c.y : 0), s.push(l)), c.x = n, c.y = i, t[r] = s;
|
|
1446
|
+
}), t;
|
|
1447
|
+
}, Wt = (e, t) => {
|
|
1448
|
+
let s = 0, r = 0, n = 0, i = 0, o = 0, a = 0, c = "M";
|
|
1449
|
+
const l = { ...X }, u = R(e), m = t && Object.keys(t);
|
|
1450
|
+
if (!t || m && !m.length) return u.slice(0);
|
|
1451
|
+
t.origin || Object.assign(t, { origin: V.origin });
|
|
1452
|
+
const f = t.origin, y = Re(t);
|
|
1453
|
+
return y.isIdentity ? u.slice(0) : j(u, (h, x, b, A) => {
|
|
1454
|
+
l.x = b, l.y = A, [c] = h;
|
|
1455
|
+
const w = c.toUpperCase(), M = w !== c ? jt(h, x, b, A) : h.slice(0);
|
|
1456
|
+
let d = w === "A" ? Zt(M, l) : ["V", "H"].includes(w) ? G(M, l) : M;
|
|
1457
|
+
c = d[0];
|
|
1458
|
+
const v = c === "C" && d.length > 7, L = v ? d.slice(0, 7) : d.slice(0);
|
|
1459
|
+
if (v && (u.splice(x + 1, 0, ["C"].concat(d.slice(7))), d = L), c === "L")
|
|
1460
|
+
[n, i] = It(y, [d[1], d[2]], f), s !== n && r !== i ? d = ["L", n, i] : r === i ? d = ["H", n] : s === n && (d = ["V", i]);
|
|
1461
|
+
else
|
|
1462
|
+
for (o = 1, a = d.length; o < a; o += 2)
|
|
1463
|
+
[n, i] = It(y, [+d[o], +d[o + 1]], f), d[o] = n, d[o + 1] = i;
|
|
1464
|
+
s = n, r = i;
|
|
1465
|
+
const T = L.length;
|
|
1466
|
+
return l.x1 = +L[T - 2], l.y1 = +L[T - 1], l.x2 = +L[T - 4] || l.x1, l.y2 = +L[T - 3] || l.y1, d;
|
|
1388
1467
|
});
|
|
1389
|
-
}, cn = (e, t = 0.5) => {
|
|
1390
|
-
const n = t, r = e.slice(0, 2), s = e.slice(2, 4), i = e.slice(4, 6), o = e.slice(6, 8), c = R(r, s, n), l = R(s, i, n), a = R(i, o, n), m = R(c, l, n), u = R(l, a, n), g = R(m, u, n);
|
|
1391
|
-
return [
|
|
1392
|
-
["C", ...c, ...m, ...g],
|
|
1393
|
-
["C", ...u, ...a, ...o]
|
|
1394
|
-
];
|
|
1395
1468
|
};
|
|
1396
|
-
class
|
|
1469
|
+
class p {
|
|
1397
1470
|
/**
|
|
1398
1471
|
* @constructor
|
|
1399
1472
|
* @param pathValue the path string
|
|
1400
1473
|
* @param config instance options
|
|
1401
1474
|
*/
|
|
1402
|
-
constructor(t,
|
|
1403
|
-
const r =
|
|
1404
|
-
if (
|
|
1405
|
-
throw TypeError(`${E}: "pathValue" is ${
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
Number.isNaN(m) ? 0 : m,
|
|
1475
|
+
constructor(t, s) {
|
|
1476
|
+
const r = s || {}, n = typeof t > "u";
|
|
1477
|
+
if (n || !t.length)
|
|
1478
|
+
throw TypeError(`${E}: "pathValue" is ${n ? "undefined" : "empty"}`);
|
|
1479
|
+
this.segments = R(t);
|
|
1480
|
+
const { round: i, origin: o } = r;
|
|
1481
|
+
let a;
|
|
1482
|
+
Number.isInteger(i) || i === "off" ? a = i : a = V.round;
|
|
1483
|
+
let c = V.origin;
|
|
1484
|
+
if (Array.isArray(o) && o.length >= 2) {
|
|
1485
|
+
const [l, u, m] = o.map(Number);
|
|
1486
|
+
c = [
|
|
1487
|
+
Number.isNaN(l) ? 0 : l,
|
|
1416
1488
|
Number.isNaN(u) ? 0 : u,
|
|
1417
|
-
Number.isNaN(
|
|
1489
|
+
Number.isNaN(m) ? 0 : m
|
|
1418
1490
|
];
|
|
1419
1491
|
}
|
|
1420
|
-
return this.round =
|
|
1492
|
+
return this.round = a, this.origin = c, this;
|
|
1421
1493
|
}
|
|
1422
1494
|
get bbox() {
|
|
1423
|
-
return
|
|
1495
|
+
return Jt(this.segments);
|
|
1424
1496
|
}
|
|
1425
1497
|
get length() {
|
|
1426
|
-
return
|
|
1498
|
+
return rt(this.segments);
|
|
1427
1499
|
}
|
|
1428
1500
|
/**
|
|
1429
1501
|
* Returns the path bounding box, equivalent to native `path.getBBox()`.
|
|
@@ -1452,7 +1524,7 @@ class A {
|
|
|
1452
1524
|
* @returns the requested point
|
|
1453
1525
|
*/
|
|
1454
1526
|
getPointAtLength(t) {
|
|
1455
|
-
return
|
|
1527
|
+
return at(this.segments, t);
|
|
1456
1528
|
}
|
|
1457
1529
|
/**
|
|
1458
1530
|
* Convert path to absolute values
|
|
@@ -1461,7 +1533,7 @@ class A {
|
|
|
1461
1533
|
*/
|
|
1462
1534
|
toAbsolute() {
|
|
1463
1535
|
const { segments: t } = this;
|
|
1464
|
-
return this.segments =
|
|
1536
|
+
return this.segments = xt(t), this;
|
|
1465
1537
|
}
|
|
1466
1538
|
/**
|
|
1467
1539
|
* Convert path to relative values
|
|
@@ -1470,7 +1542,7 @@ class A {
|
|
|
1470
1542
|
*/
|
|
1471
1543
|
toRelative() {
|
|
1472
1544
|
const { segments: t } = this;
|
|
1473
|
-
return this.segments =
|
|
1545
|
+
return this.segments = Xt(t), this;
|
|
1474
1546
|
}
|
|
1475
1547
|
/**
|
|
1476
1548
|
* Convert path to cubic-bezier values. In addition, un-necessary `Z`
|
|
@@ -1480,7 +1552,7 @@ class A {
|
|
|
1480
1552
|
*/
|
|
1481
1553
|
toCurve() {
|
|
1482
1554
|
const { segments: t } = this;
|
|
1483
|
-
return this.segments =
|
|
1555
|
+
return this.segments = gt(t), this;
|
|
1484
1556
|
}
|
|
1485
1557
|
/**
|
|
1486
1558
|
* Reverse the order of the segments and their values.
|
|
@@ -1490,9 +1562,9 @@ class A {
|
|
|
1490
1562
|
*/
|
|
1491
1563
|
reverse(t) {
|
|
1492
1564
|
this.toAbsolute();
|
|
1493
|
-
const { segments:
|
|
1565
|
+
const { segments: s } = this, r = Kt(s), n = r.length > 1 ? r : !1, i = n ? n.map((a, c) => t ? c ? yt(a) : a.slice(0) : yt(a)) : s.slice(0);
|
|
1494
1566
|
let o = [];
|
|
1495
|
-
return
|
|
1567
|
+
return n ? o = i.flat(1) : o = t ? s : yt(s), this.segments = o.slice(0), this;
|
|
1496
1568
|
}
|
|
1497
1569
|
/**
|
|
1498
1570
|
* Normalize path in 2 steps:
|
|
@@ -1503,7 +1575,7 @@ class A {
|
|
|
1503
1575
|
*/
|
|
1504
1576
|
normalize() {
|
|
1505
1577
|
const { segments: t } = this;
|
|
1506
|
-
return this.segments =
|
|
1578
|
+
return this.segments = ut(t), this;
|
|
1507
1579
|
}
|
|
1508
1580
|
/**
|
|
1509
1581
|
* Optimize `pathArray` values:
|
|
@@ -1514,8 +1586,8 @@ class A {
|
|
|
1514
1586
|
* @public
|
|
1515
1587
|
*/
|
|
1516
1588
|
optimize() {
|
|
1517
|
-
const { segments: t } = this;
|
|
1518
|
-
return this.segments =
|
|
1589
|
+
const { segments: t } = this, s = this.round === "off" ? 2 : this.round;
|
|
1590
|
+
return this.segments = Yt(t, s), this;
|
|
1519
1591
|
}
|
|
1520
1592
|
/**
|
|
1521
1593
|
* Transform path using values from an `Object` defined as `transformObject`.
|
|
@@ -1526,21 +1598,21 @@ class A {
|
|
|
1526
1598
|
* @public
|
|
1527
1599
|
*/
|
|
1528
1600
|
transform(t) {
|
|
1529
|
-
if (!t || typeof t != "object" || typeof t == "object" && !["translate", "rotate", "skew", "scale"].some((
|
|
1601
|
+
if (!t || typeof t != "object" || typeof t == "object" && !["translate", "rotate", "skew", "scale"].some((c) => c in t))
|
|
1530
1602
|
return this;
|
|
1531
1603
|
const {
|
|
1532
|
-
segments:
|
|
1533
|
-
origin: [r,
|
|
1604
|
+
segments: s,
|
|
1605
|
+
origin: [r, n, i]
|
|
1534
1606
|
} = this, o = {};
|
|
1535
|
-
for (const [
|
|
1536
|
-
|
|
1537
|
-
const { origin:
|
|
1538
|
-
if (Array.isArray(
|
|
1539
|
-
const [
|
|
1540
|
-
o.origin = [Number.isNaN(
|
|
1607
|
+
for (const [c, l] of Object.entries(t))
|
|
1608
|
+
c === "skew" && Array.isArray(l) || (c === "rotate" || c === "translate" || c === "origin" || c === "scale") && Array.isArray(l) ? o[c] = l.map(Number) : c !== "origin" && typeof Number(l) == "number" && (o[c] = Number(l));
|
|
1609
|
+
const { origin: a } = o;
|
|
1610
|
+
if (Array.isArray(a) && a.length >= 2) {
|
|
1611
|
+
const [c, l, u] = a.map(Number);
|
|
1612
|
+
o.origin = [Number.isNaN(c) ? r : c, Number.isNaN(l) ? n : l, u || i];
|
|
1541
1613
|
} else
|
|
1542
|
-
o.origin = [r,
|
|
1543
|
-
return this.segments =
|
|
1614
|
+
o.origin = [r, n, i];
|
|
1615
|
+
return this.segments = Wt(s, o), this;
|
|
1544
1616
|
}
|
|
1545
1617
|
/**
|
|
1546
1618
|
* Rotate path 180deg vertically
|
|
@@ -1548,8 +1620,8 @@ class A {
|
|
|
1548
1620
|
* @public
|
|
1549
1621
|
*/
|
|
1550
1622
|
flipX() {
|
|
1551
|
-
const { cx: t, cy:
|
|
1552
|
-
return this.transform({ rotate: [0, 180, 0], origin: [t,
|
|
1623
|
+
const { cx: t, cy: s } = this.bbox;
|
|
1624
|
+
return this.transform({ rotate: [0, 180, 0], origin: [t, s, 0] }), this;
|
|
1553
1625
|
}
|
|
1554
1626
|
/**
|
|
1555
1627
|
* Rotate path 180deg horizontally
|
|
@@ -1557,8 +1629,8 @@ class A {
|
|
|
1557
1629
|
* @public
|
|
1558
1630
|
*/
|
|
1559
1631
|
flipY() {
|
|
1560
|
-
const { cx: t, cy:
|
|
1561
|
-
return this.transform({ rotate: [180, 0, 0], origin: [t,
|
|
1632
|
+
const { cx: t, cy: s } = this.bbox;
|
|
1633
|
+
return this.transform({ rotate: [180, 0, 0], origin: [t, s, 0] }), this;
|
|
1562
1634
|
}
|
|
1563
1635
|
/**
|
|
1564
1636
|
* Export the current path to be used
|
|
@@ -1568,11 +1640,22 @@ class A {
|
|
|
1568
1640
|
* @return the path string
|
|
1569
1641
|
*/
|
|
1570
1642
|
toString() {
|
|
1571
|
-
return
|
|
1643
|
+
return $t(this.segments, this.round);
|
|
1572
1644
|
}
|
|
1573
1645
|
}
|
|
1574
|
-
|
|
1646
|
+
g(p, "CSSMatrix", C), g(p, "pathToAbsolute", xt), g(p, "pathToRelative", Xt), g(p, "pathToCurve", gt), g(p, "pathToString", $t), g(p, "arcTools", Be), g(p, "bezierTools", {
|
|
1647
|
+
Cvalues: be,
|
|
1648
|
+
Tvalues: qt,
|
|
1649
|
+
minmaxC: kt,
|
|
1650
|
+
minmaxQ: pt,
|
|
1651
|
+
getBezierLength: ft,
|
|
1652
|
+
bezierLength: we,
|
|
1653
|
+
calculateBezier: Me,
|
|
1654
|
+
computeBezier: Ae,
|
|
1655
|
+
deriveBezier: de,
|
|
1656
|
+
CBEZIER_MINMAX_EPSILON: Ne
|
|
1657
|
+
}), g(p, "cubicTools", { getCubicLength: _t, getCubicBBox: Te, getPointAtCubicLength: ve, getPointAtCubicSegmentLength: Le }), g(p, "lineTools", { getPointAtLineLength: Ot, getLineBBox: zt, getLineLength: lt }), g(p, "quadTools", { getPointAtQuadSegmentLength: Ce, getQuadLength: Ft, getQuadBBox: ze, getPointAtQuadLength: $e }), g(p, "polygonTools", { polygonArea: _e, polygonLength: Fe }), g(p, "distanceSquareRoot", Mt), g(p, "distanceEpsilon", bt), g(p, "midPoint", O), g(p, "rotateVector", ct), g(p, "roundTo", z), g(p, "finalizeSegment", Tt), g(p, "invalidPathValue", U), g(p, "isArcCommand", fe), g(p, "isDigit", H), g(p, "isDigitStart", he), g(p, "isMoveCommand", ye), g(p, "isPathCommand", me), g(p, "isSpace", ue), g(p, "paramsCount", nt), g(p, "paramsParser", X), g(p, "pathParser", Rt), g(p, "scanFlag", ae), g(p, "scanParam", le), g(p, "scanSegment", Et), g(p, "skipSpaces", st), g(p, "getPathBBox", Jt), g(p, "getPathArea", Pe), g(p, "getTotalLength", rt), g(p, "getDrawDirection", Xe), g(p, "getPointAtLength", at), g(p, "getPropertiesAtLength", Ht), g(p, "getPropertiesAtPoint", Nt), g(p, "getClosestPoint", He), g(p, "getSegmentOfPoint", Ye), g(p, "getSegmentAtLength", Je), g(p, "isPointInStroke", We), g(p, "isValidPath", Ie), g(p, "isPathArray", Lt), g(p, "isAbsoluteArray", qe), g(p, "isRelativeArray", Ve), g(p, "isCurveArray", Ke), g(p, "isNormalizedArray", ke), g(p, "shapeToPath", rn), g(p, "shapeToPathArray", Ee), g(p, "shapeParams", mt), g(p, "parsePathString", R), g(p, "absolutizeSegment", jt), g(p, "arcToCubic", Dt), g(p, "getSVGMatrix", Re), g(p, "iterate", j), g(p, "lineToCubic", Ct), g(p, "normalizePath", ut), g(p, "normalizeSegment", G), g(p, "optimizePath", Yt), g(p, "projection2d", It), g(p, "quadToCubic", xe), g(p, "relativizeSegment", St), g(p, "reverseCurve", cn), g(p, "reversePath", yt), g(p, "roundPath", an), g(p, "roundSegment", dt), g(p, "segmentToCubic", Zt), g(p, "shortenSegment", je), g(p, "splitCubic", ln), g(p, "splitPath", Kt), g(p, "transformPath", Wt);
|
|
1575
1658
|
export {
|
|
1576
|
-
|
|
1659
|
+
p as default
|
|
1577
1660
|
};
|
|
1578
1661
|
//# sourceMappingURL=svg-path-commander.mjs.map
|