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