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