svg-path-commander 2.0.1 → 2.0.3
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 +7 -6
- package/cypress/e2e/svg-path-commander.spec.ts +0 -1
- package/dist/svg-path-commander.cjs +1 -1
- package/dist/svg-path-commander.cjs.map +1 -1
- package/dist/svg-path-commander.js +1 -1
- package/dist/svg-path-commander.js.map +1 -1
- package/dist/svg-path-commander.mjs +472 -503
- package/dist/svg-path-commander.mjs.map +1 -1
- package/package.json +78 -73
- package/vite.config.ts +1 -7
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
var Gt = Object.defineProperty;
|
|
2
|
+
var te = (e, t, n) => t in e ? Gt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var N = (e, t, n) => (te(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
1
4
|
const at = {
|
|
2
5
|
origin: [0, 0, 0],
|
|
3
6
|
round: 4
|
|
4
|
-
},
|
|
7
|
+
}, O = "SVGPathCommander Error", K = {
|
|
5
8
|
a: 7,
|
|
6
9
|
c: 6,
|
|
7
10
|
h: 1,
|
|
@@ -13,12 +16,12 @@ const at = {
|
|
|
13
16
|
t: 2,
|
|
14
17
|
v: 1,
|
|
15
18
|
z: 0
|
|
16
|
-
},
|
|
19
|
+
}, Tt = (e) => {
|
|
17
20
|
let t = e.pathValue[e.segmentStart], n = t.toLowerCase();
|
|
18
21
|
const { data: r } = e;
|
|
19
|
-
for (; r.length >=
|
|
22
|
+
for (; r.length >= K[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, K[n])]), !!K[n]); )
|
|
20
23
|
;
|
|
21
|
-
},
|
|
24
|
+
}, ee = (e) => {
|
|
22
25
|
const { index: t, pathValue: n } = e, r = n.charCodeAt(t);
|
|
23
26
|
if (r === 48) {
|
|
24
27
|
e.param = 0, e.index += 1;
|
|
@@ -28,47 +31,47 @@ const at = {
|
|
|
28
31
|
e.param = 1, e.index += 1;
|
|
29
32
|
return;
|
|
30
33
|
}
|
|
31
|
-
e.err = `${
|
|
32
|
-
},
|
|
34
|
+
e.err = `${O}: invalid Arc flag "${n[t]}", expecting 0 or 1 at index ${t}`;
|
|
35
|
+
}, D = (e) => e >= 48 && e <= 57, X = "Invalid path value", ne = (e) => {
|
|
33
36
|
const { max: t, pathValue: n, index: r } = e;
|
|
34
|
-
let s = r, i = !1, o = !1,
|
|
37
|
+
let s = r, i = !1, o = !1, a = !1, l = !1, c;
|
|
35
38
|
if (s >= t) {
|
|
36
|
-
e.err = `${
|
|
39
|
+
e.err = `${O}: ${X} at index ${s}, "pathValue" is missing param`;
|
|
37
40
|
return;
|
|
38
41
|
}
|
|
39
|
-
if (
|
|
40
|
-
e.err = `${
|
|
42
|
+
if (c = n.charCodeAt(s), (c === 43 || c === 45) && (s += 1, c = n.charCodeAt(s)), !D(c) && c !== 46) {
|
|
43
|
+
e.err = `${O}: ${X} at index ${s}, "${n[s]}" is not a number`;
|
|
41
44
|
return;
|
|
42
45
|
}
|
|
43
|
-
if (
|
|
44
|
-
if (i =
|
|
45
|
-
e.err = `${
|
|
46
|
+
if (c !== 46) {
|
|
47
|
+
if (i = c === 48, s += 1, c = n.charCodeAt(s), i && s < t && c && D(c)) {
|
|
48
|
+
e.err = `${O}: ${X} at index ${r}, "${n[r]}" illegal number`;
|
|
46
49
|
return;
|
|
47
50
|
}
|
|
48
|
-
for (; s < t &&
|
|
51
|
+
for (; s < t && D(n.charCodeAt(s)); )
|
|
49
52
|
s += 1, o = !0;
|
|
50
|
-
|
|
53
|
+
c = n.charCodeAt(s);
|
|
51
54
|
}
|
|
52
|
-
if (
|
|
53
|
-
for (
|
|
54
|
-
s += 1,
|
|
55
|
-
|
|
55
|
+
if (c === 46) {
|
|
56
|
+
for (l = !0, s += 1; D(n.charCodeAt(s)); )
|
|
57
|
+
s += 1, a = !0;
|
|
58
|
+
c = n.charCodeAt(s);
|
|
56
59
|
}
|
|
57
|
-
if (
|
|
58
|
-
if (
|
|
59
|
-
e.err = `${
|
|
60
|
+
if (c === 101 || c === 69) {
|
|
61
|
+
if (l && !o && !a) {
|
|
62
|
+
e.err = `${O}: ${X} at index ${s}, "${n[s]}" invalid float exponent`;
|
|
60
63
|
return;
|
|
61
64
|
}
|
|
62
|
-
if (s += 1,
|
|
63
|
-
for (; s < t &&
|
|
65
|
+
if (s += 1, c = n.charCodeAt(s), (c === 43 || c === 45) && (s += 1), s < t && D(n.charCodeAt(s)))
|
|
66
|
+
for (; s < t && D(n.charCodeAt(s)); )
|
|
64
67
|
s += 1;
|
|
65
68
|
else {
|
|
66
|
-
e.err = `${
|
|
69
|
+
e.err = `${O}: ${X} at index ${s}, "${n[s]}" invalid integer exponent`;
|
|
67
70
|
return;
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
73
|
e.index = s, e.param = +e.pathValue.slice(r, s);
|
|
71
|
-
},
|
|
74
|
+
}, se = (e) => [
|
|
72
75
|
// Special spaces
|
|
73
76
|
5760,
|
|
74
77
|
6158,
|
|
@@ -98,11 +101,11 @@ const at = {
|
|
|
98
101
|
11,
|
|
99
102
|
12,
|
|
100
103
|
160
|
|
101
|
-
].includes(e),
|
|
104
|
+
].includes(e), _ = (e) => {
|
|
102
105
|
const { pathValue: t, max: n } = e;
|
|
103
|
-
for (; e.index < n &&
|
|
106
|
+
for (; e.index < n && se(t.charCodeAt(e.index)); )
|
|
104
107
|
e.index += 1;
|
|
105
|
-
},
|
|
108
|
+
}, re = (e) => {
|
|
106
109
|
switch (e | 32) {
|
|
107
110
|
case 109:
|
|
108
111
|
case 122:
|
|
@@ -118,136 +121,136 @@ const at = {
|
|
|
118
121
|
default:
|
|
119
122
|
return !1;
|
|
120
123
|
}
|
|
121
|
-
},
|
|
122
|
-
const { max: t, pathValue: n, index: r } = e, s = n.charCodeAt(r), i =
|
|
123
|
-
if (e.segmentStart = r, !
|
|
124
|
-
e.err = `${
|
|
124
|
+
}, ie = (e) => D(e) || e === 43 || e === 45 || e === 46, oe = (e) => (e | 32) === 97, jt = (e) => {
|
|
125
|
+
const { max: t, pathValue: n, index: r } = e, s = n.charCodeAt(r), i = K[n[r].toLowerCase()];
|
|
126
|
+
if (e.segmentStart = r, !re(s)) {
|
|
127
|
+
e.err = `${O}: ${X} "${n[r]}" is not a path command`;
|
|
125
128
|
return;
|
|
126
129
|
}
|
|
127
|
-
if (e.index += 1,
|
|
128
|
-
|
|
130
|
+
if (e.index += 1, _(e), e.data = [], !i) {
|
|
131
|
+
Tt(e);
|
|
129
132
|
return;
|
|
130
133
|
}
|
|
131
134
|
for (; ; ) {
|
|
132
135
|
for (let o = i; o > 0; o -= 1) {
|
|
133
|
-
if (
|
|
136
|
+
if (oe(s) && (o === 3 || o === 4) ? ee(e) : ne(e), e.err.length)
|
|
134
137
|
return;
|
|
135
|
-
e.data.push(e.param),
|
|
138
|
+
e.data.push(e.param), _(e), e.index < t && n.charCodeAt(e.index) === 44 && (e.index += 1, _(e));
|
|
136
139
|
}
|
|
137
|
-
if (e.index >= e.max || !
|
|
140
|
+
if (e.index >= e.max || !ie(n.charCodeAt(e.index)))
|
|
138
141
|
break;
|
|
139
142
|
}
|
|
140
|
-
|
|
143
|
+
Tt(e);
|
|
141
144
|
};
|
|
142
|
-
class
|
|
145
|
+
class Et {
|
|
143
146
|
constructor(t) {
|
|
144
147
|
this.segments = [], this.pathValue = t, this.max = t.length, this.index = 0, this.param = 0, this.segmentStart = 0, this.data = [], this.err = "";
|
|
145
148
|
}
|
|
146
149
|
}
|
|
147
|
-
const
|
|
150
|
+
const mt = (e) => Array.isArray(e) && e.every((t) => {
|
|
148
151
|
const n = t[0].toLowerCase();
|
|
149
|
-
return
|
|
150
|
-
}),
|
|
151
|
-
if (
|
|
152
|
+
return K[n] === t.length - 1 && "achlmqstvz".includes(n);
|
|
153
|
+
}), Q = (e) => {
|
|
154
|
+
if (mt(e))
|
|
152
155
|
return [...e];
|
|
153
|
-
const t = new
|
|
154
|
-
for (
|
|
155
|
-
|
|
156
|
+
const t = new Et(e);
|
|
157
|
+
for (_(t); t.index < t.max && !t.err.length; )
|
|
158
|
+
jt(t);
|
|
156
159
|
if (t.err && t.err.length)
|
|
157
160
|
throw TypeError(t.err);
|
|
158
161
|
return t.segments;
|
|
159
|
-
},
|
|
162
|
+
}, ce = (e) => {
|
|
160
163
|
const t = e.length;
|
|
161
164
|
let n = -1, r, s = e[t - 1], i = 0;
|
|
162
165
|
for (; ++n < t; )
|
|
163
166
|
r = s, s = e[n], i += r[1] * s[0] - r[0] * s[1];
|
|
164
167
|
return i / 2;
|
|
165
|
-
},
|
|
166
|
-
var
|
|
167
|
-
const
|
|
168
|
-
const t = new
|
|
169
|
-
if (!
|
|
168
|
+
}, V = (e, t) => Math.sqrt((e[0] - t[0]) * (e[0] - t[0]) + (e[1] - t[1]) * (e[1] - t[1])), le = (e) => e.reduce((t, n, r) => r ? t + V(e[r - 1], n) : 0, 0);
|
|
169
|
+
var ae = Object.defineProperty, me = (e, t, n) => t in e ? ae(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, C = (e, t, n) => (me(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
170
|
+
const he = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, m11: 1, m12: 0, m13: 0, m14: 0, m21: 0, m22: 1, m23: 0, m24: 0, m31: 0, m32: 0, m33: 1, m34: 0, m41: 0, m42: 0, m43: 0, m44: 1, is2D: !0, isIdentity: !0 }, Dt = (e) => (e instanceof Float64Array || e instanceof Float32Array || Array.isArray(e) && e.every((t) => typeof t == "number")) && [6, 16].some((t) => e.length === t), Zt = (e) => e instanceof DOMMatrix || e instanceof w || typeof e == "object" && Object.keys(he).every((t) => e && t in e), G = (e) => {
|
|
171
|
+
const t = new w(), n = Array.from(e);
|
|
172
|
+
if (!Dt(n))
|
|
170
173
|
throw TypeError(`CSSMatrix: "${n.join(",")}" must be an array with 6/16 numbers.`);
|
|
171
174
|
if (n.length === 16) {
|
|
172
|
-
const [r, s, i, o, l, c,
|
|
173
|
-
t.m11 = r, t.a = r, t.m21 =
|
|
175
|
+
const [r, s, i, o, a, l, c, m, f, y, g, h, u, x, p, b] = n;
|
|
176
|
+
t.m11 = r, t.a = r, t.m21 = a, t.c = a, t.m31 = f, t.m41 = u, t.e = u, t.m12 = s, t.b = s, t.m22 = l, t.d = l, t.m32 = y, t.m42 = x, t.f = x, t.m13 = i, t.m23 = c, t.m33 = g, t.m43 = p, t.m14 = o, t.m24 = m, t.m34 = h, t.m44 = b;
|
|
174
177
|
} else if (n.length === 6) {
|
|
175
|
-
const [r, s, i, o,
|
|
176
|
-
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 =
|
|
178
|
+
const [r, s, i, o, a, l] = n;
|
|
179
|
+
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 = a, t.e = a, t.m42 = l, t.f = l;
|
|
177
180
|
}
|
|
178
181
|
return t;
|
|
179
|
-
},
|
|
180
|
-
if (
|
|
181
|
-
return
|
|
182
|
+
}, Rt = (e) => {
|
|
183
|
+
if (Zt(e))
|
|
184
|
+
return G([e.m11, e.m12, e.m13, e.m14, e.m21, e.m22, e.m23, e.m24, e.m31, e.m32, e.m33, e.m34, e.m41, e.m42, e.m43, e.m44]);
|
|
182
185
|
throw TypeError(`CSSMatrix: "${JSON.stringify(e)}" is not a DOMMatrix / CSSMatrix / JSON compatible object.`);
|
|
183
|
-
},
|
|
186
|
+
}, Xt = (e) => {
|
|
184
187
|
if (typeof e != "string")
|
|
185
188
|
throw TypeError(`CSSMatrix: "${JSON.stringify(e)}" is not a string.`);
|
|
186
189
|
const t = String(e).replace(/\s/g, "");
|
|
187
|
-
let n = new
|
|
190
|
+
let n = new w();
|
|
188
191
|
const r = `CSSMatrix: invalid transform string "${e}"`;
|
|
189
192
|
return t.split(")").filter((s) => s).forEach((s) => {
|
|
190
193
|
const [i, o] = s.split("(");
|
|
191
194
|
if (!o)
|
|
192
195
|
throw TypeError(r);
|
|
193
|
-
const
|
|
194
|
-
if (i === "perspective" &&
|
|
195
|
-
n.m34 = -1 /
|
|
196
|
-
else if (i.includes("matrix") && [6, 16].includes(
|
|
197
|
-
const h =
|
|
198
|
-
n = n.multiply(
|
|
196
|
+
const a = o.split(",").map((h) => h.includes("rad") ? parseFloat(h) * (180 / Math.PI) : parseFloat(h)), [l, c, m, f] = a, y = [l, c, m], g = [l, c, m, f];
|
|
197
|
+
if (i === "perspective" && l && [c, m].every((h) => h === void 0))
|
|
198
|
+
n.m34 = -1 / l;
|
|
199
|
+
else if (i.includes("matrix") && [6, 16].includes(a.length) && a.every((h) => !Number.isNaN(+h))) {
|
|
200
|
+
const h = a.map((u) => Math.abs(u) < 1e-6 ? 0 : u);
|
|
201
|
+
n = n.multiply(G(h));
|
|
199
202
|
} else if (i === "translate3d" && y.every((h) => !Number.isNaN(+h)))
|
|
200
|
-
n = n.translate(
|
|
201
|
-
else if (i === "translate" &&
|
|
202
|
-
n = n.translate(
|
|
203
|
+
n = n.translate(l, c, m);
|
|
204
|
+
else if (i === "translate" && l && m === void 0)
|
|
205
|
+
n = n.translate(l, c || 0, 0);
|
|
203
206
|
else if (i === "rotate3d" && g.every((h) => !Number.isNaN(+h)) && f)
|
|
204
|
-
n = n.rotateAxisAngle(
|
|
205
|
-
else if (i === "rotate" &&
|
|
206
|
-
n = n.rotate(0, 0,
|
|
207
|
+
n = n.rotateAxisAngle(l, c, m, f);
|
|
208
|
+
else if (i === "rotate" && l && [c, m].every((h) => h === void 0))
|
|
209
|
+
n = n.rotate(0, 0, l);
|
|
207
210
|
else if (i === "scale3d" && y.every((h) => !Number.isNaN(+h)) && y.some((h) => h !== 1))
|
|
208
|
-
n = n.scale(
|
|
209
|
-
else if (i === "scale" && !Number.isNaN(
|
|
210
|
-
const h = Number.isNaN(+
|
|
211
|
-
n = n.scale(
|
|
212
|
-
} else if (i === "skew" && (
|
|
213
|
-
n = n.skew(
|
|
214
|
-
else if (["translate", "rotate", "scale", "skew"].some((h) => i.includes(h)) && /[XYZ]/.test(i) &&
|
|
211
|
+
n = n.scale(l, c, m);
|
|
212
|
+
else if (i === "scale" && !Number.isNaN(l) && l !== 1 && m === void 0) {
|
|
213
|
+
const h = Number.isNaN(+c) ? l : c;
|
|
214
|
+
n = n.scale(l, h, 1);
|
|
215
|
+
} else if (i === "skew" && (l || !Number.isNaN(l) && c) && m === void 0)
|
|
216
|
+
n = n.skew(l, c || 0);
|
|
217
|
+
else if (["translate", "rotate", "scale", "skew"].some((h) => i.includes(h)) && /[XYZ]/.test(i) && l && [c, m].every((h) => h === void 0))
|
|
215
218
|
if (i === "skewX" || i === "skewY")
|
|
216
|
-
n = n[i](
|
|
219
|
+
n = n[i](l);
|
|
217
220
|
else {
|
|
218
|
-
const h = i.replace(/[XYZ]/, ""), u = i.replace(h, ""), x = ["X", "Y", "Z"].indexOf(u),
|
|
219
|
-
n = n[h](...
|
|
221
|
+
const h = i.replace(/[XYZ]/, ""), u = i.replace(h, ""), x = ["X", "Y", "Z"].indexOf(u), p = h === "scale" ? 1 : 0, b = [x === 0 ? l : p, x === 1 ? l : p, x === 2 ? l : p];
|
|
222
|
+
n = n[h](...b);
|
|
220
223
|
}
|
|
221
224
|
else
|
|
222
225
|
throw TypeError(r);
|
|
223
226
|
}), n;
|
|
224
|
-
},
|
|
225
|
-
const r = new
|
|
227
|
+
}, bt = (e, t) => t ? [e.a, e.b, e.c, e.d, e.e, e.f] : [e.m11, e.m12, e.m13, e.m14, e.m21, e.m22, e.m23, e.m24, e.m31, e.m32, e.m33, e.m34, e.m41, e.m42, e.m43, e.m44], Ft = (e, t, n) => {
|
|
228
|
+
const r = new w();
|
|
226
229
|
return r.m41 = e, r.e = e, r.m42 = t, r.f = t, r.m43 = n, r;
|
|
227
|
-
},
|
|
228
|
-
const r = new
|
|
230
|
+
}, Qt = (e, t, n) => {
|
|
231
|
+
const r = new w(), s = Math.PI / 180, i = e * s, o = t * s, a = n * s, l = Math.cos(i), c = -Math.sin(i), m = Math.cos(o), f = -Math.sin(o), y = Math.cos(a), g = -Math.sin(a), h = m * y, u = -m * g;
|
|
229
232
|
r.m11 = h, r.a = h, r.m12 = u, r.b = u, r.m13 = f;
|
|
230
|
-
const x =
|
|
233
|
+
const x = c * f * y + l * g;
|
|
231
234
|
r.m21 = x, r.c = x;
|
|
232
|
-
const
|
|
233
|
-
return r.m22 =
|
|
234
|
-
},
|
|
235
|
-
const s = new
|
|
235
|
+
const p = l * y - c * f * g;
|
|
236
|
+
return r.m22 = p, r.d = p, r.m23 = -c * m, r.m31 = c * g - l * f * y, r.m32 = c * y + l * f * g, r.m33 = l * m, r;
|
|
237
|
+
}, Ht = (e, t, n, r) => {
|
|
238
|
+
const s = new w(), i = Math.sqrt(e * e + t * t + n * n);
|
|
236
239
|
if (i === 0)
|
|
237
240
|
return s;
|
|
238
|
-
const o = e / i,
|
|
241
|
+
const o = e / i, a = t / i, l = n / i, c = r * (Math.PI / 360), m = Math.sin(c), f = Math.cos(c), y = m * m, g = o * o, h = a * a, u = l * l, x = 1 - 2 * (h + u) * y;
|
|
239
242
|
s.m11 = x, s.a = x;
|
|
240
|
-
const
|
|
241
|
-
s.m12 =
|
|
242
|
-
const
|
|
243
|
-
s.m21 =
|
|
243
|
+
const p = 2 * (o * a * y + l * m * f);
|
|
244
|
+
s.m12 = p, s.b = p, s.m13 = 2 * (o * l * y - a * m * f);
|
|
245
|
+
const b = 2 * (a * o * y - l * m * f);
|
|
246
|
+
s.m21 = b, s.c = b;
|
|
244
247
|
const A = 1 - 2 * (u + g) * y;
|
|
245
|
-
return s.m22 = A, s.d = A, s.m23 = 2 * (
|
|
246
|
-
},
|
|
247
|
-
const r = new
|
|
248
|
+
return s.m22 = A, s.d = A, s.m23 = 2 * (a * l * y + o * m * f), s.m31 = 2 * (l * o * y + a * m * f), s.m32 = 2 * (l * a * y - o * m * f), s.m33 = 1 - 2 * (g + h) * y, s;
|
|
249
|
+
}, Yt = (e, t, n) => {
|
|
250
|
+
const r = new w();
|
|
248
251
|
return r.m11 = e, r.a = e, r.m22 = t, r.d = t, r.m33 = n, r;
|
|
249
|
-
},
|
|
250
|
-
const n = new
|
|
252
|
+
}, ht = (e, t) => {
|
|
253
|
+
const n = new w();
|
|
251
254
|
if (e) {
|
|
252
255
|
const r = e * Math.PI / 180, s = Math.tan(r);
|
|
253
256
|
n.m21 = s, n.c = s;
|
|
@@ -257,11 +260,11 @@ const ae = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, m11: 1, m12: 0, m13: 0, m14: 0,
|
|
|
257
260
|
n.m12 = s, n.b = s;
|
|
258
261
|
}
|
|
259
262
|
return n;
|
|
260
|
-
},
|
|
261
|
-
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,
|
|
262
|
-
return
|
|
263
|
+
}, Bt = (e) => ht(e, 0), Jt = (e) => ht(0, e), $ = (e, t) => {
|
|
264
|
+
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, a = 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, c = 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, f = 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, g = 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, u = 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;
|
|
265
|
+
return G([n, r, s, i, o, a, l, c, m, f, y, g, h, u, x, p]);
|
|
263
266
|
};
|
|
264
|
-
class
|
|
267
|
+
class w {
|
|
265
268
|
constructor(t) {
|
|
266
269
|
return this.a = 1, this.b = 0, this.c = 0, this.d = 1, this.e = 0, this.f = 0, this.m11 = 1, this.m12 = 0, this.m13 = 0, this.m14 = 0, this.m21 = 0, this.m22 = 1, this.m23 = 0, this.m24 = 0, this.m31 = 0, this.m32 = 0, this.m33 = 1, this.m34 = 0, this.m41 = 0, this.m42 = 0, this.m43 = 0, this.m44 = 1, t ? this.setMatrixValue(t) : this;
|
|
267
270
|
}
|
|
@@ -272,13 +275,13 @@ class N {
|
|
|
272
275
|
return this.m31 === 0 && this.m32 === 0 && this.m33 === 1 && this.m34 === 0 && this.m43 === 0 && this.m44 === 1;
|
|
273
276
|
}
|
|
274
277
|
setMatrixValue(t) {
|
|
275
|
-
return typeof t == "string" && t.length && t !== "none" ?
|
|
278
|
+
return typeof t == "string" && t.length && t !== "none" ? Xt(t) : Array.isArray(t) || t instanceof Float64Array || t instanceof Float32Array ? G(t) : typeof t == "object" ? Rt(t) : this;
|
|
276
279
|
}
|
|
277
280
|
toFloat32Array(t) {
|
|
278
|
-
return Float32Array.from(
|
|
281
|
+
return Float32Array.from(bt(this, t));
|
|
279
282
|
}
|
|
280
283
|
toFloat64Array(t) {
|
|
281
|
-
return Float64Array.from(
|
|
284
|
+
return Float64Array.from(bt(this, t));
|
|
282
285
|
}
|
|
283
286
|
toString() {
|
|
284
287
|
const { is2D: t } = this, n = this.toFloat64Array(t).join(", ");
|
|
@@ -289,103 +292,103 @@ class N {
|
|
|
289
292
|
return { ...this, is2D: t, isIdentity: n };
|
|
290
293
|
}
|
|
291
294
|
multiply(t) {
|
|
292
|
-
return
|
|
295
|
+
return $(this, t);
|
|
293
296
|
}
|
|
294
297
|
translate(t, n, r) {
|
|
295
298
|
const s = t;
|
|
296
299
|
let i = n, o = r;
|
|
297
|
-
return typeof i > "u" && (i = 0), typeof o > "u" && (o = 0),
|
|
300
|
+
return typeof i > "u" && (i = 0), typeof o > "u" && (o = 0), $(this, Ft(s, i, o));
|
|
298
301
|
}
|
|
299
302
|
scale(t, n, r) {
|
|
300
303
|
const s = t;
|
|
301
304
|
let i = n, o = r;
|
|
302
|
-
return typeof i > "u" && (i = t), typeof o > "u" && (o = 1),
|
|
305
|
+
return typeof i > "u" && (i = t), typeof o > "u" && (o = 1), $(this, Yt(s, i, o));
|
|
303
306
|
}
|
|
304
307
|
rotate(t, n, r) {
|
|
305
308
|
let s = t, i = n || 0, o = r || 0;
|
|
306
|
-
return typeof t == "number" && typeof n > "u" && typeof r > "u" && (o = s, s = 0, i = 0),
|
|
309
|
+
return typeof t == "number" && typeof n > "u" && typeof r > "u" && (o = s, s = 0, i = 0), $(this, Qt(s, i, o));
|
|
307
310
|
}
|
|
308
311
|
rotateAxisAngle(t, n, r, s) {
|
|
309
312
|
if ([t, n, r, s].some((i) => Number.isNaN(+i)))
|
|
310
313
|
throw new TypeError("CSSMatrix: expecting 4 values");
|
|
311
|
-
return
|
|
314
|
+
return $(this, Ht(t, n, r, s));
|
|
312
315
|
}
|
|
313
316
|
skewX(t) {
|
|
314
|
-
return
|
|
317
|
+
return $(this, Bt(t));
|
|
315
318
|
}
|
|
316
319
|
skewY(t) {
|
|
317
|
-
return
|
|
320
|
+
return $(this, Jt(t));
|
|
318
321
|
}
|
|
319
322
|
skew(t, n) {
|
|
320
|
-
return
|
|
323
|
+
return $(this, ht(t, n));
|
|
321
324
|
}
|
|
322
325
|
transformPoint(t) {
|
|
323
326
|
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;
|
|
324
327
|
return t instanceof DOMPoint ? new DOMPoint(n, r, s, i) : { x: n, y: r, z: s, w: i };
|
|
325
328
|
}
|
|
326
329
|
}
|
|
327
|
-
C(
|
|
328
|
-
var
|
|
329
|
-
const
|
|
330
|
-
e.every(([t]) => t === t.toUpperCase()),
|
|
331
|
-
if (
|
|
330
|
+
C(w, "Translate", Ft), C(w, "Rotate", Qt), C(w, "RotateAxisAngle", Ht), C(w, "Scale", Yt), C(w, "SkewX", Bt), C(w, "SkewY", Jt), C(w, "Skew", ht), C(w, "Multiply", $), C(w, "fromArray", G), C(w, "fromMatrix", Rt), C(w, "fromString", Xt), C(w, "toArray", bt), C(w, "isCompatibleArray", Dt), C(w, "isCompatibleObject", Zt);
|
|
331
|
+
var Nt = w;
|
|
332
|
+
const vt = (e) => mt(e) && // `isPathArray` also checks if it's `Array`
|
|
333
|
+
e.every(([t]) => t === t.toUpperCase()), H = (e) => {
|
|
334
|
+
if (vt(e))
|
|
332
335
|
return [...e];
|
|
333
|
-
const t =
|
|
336
|
+
const t = Q(e);
|
|
334
337
|
let n = 0, r = 0, s = 0, i = 0;
|
|
335
338
|
return t.map((o) => {
|
|
336
|
-
const
|
|
337
|
-
if (
|
|
338
|
-
return [n, r] =
|
|
339
|
+
const a = o.slice(1).map(Number), [l] = o, c = l.toUpperCase();
|
|
340
|
+
if (l === "M")
|
|
341
|
+
return [n, r] = a, s = n, i = r, ["M", n, r];
|
|
339
342
|
let m = [];
|
|
340
|
-
if (
|
|
341
|
-
if (
|
|
343
|
+
if (l !== c)
|
|
344
|
+
if (c === "A")
|
|
342
345
|
m = [
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
346
|
+
c,
|
|
347
|
+
a[0],
|
|
348
|
+
a[1],
|
|
349
|
+
a[2],
|
|
350
|
+
a[3],
|
|
351
|
+
a[4],
|
|
352
|
+
a[5] + n,
|
|
353
|
+
a[6] + r
|
|
351
354
|
];
|
|
352
|
-
else if (
|
|
353
|
-
m = [
|
|
354
|
-
else if (
|
|
355
|
-
m = [
|
|
355
|
+
else if (c === "V")
|
|
356
|
+
m = [c, a[0] + r];
|
|
357
|
+
else if (c === "H")
|
|
358
|
+
m = [c, a[0] + n];
|
|
356
359
|
else {
|
|
357
|
-
const f =
|
|
358
|
-
m = [
|
|
360
|
+
const f = a.map((y, g) => y + (g % 2 ? r : n));
|
|
361
|
+
m = [c, ...f];
|
|
359
362
|
}
|
|
360
363
|
else
|
|
361
|
-
m = [
|
|
362
|
-
return
|
|
364
|
+
m = [c, ...a];
|
|
365
|
+
return c === "Z" ? (n = s, r = i) : c === "H" ? [, n] = m : c === "V" ? [, r] = m : ([n, r] = m.slice(-2), c === "M" && (s = n, i = r)), m;
|
|
363
366
|
});
|
|
364
|
-
},
|
|
365
|
-
const [n] = e, { x1: r, y1: s, x2: i, y2: o } = t,
|
|
366
|
-
let
|
|
367
|
+
}, ue = (e, t) => {
|
|
368
|
+
const [n] = e, { x1: r, y1: s, x2: i, y2: o } = t, a = e.slice(1).map(Number);
|
|
369
|
+
let l = e;
|
|
367
370
|
if ("TQ".includes(n) || (t.qx = null, t.qy = null), n === "H")
|
|
368
|
-
|
|
371
|
+
l = ["L", e[1], s];
|
|
369
372
|
else if (n === "V")
|
|
370
|
-
|
|
373
|
+
l = ["L", r, e[1]];
|
|
371
374
|
else if (n === "S") {
|
|
372
|
-
const
|
|
373
|
-
t.x1 =
|
|
375
|
+
const c = r * 2 - i, m = s * 2 - o;
|
|
376
|
+
t.x1 = c, t.y1 = m, l = ["C", c, m, ...a];
|
|
374
377
|
} else if (n === "T") {
|
|
375
|
-
const
|
|
378
|
+
const c = r * 2 - (t.qx ? t.qx : (
|
|
376
379
|
/* istanbul ignore next */
|
|
377
380
|
0
|
|
378
381
|
)), m = s * 2 - (t.qy ? t.qy : (
|
|
379
382
|
/* istanbul ignore next */
|
|
380
383
|
0
|
|
381
384
|
));
|
|
382
|
-
t.qx =
|
|
385
|
+
t.qx = c, t.qy = m, l = ["Q", c, m, ...a];
|
|
383
386
|
} else if (n === "Q") {
|
|
384
|
-
const [
|
|
385
|
-
t.qx =
|
|
387
|
+
const [c, m] = a;
|
|
388
|
+
t.qx = c, t.qy = m;
|
|
386
389
|
}
|
|
387
|
-
return
|
|
388
|
-
},
|
|
390
|
+
return l;
|
|
391
|
+
}, wt = (e) => vt(e) && e.every(([t]) => "ACLMQZ".includes(t)), ut = {
|
|
389
392
|
x1: 0,
|
|
390
393
|
y1: 0,
|
|
391
394
|
x2: 0,
|
|
@@ -394,21 +397,21 @@ e.every(([t]) => t === t.toUpperCase()), X = (e) => {
|
|
|
394
397
|
y: 0,
|
|
395
398
|
qx: null,
|
|
396
399
|
qy: null
|
|
397
|
-
},
|
|
398
|
-
if (
|
|
400
|
+
}, j = (e) => {
|
|
401
|
+
if (wt(e))
|
|
399
402
|
return [...e];
|
|
400
|
-
const t =
|
|
403
|
+
const t = H(e), n = { ...ut }, r = t.length;
|
|
401
404
|
for (let s = 0; s < r; s += 1) {
|
|
402
|
-
t[s], t[s] =
|
|
405
|
+
t[s], t[s] = ue(t[s], n);
|
|
403
406
|
const i = t[s], o = i.length;
|
|
404
407
|
n.x1 = +i[o - 2], n.y1 = +i[o - 1], n.x2 = +i[o - 4] || n.x1, n.y2 = +i[o - 3] || n.y1;
|
|
405
408
|
}
|
|
406
409
|
return t;
|
|
407
|
-
},
|
|
410
|
+
}, I = (e, t, n) => {
|
|
408
411
|
const [r, s] = e, [i, o] = t;
|
|
409
412
|
return [r + (i - r) * n, s + (o - s) * n];
|
|
410
413
|
}, dt = (e, t, n, r, s) => {
|
|
411
|
-
const i =
|
|
414
|
+
const i = V([e, t], [n, r]);
|
|
412
415
|
let o = { x: 0, y: 0 };
|
|
413
416
|
if (typeof s == "number")
|
|
414
417
|
if (s <= 0)
|
|
@@ -416,8 +419,8 @@ e.every(([t]) => t === t.toUpperCase()), X = (e) => {
|
|
|
416
419
|
else if (s >= i)
|
|
417
420
|
o = { x: n, y: r };
|
|
418
421
|
else {
|
|
419
|
-
const [
|
|
420
|
-
o = { x:
|
|
422
|
+
const [a, l] = I([e, t], [n, r], s / i);
|
|
423
|
+
o = { x: a, y: l };
|
|
421
424
|
}
|
|
422
425
|
return {
|
|
423
426
|
length: i,
|
|
@@ -431,171 +434,171 @@ e.every(([t]) => t === t.toUpperCase()), X = (e) => {
|
|
|
431
434
|
y: Math.max(t, r)
|
|
432
435
|
}
|
|
433
436
|
};
|
|
434
|
-
},
|
|
435
|
-
const { x: n, y: r } = e, { x: s, y: i } = t, o = n * s + r * i,
|
|
436
|
-
return (n * i - r * s < 0 ? -1 : 1) * Math.acos(o /
|
|
437
|
-
},
|
|
437
|
+
}, Lt = (e, t) => {
|
|
438
|
+
const { x: n, y: r } = e, { x: s, y: i } = t, o = n * s + r * i, a = Math.sqrt((n ** 2 + r ** 2) * (s ** 2 + i ** 2));
|
|
439
|
+
return (n * i - r * s < 0 ? -1 : 1) * Math.acos(o / a);
|
|
440
|
+
}, fe = (e, t, n, r, s, i, o, a, l, c) => {
|
|
438
441
|
const { abs: m, sin: f, cos: y, sqrt: g, PI: h } = Math;
|
|
439
442
|
let u = m(n), x = m(r);
|
|
440
|
-
const
|
|
441
|
-
if (e ===
|
|
443
|
+
const b = (s % 360 + 360) % 360 * (h / 180);
|
|
444
|
+
if (e === a && t === l)
|
|
442
445
|
return { x: e, y: t };
|
|
443
446
|
if (u === 0 || x === 0)
|
|
444
|
-
return dt(e, t, l, c
|
|
445
|
-
const A = (e -
|
|
446
|
-
x: y(
|
|
447
|
-
y: -f(
|
|
448
|
-
},
|
|
449
|
-
|
|
450
|
-
const
|
|
451
|
-
let
|
|
452
|
-
|
|
453
|
-
const
|
|
454
|
-
x:
|
|
455
|
-
y:
|
|
456
|
-
},
|
|
457
|
-
x: y(
|
|
458
|
-
y: f(
|
|
459
|
-
},
|
|
460
|
-
x: (M.x -
|
|
461
|
-
y: (M.y -
|
|
462
|
-
},
|
|
463
|
-
x: (-M.x -
|
|
464
|
-
y: (-M.y -
|
|
447
|
+
return dt(e, t, a, l, c).point;
|
|
448
|
+
const A = (e - a) / 2, d = (t - l) / 2, M = {
|
|
449
|
+
x: y(b) * A + f(b) * d,
|
|
450
|
+
y: -f(b) * A + y(b) * d
|
|
451
|
+
}, T = M.x ** 2 / u ** 2 + M.y ** 2 / x ** 2;
|
|
452
|
+
T > 1 && (u *= g(T), x *= g(T));
|
|
453
|
+
const z = u ** 2 * x ** 2 - u ** 2 * M.y ** 2 - x ** 2 * M.x ** 2, Y = u ** 2 * M.y ** 2 + x ** 2 * M.x ** 2;
|
|
454
|
+
let R = z / Y;
|
|
455
|
+
R = R < 0 ? 0 : R;
|
|
456
|
+
const tt = (i !== o ? 1 : -1) * g(R), k = {
|
|
457
|
+
x: tt * (u * M.y / x),
|
|
458
|
+
y: tt * (-(x * M.x) / u)
|
|
459
|
+
}, et = {
|
|
460
|
+
x: y(b) * k.x - f(b) * k.y + (e + a) / 2,
|
|
461
|
+
y: f(b) * k.x + y(b) * k.y + (t + l) / 2
|
|
462
|
+
}, B = {
|
|
463
|
+
x: (M.x - k.x) / u,
|
|
464
|
+
y: (M.y - k.y) / x
|
|
465
|
+
}, nt = Lt({ x: 1, y: 0 }, B), st = {
|
|
466
|
+
x: (-M.x - k.x) / u,
|
|
467
|
+
y: (-M.y - k.y) / x
|
|
465
468
|
};
|
|
466
|
-
let
|
|
467
|
-
!o &&
|
|
468
|
-
const
|
|
469
|
+
let S = Lt(B, st);
|
|
470
|
+
!o && S > 0 ? S -= 2 * h : o && S < 0 && (S += 2 * h), S %= 2 * h;
|
|
471
|
+
const q = nt + S * c, J = u * y(q), U = x * f(q);
|
|
469
472
|
return {
|
|
470
|
-
x: y(
|
|
471
|
-
y: f(
|
|
473
|
+
x: y(b) * J - f(b) * U + et.x,
|
|
474
|
+
y: f(b) * J + y(b) * U + et.y
|
|
472
475
|
};
|
|
473
|
-
},
|
|
474
|
-
const m = typeof
|
|
475
|
-
let f = e, y = t, g = 0, h = [f, y, g], u = [f, y], x = 0,
|
|
476
|
-
m &&
|
|
476
|
+
}, ye = (e, t, n, r, s, i, o, a, l, c) => {
|
|
477
|
+
const m = typeof c == "number";
|
|
478
|
+
let f = e, y = t, g = 0, h = [f, y, g], u = [f, y], x = 0, p = { x: 0, y: 0 }, b = [{ x: f, y }];
|
|
479
|
+
m && c <= 0 && (p = { x: f, y });
|
|
477
480
|
const A = 300;
|
|
478
|
-
for (let
|
|
479
|
-
if (x =
|
|
480
|
-
const M = (g -
|
|
481
|
-
|
|
481
|
+
for (let d = 0; d <= A; d += 1) {
|
|
482
|
+
if (x = d / A, { x: f, y } = fe(e, t, n, r, s, i, o, a, l, x), b = [...b, { x: f, y }], g += V(u, [f, y]), u = [f, y], m && g > c && c > h[2]) {
|
|
483
|
+
const M = (g - c) / (g - h[2]);
|
|
484
|
+
p = {
|
|
482
485
|
x: u[0] * (1 - M) + h[0] * M,
|
|
483
486
|
y: u[1] * (1 - M) + h[1] * M
|
|
484
487
|
};
|
|
485
488
|
}
|
|
486
489
|
h = [f, y, g];
|
|
487
490
|
}
|
|
488
|
-
return m &&
|
|
491
|
+
return m && c >= g && (p = { x: a, y: l }), {
|
|
489
492
|
length: g,
|
|
490
|
-
point:
|
|
493
|
+
point: p,
|
|
491
494
|
min: {
|
|
492
|
-
x: Math.min(...
|
|
493
|
-
y: Math.min(...
|
|
495
|
+
x: Math.min(...b.map((d) => d.x)),
|
|
496
|
+
y: Math.min(...b.map((d) => d.y))
|
|
494
497
|
},
|
|
495
498
|
max: {
|
|
496
|
-
x: Math.max(...
|
|
497
|
-
y: Math.max(...
|
|
499
|
+
x: Math.max(...b.map((d) => d.x)),
|
|
500
|
+
y: Math.max(...b.map((d) => d.y))
|
|
498
501
|
}
|
|
499
502
|
};
|
|
500
|
-
},
|
|
501
|
-
const
|
|
503
|
+
}, ge = (e, t, n, r, s, i, o, a, l) => {
|
|
504
|
+
const c = 1 - l;
|
|
502
505
|
return {
|
|
503
|
-
x:
|
|
504
|
-
y:
|
|
506
|
+
x: c ** 3 * e + 3 * c ** 2 * l * n + 3 * c * l ** 2 * s + l ** 3 * o,
|
|
507
|
+
y: c ** 3 * t + 3 * c ** 2 * l * r + 3 * c * l ** 2 * i + l ** 3 * a
|
|
505
508
|
};
|
|
506
|
-
},
|
|
507
|
-
const
|
|
508
|
-
let m = e, f = t, y = 0, g = [m, f, y], h = [m, f], u = 0, x = { x: 0, y: 0 },
|
|
509
|
-
|
|
510
|
-
const
|
|
511
|
-
for (let A = 0; A <=
|
|
512
|
-
if (u = A /
|
|
513
|
-
const
|
|
509
|
+
}, xe = (e, t, n, r, s, i, o, a, l) => {
|
|
510
|
+
const c = typeof l == "number";
|
|
511
|
+
let m = e, f = t, y = 0, g = [m, f, y], h = [m, f], u = 0, x = { x: 0, y: 0 }, p = [{ x: m, y: f }];
|
|
512
|
+
c && l <= 0 && (x = { x: m, y: f });
|
|
513
|
+
const b = 300;
|
|
514
|
+
for (let A = 0; A <= b; A += 1) {
|
|
515
|
+
if (u = A / b, { x: m, y: f } = ge(e, t, n, r, s, i, o, a, u), p = [...p, { x: m, y: f }], y += V(h, [m, f]), h = [m, f], c && y > l && l > g[2]) {
|
|
516
|
+
const d = (y - l) / (y - g[2]);
|
|
514
517
|
x = {
|
|
515
|
-
x: h[0] * (1 -
|
|
516
|
-
y: h[1] * (1 -
|
|
518
|
+
x: h[0] * (1 - d) + g[0] * d,
|
|
519
|
+
y: h[1] * (1 - d) + g[1] * d
|
|
517
520
|
};
|
|
518
521
|
}
|
|
519
522
|
g = [m, f, y];
|
|
520
523
|
}
|
|
521
|
-
return
|
|
524
|
+
return c && l >= y && (x = { x: o, y: a }), {
|
|
522
525
|
length: y,
|
|
523
526
|
point: x,
|
|
524
527
|
min: {
|
|
525
|
-
x: Math.min(...
|
|
526
|
-
y: Math.min(...
|
|
528
|
+
x: Math.min(...p.map((A) => A.x)),
|
|
529
|
+
y: Math.min(...p.map((A) => A.y))
|
|
527
530
|
},
|
|
528
531
|
max: {
|
|
529
|
-
x: Math.max(...
|
|
530
|
-
y: Math.max(...
|
|
532
|
+
x: Math.max(...p.map((A) => A.x)),
|
|
533
|
+
y: Math.max(...p.map((A) => A.y))
|
|
531
534
|
}
|
|
532
535
|
};
|
|
533
|
-
},
|
|
534
|
-
const
|
|
536
|
+
}, pe = (e, t, n, r, s, i, o) => {
|
|
537
|
+
const a = 1 - o;
|
|
535
538
|
return {
|
|
536
|
-
x:
|
|
537
|
-
y:
|
|
539
|
+
x: a ** 2 * e + 2 * a * o * n + o ** 2 * s,
|
|
540
|
+
y: a ** 2 * t + 2 * a * o * r + o ** 2 * i
|
|
538
541
|
};
|
|
539
|
-
},
|
|
540
|
-
const
|
|
541
|
-
let
|
|
542
|
-
|
|
542
|
+
}, be = (e, t, n, r, s, i, o) => {
|
|
543
|
+
const a = typeof o == "number";
|
|
544
|
+
let l = e, c = t, m = 0, f = [l, c, m], y = [l, c], g = 0, h = { x: 0, y: 0 }, u = [{ x: l, y: c }];
|
|
545
|
+
a && o <= 0 && (h = { x: l, y: c });
|
|
543
546
|
const x = 300;
|
|
544
|
-
for (let
|
|
545
|
-
if (g =
|
|
546
|
-
const
|
|
547
|
+
for (let p = 0; p <= x; p += 1) {
|
|
548
|
+
if (g = p / x, { x: l, y: c } = pe(e, t, n, r, s, i, g), u = [...u, { x: l, y: c }], m += V(y, [l, c]), y = [l, c], a && m > o && o > f[2]) {
|
|
549
|
+
const b = (m - o) / (m - f[2]);
|
|
547
550
|
h = {
|
|
548
|
-
x: y[0] * (1 -
|
|
549
|
-
y: y[1] * (1 -
|
|
551
|
+
x: y[0] * (1 - b) + f[0] * b,
|
|
552
|
+
y: y[1] * (1 - b) + f[1] * b
|
|
550
553
|
};
|
|
551
554
|
}
|
|
552
|
-
f = [
|
|
555
|
+
f = [l, c, m];
|
|
553
556
|
}
|
|
554
|
-
return
|
|
557
|
+
return a && o >= m && (h = { x: s, y: i }), {
|
|
555
558
|
length: m,
|
|
556
559
|
point: h,
|
|
557
560
|
min: {
|
|
558
|
-
x: Math.min(...u.map((
|
|
559
|
-
y: Math.min(...u.map((
|
|
561
|
+
x: Math.min(...u.map((p) => p.x)),
|
|
562
|
+
y: Math.min(...u.map((p) => p.y))
|
|
560
563
|
},
|
|
561
564
|
max: {
|
|
562
|
-
x: Math.max(...u.map((
|
|
563
|
-
y: Math.max(...u.map((
|
|
565
|
+
x: Math.max(...u.map((p) => p.x)),
|
|
566
|
+
y: Math.max(...u.map((p) => p.y))
|
|
564
567
|
}
|
|
565
568
|
};
|
|
566
|
-
},
|
|
567
|
-
const n =
|
|
568
|
-
let s, i = [], o,
|
|
569
|
-
for (let
|
|
570
|
-
f = n[
|
|
569
|
+
}, ft = (e, t) => {
|
|
570
|
+
const n = j(e), r = typeof t == "number";
|
|
571
|
+
let s, i = [], o, a = 0, l = 0, c = 0, m = 0, f, y = [], g = [], h = 0, u = { x: 0, y: 0 }, x = u, p = u, b = u, A = 0;
|
|
572
|
+
for (let d = 0, M = n.length; d < M; d += 1)
|
|
573
|
+
f = n[d], [o] = f, s = o === "M", i = s ? i : [a, l, ...f.slice(1)], s ? ([, c, m] = f, u = { x: c, y: m }, x = u, h = 0, r && t < 1e-3 && (b = u)) : o === "L" ? { length: h, min: u, max: x, point: p } = dt(
|
|
571
574
|
...i,
|
|
572
575
|
(t || 0) - A
|
|
573
|
-
) : o === "A" ? { length: h, min: u, max: x, point:
|
|
576
|
+
) : o === "A" ? { length: h, min: u, max: x, point: p } = ye(
|
|
574
577
|
...i,
|
|
575
578
|
(t || 0) - A
|
|
576
|
-
) : o === "C" ? { length: h, min: u, max: x, point:
|
|
579
|
+
) : o === "C" ? { length: h, min: u, max: x, point: p } = xe(
|
|
577
580
|
...i,
|
|
578
581
|
(t || 0) - A
|
|
579
|
-
) : o === "Q" ? { length: h, min: u, max: x, point:
|
|
582
|
+
) : o === "Q" ? { length: h, min: u, max: x, point: p } = be(
|
|
580
583
|
...i,
|
|
581
584
|
(t || 0) - A
|
|
582
|
-
) : o === "Z" && (i = [l, c,
|
|
585
|
+
) : o === "Z" && (i = [a, l, c, m], { length: h, min: u, max: x, point: p } = dt(
|
|
583
586
|
...i,
|
|
584
587
|
(t || 0) - A
|
|
585
|
-
)), r && A < t && A + h >= t && (
|
|
586
|
-
return r && t >= A && (
|
|
588
|
+
)), r && A < t && A + h >= t && (b = p), g = [...g, x], y = [...y, u], A += h, [a, l] = o !== "Z" ? f.slice(-2) : [c, m];
|
|
589
|
+
return r && t >= A && (b = { x: a, y: l }), {
|
|
587
590
|
length: A,
|
|
588
|
-
point:
|
|
591
|
+
point: b,
|
|
589
592
|
min: {
|
|
590
|
-
x: Math.min(...y.map((
|
|
591
|
-
y: Math.min(...y.map((
|
|
593
|
+
x: Math.min(...y.map((d) => d.x)),
|
|
594
|
+
y: Math.min(...y.map((d) => d.y))
|
|
592
595
|
},
|
|
593
596
|
max: {
|
|
594
|
-
x: Math.max(...g.map((
|
|
595
|
-
y: Math.max(...g.map((
|
|
597
|
+
x: Math.max(...g.map((d) => d.x)),
|
|
598
|
+
y: Math.max(...g.map((d) => d.y))
|
|
596
599
|
}
|
|
597
600
|
};
|
|
598
|
-
},
|
|
601
|
+
}, kt = (e) => {
|
|
599
602
|
if (!e)
|
|
600
603
|
return {
|
|
601
604
|
x: 0,
|
|
@@ -611,7 +614,7 @@ e.every(([t]) => t === t.toUpperCase()), X = (e) => {
|
|
|
611
614
|
const {
|
|
612
615
|
min: { x: t, y: n },
|
|
613
616
|
max: { x: r, y: s }
|
|
614
|
-
} =
|
|
617
|
+
} = ft(e), i = r - t, o = s - n;
|
|
615
618
|
return {
|
|
616
619
|
width: i,
|
|
617
620
|
height: o,
|
|
@@ -624,7 +627,7 @@ e.every(([t]) => t === t.toUpperCase()), X = (e) => {
|
|
|
624
627
|
// an estimted guess
|
|
625
628
|
cz: Math.max(i, o) + Math.min(i, o) / 2
|
|
626
629
|
};
|
|
627
|
-
},
|
|
630
|
+
}, Mt = (e, t, n) => {
|
|
628
631
|
if (e[n].length > 7) {
|
|
629
632
|
e[n].shift();
|
|
630
633
|
const r = e[n];
|
|
@@ -633,132 +636,132 @@ e.every(([t]) => t === t.toUpperCase()), X = (e) => {
|
|
|
633
636
|
t[n] = "A", e.splice(s += 1, 0, ["C", ...r.splice(0, 6)]);
|
|
634
637
|
e.splice(n, 1);
|
|
635
638
|
}
|
|
636
|
-
},
|
|
639
|
+
}, Ut = (e) => wt(e) && e.every(([t]) => "MC".includes(t)), rt = (e, t, n) => {
|
|
637
640
|
const r = e * Math.cos(n) - t * Math.sin(n), s = e * Math.sin(n) + t * Math.cos(n);
|
|
638
641
|
return { x: r, y: s };
|
|
639
|
-
},
|
|
640
|
-
let m = e, f = t, y = n, g = r, h =
|
|
641
|
-
const x = Math.PI * 120 / 180,
|
|
642
|
-
let
|
|
643
|
-
if (
|
|
644
|
-
[
|
|
642
|
+
}, Kt = (e, t, n, r, s, i, o, a, l, c) => {
|
|
643
|
+
let m = e, f = t, y = n, g = r, h = a, u = l;
|
|
644
|
+
const x = Math.PI * 120 / 180, p = Math.PI / 180 * (+s || 0);
|
|
645
|
+
let b = [], A, d, M, T, z;
|
|
646
|
+
if (c)
|
|
647
|
+
[d, M, T, z] = c;
|
|
645
648
|
else {
|
|
646
|
-
A =
|
|
647
|
-
const P = (m - h) / 2,
|
|
648
|
-
let
|
|
649
|
-
|
|
650
|
-
const
|
|
651
|
-
|
|
649
|
+
A = rt(m, f, -p), m = A.x, f = A.y, A = rt(h, u, -p), h = A.x, u = A.y;
|
|
650
|
+
const P = (m - h) / 2, L = (f - u) / 2;
|
|
651
|
+
let E = P * P / (y * y) + L * L / (g * g);
|
|
652
|
+
E > 1 && (E = Math.sqrt(E), y *= E, g *= E);
|
|
653
|
+
const xt = y * y, pt = g * g, Ct = (i === o ? -1 : 1) * Math.sqrt(Math.abs((xt * pt - xt * L * L - pt * P * P) / (xt * L * L + pt * P * P)));
|
|
654
|
+
T = Ct * y * L / g + (m + h) / 2, z = Ct * -g * P / y + (f + u) / 2, d = Math.asin(((f - z) / g * 10 ** 9 >> 0) / 10 ** 9), M = Math.asin(((u - z) / g * 10 ** 9 >> 0) / 10 ** 9), d = m < T ? Math.PI - d : d, M = h < T ? Math.PI - M : M, d < 0 && (d = Math.PI * 2 + d), M < 0 && (M = Math.PI * 2 + M), o && d > M && (d -= Math.PI * 2), !o && M > d && (M -= Math.PI * 2);
|
|
652
655
|
}
|
|
653
|
-
let
|
|
654
|
-
if (Math.abs(
|
|
655
|
-
const P = M,
|
|
656
|
-
M =
|
|
656
|
+
let Y = M - d;
|
|
657
|
+
if (Math.abs(Y) > x) {
|
|
658
|
+
const P = M, L = h, E = u;
|
|
659
|
+
M = d + x * (o && M > d ? 1 : -1), h = T + y * Math.cos(M), u = z + g * Math.sin(M), b = Kt(h, u, y, g, s, 0, o, L, E, [M, P, T, z]);
|
|
657
660
|
}
|
|
658
|
-
|
|
659
|
-
const
|
|
660
|
-
if (
|
|
661
|
-
return [...
|
|
662
|
-
|
|
663
|
-
const
|
|
664
|
-
for (let P = 0,
|
|
665
|
-
|
|
666
|
-
return
|
|
667
|
-
},
|
|
668
|
-
const o = 0.3333333333333333,
|
|
661
|
+
Y = M - d;
|
|
662
|
+
const R = Math.cos(d), tt = Math.sin(d), k = Math.cos(M), et = Math.sin(M), B = Math.tan(Y / 4), nt = 4 / 3 * y * B, st = 4 / 3 * g * B, S = [m, f], q = [m + nt * tt, f - st * R], J = [h + nt * et, u - st * k], U = [h, u];
|
|
663
|
+
if (q[0] = 2 * S[0] - q[0], q[1] = 2 * S[1] - q[1], c)
|
|
664
|
+
return [...q, ...J, ...U, ...b];
|
|
665
|
+
b = [...q, ...J, ...U, ...b];
|
|
666
|
+
const gt = [];
|
|
667
|
+
for (let P = 0, L = b.length; P < L; P += 1)
|
|
668
|
+
gt[P] = P % 2 ? rt(b[P - 1], b[P], p).y : rt(b[P], b[P + 1], p).x;
|
|
669
|
+
return gt;
|
|
670
|
+
}, de = (e, t, n, r, s, i) => {
|
|
671
|
+
const o = 0.3333333333333333, a = 2 / 3;
|
|
669
672
|
return [
|
|
670
|
-
o * e +
|
|
673
|
+
o * e + a * n,
|
|
671
674
|
// cpx1
|
|
672
|
-
o * t +
|
|
675
|
+
o * t + a * r,
|
|
673
676
|
// cpy1
|
|
674
|
-
o * s +
|
|
677
|
+
o * s + a * n,
|
|
675
678
|
// cpx2
|
|
676
|
-
o * i +
|
|
679
|
+
o * i + a * r,
|
|
677
680
|
// cpy2
|
|
678
681
|
s,
|
|
679
682
|
i
|
|
680
683
|
// x,y
|
|
681
684
|
];
|
|
682
|
-
},
|
|
685
|
+
}, St = (e, t, n, r) => [...I([e, t], [n, r], 0.5), n, r, n, r], ot = (e, t) => {
|
|
683
686
|
const [n] = e, r = e.slice(1).map(Number), [s, i] = r;
|
|
684
687
|
let o;
|
|
685
|
-
const { x1:
|
|
686
|
-
return "TQ".includes(n) || (t.qx = null, t.qy = null), n === "M" ? (t.x = s, t.y = i, e) : n === "A" ? (o = [
|
|
687
|
-
},
|
|
688
|
-
if (
|
|
688
|
+
const { x1: a, y1: l, x: c, y: m } = t;
|
|
689
|
+
return "TQ".includes(n) || (t.qx = null, t.qy = null), n === "M" ? (t.x = s, t.y = i, e) : n === "A" ? (o = [a, l, ...r], ["C", ...Kt(...o)]) : n === "Q" ? (t.qx = s, t.qy = i, o = [a, l, ...r], ["C", ...de(...o)]) : n === "L" ? ["C", ...St(a, l, s, i)] : n === "Z" ? ["C", ...St(a, l, c, m)] : e;
|
|
690
|
+
}, ct = (e) => {
|
|
691
|
+
if (Ut(e))
|
|
689
692
|
return [...e];
|
|
690
|
-
const t =
|
|
693
|
+
const t = j(e), n = { ...ut }, r = [];
|
|
691
694
|
let s = "", i = t.length;
|
|
692
695
|
for (let o = 0; o < i; o += 1) {
|
|
693
|
-
[s] = t[o], r[o] = s, t[o] =
|
|
694
|
-
const
|
|
695
|
-
n.x1 = +l
|
|
696
|
+
[s] = t[o], r[o] = s, t[o] = ot(t[o], n), Mt(t, r, o), i = t.length;
|
|
697
|
+
const a = t[o], l = a.length;
|
|
698
|
+
n.x1 = +a[l - 2], n.y1 = +a[l - 1], n.x2 = +a[l - 4] || n.x1, n.y2 = +a[l - 3] || n.y1;
|
|
696
699
|
}
|
|
697
700
|
return t;
|
|
698
|
-
},
|
|
701
|
+
}, Me = (e, t, n, r, s, i, o, a) => 3 * ((a - t) * (n + s) - (o - e) * (r + i) + r * (e - s) - n * (t - i) + a * (s + e / 3) - o * (i + t / 3)) / 20, _t = (e) => {
|
|
699
702
|
let t = 0, n = 0, r = 0;
|
|
700
|
-
return
|
|
703
|
+
return ct(e).map((s) => {
|
|
701
704
|
switch (s[0]) {
|
|
702
705
|
case "M":
|
|
703
706
|
return [, t, n] = s, 0;
|
|
704
707
|
default:
|
|
705
|
-
return r =
|
|
708
|
+
return r = Me(t, n, ...s.slice(1)), [t, n] = s.slice(-2), r;
|
|
706
709
|
}
|
|
707
710
|
}).reduce((s, i) => s + i, 0);
|
|
708
|
-
},
|
|
709
|
-
const n =
|
|
710
|
-
let r = [...n], s =
|
|
711
|
-
const [
|
|
711
|
+
}, F = (e) => ft(e).length, Ae = (e) => _t(ct(e)) >= 0, W = (e, t) => ft(e, t).point, Pt = (e, t) => {
|
|
712
|
+
const n = Q(e);
|
|
713
|
+
let r = [...n], s = F(r), i = r.length - 1, o = 0, a = 0, l = n[0];
|
|
714
|
+
const [c, m] = l.slice(-2), f = { x: c, y: m };
|
|
712
715
|
if (i <= 0 || !t || !Number.isFinite(t))
|
|
713
716
|
return {
|
|
714
|
-
segment:
|
|
717
|
+
segment: l,
|
|
715
718
|
index: 0,
|
|
716
|
-
length:
|
|
719
|
+
length: a,
|
|
717
720
|
point: f,
|
|
718
721
|
lengthAtSegment: o
|
|
719
722
|
};
|
|
720
723
|
if (t >= s)
|
|
721
|
-
return r = n.slice(0, -1), o =
|
|
724
|
+
return r = n.slice(0, -1), o = F(r), a = s - o, {
|
|
722
725
|
segment: n[i],
|
|
723
726
|
index: i,
|
|
724
|
-
length:
|
|
727
|
+
length: a,
|
|
725
728
|
lengthAtSegment: o
|
|
726
729
|
};
|
|
727
730
|
const y = [];
|
|
728
731
|
for (; i > 0; )
|
|
729
|
-
|
|
730
|
-
segment:
|
|
732
|
+
l = r[i], r = r.slice(0, -1), o = F(r), a = s - o, s = o, y.push({
|
|
733
|
+
segment: l,
|
|
731
734
|
index: i,
|
|
732
|
-
length:
|
|
735
|
+
length: a,
|
|
733
736
|
lengthAtSegment: o
|
|
734
737
|
}), i -= 1;
|
|
735
738
|
return y.find(({ lengthAtSegment: g }) => g <= t);
|
|
736
|
-
},
|
|
737
|
-
const n =
|
|
738
|
-
const M =
|
|
739
|
-
return M * M +
|
|
739
|
+
}, yt = (e, t) => {
|
|
740
|
+
const n = Q(e), r = j(n), s = F(n), i = (d) => {
|
|
741
|
+
const M = d.x - t.x, T = d.y - t.y;
|
|
742
|
+
return M * M + T * T;
|
|
740
743
|
};
|
|
741
|
-
let o = 8,
|
|
742
|
-
for (let
|
|
743
|
-
|
|
744
|
+
let o = 8, a, l = { x: 0, y: 0 }, c = 0, m = 0, f = 1 / 0;
|
|
745
|
+
for (let d = 0; d <= s; d += o)
|
|
746
|
+
a = W(r, d), c = i(a), c < f && (l = a, m = d, f = c);
|
|
744
747
|
o /= 2;
|
|
745
|
-
let y, g, h = 0, u = 0, x = 0,
|
|
748
|
+
let y, g, h = 0, u = 0, x = 0, p = 0;
|
|
746
749
|
for (; o > 0.5; )
|
|
747
|
-
h = m - o, y =
|
|
748
|
-
const
|
|
749
|
-
return { closest:
|
|
750
|
-
},
|
|
751
|
-
const { distance: n } =
|
|
750
|
+
h = m - o, y = W(r, h), x = i(y), u = m + o, g = W(r, u), p = i(g), h >= 0 && x < f ? (l = y, m = h, f = x) : u <= s && p < f ? (l = g, m = u, f = p) : o /= 2;
|
|
751
|
+
const b = Pt(n, m), A = Math.sqrt(f);
|
|
752
|
+
return { closest: l, distance: A, segment: b };
|
|
753
|
+
}, Ne = (e, t) => yt(e, t).closest, ve = (e, t) => yt(e, t).segment, we = (e, t) => Pt(e, t).segment, Pe = (e, t) => {
|
|
754
|
+
const { distance: n } = yt(e, t);
|
|
752
755
|
return Math.abs(n) < 1e-3;
|
|
753
|
-
},
|
|
756
|
+
}, Wt = (e) => {
|
|
754
757
|
if (typeof e != "string")
|
|
755
758
|
return !1;
|
|
756
|
-
const t = new
|
|
757
|
-
for (
|
|
758
|
-
|
|
759
|
+
const t = new Et(e);
|
|
760
|
+
for (_(t); t.index < t.max && !t.err.length; )
|
|
761
|
+
jt(t);
|
|
759
762
|
return !t.err.length && "mM".includes(t.segments[0][0]);
|
|
760
|
-
},
|
|
761
|
-
e.slice(1).every(([t]) => t === t.toLowerCase()),
|
|
763
|
+
}, Vt = (e) => mt(e) && // `isPathArray` checks if it's `Array`
|
|
764
|
+
e.slice(1).every(([t]) => t === t.toLowerCase()), lt = (e, t) => {
|
|
762
765
|
let { round: n } = at;
|
|
763
766
|
if (t === "off" || n === "off")
|
|
764
767
|
return [...e];
|
|
@@ -768,7 +771,7 @@ e.slice(1).every(([t]) => t === t.toLowerCase()), ot = (e, t) => {
|
|
|
768
771
|
const i = s.slice(1).map(Number).map((o) => n ? Math.round(o * r) / r : Math.round(o));
|
|
769
772
|
return [s[0], ...i];
|
|
770
773
|
});
|
|
771
|
-
},
|
|
774
|
+
}, Z = (e, t) => lt(e, t).map((n) => n[0] + n.slice(1).join(" ")).join(""), qt = {
|
|
772
775
|
line: ["x1", "y1", "x2", "y2"],
|
|
773
776
|
circle: ["cx", "cy", "r"],
|
|
774
777
|
ellipse: ["cx", "cy", "rx", "ry"],
|
|
@@ -776,33 +779,33 @@ e.slice(1).every(([t]) => t === t.toLowerCase()), ot = (e, t) => {
|
|
|
776
779
|
polygon: ["points"],
|
|
777
780
|
polyline: ["points"],
|
|
778
781
|
glyph: ["d"]
|
|
779
|
-
},
|
|
782
|
+
}, Ce = (e) => {
|
|
780
783
|
const { x1: t, y1: n, x2: r, y2: s } = e;
|
|
781
784
|
return [
|
|
782
785
|
["M", t, n],
|
|
783
786
|
["L", r, s]
|
|
784
787
|
];
|
|
785
|
-
},
|
|
788
|
+
}, Te = (e) => {
|
|
786
789
|
const t = [], n = (e.points || "").trim().split(/[\s|,]/).map(Number);
|
|
787
790
|
let r = 0;
|
|
788
791
|
for (; r < n.length; )
|
|
789
792
|
t.push([r ? "L" : "M", n[r], n[r + 1]]), r += 2;
|
|
790
793
|
return e.type === "polygon" ? [...t, ["z"]] : t;
|
|
791
|
-
},
|
|
794
|
+
}, Le = (e) => {
|
|
792
795
|
const { cx: t, cy: n, r } = e;
|
|
793
796
|
return [
|
|
794
797
|
["M", t - r, n],
|
|
795
798
|
["a", r, r, 0, 1, 0, 2 * r, 0],
|
|
796
799
|
["a", r, r, 0, 1, 0, -2 * r, 0]
|
|
797
800
|
];
|
|
798
|
-
},
|
|
801
|
+
}, ke = (e) => {
|
|
799
802
|
const { cx: t, cy: n, rx: r, ry: s } = e;
|
|
800
803
|
return [
|
|
801
804
|
["M", t - r, n],
|
|
802
805
|
["a", r, s, 0, 1, 0, 2 * r, 0],
|
|
803
806
|
["a", r, s, 0, 1, 0, -2 * r, 0]
|
|
804
807
|
];
|
|
805
|
-
},
|
|
808
|
+
}, Se = (e) => {
|
|
806
809
|
const t = +e.x || 0, n = +e.y || 0, r = +e.width, s = +e.height;
|
|
807
810
|
let i = +e.rx, o = +e.ry;
|
|
808
811
|
return i || o ? (i = i || o, o = o || i, i * 2 > r && (i -= (i * 2 - r) / 2), o * 2 > s && (o -= (o * 2 - s) / 2), [
|
|
@@ -816,113 +819,113 @@ e.slice(1).every(([t]) => t === t.toLowerCase()), ot = (e, t) => {
|
|
|
816
819
|
["v", -s + o * 2],
|
|
817
820
|
["s", 0, -o, i, -o]
|
|
818
821
|
]) : [["M", t, n], ["h", r], ["v", s], ["H", t], ["Z"]];
|
|
819
|
-
},
|
|
822
|
+
}, qe = (e, t, n) => {
|
|
820
823
|
const r = n || document, s = r.defaultView || /* istanbul ignore next */
|
|
821
|
-
window, i = Object.keys(
|
|
822
|
-
if (
|
|
823
|
-
throw TypeError(`${
|
|
824
|
-
const
|
|
824
|
+
window, i = Object.keys(qt), o = e instanceof s.SVGElement, a = o ? e.tagName : null;
|
|
825
|
+
if (a && i.every((h) => a !== h))
|
|
826
|
+
throw TypeError(`${O}: "${a}" is not SVGElement`);
|
|
827
|
+
const l = r.createElementNS("http://www.w3.org/2000/svg", "path"), c = o ? a : e.type, m = qt[c], f = { type: c };
|
|
825
828
|
o ? (m.forEach((h) => {
|
|
826
829
|
m.includes(h) && (f[h] = e.getAttribute(h));
|
|
827
830
|
}), Object.values(e.attributes).forEach(({ name: h, value: u }) => {
|
|
828
|
-
m.includes(h) ||
|
|
831
|
+
m.includes(h) || l.setAttribute(h, u);
|
|
829
832
|
})) : (Object.assign(f, e), Object.keys(f).forEach((h) => {
|
|
830
|
-
!m.includes(h) && h !== "type" &&
|
|
833
|
+
!m.includes(h) && h !== "type" && l.setAttribute(
|
|
831
834
|
h.replace(/[A-Z]/g, (u) => `-${u.toLowerCase()}`),
|
|
832
835
|
f[h]
|
|
833
836
|
);
|
|
834
837
|
}));
|
|
835
838
|
let y = "";
|
|
836
839
|
const g = at.round;
|
|
837
|
-
return
|
|
838
|
-
},
|
|
840
|
+
return c === "circle" ? y = Z(Le(f), g) : c === "ellipse" ? y = Z(ke(f), g) : ["polyline", "polygon"].includes(c) ? y = Z(Te(f), g) : c === "rect" ? y = Z(Se(f), g) : c === "line" ? y = Z(Ce(f), g) : c === "glyph" && (y = o ? e.getAttribute("d") : e.d), Wt(y) ? (l.setAttribute("d", y), t && o && (e.before(l, e), e.remove()), l) : !1;
|
|
841
|
+
}, $t = (e) => {
|
|
839
842
|
const t = [];
|
|
840
843
|
let n, r = -1;
|
|
841
844
|
return e.forEach((s) => {
|
|
842
845
|
s[0] === "M" ? (n = [s], r += 1) : n = [...n, s], t[r] = n;
|
|
843
846
|
}), t;
|
|
844
|
-
},
|
|
845
|
-
if (
|
|
847
|
+
}, At = (e) => {
|
|
848
|
+
if (Vt(e))
|
|
846
849
|
return [...e];
|
|
847
|
-
const t =
|
|
850
|
+
const t = Q(e);
|
|
848
851
|
let n = 0, r = 0, s = 0, i = 0;
|
|
849
852
|
return t.map((o) => {
|
|
850
|
-
const
|
|
851
|
-
if (
|
|
852
|
-
return [n, r] =
|
|
853
|
+
const a = o.slice(1).map(Number), [l] = o, c = l.toLowerCase();
|
|
854
|
+
if (l === "M")
|
|
855
|
+
return [n, r] = a, s = n, i = r, ["M", n, r];
|
|
853
856
|
let m = [];
|
|
854
|
-
if (
|
|
855
|
-
if (
|
|
857
|
+
if (l !== c)
|
|
858
|
+
if (c === "a")
|
|
856
859
|
m = [
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
860
|
+
c,
|
|
861
|
+
a[0],
|
|
862
|
+
a[1],
|
|
863
|
+
a[2],
|
|
864
|
+
a[3],
|
|
865
|
+
a[4],
|
|
866
|
+
a[5] - n,
|
|
867
|
+
a[6] - r
|
|
865
868
|
];
|
|
866
|
-
else if (
|
|
867
|
-
m = [
|
|
868
|
-
else if (
|
|
869
|
-
m = [
|
|
869
|
+
else if (c === "v")
|
|
870
|
+
m = [c, a[0] - r];
|
|
871
|
+
else if (c === "h")
|
|
872
|
+
m = [c, a[0] - n];
|
|
870
873
|
else {
|
|
871
|
-
const y =
|
|
872
|
-
m = [
|
|
874
|
+
const y = a.map((g, h) => g - (h % 2 ? r : n));
|
|
875
|
+
m = [c, ...y];
|
|
873
876
|
}
|
|
874
877
|
else
|
|
875
|
-
|
|
878
|
+
l === "m" && (s = a[0] + n, i = a[1] + r), m = [c, ...a];
|
|
876
879
|
const f = m.length;
|
|
877
|
-
return
|
|
880
|
+
return c === "z" ? (n = s, r = i) : c === "h" ? n += m[1] : c === "v" ? r += m[1] : (n += m[f - 2], r += m[f - 1]), m;
|
|
878
881
|
});
|
|
879
|
-
},
|
|
880
|
-
const [s] = e, i = (
|
|
882
|
+
}, $e = (e, t, n, r) => {
|
|
883
|
+
const [s] = e, i = (p) => Math.round(p * 10 ** 4) / 10 ** 4, o = e.slice(1).map((p) => +p), a = t.slice(1).map((p) => +p), { x1: l, y1: c, x2: m, y2: f, x: y, y: g } = n;
|
|
881
884
|
let h = e;
|
|
882
|
-
const [u, x] =
|
|
885
|
+
const [u, x] = a.slice(-2);
|
|
883
886
|
if ("TQ".includes(s) || (n.qx = null, n.qy = null), ["V", "H", "S", "T", "Z"].includes(s))
|
|
884
887
|
h = [s, ...o];
|
|
885
888
|
else if (s === "L")
|
|
886
889
|
i(y) === i(u) ? h = ["V", x] : i(g) === i(x) && (h = ["H", u]);
|
|
887
890
|
else if (s === "C") {
|
|
888
|
-
const [
|
|
889
|
-
"CS".includes(r) && (i(
|
|
891
|
+
const [p, b] = a;
|
|
892
|
+
"CS".includes(r) && (i(p) === i(l * 2 - m) && i(b) === i(c * 2 - f) || i(l) === i(m * 2 - y) && i(c) === i(f * 2 - g)) && (h = ["S", ...a.slice(-4)]), n.x1 = p, n.y1 = b;
|
|
890
893
|
} else if (s === "Q") {
|
|
891
|
-
const [
|
|
892
|
-
n.qx =
|
|
894
|
+
const [p, b] = a;
|
|
895
|
+
n.qx = p, n.qy = b, "QT".includes(r) && (i(p) === i(l * 2 - m) && i(b) === i(c * 2 - f) || i(l) === i(m * 2 - y) && i(c) === i(f * 2 - g)) && (h = ["T", ...a.slice(-2)]);
|
|
893
896
|
}
|
|
894
897
|
return h;
|
|
895
|
-
},
|
|
896
|
-
const n =
|
|
897
|
-
let
|
|
898
|
+
}, Ot = (e, t) => {
|
|
899
|
+
const n = H(e), r = j(n), s = { ...ut }, i = [], o = n.length;
|
|
900
|
+
let a = "", l = "", c = 0, m = 0, f = 0, y = 0;
|
|
898
901
|
for (let u = 0; u < o; u += 1) {
|
|
899
|
-
[
|
|
900
|
-
const x = n[u],
|
|
901
|
-
switch (s.x1 = +x[
|
|
902
|
+
[a] = n[u], i[u] = a, u && (l = i[u - 1]), n[u] = $e(n[u], r[u], s, l);
|
|
903
|
+
const x = n[u], p = x.length;
|
|
904
|
+
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, a) {
|
|
902
905
|
case "Z":
|
|
903
|
-
|
|
906
|
+
c = f, m = y;
|
|
904
907
|
break;
|
|
905
908
|
case "H":
|
|
906
|
-
[,
|
|
909
|
+
[, c] = x;
|
|
907
910
|
break;
|
|
908
911
|
case "V":
|
|
909
912
|
[, m] = x;
|
|
910
913
|
break;
|
|
911
914
|
default:
|
|
912
|
-
[
|
|
915
|
+
[c, m] = x.slice(-2).map(Number), a === "M" && (f = c, y = m);
|
|
913
916
|
}
|
|
914
|
-
s.x =
|
|
917
|
+
s.x = c, s.y = m;
|
|
915
918
|
}
|
|
916
|
-
const g =
|
|
919
|
+
const g = lt(n, t), h = lt(At(n), t);
|
|
917
920
|
return g.map((u, x) => x ? u.join("").length < h[x].join("").length ? u : h[x] : u);
|
|
918
|
-
},
|
|
921
|
+
}, Oe = (e) => {
|
|
919
922
|
const t = e.slice(1).map(
|
|
920
923
|
(n, r, s) => r ? [...s[r - 1].slice(-2), ...n.slice(1)] : [...e[0].slice(1), ...n.slice(1)]
|
|
921
924
|
).map((n) => n.map((r, s) => n[n.length - s - 2 * (1 - s % 2)])).reverse();
|
|
922
925
|
return [["M", ...t[0].slice(0, 2)], ...t.map((n) => ["C", ...n.slice(2)])];
|
|
923
|
-
},
|
|
924
|
-
const t =
|
|
925
|
-
const [o,
|
|
926
|
+
}, it = (e) => {
|
|
927
|
+
const t = H(e), n = t.slice(-1)[0][0] === "Z", r = j(t).map((s, i) => {
|
|
928
|
+
const [o, a] = s.slice(-2).map(Number);
|
|
926
929
|
return {
|
|
927
930
|
seg: t[i],
|
|
928
931
|
// absolute
|
|
@@ -932,30 +935,30 @@ e.slice(1).every(([t]) => t === t.toLowerCase()), ot = (e, t) => {
|
|
|
932
935
|
// pathCommand
|
|
933
936
|
x: o,
|
|
934
937
|
// x
|
|
935
|
-
y:
|
|
938
|
+
y: a
|
|
936
939
|
// y
|
|
937
940
|
};
|
|
938
941
|
}).map((s, i, o) => {
|
|
939
|
-
const
|
|
942
|
+
const a = s.seg, l = s.n, c = i && o[i - 1], m = o[i + 1], f = s.c, y = o.length, g = i ? o[i - 1].x : o[y - 1].x, h = i ? o[i - 1].y : o[y - 1].y;
|
|
940
943
|
let u = [];
|
|
941
944
|
switch (f) {
|
|
942
945
|
case "M":
|
|
943
946
|
u = n ? ["Z"] : [f, g, h];
|
|
944
947
|
break;
|
|
945
948
|
case "A":
|
|
946
|
-
u = [f, ...
|
|
949
|
+
u = [f, ...a.slice(1, -3), a[5] === 1 ? 0 : 1, g, h];
|
|
947
950
|
break;
|
|
948
951
|
case "C":
|
|
949
|
-
m && m.c === "S" ? u = ["S",
|
|
952
|
+
m && m.c === "S" ? u = ["S", a[1], a[2], g, h] : u = [f, a[3], a[4], a[1], a[2], g, h];
|
|
950
953
|
break;
|
|
951
954
|
case "S":
|
|
952
|
-
|
|
955
|
+
c && "CS".includes(c.c) && (!m || m.c !== "S") ? u = ["C", l[3], l[4], l[1], l[2], g, h] : u = [f, l[1], l[2], g, h];
|
|
953
956
|
break;
|
|
954
957
|
case "Q":
|
|
955
|
-
m && m.c === "T" ? u = ["T", g, h] : u = [f, ...
|
|
958
|
+
m && m.c === "T" ? u = ["T", g, h] : u = [f, ...a.slice(1, -2), g, h];
|
|
956
959
|
break;
|
|
957
960
|
case "T":
|
|
958
|
-
|
|
961
|
+
c && "QT".includes(c.c) && (!m || m.c !== "T") ? u = ["Q", l[1], l[2], g, h] : u = [f, g, h];
|
|
959
962
|
break;
|
|
960
963
|
case "Z":
|
|
961
964
|
u = ["M", g, h];
|
|
@@ -967,41 +970,41 @@ e.slice(1).every(([t]) => t === t.toLowerCase()), ot = (e, t) => {
|
|
|
967
970
|
u = [f, h];
|
|
968
971
|
break;
|
|
969
972
|
default:
|
|
970
|
-
u = [f, ...
|
|
973
|
+
u = [f, ...a.slice(1, -2), g, h];
|
|
971
974
|
}
|
|
972
975
|
return u;
|
|
973
976
|
});
|
|
974
977
|
return n ? r.reverse() : [r[0], ...r.slice(1).reverse()];
|
|
975
|
-
},
|
|
976
|
-
let t = new
|
|
977
|
-
const { origin: n } = e, [r, s] = n, { translate: i } = e, { rotate: o } = e, { skew:
|
|
978
|
-
return Array.isArray(i) && i.length >= 2 && i.every((
|
|
979
|
-
},
|
|
980
|
-
let n =
|
|
978
|
+
}, ze = (e) => {
|
|
979
|
+
let t = new Nt();
|
|
980
|
+
const { origin: n } = e, [r, s] = n, { translate: i } = e, { rotate: o } = e, { skew: a } = e, { scale: l } = e;
|
|
981
|
+
return Array.isArray(i) && i.length >= 2 && i.every((c) => !Number.isNaN(+c)) && i.some((c) => c !== 0) ? t = t.translate(...i) : typeof i == "number" && !Number.isNaN(i) && (t = t.translate(i)), (o || a || l) && (t = t.translate(r, s), Array.isArray(o) && o.length >= 2 && o.every((c) => !Number.isNaN(+c)) && o.some((c) => c !== 0) ? t = t.rotate(...o) : typeof o == "number" && !Number.isNaN(o) && (t = t.rotate(o)), Array.isArray(a) && a.length === 2 && a.every((c) => !Number.isNaN(+c)) && a.some((c) => c !== 0) ? (t = a[0] ? t.skewX(a[0]) : t, t = a[1] ? t.skewY(a[1]) : t) : typeof a == "number" && !Number.isNaN(a) && (t = t.skewX(a)), Array.isArray(l) && l.length >= 2 && l.every((c) => !Number.isNaN(+c)) && l.some((c) => c !== 1) ? t = t.scale(...l) : typeof l == "number" && !Number.isNaN(l) && (t = t.scale(l)), t = t.translate(-r, -s)), t;
|
|
982
|
+
}, Ie = (e, t) => {
|
|
983
|
+
let n = Nt.Translate(...t.slice(0, -1));
|
|
981
984
|
return [, , , n.m44] = t, n = e.multiply(n), [n.m41, n.m42, n.m43, n.m44];
|
|
982
|
-
},
|
|
983
|
-
const [r, s, i] = n, [o,
|
|
985
|
+
}, zt = (e, t, n) => {
|
|
986
|
+
const [r, s, i] = n, [o, a, l] = Ie(e, [...t, 0, 1]), c = o - r, m = a - s, f = l - i;
|
|
984
987
|
return [
|
|
985
988
|
// protect against division by ZERO
|
|
986
|
-
|
|
989
|
+
c * (Math.abs(i) / Math.abs(f) || 1) + r,
|
|
987
990
|
m * (Math.abs(i) / Math.abs(f) || 1) + s
|
|
988
991
|
];
|
|
989
|
-
},
|
|
990
|
-
let n = 0, r = 0, s, i, o, l, c
|
|
991
|
-
const m =
|
|
992
|
+
}, It = (e, t) => {
|
|
993
|
+
let n = 0, r = 0, s, i, o, a, l, c;
|
|
994
|
+
const m = H(e), f = t && Object.keys(t);
|
|
992
995
|
if (!t || f && !f.length)
|
|
993
996
|
return [...m];
|
|
994
|
-
const y =
|
|
997
|
+
const y = j(m);
|
|
995
998
|
if (!t.origin) {
|
|
996
999
|
const { origin: M } = at;
|
|
997
1000
|
Object.assign(t, { origin: M });
|
|
998
1001
|
}
|
|
999
|
-
const g =
|
|
1000
|
-
let x = [],
|
|
1001
|
-
const
|
|
1002
|
+
const g = ze(t), { origin: h } = t, u = { ...ut };
|
|
1003
|
+
let x = [], p = 0, b = "", A = [];
|
|
1004
|
+
const d = [];
|
|
1002
1005
|
if (!g.isIdentity) {
|
|
1003
1006
|
for (s = 0, o = m.length; s < o; s += 1) {
|
|
1004
|
-
x = m[s], m[s] && ([
|
|
1007
|
+
x = m[s], m[s] && ([b] = x), d[s] = b, b === "A" && (x = ot(y[s], u), m[s] = ot(y[s], u), Mt(m, d, s), y[s] = ot(y[s], u), Mt(y, d, s), o = Math.max(m.length, y.length)), x = y[s], p = x.length, u.x1 = +x[p - 2], u.y1 = +x[p - 1], u.x2 = +x[p - 4] || u.x1, u.y2 = +x[p - 3] || u.y1;
|
|
1005
1008
|
const M = {
|
|
1006
1009
|
s: m[s],
|
|
1007
1010
|
c: m[s][0],
|
|
@@ -1011,58 +1014,22 @@ e.slice(1).every(([t]) => t === t.toLowerCase()), ot = (e, t) => {
|
|
|
1011
1014
|
A = [...A, M];
|
|
1012
1015
|
}
|
|
1013
1016
|
return A.map((M) => {
|
|
1014
|
-
if (
|
|
1015
|
-
return [
|
|
1016
|
-
for (i = 1,
|
|
1017
|
-
[n, r] =
|
|
1017
|
+
if (b = M.c, x = M.s, b === "L" || b === "H" || b === "V")
|
|
1018
|
+
return [l, c] = zt(g, [M.x, M.y], h), n !== l && r !== c ? x = ["L", l, c] : r === c ? x = ["H", l] : n === l && (x = ["V", c]), n = l, r = c, x;
|
|
1019
|
+
for (i = 1, a = x.length; i < a; i += 2)
|
|
1020
|
+
[n, r] = zt(g, [+x[i], +x[i + 1]], h), x[i] = n, x[i + 1] = r;
|
|
1018
1021
|
return x;
|
|
1019
1022
|
});
|
|
1020
1023
|
}
|
|
1021
1024
|
return [...m];
|
|
1022
|
-
},
|
|
1023
|
-
const n = e.slice(0, 2), r = e.slice(2, 4), s = e.slice(4, 6), i = e.slice(6, 8), o =
|
|
1025
|
+
}, je = (e) => {
|
|
1026
|
+
const n = e.slice(0, 2), r = e.slice(2, 4), s = e.slice(4, 6), i = e.slice(6, 8), o = I(n, r, 0.5), a = I(r, s, 0.5), l = I(s, i, 0.5), c = I(o, a, 0.5), m = I(a, l, 0.5), f = I(c, m, 0.5);
|
|
1024
1027
|
return [
|
|
1025
|
-
["C", ...o, ...
|
|
1026
|
-
["C", ...m, ...
|
|
1028
|
+
["C", ...o, ...c, ...f],
|
|
1029
|
+
["C", ...m, ...l, ...i]
|
|
1027
1030
|
];
|
|
1028
1031
|
};
|
|
1029
|
-
class
|
|
1030
|
-
// bring main utilities to front
|
|
1031
|
-
static CSSMatrix = Mt;
|
|
1032
|
-
static getPathBBox = St;
|
|
1033
|
-
static getPathArea = Gt;
|
|
1034
|
-
static getTotalLength = Z;
|
|
1035
|
-
static getDrawDirection = de;
|
|
1036
|
-
static getPointAtLength = J;
|
|
1037
|
-
static pathLengthFactory = ht;
|
|
1038
|
-
static getPropertiesAtLength = Pt;
|
|
1039
|
-
static getPropertiesAtPoint = ut;
|
|
1040
|
-
static polygonLength = re;
|
|
1041
|
-
static polygonArea = se;
|
|
1042
|
-
static getClosestPoint = pe;
|
|
1043
|
-
static getSegmentOfPoint = be;
|
|
1044
|
-
static getSegmentAtLength = Me;
|
|
1045
|
-
static isPointInStroke = Ae;
|
|
1046
|
-
static isValidPath = Jt;
|
|
1047
|
-
static isPathArray = ct;
|
|
1048
|
-
static isAbsoluteArray = At;
|
|
1049
|
-
static isRelativeArray = Ut;
|
|
1050
|
-
static isCurveArray = Yt;
|
|
1051
|
-
static isNormalizedArray = Nt;
|
|
1052
|
-
static shapeToPath = Se;
|
|
1053
|
-
static parsePathString = R;
|
|
1054
|
-
static roundPath = ot;
|
|
1055
|
-
static splitPath = kt;
|
|
1056
|
-
static splitCubic = $e;
|
|
1057
|
-
static optimizePath = qt;
|
|
1058
|
-
static reverseCurve = Le;
|
|
1059
|
-
static reversePath = st;
|
|
1060
|
-
static normalizePath = O;
|
|
1061
|
-
static transformPath = Vt;
|
|
1062
|
-
static pathToAbsolute = X;
|
|
1063
|
-
static pathToRelative = bt;
|
|
1064
|
-
static pathToCurve = it;
|
|
1065
|
-
static pathToString = j;
|
|
1032
|
+
class v {
|
|
1066
1033
|
/**
|
|
1067
1034
|
* @constructor
|
|
1068
1035
|
* @param {string} pathValue the path string
|
|
@@ -1071,26 +1038,26 @@ class Ve {
|
|
|
1071
1038
|
constructor(t, n) {
|
|
1072
1039
|
const r = n || {}, s = typeof t > "u";
|
|
1073
1040
|
if (s || !t.length)
|
|
1074
|
-
throw TypeError(`${
|
|
1075
|
-
const i =
|
|
1041
|
+
throw TypeError(`${O}: "pathValue" is ${s ? "undefined" : "empty"}`);
|
|
1042
|
+
const i = Q(t);
|
|
1076
1043
|
this.segments = i;
|
|
1077
|
-
const { width: o, height:
|
|
1044
|
+
const { width: o, height: a, cx: l, cy: c, cz: m } = this.getBBox(), { round: f, origin: y } = r;
|
|
1078
1045
|
let g;
|
|
1079
1046
|
if (f === "auto") {
|
|
1080
|
-
const u = `${Math.floor(Math.max(o,
|
|
1047
|
+
const u = `${Math.floor(Math.max(o, a))}`.length;
|
|
1081
1048
|
g = u >= 4 ? 0 : 4 - u;
|
|
1082
1049
|
} else
|
|
1083
1050
|
Number.isInteger(f) || f === "off" ? g = f : g = at.round;
|
|
1084
1051
|
let h;
|
|
1085
1052
|
if (Array.isArray(y) && y.length >= 2) {
|
|
1086
|
-
const [u, x,
|
|
1053
|
+
const [u, x, p] = y.map(Number);
|
|
1087
1054
|
h = [
|
|
1088
|
-
Number.isNaN(u) ?
|
|
1089
|
-
Number.isNaN(x) ?
|
|
1090
|
-
Number.isNaN(
|
|
1055
|
+
Number.isNaN(u) ? l : u,
|
|
1056
|
+
Number.isNaN(x) ? c : x,
|
|
1057
|
+
Number.isNaN(p) ? m : p
|
|
1091
1058
|
];
|
|
1092
1059
|
} else
|
|
1093
|
-
h = [
|
|
1060
|
+
h = [l, c, m];
|
|
1094
1061
|
return this.round = g, this.origin = h, this;
|
|
1095
1062
|
}
|
|
1096
1063
|
/**
|
|
@@ -1100,7 +1067,7 @@ class Ve {
|
|
|
1100
1067
|
* @returns the pathBBox
|
|
1101
1068
|
*/
|
|
1102
1069
|
getBBox() {
|
|
1103
|
-
return
|
|
1070
|
+
return kt(this.segments);
|
|
1104
1071
|
}
|
|
1105
1072
|
/**
|
|
1106
1073
|
* Returns the total path length, equivalent to native `path.getTotalLength()`.
|
|
@@ -1109,7 +1076,7 @@ class Ve {
|
|
|
1109
1076
|
* @returns the path total length
|
|
1110
1077
|
*/
|
|
1111
1078
|
getTotalLength() {
|
|
1112
|
-
return
|
|
1079
|
+
return F(this.segments);
|
|
1113
1080
|
}
|
|
1114
1081
|
/**
|
|
1115
1082
|
* Returns an `{x,y}` point in the path stroke at a given length,
|
|
@@ -1120,7 +1087,7 @@ class Ve {
|
|
|
1120
1087
|
* @returns the requested point
|
|
1121
1088
|
*/
|
|
1122
1089
|
getPointAtLength(t) {
|
|
1123
|
-
return
|
|
1090
|
+
return W(this.segments, t);
|
|
1124
1091
|
}
|
|
1125
1092
|
/**
|
|
1126
1093
|
* Convert path to absolute values
|
|
@@ -1129,7 +1096,7 @@ class Ve {
|
|
|
1129
1096
|
*/
|
|
1130
1097
|
toAbsolute() {
|
|
1131
1098
|
const { segments: t } = this;
|
|
1132
|
-
return this.segments =
|
|
1099
|
+
return this.segments = H(t), this;
|
|
1133
1100
|
}
|
|
1134
1101
|
/**
|
|
1135
1102
|
* Convert path to relative values
|
|
@@ -1138,7 +1105,7 @@ class Ve {
|
|
|
1138
1105
|
*/
|
|
1139
1106
|
toRelative() {
|
|
1140
1107
|
const { segments: t } = this;
|
|
1141
|
-
return this.segments =
|
|
1108
|
+
return this.segments = At(t), this;
|
|
1142
1109
|
}
|
|
1143
1110
|
/**
|
|
1144
1111
|
* Convert path to cubic-bezier values. In addition, un-necessary `Z`
|
|
@@ -1148,7 +1115,7 @@ class Ve {
|
|
|
1148
1115
|
*/
|
|
1149
1116
|
toCurve() {
|
|
1150
1117
|
const { segments: t } = this;
|
|
1151
|
-
return this.segments =
|
|
1118
|
+
return this.segments = ct(t), this;
|
|
1152
1119
|
}
|
|
1153
1120
|
/**
|
|
1154
1121
|
* Reverse the order of the segments and their values.
|
|
@@ -1158,9 +1125,9 @@ class Ve {
|
|
|
1158
1125
|
*/
|
|
1159
1126
|
reverse(t) {
|
|
1160
1127
|
this.toAbsolute();
|
|
1161
|
-
const { segments: n } = this, r =
|
|
1128
|
+
const { segments: n } = this, r = $t(n), s = r.length > 1 ? r : !1, i = s ? [...s].map((a, l) => t ? l ? it(a) : [...a] : it(a)) : [...n];
|
|
1162
1129
|
let o = [];
|
|
1163
|
-
return s ? o = i.flat(1) : o = t ? n :
|
|
1130
|
+
return s ? o = i.flat(1) : o = t ? n : it(n), this.segments = [...o], this;
|
|
1164
1131
|
}
|
|
1165
1132
|
/**
|
|
1166
1133
|
* Normalize path in 2 steps:
|
|
@@ -1171,7 +1138,7 @@ class Ve {
|
|
|
1171
1138
|
*/
|
|
1172
1139
|
normalize() {
|
|
1173
1140
|
const { segments: t } = this;
|
|
1174
|
-
return this.segments =
|
|
1141
|
+
return this.segments = j(t), this;
|
|
1175
1142
|
}
|
|
1176
1143
|
/**
|
|
1177
1144
|
* Optimize `pathArray` values:
|
|
@@ -1183,7 +1150,7 @@ class Ve {
|
|
|
1183
1150
|
*/
|
|
1184
1151
|
optimize() {
|
|
1185
1152
|
const { segments: t } = this;
|
|
1186
|
-
return this.segments =
|
|
1153
|
+
return this.segments = Ot(t, this.round), this;
|
|
1187
1154
|
}
|
|
1188
1155
|
/**
|
|
1189
1156
|
* Transform path using values from an `Object` defined as `transformObject`.
|
|
@@ -1194,21 +1161,21 @@ class Ve {
|
|
|
1194
1161
|
* @public
|
|
1195
1162
|
*/
|
|
1196
1163
|
transform(t) {
|
|
1197
|
-
if (!t || typeof t != "object" || typeof t == "object" && !["translate", "rotate", "skew", "scale"].some((
|
|
1164
|
+
if (!t || typeof t != "object" || typeof t == "object" && !["translate", "rotate", "skew", "scale"].some((l) => l in t))
|
|
1198
1165
|
return this;
|
|
1199
1166
|
const {
|
|
1200
1167
|
segments: n,
|
|
1201
1168
|
origin: [r, s, i]
|
|
1202
1169
|
} = this, o = {};
|
|
1203
|
-
for (const [
|
|
1204
|
-
|
|
1205
|
-
const { origin:
|
|
1206
|
-
if (Array.isArray(
|
|
1207
|
-
const [
|
|
1208
|
-
o.origin = [Number.isNaN(
|
|
1170
|
+
for (const [l, c] of Object.entries(t))
|
|
1171
|
+
l === "skew" && Array.isArray(c) || (l === "rotate" || l === "translate" || l === "origin" || l === "scale") && Array.isArray(c) ? o[l] = c.map(Number) : l !== "origin" && typeof Number(c) == "number" && (o[l] = Number(c));
|
|
1172
|
+
const { origin: a } = o;
|
|
1173
|
+
if (Array.isArray(a) && a.length >= 2) {
|
|
1174
|
+
const [l, c, m] = a.map(Number);
|
|
1175
|
+
o.origin = [Number.isNaN(l) ? r : l, Number.isNaN(c) ? s : c, m || i];
|
|
1209
1176
|
} else
|
|
1210
1177
|
o.origin = [r, s, i];
|
|
1211
|
-
return this.segments =
|
|
1178
|
+
return this.segments = It(n, o), this;
|
|
1212
1179
|
}
|
|
1213
1180
|
/**
|
|
1214
1181
|
* Rotate path 180deg vertically
|
|
@@ -1234,10 +1201,12 @@ class Ve {
|
|
|
1234
1201
|
* @return the path string
|
|
1235
1202
|
*/
|
|
1236
1203
|
toString() {
|
|
1237
|
-
return
|
|
1204
|
+
return Z(this.segments, this.round);
|
|
1238
1205
|
}
|
|
1239
1206
|
}
|
|
1207
|
+
// bring main utilities to front
|
|
1208
|
+
N(v, "CSSMatrix", Nt), N(v, "getPathBBox", kt), N(v, "getPathArea", _t), N(v, "getTotalLength", F), N(v, "getDrawDirection", Ae), N(v, "getPointAtLength", W), N(v, "pathLengthFactory", ft), N(v, "getPropertiesAtLength", Pt), N(v, "getPropertiesAtPoint", yt), N(v, "polygonLength", le), N(v, "polygonArea", ce), N(v, "getClosestPoint", Ne), N(v, "getSegmentOfPoint", ve), N(v, "getSegmentAtLength", we), N(v, "isPointInStroke", Pe), N(v, "isValidPath", Wt), N(v, "isPathArray", mt), N(v, "isAbsoluteArray", vt), N(v, "isRelativeArray", Vt), N(v, "isCurveArray", Ut), N(v, "isNormalizedArray", wt), N(v, "shapeToPath", qe), N(v, "parsePathString", Q), N(v, "roundPath", lt), N(v, "splitPath", $t), N(v, "splitCubic", je), N(v, "optimizePath", Ot), N(v, "reverseCurve", Oe), N(v, "reversePath", it), N(v, "normalizePath", j), N(v, "transformPath", It), N(v, "pathToAbsolute", H), N(v, "pathToRelative", At), N(v, "pathToCurve", ct), N(v, "pathToString", Z);
|
|
1240
1209
|
export {
|
|
1241
|
-
|
|
1210
|
+
v as default
|
|
1242
1211
|
};
|
|
1243
1212
|
//# sourceMappingURL=svg-path-commander.mjs.map
|