svg-path-commander 2.0.10 → 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 +137 -30
- package/dist/svg-path-commander.js +1 -1
- package/dist/svg-path-commander.js.map +1 -1
- package/dist/svg-path-commander.mjs +868 -698
- package/dist/svg-path-commander.mjs.map +1 -1
- package/package.json +20 -22
- 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,43 +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) throw TypeError(
|
|
237
|
-
const
|
|
238
|
-
if (i === "perspective" &&
|
|
239
|
-
n.m34 = -1 /
|
|
240
|
-
else if (i.includes("matrix") && [6, 16].includes(
|
|
241
|
-
const f =
|
|
242
|
-
n = n.multiply(
|
|
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));
|
|
243
257
|
} else if (i === "translate3d" && y.every((f) => !Number.isNaN(+f)))
|
|
244
|
-
n = n.translate(
|
|
245
|
-
else if (i === "translate" &&
|
|
246
|
-
n = n.translate(
|
|
247
|
-
else if (i === "rotate3d" &&
|
|
248
|
-
n = n.rotateAxisAngle(
|
|
249
|
-
else if (i === "rotate" &&
|
|
250
|
-
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);
|
|
251
265
|
else if (i === "scale3d" && y.every((f) => !Number.isNaN(+f)) && y.some((f) => f !== 1))
|
|
252
|
-
n = n.scale(
|
|
253
|
-
else if (i === "scale" && !Number.isNaN(
|
|
254
|
-
const f = Number.isNaN(+
|
|
255
|
-
n = n.scale(
|
|
256
|
-
} else if (i === "skew" && (
|
|
257
|
-
n = n.skew(
|
|
258
|
-
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))
|
|
259
273
|
if (i === "skewX" || i === "skewY")
|
|
260
|
-
n = n[i](
|
|
274
|
+
n = n[i](a);
|
|
261
275
|
else {
|
|
262
|
-
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];
|
|
263
277
|
n = n[f](...b);
|
|
264
278
|
}
|
|
265
279
|
else
|
|
266
|
-
throw TypeError(
|
|
280
|
+
throw TypeError(s);
|
|
267
281
|
}), n;
|
|
268
|
-
},
|
|
282
|
+
}, dt = (e, t) => t ? [e.a, e.b, e.c, e.d, e.e, e.f] : [
|
|
269
283
|
e.m11,
|
|
270
284
|
e.m12,
|
|
271
285
|
e.m13,
|
|
@@ -282,47 +296,47 @@ const ue = {
|
|
|
282
296
|
e.m42,
|
|
283
297
|
e.m43,
|
|
284
298
|
e.m44
|
|
285
|
-
],
|
|
286
|
-
const
|
|
287
|
-
return
|
|
288
|
-
},
|
|
289
|
-
const
|
|
290
|
-
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
const p =
|
|
294
|
-
return
|
|
295
|
-
},
|
|
296
|
-
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);
|
|
297
311
|
if (i === 0)
|
|
298
|
-
return
|
|
299
|
-
const o = e / i,
|
|
300
|
-
|
|
301
|
-
const p = 2 * (o *
|
|
302
|
-
|
|
303
|
-
const b = 2 * (
|
|
304
|
-
|
|
305
|
-
const
|
|
306
|
-
return
|
|
307
|
-
},
|
|
308
|
-
const
|
|
309
|
-
return
|
|
310
|
-
},
|
|
311
|
-
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();
|
|
312
326
|
if (e) {
|
|
313
|
-
const
|
|
314
|
-
n.m21 =
|
|
327
|
+
const s = e * Math.PI / 180, r = Math.tan(s);
|
|
328
|
+
n.m21 = r, n.c = r;
|
|
315
329
|
}
|
|
316
330
|
if (t) {
|
|
317
|
-
const
|
|
318
|
-
n.m12 =
|
|
331
|
+
const s = t * Math.PI / 180, r = Math.tan(s);
|
|
332
|
+
n.m12 = r, n.b = r;
|
|
319
333
|
}
|
|
320
334
|
return n;
|
|
321
|
-
},
|
|
322
|
-
const n = t.m11 * e.m11 + t.m12 * e.m21 + t.m13 * e.m31 + t.m14 * e.m41,
|
|
323
|
-
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]);
|
|
324
338
|
};
|
|
325
|
-
class
|
|
339
|
+
class P {
|
|
326
340
|
/**
|
|
327
341
|
* @constructor
|
|
328
342
|
* @param init accepts all parameter configurations:
|
|
@@ -367,7 +381,7 @@ class v {
|
|
|
367
381
|
* @return the matrix instance
|
|
368
382
|
*/
|
|
369
383
|
setMatrixValue(t) {
|
|
370
|
-
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;
|
|
371
385
|
}
|
|
372
386
|
/**
|
|
373
387
|
* Returns a *Float32Array* containing elements which comprise the matrix.
|
|
@@ -378,7 +392,7 @@ class v {
|
|
|
378
392
|
* @return an *Array* representation of the matrix
|
|
379
393
|
*/
|
|
380
394
|
toFloat32Array(t) {
|
|
381
|
-
return Float32Array.from(
|
|
395
|
+
return Float32Array.from(dt(this, t));
|
|
382
396
|
}
|
|
383
397
|
/**
|
|
384
398
|
* Returns a *Float64Array* containing elements which comprise the matrix.
|
|
@@ -389,7 +403,7 @@ class v {
|
|
|
389
403
|
* @return an *Array* representation of the matrix
|
|
390
404
|
*/
|
|
391
405
|
toFloat64Array(t) {
|
|
392
|
-
return Float64Array.from(
|
|
406
|
+
return Float64Array.from(dt(this, t));
|
|
393
407
|
}
|
|
394
408
|
/**
|
|
395
409
|
* Creates and returns a string representation of the matrix in `CSS` matrix syntax,
|
|
@@ -427,7 +441,7 @@ class v {
|
|
|
427
441
|
* @return The resulted matrix.
|
|
428
442
|
*/
|
|
429
443
|
multiply(t) {
|
|
430
|
-
return
|
|
444
|
+
return E(this, t);
|
|
431
445
|
}
|
|
432
446
|
/**
|
|
433
447
|
* The translate method returns a new matrix which is this matrix post
|
|
@@ -440,10 +454,10 @@ class v {
|
|
|
440
454
|
* @param z Z component of the translation value.
|
|
441
455
|
* @return The resulted matrix
|
|
442
456
|
*/
|
|
443
|
-
translate(t, n,
|
|
444
|
-
const
|
|
445
|
-
let i = n, o =
|
|
446
|
-
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));
|
|
447
461
|
}
|
|
448
462
|
/**
|
|
449
463
|
* The scale method returns a new matrix which is this matrix post multiplied by
|
|
@@ -456,10 +470,10 @@ class v {
|
|
|
456
470
|
* @param z The Z component of the scale value.
|
|
457
471
|
* @return The resulted matrix
|
|
458
472
|
*/
|
|
459
|
-
scale(t, n,
|
|
460
|
-
const
|
|
461
|
-
let i = n, o =
|
|
462
|
-
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));
|
|
463
477
|
}
|
|
464
478
|
/**
|
|
465
479
|
* The rotate method returns a new matrix which is this matrix post multiplied
|
|
@@ -473,9 +487,9 @@ class v {
|
|
|
473
487
|
* @param rz The (optional) Z component of the rotation value.
|
|
474
488
|
* @return The resulted matrix
|
|
475
489
|
*/
|
|
476
|
-
rotate(t, n,
|
|
477
|
-
let
|
|
478
|
-
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));
|
|
479
493
|
}
|
|
480
494
|
/**
|
|
481
495
|
* The rotateAxisAngle method returns a new matrix which is this matrix post
|
|
@@ -489,10 +503,10 @@ class v {
|
|
|
489
503
|
* @param angle The angle of rotation about the axis vector, in degrees.
|
|
490
504
|
* @return The resulted matrix
|
|
491
505
|
*/
|
|
492
|
-
rotateAxisAngle(t, n,
|
|
493
|
-
if ([t, n,
|
|
506
|
+
rotateAxisAngle(t, n, s, r) {
|
|
507
|
+
if ([t, n, s, r].some((i) => Number.isNaN(+i)))
|
|
494
508
|
throw new TypeError("CSSMatrix: expecting 4 values");
|
|
495
|
-
return
|
|
509
|
+
return E(this, Jt(t, n, s, r));
|
|
496
510
|
}
|
|
497
511
|
/**
|
|
498
512
|
* Specifies a skew transformation along the `x-axis` by the given angle.
|
|
@@ -502,7 +516,7 @@ class v {
|
|
|
502
516
|
* @return The resulted matrix
|
|
503
517
|
*/
|
|
504
518
|
skewX(t) {
|
|
505
|
-
return
|
|
519
|
+
return E(this, Kt(t));
|
|
506
520
|
}
|
|
507
521
|
/**
|
|
508
522
|
* Specifies a skew transformation along the `y-axis` by the given angle.
|
|
@@ -512,7 +526,7 @@ class v {
|
|
|
512
526
|
* @return The resulted matrix
|
|
513
527
|
*/
|
|
514
528
|
skewY(t) {
|
|
515
|
-
return
|
|
529
|
+
return E(this, Ut(t));
|
|
516
530
|
}
|
|
517
531
|
/**
|
|
518
532
|
* Specifies a skew transformation along both the `x-axis` and `y-axis`.
|
|
@@ -523,7 +537,7 @@ class v {
|
|
|
523
537
|
* @return The resulted matrix
|
|
524
538
|
*/
|
|
525
539
|
skew(t, n) {
|
|
526
|
-
return
|
|
540
|
+
return E(this, ut(t, n));
|
|
527
541
|
}
|
|
528
542
|
/**
|
|
529
543
|
* Transforms a specified vector using the matrix, returning a new
|
|
@@ -537,76 +551,76 @@ class v {
|
|
|
537
551
|
* @return the resulting Tuple
|
|
538
552
|
*/
|
|
539
553
|
transformPoint(t) {
|
|
540
|
-
const n = this.m11 * t.x + this.m21 * t.y + this.m31 * t.z + this.m41 * t.w,
|
|
541
|
-
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) : {
|
|
542
556
|
x: n,
|
|
543
|
-
y:
|
|
544
|
-
z:
|
|
557
|
+
y: s,
|
|
558
|
+
z: r,
|
|
545
559
|
w: i
|
|
546
560
|
};
|
|
547
561
|
}
|
|
548
562
|
}
|
|
549
|
-
C(
|
|
550
|
-
const
|
|
551
|
-
e.every(([t]) => t === t.toUpperCase()),
|
|
552
|
-
if (
|
|
553
|
-
return
|
|
554
|
-
const t =
|
|
555
|
-
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;
|
|
556
570
|
return t.map((o) => {
|
|
557
|
-
const
|
|
558
|
-
if (
|
|
559
|
-
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];
|
|
560
574
|
let m = [];
|
|
561
|
-
if (
|
|
562
|
-
if (
|
|
575
|
+
if (a !== l)
|
|
576
|
+
if (l === "A")
|
|
563
577
|
m = [
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
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
|
|
572
586
|
];
|
|
573
|
-
else if (
|
|
574
|
-
m = [
|
|
575
|
-
else if (
|
|
576
|
-
m = [
|
|
587
|
+
else if (l === "V")
|
|
588
|
+
m = [l, c[0] + s];
|
|
589
|
+
else if (l === "H")
|
|
590
|
+
m = [l, c[0] + n];
|
|
577
591
|
else {
|
|
578
|
-
const u =
|
|
579
|
-
m = [
|
|
592
|
+
const u = c.map((y, x) => y + (x % 2 ? s : n));
|
|
593
|
+
m = [l, ...u];
|
|
580
594
|
}
|
|
581
595
|
else
|
|
582
|
-
m = [
|
|
583
|
-
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;
|
|
584
598
|
});
|
|
585
|
-
},
|
|
586
|
-
const [n] = e, { x1:
|
|
587
|
-
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;
|
|
588
602
|
if ("TQ".includes(n) || (t.qx = null, t.qy = null), n === "H")
|
|
589
|
-
|
|
603
|
+
a = ["L", e[1], r];
|
|
590
604
|
else if (n === "V")
|
|
591
|
-
|
|
605
|
+
a = ["L", s, e[1]];
|
|
592
606
|
else if (n === "S") {
|
|
593
|
-
const
|
|
594
|
-
t.x1 =
|
|
607
|
+
const l = s * 2 - i, m = r * 2 - o;
|
|
608
|
+
t.x1 = l, t.y1 = m, a = ["C", l, m, ...c];
|
|
595
609
|
} else if (n === "T") {
|
|
596
|
-
const
|
|
610
|
+
const l = s * 2 - (t.qx ? t.qx : (
|
|
597
611
|
/* istanbul ignore next */
|
|
598
612
|
0
|
|
599
|
-
)), m =
|
|
613
|
+
)), m = r * 2 - (t.qy ? t.qy : (
|
|
600
614
|
/* istanbul ignore next */
|
|
601
615
|
0
|
|
602
616
|
));
|
|
603
|
-
t.qx =
|
|
617
|
+
t.qx = l, t.qy = m, a = ["Q", l, m, ...c];
|
|
604
618
|
} else if (n === "Q") {
|
|
605
|
-
const [
|
|
606
|
-
t.qx =
|
|
619
|
+
const [l, m] = c;
|
|
620
|
+
t.qx = l, t.qy = m;
|
|
607
621
|
}
|
|
608
|
-
return
|
|
609
|
-
},
|
|
622
|
+
return a;
|
|
623
|
+
}, gt = (e) => ft(e) && e.every(([t]) => "ACLMQZ".includes(t)), et = {
|
|
610
624
|
x1: 0,
|
|
611
625
|
y1: 0,
|
|
612
626
|
x2: 0,
|
|
@@ -615,208 +629,348 @@ e.every(([t]) => t === t.toUpperCase()), Q = (e) => {
|
|
|
615
629
|
y: 0,
|
|
616
630
|
qx: null,
|
|
617
631
|
qy: null
|
|
618
|
-
},
|
|
619
|
-
if (
|
|
620
|
-
return
|
|
621
|
-
const t =
|
|
622
|
-
for (let
|
|
623
|
-
t[
|
|
624
|
-
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;
|
|
625
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;
|
|
626
640
|
}
|
|
627
641
|
return t;
|
|
628
|
-
},
|
|
629
|
-
const [
|
|
630
|
-
return [
|
|
631
|
-
},
|
|
632
|
-
const
|
|
633
|
-
let
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
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 };
|
|
639
655
|
else {
|
|
640
|
-
const [
|
|
641
|
-
|
|
656
|
+
const [m, u] = z([e, t], [n, s], r / l);
|
|
657
|
+
c = { x: m, y: u };
|
|
642
658
|
}
|
|
659
|
+
}
|
|
643
660
|
return {
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
x: Math.min(e, n),
|
|
648
|
-
y: Math.min(t, r)
|
|
661
|
+
point: c,
|
|
662
|
+
get length() {
|
|
663
|
+
return a();
|
|
649
664
|
},
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
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
|
+
};
|
|
653
676
|
}
|
|
654
677
|
};
|
|
655
|
-
},
|
|
656
|
-
const
|
|
657
|
-
return
|
|
658
|
-
},
|
|
659
|
-
const {
|
|
660
|
-
let h = m(n), x = m(r);
|
|
661
|
-
const b = (s % 360 + 360) % 360 * (f / 180);
|
|
662
|
-
if (e === a && t === l)
|
|
663
|
-
return { x: e, y: t };
|
|
664
|
-
if (h === 0 || x === 0)
|
|
665
|
-
return dt(e, t, a, l, c).point;
|
|
666
|
-
const A = (e - a) / 2, d = (t - l) / 2, M = {
|
|
667
|
-
x: y(b) * A + u(b) * d,
|
|
668
|
-
y: -u(b) * A + y(b) * d
|
|
669
|
-
}, T = M.x ** 2 / h ** 2 + M.y ** 2 / x ** 2;
|
|
670
|
-
T > 1 && (h *= g(T), x *= g(T));
|
|
671
|
-
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;
|
|
672
|
-
let F = j / H;
|
|
673
|
-
F = F < 0 ? 0 : F;
|
|
674
|
-
const tt = (i !== o ? 1 : -1) * g(F), S = {
|
|
675
|
-
x: tt * (h * M.y / x),
|
|
676
|
-
y: tt * (-(x * M.x) / h)
|
|
677
|
-
}, et = {
|
|
678
|
-
x: y(b) * S.x - u(b) * S.y + (e + a) / 2,
|
|
679
|
-
y: u(b) * S.x + y(b) * S.y + (t + l) / 2
|
|
680
|
-
}, Y = {
|
|
681
|
-
x: (M.x - S.x) / h,
|
|
682
|
-
y: (M.y - S.y) / x
|
|
683
|
-
}, nt = Lt({ x: 1, y: 0 }, Y), st = {
|
|
684
|
-
x: (-M.x - S.x) / h,
|
|
685
|
-
y: (-M.y - S.y) / x
|
|
686
|
-
};
|
|
687
|
-
let $ = Lt(Y, st);
|
|
688
|
-
!o && $ > 0 ? $ -= 2 * f : o && $ < 0 && ($ += 2 * f), $ %= 2 * f;
|
|
689
|
-
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);
|
|
690
683
|
return {
|
|
691
|
-
x:
|
|
692
|
-
|
|
684
|
+
min: { x: l(h, p), y: l(g, b) },
|
|
685
|
+
max: { x: m(h, p), y: m(g, b) }
|
|
693
686
|
};
|
|
694
|
-
},
|
|
695
|
-
const
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
const
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
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);
|
|
715
739
|
},
|
|
716
|
-
|
|
717
|
-
x
|
|
718
|
-
y: Math.max(...b.map((d) => d.y))
|
|
740
|
+
get bbox() {
|
|
741
|
+
return we(D.x, D.y, h, g, b, I, I + L);
|
|
719
742
|
}
|
|
720
743
|
};
|
|
721
|
-
},
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
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
|
|
726
829
|
};
|
|
727
|
-
},
|
|
728
|
-
const
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
const
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
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);
|
|
739
868
|
}
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
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();
|
|
748
888
|
},
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
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
|
+
};
|
|
752
895
|
}
|
|
753
896
|
};
|
|
754
|
-
},
|
|
755
|
-
const
|
|
897
|
+
}, Ee = ([e, t, n, s, r, i], o) => {
|
|
898
|
+
const c = 1 - o;
|
|
756
899
|
return {
|
|
757
|
-
x:
|
|
758
|
-
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
|
|
759
902
|
};
|
|
760
|
-
},
|
|
761
|
-
const
|
|
762
|
-
let
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
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] }
|
|
771
921
|
};
|
|
772
922
|
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
x:
|
|
784
|
-
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 }
|
|
785
934
|
}
|
|
786
935
|
};
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
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(
|
|
792
942
|
...i,
|
|
793
|
-
|
|
794
|
-
) : o === "A" ?
|
|
943
|
+
s ? t - p : void 0
|
|
944
|
+
) : o === "A" ? b = ve(
|
|
795
945
|
...i,
|
|
796
|
-
|
|
797
|
-
) : o === "C" ?
|
|
946
|
+
s ? t - p : void 0
|
|
947
|
+
) : o === "C" ? b = Se(
|
|
798
948
|
...i,
|
|
799
|
-
|
|
800
|
-
) : o === "Q" ?
|
|
949
|
+
s ? t - p : void 0
|
|
950
|
+
) : o === "Q" ? b = ze(
|
|
801
951
|
...i,
|
|
802
|
-
|
|
803
|
-
) : o === "Z" && (i = [a, l,
|
|
952
|
+
s ? t - p : void 0
|
|
953
|
+
) : o === "Z" && (i = [c, a, l, m], b = Mt(
|
|
804
954
|
...i,
|
|
805
|
-
|
|
806
|
-
)),
|
|
807
|
-
return
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
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
|
+
};
|
|
817
971
|
}
|
|
818
972
|
};
|
|
819
|
-
},
|
|
973
|
+
}, St = (e) => {
|
|
820
974
|
if (!e)
|
|
821
975
|
return {
|
|
822
976
|
x: 0,
|
|
@@ -829,160 +983,160 @@ e.every(([t]) => t === t.toUpperCase()), Q = (e) => {
|
|
|
829
983
|
cy: 0,
|
|
830
984
|
cz: 0
|
|
831
985
|
};
|
|
832
|
-
const {
|
|
833
|
-
min: { x:
|
|
834
|
-
max: { x: r, y:
|
|
835
|
-
} =
|
|
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;
|
|
836
990
|
return {
|
|
837
|
-
width:
|
|
838
|
-
height:
|
|
839
|
-
x:
|
|
840
|
-
y:
|
|
991
|
+
width: o,
|
|
992
|
+
height: c,
|
|
993
|
+
x: n,
|
|
994
|
+
y: s,
|
|
841
995
|
x2: r,
|
|
842
|
-
y2:
|
|
843
|
-
cx:
|
|
844
|
-
cy:
|
|
996
|
+
y2: i,
|
|
997
|
+
cx: n + o / 2,
|
|
998
|
+
cy: s + c / 2,
|
|
845
999
|
// an estimted guess
|
|
846
|
-
cz: Math.max(
|
|
1000
|
+
cz: Math.max(o, c) + Math.min(o, c) / 2
|
|
847
1001
|
};
|
|
848
|
-
},
|
|
1002
|
+
}, vt = (e, t, n) => {
|
|
849
1003
|
if (e[n].length > 7) {
|
|
850
1004
|
e[n].shift();
|
|
851
|
-
const
|
|
852
|
-
let
|
|
853
|
-
for (;
|
|
854
|
-
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)]);
|
|
855
1009
|
e.splice(n, 1);
|
|
856
1010
|
}
|
|
857
|
-
},
|
|
858
|
-
const
|
|
859
|
-
return { x:
|
|
860
|
-
},
|
|
861
|
-
let m = e, u = t, y = n,
|
|
862
|
-
const
|
|
863
|
-
let b = [],
|
|
864
|
-
if (
|
|
865
|
-
[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;
|
|
866
1020
|
else {
|
|
867
|
-
|
|
868
|
-
const
|
|
869
|
-
let
|
|
870
|
-
|
|
871
|
-
const
|
|
872
|
-
T =
|
|
873
|
-
}
|
|
874
|
-
let
|
|
875
|
-
if (Math.abs(
|
|
876
|
-
const
|
|
877
|
-
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
const
|
|
881
|
-
if (
|
|
882
|
-
return [...
|
|
883
|
-
b = [...
|
|
884
|
-
const
|
|
885
|
-
for (let
|
|
886
|
-
|
|
887
|
-
return
|
|
888
|
-
},
|
|
889
|
-
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;
|
|
890
1044
|
return [
|
|
891
|
-
o * e +
|
|
1045
|
+
o * e + c * n,
|
|
892
1046
|
// cpx1
|
|
893
|
-
o * t +
|
|
1047
|
+
o * t + c * s,
|
|
894
1048
|
// cpy1
|
|
895
|
-
o *
|
|
1049
|
+
o * r + c * n,
|
|
896
1050
|
// cpx2
|
|
897
|
-
o * i +
|
|
1051
|
+
o * i + c * s,
|
|
898
1052
|
// cpy2
|
|
899
|
-
|
|
1053
|
+
r,
|
|
900
1054
|
i
|
|
901
1055
|
// x,y
|
|
902
1056
|
];
|
|
903
|
-
},
|
|
904
|
-
const
|
|
905
|
-
return [...
|
|
906
|
-
},
|
|
907
|
-
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;
|
|
908
1062
|
let o;
|
|
909
|
-
const { x1:
|
|
910
|
-
return "TQ".includes(n) || (t.qx = null, t.qy = null), n === "M" ? (t.x =
|
|
911
|
-
},
|
|
912
|
-
if (
|
|
913
|
-
return
|
|
914
|
-
const t =
|
|
915
|
-
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;
|
|
916
1070
|
for (let o = 0; o < i; o += 1) {
|
|
917
|
-
[
|
|
918
|
-
const
|
|
919
|
-
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;
|
|
920
1074
|
}
|
|
921
1075
|
return t;
|
|
922
|
-
},
|
|
923
|
-
let t = 0, n = 0,
|
|
924
|
-
return
|
|
925
|
-
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]) {
|
|
926
1080
|
case "M":
|
|
927
|
-
return [, t, n] =
|
|
1081
|
+
return [, t, n] = r, 0;
|
|
928
1082
|
default:
|
|
929
|
-
return
|
|
1083
|
+
return s = je(t, n, ...r.slice(1)), [t, n] = r.slice(-2), s;
|
|
930
1084
|
}
|
|
931
|
-
}).reduce((
|
|
932
|
-
},
|
|
933
|
-
const n =
|
|
934
|
-
let
|
|
935
|
-
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 };
|
|
936
1090
|
if (i <= 0 || !t || !Number.isFinite(t))
|
|
937
1091
|
return {
|
|
938
|
-
segment:
|
|
1092
|
+
segment: a,
|
|
939
1093
|
index: 0,
|
|
940
|
-
length:
|
|
1094
|
+
length: c,
|
|
941
1095
|
point: u,
|
|
942
1096
|
lengthAtSegment: o
|
|
943
1097
|
};
|
|
944
|
-
if (t >=
|
|
945
|
-
return
|
|
1098
|
+
if (t >= r)
|
|
1099
|
+
return s = n.slice(0, -1), o = F(s), c = r - o, {
|
|
946
1100
|
segment: n[i],
|
|
947
1101
|
index: i,
|
|
948
|
-
length:
|
|
1102
|
+
length: c,
|
|
949
1103
|
lengthAtSegment: o
|
|
950
1104
|
};
|
|
951
1105
|
const y = [];
|
|
952
1106
|
for (; i > 0; )
|
|
953
|
-
|
|
954
|
-
segment:
|
|
1107
|
+
a = s[i], s = s.slice(0, -1), o = F(s), c = r - o, r = o, y.push({
|
|
1108
|
+
segment: a,
|
|
955
1109
|
index: i,
|
|
956
|
-
length:
|
|
1110
|
+
length: c,
|
|
957
1111
|
lengthAtSegment: o
|
|
958
1112
|
}), i -= 1;
|
|
959
|
-
return y.find(({ lengthAtSegment:
|
|
960
|
-
},
|
|
961
|
-
const n =
|
|
962
|
-
const
|
|
963
|
-
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;
|
|
964
1118
|
};
|
|
965
|
-
let o = 8,
|
|
966
|
-
for (let d = 0; d <=
|
|
967
|
-
|
|
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);
|
|
968
1122
|
o /= 2;
|
|
969
|
-
let y,
|
|
970
|
-
for (; o > 0
|
|
971
|
-
|
|
972
|
-
const b =
|
|
973
|
-
return { closest:
|
|
974
|
-
},
|
|
975
|
-
const { distance: n } =
|
|
976
|
-
return Math.abs(n) <
|
|
977
|
-
},
|
|
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) => {
|
|
978
1132
|
if (typeof e != "string" || !e.length)
|
|
979
1133
|
return !1;
|
|
980
|
-
const t = new
|
|
1134
|
+
const t = new Rt(e);
|
|
981
1135
|
for (V(t); t.index < t.max && !t.err.length; )
|
|
982
|
-
|
|
1136
|
+
Dt(t);
|
|
983
1137
|
return !t.err.length && "mM".includes(t.segments[0][0]);
|
|
984
|
-
},
|
|
985
|
-
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 = {
|
|
986
1140
|
line: ["x1", "y1", "x2", "y2"],
|
|
987
1141
|
circle: ["cx", "cy", "r"],
|
|
988
1142
|
ellipse: ["cx", "cy", "rx", "ry"],
|
|
@@ -990,301 +1144,317 @@ e.slice(1).every(([t]) => t === t.toLowerCase()), lt = {
|
|
|
990
1144
|
polygon: ["points"],
|
|
991
1145
|
polyline: ["points"],
|
|
992
1146
|
glyph: ["d"]
|
|
993
|
-
},
|
|
994
|
-
let { x1: t, y1: n, x2:
|
|
995
|
-
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), [
|
|
996
1150
|
["M", t, n],
|
|
997
|
-
["L",
|
|
1151
|
+
["L", s, r]
|
|
998
1152
|
];
|
|
999
|
-
},
|
|
1000
|
-
const t = [], n = (e.points || "").trim().split(/[\s|,]/).map((
|
|
1001
|
-
let
|
|
1002
|
-
for (;
|
|
1003
|
-
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;
|
|
1004
1158
|
return e.type === "polygon" ? [...t, ["z"]] : t;
|
|
1005
|
-
},
|
|
1006
|
-
let { cx: t, cy: n, r } = e;
|
|
1007
|
-
return [t, n,
|
|
1008
|
-
["M", t -
|
|
1009
|
-
["a",
|
|
1010
|
-
["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]
|
|
1011
1165
|
];
|
|
1012
|
-
},
|
|
1013
|
-
let { cx: t, cy: n } = e,
|
|
1014
|
-
return [t, n,
|
|
1015
|
-
["M", t -
|
|
1016
|
-
["a",
|
|
1017
|
-
["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]
|
|
1018
1172
|
];
|
|
1019
|
-
},
|
|
1020
|
-
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;
|
|
1021
1175
|
let i = +(e.rx || 0), o = +(e.ry || i);
|
|
1022
|
-
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), [
|
|
1023
1177
|
["M", t + i, n],
|
|
1024
|
-
["h",
|
|
1178
|
+
["h", s - i * 2],
|
|
1025
1179
|
["s", i, 0, i, o],
|
|
1026
|
-
["v",
|
|
1180
|
+
["v", r - o * 2],
|
|
1027
1181
|
["s", 0, o, -i, o],
|
|
1028
|
-
["h", -
|
|
1182
|
+
["h", -s + i * 2],
|
|
1029
1183
|
["s", -i, 0, -i, -o],
|
|
1030
|
-
["v", -
|
|
1184
|
+
["v", -r + o * 2],
|
|
1031
1185
|
["s", 0, -o, i, -o]
|
|
1032
|
-
]) : [["M", t, n], ["h",
|
|
1033
|
-
},
|
|
1034
|
-
const
|
|
1035
|
-
window,
|
|
1036
|
-
if (o && [...
|
|
1037
|
-
throw TypeError(`${
|
|
1038
|
-
const
|
|
1039
|
-
i ?
|
|
1040
|
-
|
|
1041
|
-
}) : 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);
|
|
1042
1196
|
let m = [];
|
|
1043
|
-
return
|
|
1044
|
-
|
|
1045
|
-
|
|
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;
|
|
1046
1203
|
if (t === "off" || n === "off") return [...e];
|
|
1047
1204
|
n = typeof t == "number" && t >= 0 ? t : n;
|
|
1048
|
-
const
|
|
1049
|
-
return e.map((
|
|
1050
|
-
const i =
|
|
1051
|
-
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];
|
|
1052
1209
|
});
|
|
1053
|
-
},
|
|
1054
|
-
const
|
|
1055
|
-
window, i = Object.keys(
|
|
1056
|
-
if (
|
|
1057
|
-
if (
|
|
1058
|
-
const
|
|
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) : "";
|
|
1059
1216
|
return o ? (m.forEach((h) => {
|
|
1060
1217
|
u[h] = e.getAttribute(h);
|
|
1061
|
-
}), Object.values(e.attributes).forEach(({ name: h, value:
|
|
1062
|
-
m.includes(h) ||
|
|
1218
|
+
}), Object.values(e.attributes).forEach(({ name: h, value: g }) => {
|
|
1219
|
+
m.includes(h) || a.setAttribute(h, g);
|
|
1063
1220
|
})) : (Object.assign(u, e), Object.keys(u).forEach((h) => {
|
|
1064
|
-
!m.includes(h) && h !== "type" &&
|
|
1065
|
-
h.replace(/[A-Z]/g, (
|
|
1221
|
+
!m.includes(h) && h !== "type" && a.setAttribute(
|
|
1222
|
+
h.replace(/[A-Z]/g, (g) => `-${g.toLowerCase()}`),
|
|
1066
1223
|
u[h]
|
|
1067
1224
|
);
|
|
1068
|
-
})),
|
|
1069
|
-
},
|
|
1225
|
+
})), ee(f) ? (a.setAttribute("d", f), t && o && (e.before(a, e), e.remove()), a) : !1;
|
|
1226
|
+
}, zt = (e) => {
|
|
1070
1227
|
const t = [];
|
|
1071
|
-
let n,
|
|
1072
|
-
return e.forEach((
|
|
1073
|
-
|
|
1228
|
+
let n, s = -1;
|
|
1229
|
+
return e.forEach((r) => {
|
|
1230
|
+
r[0] === "M" ? (n = [r], s += 1) : n.push(r), t[s] = n;
|
|
1074
1231
|
}), t;
|
|
1075
|
-
},
|
|
1076
|
-
let t = new
|
|
1077
|
-
const { origin: n } = e, [
|
|
1078
|
-
return Array.isArray(i) && i.length >= 2 && i.every((
|
|
1079
|
-
},
|
|
1080
|
-
if (
|
|
1081
|
-
return
|
|
1082
|
-
const t =
|
|
1083
|
-
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;
|
|
1084
1241
|
return t.map((o) => {
|
|
1085
|
-
const
|
|
1086
|
-
if (
|
|
1087
|
-
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];
|
|
1088
1245
|
let m = [];
|
|
1089
|
-
if (
|
|
1090
|
-
if (
|
|
1246
|
+
if (a !== l)
|
|
1247
|
+
if (l === "a")
|
|
1091
1248
|
m = [
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
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
|
|
1100
1257
|
];
|
|
1101
|
-
else if (
|
|
1102
|
-
m = [
|
|
1103
|
-
else if (
|
|
1104
|
-
m = [
|
|
1258
|
+
else if (l === "v")
|
|
1259
|
+
m = [l, c[0] - s];
|
|
1260
|
+
else if (l === "h")
|
|
1261
|
+
m = [l, c[0] - n];
|
|
1105
1262
|
else {
|
|
1106
|
-
const y =
|
|
1107
|
-
m = [
|
|
1263
|
+
const y = c.map((x, f) => x - (f % 2 ? s : n));
|
|
1264
|
+
m = [l, ...y];
|
|
1108
1265
|
}
|
|
1109
1266
|
else
|
|
1110
|
-
|
|
1267
|
+
a === "m" && (r = c[0] + n, i = c[1] + s), m = [l, ...c];
|
|
1111
1268
|
const u = m.length;
|
|
1112
|
-
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;
|
|
1113
1270
|
});
|
|
1114
|
-
},
|
|
1115
|
-
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;
|
|
1116
1273
|
let f = e;
|
|
1117
|
-
const [h,
|
|
1118
|
-
if ("TQ".includes(
|
|
1119
|
-
f = [
|
|
1120
|
-
else if (
|
|
1121
|
-
i(y) === i(h) ? f = ["V",
|
|
1122
|
-
else if (
|
|
1123
|
-
const [p, b] =
|
|
1124
|
-
"CS".includes(
|
|
1125
|
-
} else if (
|
|
1126
|
-
const [p, b] =
|
|
1127
|
-
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)]);
|
|
1128
1285
|
}
|
|
1129
1286
|
return f;
|
|
1130
|
-
},
|
|
1131
|
-
const n =
|
|
1132
|
-
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;
|
|
1133
1290
|
for (let h = 0; h < o; h += 1) {
|
|
1134
|
-
[
|
|
1135
|
-
const
|
|
1136
|
-
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) {
|
|
1137
1294
|
case "Z":
|
|
1138
|
-
|
|
1295
|
+
l = u, m = y;
|
|
1139
1296
|
break;
|
|
1140
1297
|
case "H":
|
|
1141
|
-
[,
|
|
1298
|
+
[, l] = g;
|
|
1142
1299
|
break;
|
|
1143
1300
|
case "V":
|
|
1144
|
-
[, m] =
|
|
1301
|
+
[, m] = g;
|
|
1145
1302
|
break;
|
|
1146
1303
|
default:
|
|
1147
|
-
[
|
|
1304
|
+
[l, m] = g.slice(-2).map(Number), c === "M" && (u = l, y = m);
|
|
1148
1305
|
}
|
|
1149
|
-
|
|
1306
|
+
r.x = l, r.y = m;
|
|
1150
1307
|
}
|
|
1151
|
-
const
|
|
1152
|
-
return
|
|
1153
|
-
},
|
|
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) => {
|
|
1154
1311
|
const t = e.slice(1).map(
|
|
1155
|
-
(n,
|
|
1156
|
-
).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();
|
|
1157
1314
|
return [["M", ...t[0].slice(0, 2)], ...t.map((n) => ["C", ...n.slice(2)])];
|
|
1158
|
-
},
|
|
1159
|
-
const t =
|
|
1160
|
-
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);
|
|
1161
1318
|
return {
|
|
1162
1319
|
seg: t[i],
|
|
1163
1320
|
// absolute
|
|
1164
|
-
n:
|
|
1321
|
+
n: r,
|
|
1165
1322
|
// normalized
|
|
1166
1323
|
c: t[i][0],
|
|
1167
1324
|
// pathCommand
|
|
1168
1325
|
x: o,
|
|
1169
1326
|
// x
|
|
1170
|
-
y:
|
|
1327
|
+
y: c
|
|
1171
1328
|
// y
|
|
1172
1329
|
};
|
|
1173
|
-
}).map((
|
|
1174
|
-
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;
|
|
1175
1332
|
let h = [];
|
|
1176
1333
|
switch (u) {
|
|
1177
1334
|
case "M":
|
|
1178
|
-
h = n ? ["Z"] : [u,
|
|
1335
|
+
h = n ? ["Z"] : [u, x, f];
|
|
1179
1336
|
break;
|
|
1180
1337
|
case "A":
|
|
1181
|
-
h = [u, ...
|
|
1338
|
+
h = [u, ...c.slice(1, -3), c[5] === 1 ? 0 : 1, x, f];
|
|
1182
1339
|
break;
|
|
1183
1340
|
case "C":
|
|
1184
|
-
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];
|
|
1185
1342
|
break;
|
|
1186
1343
|
case "S":
|
|
1187
|
-
|
|
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];
|
|
1188
1345
|
break;
|
|
1189
1346
|
case "Q":
|
|
1190
|
-
m && m.c === "T" ? h = ["T",
|
|
1347
|
+
m && m.c === "T" ? h = ["T", x, f] : h = [u, ...c.slice(1, -2), x, f];
|
|
1191
1348
|
break;
|
|
1192
1349
|
case "T":
|
|
1193
|
-
|
|
1350
|
+
l && "QT".includes(l.c) && (!m || m.c !== "T") ? h = ["Q", a[1], a[2], x, f] : h = [u, x, f];
|
|
1194
1351
|
break;
|
|
1195
1352
|
case "Z":
|
|
1196
|
-
h = ["M",
|
|
1353
|
+
h = ["M", x, f];
|
|
1197
1354
|
break;
|
|
1198
1355
|
case "H":
|
|
1199
|
-
h = [u,
|
|
1356
|
+
h = [u, x];
|
|
1200
1357
|
break;
|
|
1201
1358
|
case "V":
|
|
1202
1359
|
h = [u, f];
|
|
1203
1360
|
break;
|
|
1204
1361
|
default:
|
|
1205
|
-
h = [u, ...
|
|
1362
|
+
h = [u, ...c.slice(1, -2), x, f];
|
|
1206
1363
|
}
|
|
1207
1364
|
return h;
|
|
1208
1365
|
});
|
|
1209
|
-
return n ?
|
|
1210
|
-
},
|
|
1211
|
-
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));
|
|
1212
1369
|
return [, , , n.m44] = t, n = e.multiply(n), [n.m41, n.m42, n.m43, n.m44];
|
|
1213
|
-
},
|
|
1214
|
-
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;
|
|
1215
1372
|
return [
|
|
1216
1373
|
// protect against division by ZERO
|
|
1217
|
-
|
|
1218
|
-
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
|
|
1219
1376
|
];
|
|
1220
|
-
},
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
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);
|
|
1225
1390
|
if (!t.origin) {
|
|
1226
|
-
const { origin:
|
|
1227
|
-
Object.assign(t, { origin:
|
|
1228
|
-
}
|
|
1229
|
-
const
|
|
1230
|
-
let
|
|
1231
|
-
const
|
|
1232
|
-
if (!
|
|
1233
|
-
for (
|
|
1234
|
-
|
|
1235
|
-
const
|
|
1236
|
-
s: m[
|
|
1237
|
-
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],
|
|
1238
1403
|
x: h.x1,
|
|
1239
1404
|
y: h.y1
|
|
1240
1405
|
};
|
|
1241
|
-
|
|
1406
|
+
v.push(d);
|
|
1242
1407
|
}
|
|
1243
|
-
return
|
|
1244
|
-
if (b =
|
|
1245
|
-
return [
|
|
1246
|
-
for (i = 1,
|
|
1247
|
-
[n,
|
|
1248
|
-
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;
|
|
1249
1414
|
});
|
|
1250
1415
|
}
|
|
1251
|
-
return
|
|
1252
|
-
},
|
|
1253
|
-
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);
|
|
1254
1419
|
return [
|
|
1255
|
-
["C", ...o, ...
|
|
1256
|
-
["C", ...m, ...
|
|
1420
|
+
["C", ...o, ...l, ...u],
|
|
1421
|
+
["C", ...m, ...a, ...i]
|
|
1257
1422
|
];
|
|
1258
1423
|
};
|
|
1259
|
-
class
|
|
1424
|
+
class N {
|
|
1260
1425
|
/**
|
|
1261
1426
|
* @constructor
|
|
1262
|
-
* @param
|
|
1263
|
-
* @param
|
|
1427
|
+
* @param pathValue the path string
|
|
1428
|
+
* @param config instance options
|
|
1264
1429
|
*/
|
|
1265
1430
|
constructor(t, n) {
|
|
1266
|
-
const
|
|
1267
|
-
if (
|
|
1268
|
-
throw TypeError(`${
|
|
1269
|
-
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);
|
|
1270
1435
|
this.segments = i;
|
|
1271
|
-
const { width: o, height:
|
|
1272
|
-
let
|
|
1436
|
+
const { width: o, height: c, cx: a, cy: l, cz: m } = this.bbox, { round: u, origin: y } = s;
|
|
1437
|
+
let x;
|
|
1273
1438
|
if (u === "auto") {
|
|
1274
|
-
const h = `${Math.floor(Math.max(o,
|
|
1275
|
-
|
|
1276
|
-
} else Number.isInteger(u) || u === "off" ?
|
|
1277
|
-
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];
|
|
1278
1443
|
if (Array.isArray(y) && y.length >= 2) {
|
|
1279
|
-
const [h,
|
|
1444
|
+
const [h, g, p] = y.map(Number);
|
|
1280
1445
|
f = [
|
|
1281
|
-
Number.isNaN(h) ?
|
|
1282
|
-
Number.isNaN(
|
|
1446
|
+
Number.isNaN(h) ? a : h,
|
|
1447
|
+
Number.isNaN(g) ? l : g,
|
|
1283
1448
|
Number.isNaN(p) ? m : p
|
|
1284
1449
|
];
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
|
|
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);
|
|
1288
1458
|
}
|
|
1289
1459
|
/**
|
|
1290
1460
|
* Returns the path bounding box, equivalent to native `path.getBBox()`.
|
|
@@ -1293,7 +1463,7 @@ class w {
|
|
|
1293
1463
|
* @returns the pathBBox
|
|
1294
1464
|
*/
|
|
1295
1465
|
getBBox() {
|
|
1296
|
-
return
|
|
1466
|
+
return this.bbox;
|
|
1297
1467
|
}
|
|
1298
1468
|
/**
|
|
1299
1469
|
* Returns the total path length, equivalent to native `path.getTotalLength()`.
|
|
@@ -1302,7 +1472,7 @@ class w {
|
|
|
1302
1472
|
* @returns the path total length
|
|
1303
1473
|
*/
|
|
1304
1474
|
getTotalLength() {
|
|
1305
|
-
return
|
|
1475
|
+
return this.length;
|
|
1306
1476
|
}
|
|
1307
1477
|
/**
|
|
1308
1478
|
* Returns an `{x,y}` point in the path stroke at a given length,
|
|
@@ -1313,7 +1483,7 @@ class w {
|
|
|
1313
1483
|
* @returns the requested point
|
|
1314
1484
|
*/
|
|
1315
1485
|
getPointAtLength(t) {
|
|
1316
|
-
return
|
|
1486
|
+
return W(this.segments, t);
|
|
1317
1487
|
}
|
|
1318
1488
|
/**
|
|
1319
1489
|
* Convert path to absolute values
|
|
@@ -1322,7 +1492,7 @@ class w {
|
|
|
1322
1492
|
*/
|
|
1323
1493
|
toAbsolute() {
|
|
1324
1494
|
const { segments: t } = this;
|
|
1325
|
-
return this.segments =
|
|
1495
|
+
return this.segments = H(t), this;
|
|
1326
1496
|
}
|
|
1327
1497
|
/**
|
|
1328
1498
|
* Convert path to relative values
|
|
@@ -1331,7 +1501,7 @@ class w {
|
|
|
1331
1501
|
*/
|
|
1332
1502
|
toRelative() {
|
|
1333
1503
|
const { segments: t } = this;
|
|
1334
|
-
return this.segments =
|
|
1504
|
+
return this.segments = At(t), this;
|
|
1335
1505
|
}
|
|
1336
1506
|
/**
|
|
1337
1507
|
* Convert path to cubic-bezier values. In addition, un-necessary `Z`
|
|
@@ -1341,7 +1511,7 @@ class w {
|
|
|
1341
1511
|
*/
|
|
1342
1512
|
toCurve() {
|
|
1343
1513
|
const { segments: t } = this;
|
|
1344
|
-
return this.segments =
|
|
1514
|
+
return this.segments = lt(t), this;
|
|
1345
1515
|
}
|
|
1346
1516
|
/**
|
|
1347
1517
|
* Reverse the order of the segments and their values.
|
|
@@ -1351,9 +1521,9 @@ class w {
|
|
|
1351
1521
|
*/
|
|
1352
1522
|
reverse(t) {
|
|
1353
1523
|
this.toAbsolute();
|
|
1354
|
-
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);
|
|
1355
1525
|
let o = [];
|
|
1356
|
-
return
|
|
1526
|
+
return r ? o = i.flat(1) : o = t ? n : ot(n), this.segments = o.slice(0), this;
|
|
1357
1527
|
}
|
|
1358
1528
|
/**
|
|
1359
1529
|
* Normalize path in 2 steps:
|
|
@@ -1364,7 +1534,7 @@ class w {
|
|
|
1364
1534
|
*/
|
|
1365
1535
|
normalize() {
|
|
1366
1536
|
const { segments: t } = this;
|
|
1367
|
-
return this.segments =
|
|
1537
|
+
return this.segments = O(t), this;
|
|
1368
1538
|
}
|
|
1369
1539
|
/**
|
|
1370
1540
|
* Optimize `pathArray` values:
|
|
@@ -1376,7 +1546,7 @@ class w {
|
|
|
1376
1546
|
*/
|
|
1377
1547
|
optimize() {
|
|
1378
1548
|
const { segments: t } = this;
|
|
1379
|
-
return this.segments =
|
|
1549
|
+
return this.segments = Ot(t, this.round), this;
|
|
1380
1550
|
}
|
|
1381
1551
|
/**
|
|
1382
1552
|
* Transform path using values from an `Object` defined as `transformObject`.
|
|
@@ -1387,21 +1557,21 @@ class w {
|
|
|
1387
1557
|
* @public
|
|
1388
1558
|
*/
|
|
1389
1559
|
transform(t) {
|
|
1390
|
-
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))
|
|
1391
1561
|
return this;
|
|
1392
1562
|
const {
|
|
1393
1563
|
segments: n,
|
|
1394
|
-
origin: [
|
|
1564
|
+
origin: [s, r, i]
|
|
1395
1565
|
} = this, o = {};
|
|
1396
|
-
for (const [
|
|
1397
|
-
|
|
1398
|
-
const { origin:
|
|
1399
|
-
if (Array.isArray(
|
|
1400
|
-
const [
|
|
1401
|
-
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];
|
|
1402
1572
|
} else
|
|
1403
|
-
o.origin = [
|
|
1404
|
-
return this.segments =
|
|
1573
|
+
o.origin = [s, r, i];
|
|
1574
|
+
return this.segments = It(n, o), this;
|
|
1405
1575
|
}
|
|
1406
1576
|
/**
|
|
1407
1577
|
* Rotate path 180deg vertically
|
|
@@ -1427,12 +1597,12 @@ class w {
|
|
|
1427
1597
|
* @return the path string
|
|
1428
1598
|
*/
|
|
1429
1599
|
toString() {
|
|
1430
|
-
return
|
|
1600
|
+
return Pt(this.segments, this.round);
|
|
1431
1601
|
}
|
|
1432
1602
|
}
|
|
1433
1603
|
// bring main utilities to front
|
|
1434
|
-
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);
|
|
1435
1605
|
export {
|
|
1436
|
-
|
|
1606
|
+
N as default
|
|
1437
1607
|
};
|
|
1438
1608
|
//# sourceMappingURL=svg-path-commander.mjs.map
|