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