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