pantograph2d 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{QuadraticBezier-BKElJOgn.cjs → QuadraticBezier--UZr_xcV.cjs} +2 -2
- package/dist/QuadraticBezier--UZr_xcV.cjs.map +1 -0
- package/dist/{QuadraticBezier-PcRS9HZK.js → QuadraticBezier-DxieHk9z.js} +4 -2
- package/dist/QuadraticBezier-DxieHk9z.js.map +1 -0
- package/dist/{draw-L71G180-.cjs → draw-BUUNobTS.cjs} +2 -2
- package/dist/{draw-L71G180-.cjs.map → draw-BUUNobTS.cjs.map} +1 -1
- package/dist/{draw-N2ntigsw.js → draw-lOWnIN1o.js} +5 -3
- package/dist/{draw-N2ntigsw.js.map → draw-lOWnIN1o.js.map} +1 -1
- package/dist/models-CCo90hZc.cjs +4 -0
- package/dist/models-CCo90hZc.cjs.map +1 -0
- package/dist/{models-BjaFYsN2.js → models-DCkOI0hV.js} +643 -581
- package/dist/models-DCkOI0hV.js.map +1 -0
- package/dist/pantograph/drawShape.cjs +1 -1
- package/dist/pantograph/drawShape.js +1 -1
- package/dist/pantograph/models.cjs +1 -1
- package/dist/pantograph/models.js +2 -2
- package/dist/pantograph/svg.cjs +1 -1
- package/dist/pantograph/svg.js +1 -1
- package/dist/pantograph.cjs +2 -2
- package/dist/pantograph.cjs.map +1 -1
- package/dist/pantograph.js +621 -425
- package/dist/pantograph.js.map +1 -1
- package/dist/{svg-hNHYuj_r.js → svg-BIphc_zE.js} +3 -3
- package/dist/{svg-hNHYuj_r.js.map → svg-BIphc_zE.js.map} +1 -1
- package/dist/{svg-ZTvNxsWu.cjs → svg-BY5h3CDD.cjs} +3 -3
- package/dist/{svg-ZTvNxsWu.cjs.map → svg-BY5h3CDD.cjs.map} +1 -1
- package/dist/types/src/algorithms/boolean/loopBooleans.d.ts +10 -5
- package/dist/types/src/drawShape/drawPolysides.d.ts +1 -0
- package/dist/types/src/drawShape/index.d.ts +1 -0
- package/dist/types/src/featureOperations.d.ts +88 -0
- package/dist/types/src/main.d.ts +2 -2
- package/dist/types/src/models/Diagram.d.ts +3 -1
- package/dist/types/src/models/Figure.d.ts +3 -1
- package/dist/types/src/models/Loop.d.ts +3 -1
- package/dist/types/src/operations.d.ts +1 -0
- package/dist/types/src/vectorOperations.d.ts +1 -1
- package/package.json +3 -2
- package/dist/QuadraticBezier-BKElJOgn.cjs.map +0 -1
- package/dist/QuadraticBezier-PcRS9HZK.js.map +0 -1
- package/dist/models-BXU-Gx3U.cjs +0 -4
- package/dist/models-BXU-Gx3U.cjs.map +0 -1
- package/dist/models-BjaFYsN2.js.map +0 -1
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var C = (t, n, e) =>
|
|
4
|
-
import { b as k, d as
|
|
5
|
-
function
|
|
6
|
-
const e = k(n, t.firstPoint), s =
|
|
1
|
+
var nn = Object.defineProperty;
|
|
2
|
+
var en = (t, n, e) => n in t ? nn(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
|
|
3
|
+
var C = (t, n, e) => en(t, typeof n != "symbol" ? n + "" : n, e);
|
|
4
|
+
import { b as k, d as sn, e as Tt, a as z, s as V, n as on, p as Lt, r as U, A as S, g as P, u as qt, E as M, T as rn, v as ln, Q as I, w as $, C as A, c as un, x as cn, L as b, y as zt, F as ut, z as N, G as an, l as fn, o as hn, H as mt, B as pn } from "./QuadraticBezier-DxieHk9z.js";
|
|
5
|
+
function dn(t, n) {
|
|
6
|
+
const e = k(n, t.firstPoint), s = sn(e, t.V) / t.squareLength;
|
|
7
7
|
return t.paramPoint(s);
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
const s = e || t.precision, i =
|
|
9
|
+
function K(t, n, e) {
|
|
10
|
+
const s = e || t.precision, i = dn(t, n.center), o = Tt(i, n.center);
|
|
11
11
|
if (o > n.radius + s) return [];
|
|
12
12
|
if (Math.abs(o - n.radius) < s) {
|
|
13
|
-
const
|
|
14
|
-
return t.isOnSegment(
|
|
13
|
+
const c = i;
|
|
14
|
+
return t.isOnSegment(c) && n.isOnSegment(c) ? [c] : [];
|
|
15
15
|
}
|
|
16
|
-
const
|
|
16
|
+
const l = [], r = Math.sqrt(
|
|
17
17
|
n.radius * n.radius - o * o
|
|
18
|
-
),
|
|
19
|
-
t.isOnSegment(a) && n.isOnSegment(a) &&
|
|
20
|
-
const f =
|
|
21
|
-
return t.isOnSegment(f) && n.isOnSegment(f) &&
|
|
18
|
+
), u = t.tangentAtFirstPoint, a = z(i, V(u, r));
|
|
19
|
+
t.isOnSegment(a) && n.isOnSegment(a) && l.push(a);
|
|
20
|
+
const f = z(i, V(u, -r));
|
|
21
|
+
return t.isOnSegment(f) && n.isOnSegment(f) && l.push(f), l;
|
|
22
22
|
}
|
|
23
|
-
const
|
|
23
|
+
const mn = (t) => {
|
|
24
24
|
const { firstPoint: n, lastPoint: e, center: s, clockwise: i } = t;
|
|
25
25
|
return new S(e, n, s, i, {
|
|
26
26
|
ignoreChecks: !0
|
|
27
27
|
});
|
|
28
|
-
},
|
|
28
|
+
}, gn = (t, n) => {
|
|
29
29
|
if (t.isSame(n))
|
|
30
30
|
return [t];
|
|
31
31
|
const e = U(
|
|
@@ -41,9 +41,9 @@ const dn = (t) => {
|
|
|
41
41
|
if (e.length === 0) return [];
|
|
42
42
|
if (e.length === 1) return [];
|
|
43
43
|
if (e.length === 2)
|
|
44
|
-
return t.isSame(
|
|
44
|
+
return t.isSame(mn(n)) ? [] : [new S(e[0], e[1], t.center, t.clockwise)];
|
|
45
45
|
if (e.length === 3) {
|
|
46
|
-
const s =
|
|
46
|
+
const s = P(e[0], n.lastPoint) || P(e[0], n.firstPoint) ? 1 : 0;
|
|
47
47
|
return [
|
|
48
48
|
new S(
|
|
49
49
|
e[0 + s],
|
|
@@ -59,101 +59,101 @@ const dn = (t) => {
|
|
|
59
59
|
];
|
|
60
60
|
throw new Error("Bug in the arc arc overlap algorithm");
|
|
61
61
|
};
|
|
62
|
-
function
|
|
63
|
-
const i = s || t.precision, o =
|
|
64
|
-
if (o >
|
|
62
|
+
function Dt(t, n, e = !1, s) {
|
|
63
|
+
const i = s || t.precision, o = Tt(t.center, n.center), l = t.radius + n.radius;
|
|
64
|
+
if (o > l + i)
|
|
65
65
|
return [];
|
|
66
|
-
const
|
|
67
|
-
if (o <
|
|
66
|
+
const r = Math.abs(t.radius - n.radius);
|
|
67
|
+
if (o < r - i)
|
|
68
68
|
return [];
|
|
69
69
|
if (o < i)
|
|
70
|
-
return
|
|
71
|
-
const
|
|
70
|
+
return r > i ? [] : e ? gn(t, n) : [];
|
|
71
|
+
const u = on(k(n.center, t.center)), a = o > l - i;
|
|
72
72
|
if (
|
|
73
73
|
// circles are outside each other
|
|
74
74
|
a || // circles are inside each other
|
|
75
|
-
Math.abs(o -
|
|
75
|
+
Math.abs(o - r) < i
|
|
76
76
|
) {
|
|
77
|
-
const
|
|
77
|
+
const g = a || t.radius > n.radius ? 1 : -1, w = z(
|
|
78
78
|
t.center,
|
|
79
|
-
V(
|
|
79
|
+
V(u, g * t.radius)
|
|
80
80
|
);
|
|
81
|
-
return t.isOnSegment(
|
|
81
|
+
return t.isOnSegment(w) && n.isOnSegment(w) ? [w] : [];
|
|
82
82
|
}
|
|
83
|
-
const f = t.radius * t.radius / (2 * o) - n.radius * n.radius / (2 * o) + o / 2,
|
|
83
|
+
const f = t.radius * t.radius / (2 * o) - n.radius * n.radius / (2 * o) + o / 2, c = z(
|
|
84
84
|
t.center,
|
|
85
|
-
V(
|
|
85
|
+
V(u, f)
|
|
86
86
|
), h = Math.sqrt(
|
|
87
87
|
t.radius * t.radius - f * f
|
|
88
|
-
), p =
|
|
89
|
-
return t.isOnSegment(d) && n.isOnSegment(d) &&
|
|
88
|
+
), p = Lt(u), d = z(c, V(p, h)), m = z(c, V(p, -h)), x = [];
|
|
89
|
+
return t.isOnSegment(d) && n.isOnSegment(d) && x.push(d), t.isOnSegment(m) && n.isOnSegment(m) && x.push(m), x;
|
|
90
90
|
}
|
|
91
|
-
function
|
|
92
|
-
const s = t.transform(n.ellipseReferenceFrameTransform), i = s.slope, o = s.yIntercept,
|
|
93
|
-
(
|
|
94
|
-
).filter((
|
|
91
|
+
function st(t, n, e = 1e-9) {
|
|
92
|
+
const s = t.transform(n.ellipseReferenceFrameTransform), i = s.slope, o = s.yIntercept, l = n.majorRadius * n.majorRadius, r = n.minorRadius * n.minorRadius, u = n.majorRadius * n.minorRadius, a = s.slope * s.slope, f = s.yIntercept * s.yIntercept, c = (g) => g.map(
|
|
93
|
+
(w) => n.reverseEllipseReferenceFrameTransform.transform(w)
|
|
94
|
+
).filter((w) => t.isOnSegment(w) && n.isOnSegment(w));
|
|
95
95
|
if (!Number.isFinite(i)) {
|
|
96
|
-
const
|
|
97
|
-
if (Math.abs(
|
|
98
|
-
if (Math.abs(Math.abs(
|
|
99
|
-
return
|
|
100
|
-
const
|
|
101
|
-
return
|
|
102
|
-
}
|
|
103
|
-
const h =
|
|
96
|
+
const g = s.firstPoint[0];
|
|
97
|
+
if (Math.abs(g) - n.majorRadius > e) return [];
|
|
98
|
+
if (Math.abs(Math.abs(g) - n.majorRadius) < e)
|
|
99
|
+
return c([[g, 0]]);
|
|
100
|
+
const w = n.minorRadius * Math.sqrt(1 - g * g / l), F = [g, w], y = [g, -w];
|
|
101
|
+
return c([F, y]);
|
|
102
|
+
}
|
|
103
|
+
const h = l * a + r - f;
|
|
104
104
|
if (h < -e)
|
|
105
105
|
return [];
|
|
106
|
-
const p =
|
|
106
|
+
const p = l * a + r;
|
|
107
107
|
if (Math.abs(h) < e) {
|
|
108
|
-
const
|
|
109
|
-
return
|
|
108
|
+
const g = -(l * i * o) / p, w = r * o / p;
|
|
109
|
+
return c([[g, w]]);
|
|
110
110
|
}
|
|
111
111
|
const d = Math.sqrt(h), m = [
|
|
112
|
-
-(
|
|
113
|
-
(
|
|
114
|
-
],
|
|
115
|
-
-(
|
|
116
|
-
(
|
|
112
|
+
-(l * i * o + u * d) / p,
|
|
113
|
+
(r * o - u * i * d) / p
|
|
114
|
+
], x = [
|
|
115
|
+
-(l * i * o - u * d) / p,
|
|
116
|
+
(r * o + u * i * d) / p
|
|
117
117
|
];
|
|
118
|
-
return
|
|
119
|
-
}
|
|
120
|
-
function
|
|
121
|
-
const e = Math.max(t.precision, n.precision), s = t.coefficients, i = s.x2, o = s.xy,
|
|
122
|
-
z0: a * i * d * d + i * i *
|
|
123
|
-
z1: m *
|
|
124
|
-
z2: m * m * i * i + 2 * p *
|
|
125
|
-
z3: -2 * i *
|
|
126
|
-
z4: i * i * p * p - 2 * i * p *
|
|
127
|
-
}, F =
|
|
128
|
-
[
|
|
118
|
+
return c([m, x]);
|
|
119
|
+
}
|
|
120
|
+
function Rt(t, n) {
|
|
121
|
+
const e = Math.max(t.precision, n.precision), s = t.coefficients, i = s.x2, o = s.xy, l = s.y2, r = s.x, u = s.y, a = s.c, f = n.coefficients, c = f.x2, h = f.xy, p = f.y2, d = f.x, m = f.y, x = f.c, g = {
|
|
122
|
+
z0: a * i * d * d + i * i * x * x - r * i * d * x + c * c * a * a - 2 * i * x * c * a - r * d * c * a + c * r * r * x,
|
|
123
|
+
z1: m * r * r * c - x * d * i * o - 2 * i * x * c * u - a * c * h * r + 2 * d * h * i * a + 2 * m * x * i * i + d * d * i * u - m * d * i * r - 2 * i * m * c * a - a * c * d * o + 2 * a * u * c * c - x * h * i * r - u * c * d * r + 2 * x * o * c * r,
|
|
124
|
+
z2: m * m * i * i + 2 * p * x * i * i - u * c * d * o + x * c * o * o - u * c * h * r - x * h * i * o - 2 * i * m * c * u + 2 * d * h * i * u - p * d * i * r - 2 * i * p * c * a + h * h * i * a + 2 * m * o * c * r + u * u * c * c - l * c * d * r - m * h * i * r + 2 * a * l * c * c - a * c * h * o + p * r * r * c + d * d * i * l - m * d * i * o - 2 * i * x * c * l,
|
|
125
|
+
z3: -2 * i * c * l * m + m * c * o * o + 2 * p * o * c * r - l * c * h * r + h * h * i * u - m * h * i * o - 2 * i * p * c * u - u * c * h * o - p * h * i * r + 2 * m * p * i * i + 2 * u * l * c * c - l * c * d * o + 2 * d * h * i * l - p * d * i * o,
|
|
126
|
+
z4: i * i * p * p - 2 * i * p * c * l + c * c * l * l - o * i * h * p - o * h * c * l + o * o * c * p + l * i * h * h
|
|
127
|
+
}, F = qt(
|
|
128
|
+
[g.z0, g.z1, g.z2, g.z3, g.z4],
|
|
129
129
|
e
|
|
130
|
-
).flatMap((
|
|
131
|
-
const R = i * h *
|
|
130
|
+
).flatMap((y) => {
|
|
131
|
+
const R = i * h * y + i * d - c * o * y - c * r;
|
|
132
132
|
if (R)
|
|
133
|
-
return [[-(i *
|
|
134
|
-
const T = o *
|
|
135
|
-
if (Math.abs(
|
|
136
|
-
return [[L,
|
|
137
|
-
if (
|
|
138
|
-
const H = Math.sqrt(
|
|
139
|
-
return [[L + H,
|
|
133
|
+
return [[-(i * x + i * p * y * y - c * l * y * y + i * m * y - c * u * y - c * a) / R, y]];
|
|
134
|
+
const T = o * y + r, L = -T / (2 * i), j = l * y * y + u * y + a, q = T * T / (4 * i * i) - j / i;
|
|
135
|
+
if (Math.abs(q) < e)
|
|
136
|
+
return [[L, y]];
|
|
137
|
+
if (q > 0) {
|
|
138
|
+
const H = Math.sqrt(q);
|
|
139
|
+
return [[L + H, y], [L - H, y]];
|
|
140
140
|
}
|
|
141
141
|
return [];
|
|
142
142
|
});
|
|
143
143
|
return U(F, e);
|
|
144
144
|
}
|
|
145
|
-
function
|
|
146
|
-
return
|
|
145
|
+
function gt(t, n) {
|
|
146
|
+
return Rt(t, n).filter((s) => t.isOnSegment(s) && n.isOnSegment(s));
|
|
147
147
|
}
|
|
148
|
-
const
|
|
148
|
+
const Pn = (t) => {
|
|
149
149
|
const {
|
|
150
150
|
firstPoint: n,
|
|
151
151
|
lastPoint: e,
|
|
152
152
|
center: s,
|
|
153
153
|
majorRadius: i,
|
|
154
154
|
minorRadius: o,
|
|
155
|
-
tiltAngle:
|
|
156
|
-
clockwise:
|
|
155
|
+
tiltAngle: l,
|
|
156
|
+
clockwise: r
|
|
157
157
|
} = t;
|
|
158
158
|
return new M(
|
|
159
159
|
e,
|
|
@@ -161,14 +161,14 @@ const gn = (t) => {
|
|
|
161
161
|
s,
|
|
162
162
|
i,
|
|
163
163
|
o,
|
|
164
|
-
r,
|
|
165
164
|
l,
|
|
165
|
+
r,
|
|
166
166
|
{
|
|
167
167
|
ignoreChecks: !0,
|
|
168
168
|
angleUnits: "rad"
|
|
169
169
|
}
|
|
170
170
|
);
|
|
171
|
-
},
|
|
171
|
+
}, wn = (t, n) => {
|
|
172
172
|
if (t.isSame(n))
|
|
173
173
|
return [t];
|
|
174
174
|
const e = (i, o) => new M(
|
|
@@ -193,50 +193,50 @@ const gn = (t) => {
|
|
|
193
193
|
if (s.length === 0) return [];
|
|
194
194
|
if (s.length === 1) return [];
|
|
195
195
|
if (s.length === 2)
|
|
196
|
-
return t.isSame(
|
|
196
|
+
return t.isSame(Pn(n)) ? [] : [e(s[0], s[1])];
|
|
197
197
|
if (s.length === 3) {
|
|
198
|
-
const i =
|
|
198
|
+
const i = P(s[0], n.lastPoint) || P(s[0], n.firstPoint) ? 1 : 0;
|
|
199
199
|
return [e(s[0 + i], s[1 + i])];
|
|
200
200
|
} else if (s.length === 4)
|
|
201
201
|
return [e(s[0], s[1]), e(s[2], s[3])];
|
|
202
202
|
throw new Error("Bug in the ellipse arc ellipse arc overlap algorithm");
|
|
203
203
|
};
|
|
204
|
-
function
|
|
204
|
+
function xn(t, n, e = !1) {
|
|
205
205
|
const s = Math.max(t.precision, n.precision);
|
|
206
|
-
return
|
|
206
|
+
return P(t.center, n.center) && Math.abs(t.majorRadius - n.majorRadius) < s && Math.abs(t.minorRadius - n.minorRadius) < s && (Math.abs(t.tiltAngle - n.tiltAngle) < s || Math.abs(Math.abs(t.tiltAngle - n.tiltAngle) - Math.PI) < s) ? e ? wn(t, n) : [] : Rt(t, n).filter((l) => t.isOnSegment(l) && n.isOnSegment(l));
|
|
207
207
|
}
|
|
208
|
-
function
|
|
209
|
-
const [e, s] = t.firstPoint, [i, o] = t.lastPoint,
|
|
210
|
-
return
|
|
208
|
+
function Pt(t, n) {
|
|
209
|
+
const [e, s] = t.firstPoint, [i, o] = t.lastPoint, l = new rn().translate(-e, -s).rotate(-Math.atan2(o - s, i - e)), r = l.clone().inverse(), u = n.transform(l);
|
|
210
|
+
return u.paramsAtY(0).map((a) => u.paramPoint(a)).map((a) => r.transform(a)).filter((a) => t.isOnSegment(a));
|
|
211
211
|
}
|
|
212
|
-
const
|
|
212
|
+
const Sn = (t, n = 1e-9) => {
|
|
213
213
|
let e = t;
|
|
214
214
|
return Math.abs(t) < n && (e = 0), e.toFixed(-Math.log10(n));
|
|
215
215
|
};
|
|
216
|
-
function
|
|
216
|
+
function Vt(t, n = 1e-9) {
|
|
217
217
|
return Array.from(
|
|
218
|
-
new Map(t.map((e) => [
|
|
218
|
+
new Map(t.map((e) => [Sn(e, n), e])).values()
|
|
219
219
|
);
|
|
220
220
|
}
|
|
221
|
-
const Sn = (t, n) => {
|
|
222
|
-
const [[e, s, i, o], [r, l, c, a]] = n.polynomialCoefficients, f = t.coefficients, u = f.x2, h = f.xy, p = f.y2, d = f.x, m = f.y, P = f.c, w = e * e, x = s * s, F = i * i, b = o * o, R = r * r, T = l * l, L = c * c, j = a * a, z = P + d * e + u * w + m * r + h * e * r + p * R, H = d * s + 2 * u * e * s + h * s * r + m * l + h * e * l + 2 * p * r * l, Qt = u * x + d * i + 2 * u * e * i + h * i * r + h * s * l + p * T + m * c + h * e * c + 2 * p * r * c, Wt = 2 * u * s * i + d * o + 2 * u * e * o + h * o * r + h * i * l + h * s * c + 2 * p * l * c + m * a + h * e * a + 2 * p * r * a, Jt = u * F + 2 * u * s * o + h * o * l + h * i * c + p * L + h * s * a + 2 * p * l * a, Kt = 2 * u * i * o + h * o * c + h * i * a + 2 * p * c * a, Zt = u * b + h * o * a + p * j;
|
|
223
|
-
return [z, H, Qt, Wt, Jt, Kt, Zt];
|
|
224
|
-
};
|
|
225
|
-
function Pt(t, n) {
|
|
226
|
-
const e = Math.max(t.precision, n.precision), s = Sn(t, n), i = Lt(s, e).filter((o) => o >= -n.precision && o <= 1 + n.precision);
|
|
227
|
-
return Rt(i, e).map((o) => n.paramPoint(o)).filter((o) => t.isOnSegment(o));
|
|
228
|
-
}
|
|
229
221
|
const yn = (t, n) => {
|
|
230
|
-
const [[e, s, i], [
|
|
231
|
-
return [
|
|
222
|
+
const [[e, s, i, o], [l, r, u, a]] = n.polynomialCoefficients, f = t.coefficients, c = f.x2, h = f.xy, p = f.y2, d = f.x, m = f.y, x = f.c, g = e * e, w = s * s, F = i * i, y = o * o, R = l * l, T = r * r, L = u * u, j = a * a, q = x + d * e + c * g + m * l + h * e * l + p * R, H = d * s + 2 * c * e * s + h * s * l + m * r + h * e * r + 2 * p * l * r, Wt = c * w + d * i + 2 * c * e * i + h * i * l + h * s * r + p * T + m * u + h * e * u + 2 * p * l * u, Jt = 2 * c * s * i + d * o + 2 * c * e * o + h * o * l + h * i * r + h * s * u + 2 * p * r * u + m * a + h * e * a + 2 * p * l * a, Kt = c * F + 2 * c * s * o + h * o * r + h * i * u + p * L + h * s * a + 2 * p * r * a, Zt = 2 * c * i * o + h * o * u + h * i * a + 2 * p * u * a, tn = c * y + h * o * a + p * j;
|
|
223
|
+
return [q, H, Wt, Jt, Kt, Zt, tn];
|
|
232
224
|
};
|
|
233
225
|
function wt(t, n) {
|
|
234
|
-
const e = Math.max(t.precision, n.precision), s = yn(t, n), i =
|
|
235
|
-
return
|
|
226
|
+
const e = Math.max(t.precision, n.precision), s = yn(t, n), i = qt(s, e).filter((o) => o >= -n.precision && o <= 1 + n.precision);
|
|
227
|
+
return Vt(i, e).map((o) => n.paramPoint(o)).filter((o) => t.isOnSegment(o));
|
|
228
|
+
}
|
|
229
|
+
const bn = (t, n) => {
|
|
230
|
+
const [[e, s, i], [o, l, r]] = n.polynomialCoefficients, u = t.coefficients, a = u.x2, f = u.xy, c = u.y2, h = u.x, p = u.y, d = u.c, m = e * e, x = s * s, g = i * i, w = o * o, F = l * l, y = r * r, R = a * m + f * e * o + c * w + h * e + p * o + d, T = 2 * a * e * s + f * e * l + f * s * o + 2 * c * o * l + h * s + p * l, L = 2 * a * e * i + a * x + f * e * r + f * s * l + f * i * o + 2 * c * o * r + c * F + h * i + p * r, j = 2 * a * s * i + f * s * r + f * i * l + 2 * c * l * r, q = a * g + f * i * r + c * y;
|
|
231
|
+
return [R, T, L, j, q];
|
|
232
|
+
};
|
|
233
|
+
function xt(t, n) {
|
|
234
|
+
const e = Math.max(t.precision, n.precision), s = bn(t, n), i = ln(...s).filter((o) => o >= -n.precision && o <= 1 + n.precision);
|
|
235
|
+
return Vt(i, e).map((o) => n.paramPoint(o)).filter((o) => t.isOnSegment(o));
|
|
236
236
|
}
|
|
237
237
|
function E(t, { firstPoint: n, lastPoint: e }, s = 1e-9) {
|
|
238
238
|
const i = k(e, n);
|
|
239
|
-
return Math.abs(i[0]) < s ? i[1] > 0 ? n[0] - t[0] : t[0] - n[0] : Math.abs(i[1]) < s ? i[0] > 0 ? t[1] - n[1] : n[1] - t[1] :
|
|
239
|
+
return Math.abs(i[0]) < s ? i[1] > 0 ? n[0] - t[0] : t[0] - n[0] : Math.abs(i[1]) < s ? i[0] > 0 ? t[1] - n[1] : n[1] - t[1] : un(i, k(t, n)) / cn(i);
|
|
240
240
|
}
|
|
241
241
|
class ct {
|
|
242
242
|
constructor(n, e, s, i) {
|
|
@@ -246,9 +246,9 @@ class ct {
|
|
|
246
246
|
return this.positiveThickness - this.negativeThickness;
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
|
-
const
|
|
250
|
-
function
|
|
251
|
-
const n = E(t.firstControlPoint, t), e = E(t.lastControlPoint, t), s = n * e > 0 ?
|
|
249
|
+
const Cn = 3 / 4, Mn = 4 / 9;
|
|
250
|
+
function In(t) {
|
|
251
|
+
const n = E(t.firstControlPoint, t), e = E(t.lastControlPoint, t), s = n * e > 0 ? Cn : Mn;
|
|
252
252
|
return new ct(
|
|
253
253
|
t.firstPoint,
|
|
254
254
|
t.lastPoint,
|
|
@@ -265,32 +265,32 @@ function An(t) {
|
|
|
265
265
|
Math.max(0, n / 2)
|
|
266
266
|
);
|
|
267
267
|
}
|
|
268
|
-
function
|
|
269
|
-
if (t instanceof I)
|
|
270
|
-
return Mn(t);
|
|
268
|
+
function En(t) {
|
|
271
269
|
if (t instanceof A)
|
|
270
|
+
return In(t);
|
|
271
|
+
if (t instanceof I)
|
|
272
272
|
return An(t);
|
|
273
273
|
throw new Error("Not implemented");
|
|
274
274
|
}
|
|
275
|
-
function
|
|
276
|
-
const n = t.paramPoint(0.5), e =
|
|
275
|
+
function Fn(t) {
|
|
276
|
+
const n = t.paramPoint(0.5), e = Lt(k(n, t.firstPoint)), s = z(n, e), i = {
|
|
277
277
|
firstPoint: n,
|
|
278
278
|
lastPoint: s
|
|
279
279
|
}, o = [
|
|
280
280
|
E(t.firstPoint, i),
|
|
281
281
|
E(t.lastPoint, i)
|
|
282
282
|
];
|
|
283
|
-
return t instanceof
|
|
283
|
+
return t instanceof A ? o.push(
|
|
284
284
|
E(t.firstControlPoint, i),
|
|
285
285
|
E(t.lastControlPoint, i)
|
|
286
|
-
) : t instanceof
|
|
286
|
+
) : t instanceof I && o.push(E(t.controlPoint, i)), new ct(
|
|
287
287
|
n,
|
|
288
288
|
s,
|
|
289
289
|
Math.min(...o),
|
|
290
290
|
Math.max(...o)
|
|
291
291
|
);
|
|
292
292
|
}
|
|
293
|
-
function
|
|
293
|
+
function St(t, n) {
|
|
294
294
|
const e = [];
|
|
295
295
|
for (let s = 1; s < t.length; s++) {
|
|
296
296
|
const i = t[s];
|
|
@@ -298,8 +298,8 @@ function xt(t, n) {
|
|
|
298
298
|
e.push(i[0]);
|
|
299
299
|
continue;
|
|
300
300
|
}
|
|
301
|
-
const o = t[s - 1],
|
|
302
|
-
if (
|
|
301
|
+
const o = t[s - 1], l = n - o[1], r = n - i[1];
|
|
302
|
+
if (l * r < 0) {
|
|
303
303
|
e.push(
|
|
304
304
|
o[0] + (n - o[1]) * (i[0] - o[0]) / (i[1] - o[1])
|
|
305
305
|
);
|
|
@@ -319,29 +319,29 @@ class Y {
|
|
|
319
319
|
return this.from === "start" ? this.to === "end" ? n : n.splitAtParameters([this.to])[0] : this.to === "end" ? n.splitAtParameters([this.from])[1] : n.splitAtParameters([this.from, this.to])[1];
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
|
-
function
|
|
323
|
-
if (t instanceof
|
|
324
|
-
return new
|
|
322
|
+
function vn(t, n) {
|
|
323
|
+
if (t instanceof A)
|
|
324
|
+
return new kn([
|
|
325
325
|
E(t.firstPoint, n),
|
|
326
326
|
E(t.firstControlPoint, n),
|
|
327
327
|
E(t.lastControlPoint, n),
|
|
328
328
|
E(t.lastPoint, n)
|
|
329
329
|
]);
|
|
330
|
-
if (t instanceof
|
|
331
|
-
return new
|
|
330
|
+
if (t instanceof I)
|
|
331
|
+
return new Bn([
|
|
332
332
|
E(t.firstPoint, n),
|
|
333
333
|
E(t.controlPoint, n),
|
|
334
334
|
E(t.lastPoint, n)
|
|
335
335
|
]);
|
|
336
336
|
throw new Error("Not implemented");
|
|
337
337
|
}
|
|
338
|
-
class
|
|
338
|
+
class Bn {
|
|
339
339
|
constructor(n) {
|
|
340
340
|
C(this, "topHull", []);
|
|
341
341
|
C(this, "bottomHull", []);
|
|
342
342
|
this.distances = n;
|
|
343
|
-
const [e, s, i] = n, o = [0, e],
|
|
344
|
-
s - (
|
|
343
|
+
const [e, s, i] = n, o = [0, e], l = [1 / 2, s], r = [1, i], u = i - e, a = e;
|
|
344
|
+
s - (u * (1 / 2) + a) > 0 ? (this.topHull = [o, l, r], this.bottomHull = [o, r]) : (this.topHull = [o, r], this.bottomHull = [o, l, r]);
|
|
345
345
|
}
|
|
346
346
|
get startDistance() {
|
|
347
347
|
return this.distances[0];
|
|
@@ -350,18 +350,18 @@ class vn {
|
|
|
350
350
|
return this.distances[2];
|
|
351
351
|
}
|
|
352
352
|
}
|
|
353
|
-
class
|
|
353
|
+
class kn {
|
|
354
354
|
constructor(n) {
|
|
355
355
|
C(this, "topHull", []);
|
|
356
356
|
C(this, "bottomHull", []);
|
|
357
357
|
this.distances = n;
|
|
358
|
-
const [e, s, i, o] = n,
|
|
358
|
+
const [e, s, i, o] = n, l = [0, e], r = [1 / 3, s], u = [2 / 3, i], a = [1, o], f = o - e, c = e, h = s - (f * (1 / 3) + c), p = i - (f * (2 / 3) + c);
|
|
359
359
|
let d = null, m = null;
|
|
360
360
|
if (h * p < 0)
|
|
361
|
-
d = [
|
|
361
|
+
d = [l, r, a], m = [l, u, a];
|
|
362
362
|
else {
|
|
363
|
-
const
|
|
364
|
-
|
|
363
|
+
const g = h / p;
|
|
364
|
+
g >= 2 ? (d = [l, r, a], m = [l, a]) : g <= 0.5 ? (d = [l, u, a], m = [l, a]) : (d = [l, r, u, a], m = [l, a]);
|
|
365
365
|
}
|
|
366
366
|
h < 0 && ([d, m] = [m, d]), this.topHull = d, this.bottomHull = m;
|
|
367
367
|
}
|
|
@@ -372,11 +372,11 @@ class Bn {
|
|
|
372
372
|
return this.distances[3];
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
|
-
function
|
|
376
|
-
const e =
|
|
375
|
+
function yt(t, n) {
|
|
376
|
+
const e = vn(n, t), s = St(
|
|
377
377
|
e.topHull,
|
|
378
378
|
t.negativeThickness
|
|
379
|
-
), i =
|
|
379
|
+
), i = St(
|
|
380
380
|
e.bottomHull,
|
|
381
381
|
t.positiveThickness
|
|
382
382
|
), o = e.endDistance >= t.negativeThickness && e.endDistance <= t.positiveThickness;
|
|
@@ -388,39 +388,39 @@ function St(t, n) {
|
|
|
388
388
|
throw new Error(
|
|
389
389
|
"Bug in the clipping algorithm, unexpected number of crossing points"
|
|
390
390
|
);
|
|
391
|
-
const
|
|
392
|
-
return
|
|
391
|
+
const l = s.length ? s : i;
|
|
392
|
+
return l.length === 2 ? new Y(l[0], l[1]) : o ? new Y(l[0], "end") : new Y("start", l[0]);
|
|
393
393
|
}
|
|
394
|
-
function
|
|
395
|
-
const e =
|
|
394
|
+
function bt(t, n) {
|
|
395
|
+
const e = En(t), s = yt(e, n);
|
|
396
396
|
if (!s)
|
|
397
397
|
return null;
|
|
398
|
-
const i =
|
|
398
|
+
const i = Fn(t), o = yt(
|
|
399
399
|
i,
|
|
400
400
|
n
|
|
401
401
|
);
|
|
402
402
|
return o ? s.size > o.size ? o.clipCurve(n) : s.clipCurve(n) : null;
|
|
403
403
|
}
|
|
404
|
-
const W = (t) => t instanceof
|
|
404
|
+
const W = (t) => t instanceof I ? $(k(t.controlPoint, t.firstPoint)) + $(k(t.controlPoint, t.lastPoint)) : $(k(t.firstControlPoint, t.firstPoint)) + $(k(t.lastControlPoint, t.firstControlPoint)) + $(k(t.lastControlPoint, t.lastPoint));
|
|
405
405
|
function D(t, n, e = 1e-9, { maxIterations: s = 100 } = {}) {
|
|
406
406
|
const i = Math.max(e * e, Number.EPSILON * 10);
|
|
407
|
-
let o = t,
|
|
407
|
+
let o = t, l = n, r = W(o), u = W(l);
|
|
408
408
|
for (let a = 0; a < s; a++) {
|
|
409
|
-
const f =
|
|
409
|
+
const f = r > i ? bt(l, o) : o;
|
|
410
410
|
if (!f) return [];
|
|
411
|
-
const
|
|
411
|
+
const c = W(f), h = u > i ? bt(f, l) : l;
|
|
412
412
|
if (!h) return [];
|
|
413
413
|
const p = W(h);
|
|
414
|
-
if (
|
|
414
|
+
if (c <= i && p <= i)
|
|
415
415
|
return [
|
|
416
416
|
f.boundingBox.intersection(h.boundingBox).center
|
|
417
417
|
];
|
|
418
|
-
if (
|
|
418
|
+
if (P(f.firstPoint, f.lastPoint) && h.isOnSegment(f.firstPoint))
|
|
419
419
|
return [f.firstPoint];
|
|
420
|
-
if (
|
|
420
|
+
if (P(h.firstPoint, h.lastPoint) && f.isOnSegment(h.firstPoint))
|
|
421
421
|
return [h.firstPoint];
|
|
422
|
-
if (
|
|
423
|
-
if (
|
|
422
|
+
if (c > 0.8 * r && p > 0.8 * u)
|
|
423
|
+
if (c / r > p / u) {
|
|
424
424
|
const [d, m] = f.splitAtParameters([
|
|
425
425
|
0.5
|
|
426
426
|
]);
|
|
@@ -451,11 +451,11 @@ function D(t, n, e = 1e-9, { maxIterations: s = 100 } = {}) {
|
|
|
451
451
|
e
|
|
452
452
|
);
|
|
453
453
|
}
|
|
454
|
-
o = f,
|
|
454
|
+
o = f, l = h, r = c, u = p;
|
|
455
455
|
}
|
|
456
456
|
throw new Error("Bézier clip: Maximum number of iterations reached");
|
|
457
457
|
}
|
|
458
|
-
function
|
|
458
|
+
function On(t, n) {
|
|
459
459
|
const e = [];
|
|
460
460
|
if ([
|
|
461
461
|
[t.firstPoint, n],
|
|
@@ -469,20 +469,20 @@ function kn(t, n) {
|
|
|
469
469
|
if (e.length === 2)
|
|
470
470
|
return [t.splitAt(e)[1]];
|
|
471
471
|
if (e.length === 3)
|
|
472
|
-
return
|
|
472
|
+
return P(e[0], t.firstPoint) && P(e[1], t.lastPoint) ? [t] : [n];
|
|
473
473
|
if (e.length === 4)
|
|
474
474
|
return [t];
|
|
475
475
|
}
|
|
476
476
|
function _n(t, n, e = !1) {
|
|
477
477
|
const s = Math.max(t.precision, n.precision);
|
|
478
478
|
if (e) {
|
|
479
|
-
const i =
|
|
479
|
+
const i = On(t, n);
|
|
480
480
|
if (i)
|
|
481
481
|
return i;
|
|
482
482
|
}
|
|
483
483
|
return D(t, n, s);
|
|
484
484
|
}
|
|
485
|
-
function
|
|
485
|
+
function Tn(t, n) {
|
|
486
486
|
const e = [];
|
|
487
487
|
if ([
|
|
488
488
|
[t.firstPoint, n],
|
|
@@ -496,21 +496,21 @@ function On(t, n) {
|
|
|
496
496
|
if (e.length === 2)
|
|
497
497
|
return [t.splitAt(e)[1]];
|
|
498
498
|
if (e.length === 3)
|
|
499
|
-
return
|
|
499
|
+
return P(e[0], t.firstPoint) && P(e[1], t.lastPoint) ? [t] : [n];
|
|
500
500
|
if (e.length === 4)
|
|
501
501
|
return [t];
|
|
502
502
|
}
|
|
503
|
-
function
|
|
503
|
+
function Ln(t, n, e = !1) {
|
|
504
504
|
const s = Math.max(t.precision, n.precision);
|
|
505
505
|
if (e) {
|
|
506
|
-
const i =
|
|
506
|
+
const i = Tn(t, n);
|
|
507
507
|
if (i)
|
|
508
508
|
return i;
|
|
509
509
|
}
|
|
510
510
|
return D(t, n, s);
|
|
511
511
|
}
|
|
512
|
-
function
|
|
513
|
-
if (t instanceof
|
|
512
|
+
function de(t, n, e) {
|
|
513
|
+
if (t instanceof b && n instanceof b) {
|
|
514
514
|
const s = zt(
|
|
515
515
|
t,
|
|
516
516
|
n,
|
|
@@ -519,36 +519,36 @@ function ae(t, n, e) {
|
|
|
519
519
|
);
|
|
520
520
|
return s === null ? [] : [s];
|
|
521
521
|
}
|
|
522
|
-
if (t instanceof
|
|
523
|
-
return
|
|
524
|
-
if (t instanceof S && n instanceof
|
|
525
|
-
return
|
|
522
|
+
if (t instanceof b && n instanceof S)
|
|
523
|
+
return K(t, n, e);
|
|
524
|
+
if (t instanceof S && n instanceof b)
|
|
525
|
+
return K(n, t, e);
|
|
526
526
|
if (t instanceof S && n instanceof S)
|
|
527
|
-
return
|
|
527
|
+
return Dt(t, n, !1, e);
|
|
528
528
|
throw new Error("Not implemented");
|
|
529
529
|
}
|
|
530
|
-
function
|
|
531
|
-
if (t instanceof
|
|
530
|
+
function Z(t, n, e) {
|
|
531
|
+
if (t instanceof b && n instanceof b) {
|
|
532
532
|
const s = zt(
|
|
533
533
|
t,
|
|
534
534
|
n,
|
|
535
535
|
!0,
|
|
536
536
|
e
|
|
537
537
|
);
|
|
538
|
-
return s === null ? { intersections: [], overlaps: [], count: 0 } : s instanceof
|
|
538
|
+
return s === null ? { intersections: [], overlaps: [], count: 0 } : s instanceof b ? { intersections: [], overlaps: [s], count: 1 } : { intersections: [s], overlaps: [], count: 1 };
|
|
539
539
|
}
|
|
540
540
|
if (!t.boundingBox.overlaps(n.boundingBox))
|
|
541
541
|
return { intersections: [], overlaps: [], count: 0 };
|
|
542
|
-
if (t instanceof
|
|
543
|
-
const s =
|
|
542
|
+
if (t instanceof b && n instanceof S) {
|
|
543
|
+
const s = K(t, n, e);
|
|
544
544
|
return { intersections: s, overlaps: [], count: s.length };
|
|
545
545
|
}
|
|
546
|
-
if (t instanceof S && n instanceof
|
|
547
|
-
const s =
|
|
546
|
+
if (t instanceof S && n instanceof b) {
|
|
547
|
+
const s = K(n, t, e);
|
|
548
548
|
return { intersections: s, overlaps: [], count: s.length };
|
|
549
549
|
}
|
|
550
550
|
if (t instanceof S && n instanceof S) {
|
|
551
|
-
const s =
|
|
551
|
+
const s = Dt(
|
|
552
552
|
t,
|
|
553
553
|
n,
|
|
554
554
|
!0,
|
|
@@ -564,16 +564,16 @@ function K(t, n, e) {
|
|
|
564
564
|
count: s.length
|
|
565
565
|
} : { intersections: [], overlaps: [], count: 0 };
|
|
566
566
|
}
|
|
567
|
-
if (t instanceof
|
|
568
|
-
const s =
|
|
567
|
+
if (t instanceof b && n instanceof M) {
|
|
568
|
+
const s = st(
|
|
569
569
|
t,
|
|
570
570
|
n,
|
|
571
571
|
e
|
|
572
572
|
);
|
|
573
573
|
return { intersections: s, overlaps: [], count: s.length };
|
|
574
574
|
}
|
|
575
|
-
if (n instanceof
|
|
576
|
-
const s =
|
|
575
|
+
if (n instanceof b && t instanceof M) {
|
|
576
|
+
const s = st(
|
|
577
577
|
n,
|
|
578
578
|
t,
|
|
579
579
|
e
|
|
@@ -581,15 +581,15 @@ function K(t, n, e) {
|
|
|
581
581
|
return { intersections: s, overlaps: [], count: s.length };
|
|
582
582
|
}
|
|
583
583
|
if (t instanceof S && n instanceof M) {
|
|
584
|
-
const s =
|
|
584
|
+
const s = gt(t, n);
|
|
585
585
|
return { intersections: s, overlaps: [], count: s.length };
|
|
586
586
|
}
|
|
587
587
|
if (n instanceof S && t instanceof M) {
|
|
588
|
-
const s =
|
|
588
|
+
const s = gt(n, t);
|
|
589
589
|
return { intersections: s, overlaps: [], count: s.length };
|
|
590
590
|
}
|
|
591
591
|
if (t instanceof M && n instanceof M) {
|
|
592
|
-
const s =
|
|
592
|
+
const s = xn(
|
|
593
593
|
t,
|
|
594
594
|
n,
|
|
595
595
|
!0
|
|
@@ -604,36 +604,36 @@ function K(t, n, e) {
|
|
|
604
604
|
count: s.length
|
|
605
605
|
} : { intersections: [], overlaps: [], count: 0 };
|
|
606
606
|
}
|
|
607
|
-
if (t instanceof
|
|
608
|
-
const s =
|
|
607
|
+
if (t instanceof b && (n instanceof A || n instanceof I)) {
|
|
608
|
+
const s = Pt(t, n);
|
|
609
609
|
return { intersections: s, overlaps: [], count: s.length };
|
|
610
610
|
}
|
|
611
|
-
if (n instanceof
|
|
612
|
-
const s =
|
|
611
|
+
if (n instanceof b && (t instanceof A || t instanceof I)) {
|
|
612
|
+
const s = Pt(n, t);
|
|
613
613
|
return { intersections: s, overlaps: [], count: s.length };
|
|
614
614
|
}
|
|
615
|
-
if ((t instanceof S || t instanceof M) && n instanceof
|
|
616
|
-
const s =
|
|
615
|
+
if ((t instanceof S || t instanceof M) && n instanceof I) {
|
|
616
|
+
const s = xt(t, n);
|
|
617
617
|
return { intersections: s, overlaps: [], count: s.length };
|
|
618
618
|
}
|
|
619
|
-
if ((n instanceof S || n instanceof M) && t instanceof
|
|
620
|
-
const s =
|
|
619
|
+
if ((n instanceof S || n instanceof M) && t instanceof I) {
|
|
620
|
+
const s = xt(n, t);
|
|
621
621
|
return { intersections: s, overlaps: [], count: s.length };
|
|
622
622
|
}
|
|
623
|
-
if ((t instanceof S || t instanceof M) && n instanceof
|
|
624
|
-
const s =
|
|
623
|
+
if ((t instanceof S || t instanceof M) && n instanceof A) {
|
|
624
|
+
const s = wt(t, n);
|
|
625
625
|
return { intersections: s, overlaps: [], count: s.length };
|
|
626
626
|
}
|
|
627
|
-
if ((n instanceof S || n instanceof M) && t instanceof
|
|
628
|
-
const s =
|
|
627
|
+
if ((n instanceof S || n instanceof M) && t instanceof A) {
|
|
628
|
+
const s = wt(n, t);
|
|
629
629
|
return { intersections: s, overlaps: [], count: s.length };
|
|
630
630
|
}
|
|
631
|
-
if (t instanceof
|
|
632
|
-
const s =
|
|
631
|
+
if (t instanceof I && n instanceof I) {
|
|
632
|
+
const s = Ln(
|
|
633
633
|
t,
|
|
634
634
|
n
|
|
635
635
|
);
|
|
636
|
-
return s.length ? s[0] instanceof
|
|
636
|
+
return s.length ? s[0] instanceof I ? {
|
|
637
637
|
intersections: [],
|
|
638
638
|
overlaps: s,
|
|
639
639
|
count: s.length
|
|
@@ -643,16 +643,16 @@ function K(t, n, e) {
|
|
|
643
643
|
count: s.length
|
|
644
644
|
} : { intersections: [], overlaps: [], count: 0 };
|
|
645
645
|
}
|
|
646
|
-
if (t instanceof
|
|
646
|
+
if (t instanceof I && n instanceof A || n instanceof I && t instanceof A) {
|
|
647
647
|
const s = D(t, n);
|
|
648
648
|
return { intersections: s, overlaps: [], count: s.length };
|
|
649
649
|
}
|
|
650
|
-
if (t instanceof
|
|
650
|
+
if (t instanceof A && n instanceof A) {
|
|
651
651
|
const s = _n(
|
|
652
652
|
t,
|
|
653
653
|
n
|
|
654
654
|
);
|
|
655
|
-
return s.length ? s[0] instanceof
|
|
655
|
+
return s.length ? s[0] instanceof A ? {
|
|
656
656
|
intersections: [],
|
|
657
657
|
overlaps: s,
|
|
658
658
|
count: s.length
|
|
@@ -664,23 +664,23 @@ function K(t, n, e) {
|
|
|
664
664
|
}
|
|
665
665
|
throw new Error("Not implemented");
|
|
666
666
|
}
|
|
667
|
-
function
|
|
667
|
+
function Nt(t) {
|
|
668
668
|
const n = [];
|
|
669
669
|
for (let e = 0; e < t; e++)
|
|
670
670
|
for (let s = 0; s <= e; s++)
|
|
671
671
|
n.push([e, s]);
|
|
672
672
|
return n;
|
|
673
673
|
}
|
|
674
|
-
function*
|
|
675
|
-
for (const [n, e] of
|
|
674
|
+
function* it(t) {
|
|
675
|
+
for (const [n, e] of Nt(t.length))
|
|
676
676
|
n !== e && (yield [t[n], t[e]]);
|
|
677
677
|
}
|
|
678
|
-
class
|
|
678
|
+
class Ut extends ut {
|
|
679
679
|
constructor(e, { ignoreChecks: s = !1 } = {}) {
|
|
680
680
|
super();
|
|
681
681
|
C(this, "segments");
|
|
682
682
|
C(this, "_boundingBox", null);
|
|
683
|
-
s ||
|
|
683
|
+
s || jt(e), this.segments = e;
|
|
684
684
|
}
|
|
685
685
|
get repr() {
|
|
686
686
|
return this.segments.map((e) => e.repr).join(`
|
|
@@ -705,12 +705,12 @@ class Nt extends lt {
|
|
|
705
705
|
intersects(e) {
|
|
706
706
|
return this.boundingBox.overlaps(e.boundingBox) ? this.segments.some(
|
|
707
707
|
(s) => e.segments.some(
|
|
708
|
-
(i) =>
|
|
708
|
+
(i) => Z(s, i).count > 0
|
|
709
709
|
)
|
|
710
710
|
) : !1;
|
|
711
711
|
}
|
|
712
712
|
overlappingSegments(e) {
|
|
713
|
-
return this.segments.flatMap((s) => e.segments.flatMap((i) => s.boundingBox.overlaps(i.boundingBox) ?
|
|
713
|
+
return this.segments.flatMap((s) => e.segments.flatMap((i) => s.boundingBox.overlaps(i.boundingBox) ? Z(s, i).overlaps : []));
|
|
714
714
|
}
|
|
715
715
|
get boundingBox() {
|
|
716
716
|
if (this._boundingBox === null) {
|
|
@@ -725,61 +725,61 @@ class Nt extends lt {
|
|
|
725
725
|
return this.repr;
|
|
726
726
|
}
|
|
727
727
|
}
|
|
728
|
-
function
|
|
729
|
-
|
|
728
|
+
function qn(t, n = "Stroke") {
|
|
729
|
+
Nt(t.length).forEach(
|
|
730
730
|
([e, s]) => {
|
|
731
731
|
if (e === s) return;
|
|
732
|
-
const i = t[e], o = t[s],
|
|
733
|
-
if (
|
|
734
|
-
if (
|
|
735
|
-
const
|
|
736
|
-
if (
|
|
732
|
+
const i = t[e], o = t[s], l = Z(i, o), r = Math.max(i.precision, o.precision);
|
|
733
|
+
if (l.count !== 0) {
|
|
734
|
+
if (l.count === 1 && !l.overlaps.length) {
|
|
735
|
+
const u = e - s, a = l.intersections[0];
|
|
736
|
+
if (u === 1 && P(i.firstPoint, a, r) || u === -1 && P(i.lastPoint, a, r) || u === t.length - 1 && P(i.lastPoint, a, r) && P(o.firstPoint, a, r) || -u === t.length - 1 && P(i.firstPoint, a, r) && P(o.lastPoint, a, r))
|
|
737
737
|
return;
|
|
738
738
|
}
|
|
739
|
-
if (!(
|
|
739
|
+
if (!(l.count === 2 && t.length === 2 && (P(
|
|
740
740
|
i.firstPoint,
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
) &&
|
|
741
|
+
l.intersections[0],
|
|
742
|
+
r
|
|
743
|
+
) && P(
|
|
744
744
|
i.lastPoint,
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
) ||
|
|
745
|
+
l.intersections[1],
|
|
746
|
+
r
|
|
747
|
+
) || P(
|
|
748
748
|
i.firstPoint,
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
) &&
|
|
749
|
+
l.intersections[1],
|
|
750
|
+
r
|
|
751
|
+
) && P(
|
|
752
752
|
i.lastPoint,
|
|
753
|
-
|
|
754
|
-
|
|
753
|
+
l.intersections[0],
|
|
754
|
+
r
|
|
755
755
|
))))
|
|
756
756
|
throw new Error(
|
|
757
757
|
`${n} segments must not intersect, but segments ${i.info} and ${o.info} do at ${JSON.stringify(
|
|
758
|
-
|
|
758
|
+
l.intersections
|
|
759
759
|
)}`
|
|
760
760
|
);
|
|
761
761
|
}
|
|
762
762
|
}
|
|
763
763
|
);
|
|
764
764
|
}
|
|
765
|
-
function
|
|
765
|
+
function jt(t, n = "Stroke") {
|
|
766
766
|
if (t.length === 0)
|
|
767
767
|
throw new Error(`${n} must have at least one segment`);
|
|
768
768
|
N([t.slice(0, -1), t.slice(1)]).forEach(
|
|
769
769
|
([e, s]) => {
|
|
770
|
-
if (!
|
|
770
|
+
if (!P(e.lastPoint, s.firstPoint))
|
|
771
771
|
throw new Error(
|
|
772
772
|
`${n} segments must be connected, but ${e.info} and ${s.info} are not`
|
|
773
773
|
);
|
|
774
774
|
}
|
|
775
|
-
),
|
|
776
|
-
}
|
|
777
|
-
function bt(t, n) {
|
|
778
|
-
return !!(t instanceof y && n instanceof y && un(t.V, n.V) || t instanceof S && n instanceof S && g(t.center, n.center) && t.radius - n.radius < t.precision);
|
|
775
|
+
), qn(t, n);
|
|
779
776
|
}
|
|
780
777
|
function Ct(t, n) {
|
|
781
|
-
|
|
782
|
-
|
|
778
|
+
return !!(t instanceof b && n instanceof b && an(t.V, n.V) || t instanceof S && n instanceof S && P(t.center, n.center) && t.radius - n.radius < t.precision);
|
|
779
|
+
}
|
|
780
|
+
function Mt(t, n) {
|
|
781
|
+
if (t instanceof b && n instanceof b)
|
|
782
|
+
return new b(t.firstPoint, n.lastPoint);
|
|
783
783
|
if (t instanceof S && n instanceof S)
|
|
784
784
|
return new S(
|
|
785
785
|
t.firstPoint,
|
|
@@ -789,7 +789,7 @@ function Ct(t, n) {
|
|
|
789
789
|
);
|
|
790
790
|
throw new Error("Not implemented");
|
|
791
791
|
}
|
|
792
|
-
function
|
|
792
|
+
function Ht(t) {
|
|
793
793
|
let n = !1;
|
|
794
794
|
const e = [];
|
|
795
795
|
for (const s of t.segments) {
|
|
@@ -798,19 +798,19 @@ function jt(t) {
|
|
|
798
798
|
continue;
|
|
799
799
|
}
|
|
800
800
|
const i = e[e.length - 1];
|
|
801
|
-
|
|
801
|
+
Ct(i, s) ? (n = !0, e.pop(), e.push(Mt(i, s))) : e.push(s);
|
|
802
802
|
}
|
|
803
|
-
if (
|
|
803
|
+
if (P(t.firstPoint, t.lastPoint) && Ct(
|
|
804
804
|
e[0],
|
|
805
805
|
e[e.length - 1]
|
|
806
806
|
)) {
|
|
807
807
|
n = !0;
|
|
808
808
|
const s = e.pop();
|
|
809
|
-
e[0] =
|
|
809
|
+
e[0] = Mt(s, e[0]);
|
|
810
810
|
}
|
|
811
811
|
return n ? e : null;
|
|
812
812
|
}
|
|
813
|
-
class B extends
|
|
813
|
+
class B extends Ut {
|
|
814
814
|
constructor() {
|
|
815
815
|
super(...arguments);
|
|
816
816
|
C(this, "strokeType", "STRAND");
|
|
@@ -826,12 +826,12 @@ class B extends Nt {
|
|
|
826
826
|
);
|
|
827
827
|
}
|
|
828
828
|
extend(e) {
|
|
829
|
-
if (!
|
|
829
|
+
if (!P(this.lastPoint, e.firstPoint))
|
|
830
830
|
throw console.error(this.repr, e.repr), new Error("Cannot extend strand: connection point is not the same");
|
|
831
831
|
return new B([...this.segments, ...e.segments]);
|
|
832
832
|
}
|
|
833
833
|
simplify() {
|
|
834
|
-
const e =
|
|
834
|
+
const e = Ht(this);
|
|
835
835
|
return e ? new B(e, { ignoreChecks: !0 }) : this;
|
|
836
836
|
}
|
|
837
837
|
transform(e) {
|
|
@@ -842,7 +842,7 @@ class B extends Nt {
|
|
|
842
842
|
}
|
|
843
843
|
}
|
|
844
844
|
const zn = (t, n) => {
|
|
845
|
-
const e =
|
|
845
|
+
const e = fn(n, {
|
|
846
846
|
V: [1, 0],
|
|
847
847
|
firstPoint: t,
|
|
848
848
|
precision: n.precision
|
|
@@ -857,38 +857,38 @@ const zn = (t, n) => {
|
|
|
857
857
|
}
|
|
858
858
|
return 1;
|
|
859
859
|
};
|
|
860
|
-
class
|
|
860
|
+
class at {
|
|
861
861
|
constructor(n) {
|
|
862
862
|
C(this, "_count", 0);
|
|
863
863
|
C(this, "segment");
|
|
864
864
|
this.segment = n;
|
|
865
865
|
}
|
|
866
866
|
update(n, e = !1) {
|
|
867
|
-
!e && !this.segment.isOnSegment(n) || (
|
|
867
|
+
!e && !this.segment.isOnSegment(n) || (P(n, this.segment.firstPoint) ? this._count += this.segment.tangentAtFirstPoint[1] > 0 ? 1 : 0 : P(n, this.segment.lastPoint) ? this._count += this.segment.tangentAtLastPoint[1] > 0 ? 0 : 1 : this._count += 1);
|
|
868
868
|
}
|
|
869
869
|
get count() {
|
|
870
870
|
return this._count;
|
|
871
871
|
}
|
|
872
872
|
}
|
|
873
|
-
const
|
|
873
|
+
const Dn = (t, n) => {
|
|
874
874
|
const e = n.precision, s = Math.abs(t[1] - n.center[1]);
|
|
875
875
|
if (s > n.radius + e) return 0;
|
|
876
|
-
const i =
|
|
877
|
-
if (Math.abs(i - o) <
|
|
876
|
+
const i = hn(t, n.center), o = n.radius * n.radius, l = e * e;
|
|
877
|
+
if (Math.abs(i - o) < l && n.isOnSegment(t))
|
|
878
878
|
return 0;
|
|
879
|
-
const
|
|
880
|
-
if (
|
|
881
|
-
const
|
|
879
|
+
const r = i - o > l;
|
|
880
|
+
if (r && n.center[0] < t[0]) return 0;
|
|
881
|
+
const u = Math.sqrt(
|
|
882
882
|
n.radius * n.radius - s * s
|
|
883
|
-
), a = new
|
|
884
|
-
return a.update([n.center[0] +
|
|
885
|
-
},
|
|
886
|
-
const e = n.boundingBox.xMax + n.boundingBox.width / 2, s = new
|
|
887
|
-
return
|
|
883
|
+
), a = new at(n);
|
|
884
|
+
return a.update([n.center[0] + u, t[1]]), r && a.update([n.center[0] - u, t[1]]), a.count;
|
|
885
|
+
}, Rn = (t, n) => {
|
|
886
|
+
const e = n.boundingBox.xMax + n.boundingBox.width / 2, s = new b(t, [e, t[1]]), i = new at(n);
|
|
887
|
+
return st(s, n).forEach((o) => {
|
|
888
888
|
i.update(o, !0);
|
|
889
889
|
}), i.count;
|
|
890
|
-
},
|
|
891
|
-
const e = new
|
|
890
|
+
}, Vn = (t, n) => {
|
|
891
|
+
const e = new at(n);
|
|
892
892
|
return n.paramsAtY(t[1]).map((s) => {
|
|
893
893
|
try {
|
|
894
894
|
return n.paramPoint(s);
|
|
@@ -902,74 +902,74 @@ const qn = (t, n) => {
|
|
|
902
902
|
e.update(s, !0);
|
|
903
903
|
}), e.count;
|
|
904
904
|
};
|
|
905
|
-
function
|
|
906
|
-
if (n instanceof
|
|
905
|
+
function Nn(t, n) {
|
|
906
|
+
if (n instanceof b)
|
|
907
907
|
return zn(t, n);
|
|
908
908
|
if (n instanceof S)
|
|
909
|
-
return qn(t, n);
|
|
910
|
-
if (n instanceof M)
|
|
911
909
|
return Dn(t, n);
|
|
912
|
-
if (n instanceof
|
|
910
|
+
if (n instanceof M)
|
|
913
911
|
return Rn(t, n);
|
|
912
|
+
if (n instanceof A || n instanceof I)
|
|
913
|
+
return Vn(t, n);
|
|
914
914
|
throw new Error("Not implemented");
|
|
915
915
|
}
|
|
916
|
-
class
|
|
916
|
+
class _ extends Ut {
|
|
917
917
|
constructor(e, { ignoreChecks: s = !1 } = {}) {
|
|
918
918
|
super(e, { ignoreChecks: !0 });
|
|
919
919
|
C(this, "strokeType", "LOOP");
|
|
920
920
|
C(this, "_clockwise", null);
|
|
921
|
-
s ||
|
|
921
|
+
s || Un(e);
|
|
922
922
|
}
|
|
923
923
|
get clockwise() {
|
|
924
924
|
if (this._clockwise === null) {
|
|
925
|
-
const e = this.segments.flatMap((i) => i instanceof
|
|
926
|
-
const
|
|
927
|
-
return (
|
|
925
|
+
const e = this.segments.flatMap((i) => i instanceof b ? [i.firstPoint] : [i.firstPoint, i.paramPoint(0.5)]), s = e.map((i, o) => {
|
|
926
|
+
const l = e[(o + 1) % e.length];
|
|
927
|
+
return (l[0] - i[0]) * (l[1] + i[1]);
|
|
928
928
|
}).reduce((i, o) => i + o, 0);
|
|
929
929
|
this._clockwise = s > 0;
|
|
930
930
|
}
|
|
931
931
|
return this._clockwise;
|
|
932
932
|
}
|
|
933
933
|
clone() {
|
|
934
|
-
return new
|
|
934
|
+
return new _(
|
|
935
935
|
this.segments.map((e) => e.clone()),
|
|
936
936
|
{ ignoreChecks: !0 }
|
|
937
937
|
);
|
|
938
938
|
}
|
|
939
939
|
reverse() {
|
|
940
940
|
const e = this.segments.map((s) => s.reverse());
|
|
941
|
-
return e.reverse(), new
|
|
941
|
+
return e.reverse(), new _(e, { ignoreChecks: !0 });
|
|
942
942
|
}
|
|
943
943
|
transform(e) {
|
|
944
|
-
return new
|
|
944
|
+
return new _(
|
|
945
945
|
this.segments.map((s) => s.transform(e)),
|
|
946
946
|
{ ignoreChecks: !0 }
|
|
947
947
|
);
|
|
948
948
|
}
|
|
949
|
-
contains(e) {
|
|
950
|
-
return this.onStroke(e)
|
|
949
|
+
contains(e, { strokeIsInside: s = !1 } = {}) {
|
|
950
|
+
return this.onStroke(e) ? s : this.boundingBox.contains(e) ? this.segments.reduce((o, l) => o + Nn(e, l), 0) % 2 === 1 : !1;
|
|
951
951
|
}
|
|
952
952
|
simplify() {
|
|
953
|
-
const e =
|
|
954
|
-
return e ? new
|
|
953
|
+
const e = Ht(this);
|
|
954
|
+
return e ? new _(e, { ignoreChecks: !0 }) : this;
|
|
955
955
|
}
|
|
956
956
|
}
|
|
957
|
-
function
|
|
958
|
-
if (
|
|
957
|
+
function Un(t) {
|
|
958
|
+
if (jt(t, "Loop"), !P(t[0].firstPoint, t[t.length - 1].lastPoint))
|
|
959
959
|
throw new Error("Loop segment must be closed");
|
|
960
960
|
}
|
|
961
|
-
const
|
|
962
|
-
|
|
961
|
+
const jn = [
|
|
962
|
+
b,
|
|
963
963
|
S,
|
|
964
964
|
M,
|
|
965
|
-
|
|
966
|
-
|
|
965
|
+
I,
|
|
966
|
+
A
|
|
967
967
|
];
|
|
968
|
-
function
|
|
969
|
-
return
|
|
968
|
+
function Hn(t) {
|
|
969
|
+
return jn.some((n) => t instanceof n);
|
|
970
970
|
}
|
|
971
|
-
function
|
|
972
|
-
if (t instanceof
|
|
971
|
+
function $t(t) {
|
|
972
|
+
if (t instanceof b)
|
|
973
973
|
return {
|
|
974
974
|
type: t.segmentType,
|
|
975
975
|
firstPoint: t.firstPoint,
|
|
@@ -994,14 +994,14 @@ function Ht(t) {
|
|
|
994
994
|
minorRadius: t.minorRadius,
|
|
995
995
|
tiltAngle: t.tiltAngle
|
|
996
996
|
};
|
|
997
|
-
if (t instanceof
|
|
997
|
+
if (t instanceof I)
|
|
998
998
|
return {
|
|
999
999
|
type: t.segmentType,
|
|
1000
1000
|
firstPoint: t.firstPoint,
|
|
1001
1001
|
lastPoint: t.lastPoint,
|
|
1002
1002
|
controlPoint: t.controlPoint
|
|
1003
1003
|
};
|
|
1004
|
-
if (t instanceof
|
|
1004
|
+
if (t instanceof A)
|
|
1005
1005
|
return {
|
|
1006
1006
|
type: t.segmentType,
|
|
1007
1007
|
firstPoint: t.firstPoint,
|
|
@@ -1011,37 +1011,37 @@ function Ht(t) {
|
|
|
1011
1011
|
};
|
|
1012
1012
|
throw new Error("Unknown segment type");
|
|
1013
1013
|
}
|
|
1014
|
-
function
|
|
1014
|
+
function ot(t) {
|
|
1015
1015
|
return {
|
|
1016
1016
|
type: "LOOP",
|
|
1017
|
-
segments: t.segments.map(
|
|
1017
|
+
segments: t.segments.map($t)
|
|
1018
1018
|
};
|
|
1019
1019
|
}
|
|
1020
|
-
function
|
|
1020
|
+
function Yt(t) {
|
|
1021
1021
|
return {
|
|
1022
1022
|
type: "FIGURE",
|
|
1023
|
-
contour:
|
|
1024
|
-
holes: t.holes.map(
|
|
1023
|
+
contour: ot(t.contour),
|
|
1024
|
+
holes: t.holes.map(ot)
|
|
1025
1025
|
};
|
|
1026
1026
|
}
|
|
1027
|
-
function
|
|
1027
|
+
function $n(t) {
|
|
1028
1028
|
return {
|
|
1029
1029
|
type: "DIAGRAM",
|
|
1030
|
-
figures: t.figures.map(
|
|
1030
|
+
figures: t.figures.map(Yt)
|
|
1031
1031
|
};
|
|
1032
1032
|
}
|
|
1033
|
-
function
|
|
1034
|
-
if (t instanceof
|
|
1035
|
-
return
|
|
1033
|
+
function It(t) {
|
|
1034
|
+
if (t instanceof O)
|
|
1035
|
+
return $n(t);
|
|
1036
1036
|
if (t instanceof v)
|
|
1037
|
+
return Yt(t);
|
|
1038
|
+
if (t instanceof _)
|
|
1039
|
+
return ot(t);
|
|
1040
|
+
if (Hn(t))
|
|
1037
1041
|
return $t(t);
|
|
1038
|
-
if (t instanceof O)
|
|
1039
|
-
return it(t);
|
|
1040
|
-
if (jn(t))
|
|
1041
|
-
return Ht(t);
|
|
1042
1042
|
throw new Error("Unknown shape type");
|
|
1043
1043
|
}
|
|
1044
|
-
class
|
|
1044
|
+
class Yn {
|
|
1045
1045
|
constructor() {
|
|
1046
1046
|
this.ids = [], this.values = [], this.length = 0;
|
|
1047
1047
|
}
|
|
@@ -1064,12 +1064,12 @@ class $n {
|
|
|
1064
1064
|
const e = this.ids[0] = this.ids[this.length], s = this.values[0] = this.values[this.length], i = this.length >> 1;
|
|
1065
1065
|
let o = 0;
|
|
1066
1066
|
for (; o < i; ) {
|
|
1067
|
-
let
|
|
1068
|
-
const
|
|
1069
|
-
let
|
|
1070
|
-
const f = this.values[
|
|
1071
|
-
if (
|
|
1072
|
-
this.ids[o] =
|
|
1067
|
+
let l = (o << 1) + 1;
|
|
1068
|
+
const r = l + 1;
|
|
1069
|
+
let u = this.ids[l], a = this.values[l];
|
|
1070
|
+
const f = this.values[r];
|
|
1071
|
+
if (r < this.length && f < a && (l = r, u = this.ids[r], a = f), a >= s) break;
|
|
1072
|
+
this.ids[o] = u, this.values[o] = a, o = l;
|
|
1073
1073
|
}
|
|
1074
1074
|
this.ids[o] = e, this.values[o] = s;
|
|
1075
1075
|
}
|
|
@@ -1087,8 +1087,8 @@ class $n {
|
|
|
1087
1087
|
this.ids.length = this.values.length = this.length;
|
|
1088
1088
|
}
|
|
1089
1089
|
}
|
|
1090
|
-
const At = [Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array],
|
|
1091
|
-
class
|
|
1090
|
+
const At = [Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array], et = 3;
|
|
1091
|
+
class ft {
|
|
1092
1092
|
/**
|
|
1093
1093
|
* Recreate a Flatbush index from raw `ArrayBuffer` or `SharedArrayBuffer` data.
|
|
1094
1094
|
* @param {ArrayBuffer | SharedArrayBuffer} data
|
|
@@ -1104,13 +1104,13 @@ class at {
|
|
|
1104
1104
|
if (s !== 251)
|
|
1105
1105
|
throw new Error("Data does not appear to be in a Flatbush format.");
|
|
1106
1106
|
const o = i >> 4;
|
|
1107
|
-
if (o !==
|
|
1108
|
-
throw new Error(`Got v${o} data when expected v${
|
|
1109
|
-
const
|
|
1110
|
-
if (!
|
|
1107
|
+
if (o !== et)
|
|
1108
|
+
throw new Error(`Got v${o} data when expected v${et}.`);
|
|
1109
|
+
const l = At[i & 15];
|
|
1110
|
+
if (!l)
|
|
1111
1111
|
throw new Error("Unrecognized array type.");
|
|
1112
|
-
const [
|
|
1113
|
-
return new
|
|
1112
|
+
const [r] = new Uint16Array(n, e + 2, 1), [u] = new Uint32Array(n, e + 4, 1);
|
|
1113
|
+
return new ft(u, r, l, void 0, n, e);
|
|
1114
1114
|
}
|
|
1115
1115
|
/**
|
|
1116
1116
|
* Create a Flatbush index that will hold a given number of items.
|
|
@@ -1121,20 +1121,20 @@ class at {
|
|
|
1121
1121
|
* @param {ArrayBuffer | SharedArrayBuffer} [data] (Only used internally)
|
|
1122
1122
|
* @param {number} [byteOffset=0] (Only used internally)
|
|
1123
1123
|
*/
|
|
1124
|
-
constructor(n, e = 16, s = Float64Array, i = ArrayBuffer, o,
|
|
1124
|
+
constructor(n, e = 16, s = Float64Array, i = ArrayBuffer, o, l = 0) {
|
|
1125
1125
|
if (n === void 0) throw new Error("Missing required argument: numItems.");
|
|
1126
1126
|
if (isNaN(n) || n <= 0) throw new Error(`Unexpected numItems value: ${n}.`);
|
|
1127
|
-
this.numItems = +n, this.nodeSize = Math.min(Math.max(+e, 2), 65535), this.byteOffset =
|
|
1128
|
-
let
|
|
1129
|
-
this._levelBounds = [
|
|
1127
|
+
this.numItems = +n, this.nodeSize = Math.min(Math.max(+e, 2), 65535), this.byteOffset = l;
|
|
1128
|
+
let r = n, u = r;
|
|
1129
|
+
this._levelBounds = [r * 4];
|
|
1130
1130
|
do
|
|
1131
|
-
|
|
1132
|
-
while (
|
|
1133
|
-
this.ArrayType = s, this.IndexArrayType =
|
|
1134
|
-
const a = At.indexOf(this.ArrayType), f =
|
|
1131
|
+
r = Math.ceil(r / this.nodeSize), u += r, this._levelBounds.push(u * 4);
|
|
1132
|
+
while (r !== 1);
|
|
1133
|
+
this.ArrayType = s, this.IndexArrayType = u < 16384 ? Uint16Array : Uint32Array;
|
|
1134
|
+
const a = At.indexOf(this.ArrayType), f = u * 4 * this.ArrayType.BYTES_PER_ELEMENT;
|
|
1135
1135
|
if (a < 0)
|
|
1136
1136
|
throw new Error(`Unexpected typed array class: ${s}.`);
|
|
1137
|
-
o && o.byteLength !== void 0 && !o.buffer ? (this.data = o, this._boxes = new this.ArrayType(this.data,
|
|
1137
|
+
o && o.byteLength !== void 0 && !o.buffer ? (this.data = o, this._boxes = new this.ArrayType(this.data, l + 8, u * 4), this._indices = new this.IndexArrayType(this.data, l + 8 + f, u), this._pos = u * 4, this.minX = this._boxes[this._pos - 4], this.minY = this._boxes[this._pos - 3], this.maxX = this._boxes[this._pos - 2], this.maxY = this._boxes[this._pos - 1]) : (this.data = new i(8 + f + u * this.IndexArrayType.BYTES_PER_ELEMENT), this._boxes = new this.ArrayType(this.data, 8, u * 4), this._indices = new this.IndexArrayType(this.data, 8 + f, u), this._pos = 0, this.minX = 1 / 0, this.minY = 1 / 0, this.maxX = -1 / 0, this.maxY = -1 / 0, new Uint8Array(this.data, 0, 2).set([251, (et << 4) + a]), new Uint16Array(this.data, 2, 1)[0] = e, new Uint32Array(this.data, 4, 1)[0] = n), this._queue = new Yn();
|
|
1138
1138
|
}
|
|
1139
1139
|
/**
|
|
1140
1140
|
* Add a given rectangle to the index.
|
|
@@ -1145,8 +1145,8 @@ class at {
|
|
|
1145
1145
|
* @returns {number} A zero-based, incremental number that represents the newly added rectangle.
|
|
1146
1146
|
*/
|
|
1147
1147
|
add(n, e, s = n, i = e) {
|
|
1148
|
-
const o = this._pos >> 2,
|
|
1149
|
-
return this._indices[o] = o,
|
|
1148
|
+
const o = this._pos >> 2, l = this._boxes;
|
|
1149
|
+
return this._indices[o] = o, l[this._pos++] = n, l[this._pos++] = e, l[this._pos++] = s, l[this._pos++] = i, n < this.minX && (this.minX = n), e < this.minY && (this.minY = e), s > this.maxX && (this.maxX = s), i > this.maxY && (this.maxY = i), o;
|
|
1150
1150
|
}
|
|
1151
1151
|
/** Perform indexing of the added rectangles. */
|
|
1152
1152
|
finish() {
|
|
@@ -1158,19 +1158,19 @@ class at {
|
|
|
1158
1158
|
return;
|
|
1159
1159
|
}
|
|
1160
1160
|
const e = this.maxX - this.minX || 1, s = this.maxY - this.minY || 1, i = new Uint32Array(this.numItems), o = 65535;
|
|
1161
|
-
for (let
|
|
1162
|
-
const
|
|
1163
|
-
i[
|
|
1161
|
+
for (let l = 0, r = 0; l < this.numItems; l++) {
|
|
1162
|
+
const u = n[r++], a = n[r++], f = n[r++], c = n[r++], h = Math.floor(o * ((u + f) / 2 - this.minX) / e), p = Math.floor(o * ((a + c) / 2 - this.minY) / s);
|
|
1163
|
+
i[l] = Gn(h, p);
|
|
1164
1164
|
}
|
|
1165
|
-
|
|
1166
|
-
for (let
|
|
1167
|
-
const
|
|
1168
|
-
for (;
|
|
1169
|
-
const a =
|
|
1170
|
-
let f = n[
|
|
1171
|
-
for (let d = 1; d < this.nodeSize &&
|
|
1172
|
-
f = Math.min(f, n[
|
|
1173
|
-
this._indices[this._pos >> 2] = a, n[this._pos++] = f, n[this._pos++] =
|
|
1165
|
+
rt(i, n, this._indices, 0, this.numItems - 1, this.nodeSize);
|
|
1166
|
+
for (let l = 0, r = 0; l < this._levelBounds.length - 1; l++) {
|
|
1167
|
+
const u = this._levelBounds[l];
|
|
1168
|
+
for (; r < u; ) {
|
|
1169
|
+
const a = r;
|
|
1170
|
+
let f = n[r++], c = n[r++], h = n[r++], p = n[r++];
|
|
1171
|
+
for (let d = 1; d < this.nodeSize && r < u; d++)
|
|
1172
|
+
f = Math.min(f, n[r++]), c = Math.min(c, n[r++]), h = Math.max(h, n[r++]), p = Math.max(p, n[r++]);
|
|
1173
|
+
this._indices[this._pos >> 2] = a, n[this._pos++] = f, n[this._pos++] = c, n[this._pos++] = h, n[this._pos++] = p;
|
|
1174
1174
|
}
|
|
1175
1175
|
}
|
|
1176
1176
|
}
|
|
@@ -1186,18 +1186,18 @@ class at {
|
|
|
1186
1186
|
search(n, e, s, i, o) {
|
|
1187
1187
|
if (this._pos !== this._boxes.length)
|
|
1188
1188
|
throw new Error("Data not yet indexed - call index.finish().");
|
|
1189
|
-
let
|
|
1190
|
-
const
|
|
1191
|
-
for (;
|
|
1192
|
-
const a = Math.min(
|
|
1193
|
-
for (let f =
|
|
1189
|
+
let l = this._boxes.length - 4;
|
|
1190
|
+
const r = [], u = [];
|
|
1191
|
+
for (; l !== void 0; ) {
|
|
1192
|
+
const a = Math.min(l + this.nodeSize * 4, Ft(l, this._levelBounds));
|
|
1193
|
+
for (let f = l; f < a; f += 4) {
|
|
1194
1194
|
if (s < this._boxes[f] || i < this._boxes[f + 1] || n > this._boxes[f + 2] || e > this._boxes[f + 3]) continue;
|
|
1195
|
-
const
|
|
1196
|
-
|
|
1195
|
+
const c = this._indices[f >> 2] | 0;
|
|
1196
|
+
l >= this.numItems * 4 ? r.push(c) : (o === void 0 || o(c)) && u.push(c);
|
|
1197
1197
|
}
|
|
1198
|
-
|
|
1198
|
+
l = r.pop();
|
|
1199
1199
|
}
|
|
1200
|
-
return
|
|
1200
|
+
return u;
|
|
1201
1201
|
}
|
|
1202
1202
|
/**
|
|
1203
1203
|
* Search items in order of distance from the given point.
|
|
@@ -1211,25 +1211,25 @@ class at {
|
|
|
1211
1211
|
neighbors(n, e, s = 1 / 0, i = 1 / 0, o) {
|
|
1212
1212
|
if (this._pos !== this._boxes.length)
|
|
1213
1213
|
throw new Error("Data not yet indexed - call index.finish().");
|
|
1214
|
-
let
|
|
1215
|
-
const
|
|
1216
|
-
t: for (;
|
|
1217
|
-
const f = Math.min(
|
|
1218
|
-
for (let
|
|
1219
|
-
const h = this._indices[
|
|
1220
|
-
m > a || (
|
|
1214
|
+
let l = this._boxes.length - 4;
|
|
1215
|
+
const r = this._queue, u = [], a = i * i;
|
|
1216
|
+
t: for (; l !== void 0; ) {
|
|
1217
|
+
const f = Math.min(l + this.nodeSize * 4, Ft(l, this._levelBounds));
|
|
1218
|
+
for (let c = l; c < f; c += 4) {
|
|
1219
|
+
const h = this._indices[c >> 2] | 0, p = Et(n, this._boxes[c], this._boxes[c + 2]), d = Et(e, this._boxes[c + 1], this._boxes[c + 3]), m = p * p + d * d;
|
|
1220
|
+
m > a || (l >= this.numItems * 4 ? r.push(h << 1, m) : (o === void 0 || o(h)) && r.push((h << 1) + 1, m));
|
|
1221
1221
|
}
|
|
1222
|
-
for (;
|
|
1223
|
-
if (
|
|
1224
|
-
|
|
1222
|
+
for (; r.length && r.peek() & 1; )
|
|
1223
|
+
if (r.peekValue() > a || (u.push(r.pop() >> 1), u.length === s)) break t;
|
|
1224
|
+
l = r.length ? r.pop() >> 1 : void 0;
|
|
1225
1225
|
}
|
|
1226
|
-
return
|
|
1226
|
+
return r.clear(), u;
|
|
1227
1227
|
}
|
|
1228
1228
|
}
|
|
1229
|
-
function
|
|
1229
|
+
function Et(t, n, e) {
|
|
1230
1230
|
return t < n ? n - t : t <= e ? 0 : t - e;
|
|
1231
1231
|
}
|
|
1232
|
-
function
|
|
1232
|
+
function Ft(t, n) {
|
|
1233
1233
|
let e = 0, s = n.length - 1;
|
|
1234
1234
|
for (; e < s; ) {
|
|
1235
1235
|
const i = e + s >> 1;
|
|
@@ -1237,79 +1237,79 @@ function Et(t, n) {
|
|
|
1237
1237
|
}
|
|
1238
1238
|
return n[e];
|
|
1239
1239
|
}
|
|
1240
|
-
function
|
|
1240
|
+
function rt(t, n, e, s, i, o) {
|
|
1241
1241
|
if (Math.floor(s / o) >= Math.floor(i / o)) return;
|
|
1242
|
-
const
|
|
1243
|
-
let
|
|
1242
|
+
const l = t[s + i >> 1];
|
|
1243
|
+
let r = s - 1, u = i + 1;
|
|
1244
1244
|
for (; ; ) {
|
|
1245
1245
|
do
|
|
1246
|
-
|
|
1247
|
-
while (t[
|
|
1246
|
+
r++;
|
|
1247
|
+
while (t[r] < l);
|
|
1248
1248
|
do
|
|
1249
|
-
|
|
1250
|
-
while (t[
|
|
1251
|
-
if (
|
|
1252
|
-
|
|
1249
|
+
u--;
|
|
1250
|
+
while (t[u] > l);
|
|
1251
|
+
if (r >= u) break;
|
|
1252
|
+
Xn(t, n, e, r, u);
|
|
1253
1253
|
}
|
|
1254
|
-
|
|
1254
|
+
rt(t, n, e, s, u, o), rt(t, n, e, u + 1, i, o);
|
|
1255
1255
|
}
|
|
1256
|
-
function
|
|
1256
|
+
function Xn(t, n, e, s, i) {
|
|
1257
1257
|
const o = t[s];
|
|
1258
1258
|
t[s] = t[i], t[i] = o;
|
|
1259
|
-
const
|
|
1260
|
-
n[
|
|
1259
|
+
const l = 4 * s, r = 4 * i, u = n[l], a = n[l + 1], f = n[l + 2], c = n[l + 3];
|
|
1260
|
+
n[l] = n[r], n[l + 1] = n[r + 1], n[l + 2] = n[r + 2], n[l + 3] = n[r + 3], n[r] = u, n[r + 1] = a, n[r + 2] = f, n[r + 3] = c;
|
|
1261
1261
|
const h = e[s];
|
|
1262
1262
|
e[s] = e[i], e[i] = h;
|
|
1263
1263
|
}
|
|
1264
|
-
function
|
|
1265
|
-
let e = t ^ n, s = 65535 ^ e, i = 65535 ^ (t | n), o = t & (n ^ 65535),
|
|
1266
|
-
e =
|
|
1267
|
-
let f = t ^ n,
|
|
1268
|
-
return f = (f | f << 8) & 16711935, f = (f | f << 4) & 252645135, f = (f | f << 2) & 858993459, f = (f | f << 1) & 1431655765,
|
|
1264
|
+
function Gn(t, n) {
|
|
1265
|
+
let e = t ^ n, s = 65535 ^ e, i = 65535 ^ (t | n), o = t & (n ^ 65535), l = e | s >> 1, r = e >> 1 ^ e, u = i >> 1 ^ s & o >> 1 ^ i, a = e & i >> 1 ^ o >> 1 ^ o;
|
|
1266
|
+
e = l, s = r, i = u, o = a, l = e & e >> 2 ^ s & s >> 2, r = e & s >> 2 ^ s & (e ^ s) >> 2, u ^= e & i >> 2 ^ s & o >> 2, a ^= s & i >> 2 ^ (e ^ s) & o >> 2, e = l, s = r, i = u, o = a, l = e & e >> 4 ^ s & s >> 4, r = e & s >> 4 ^ s & (e ^ s) >> 4, u ^= e & i >> 4 ^ s & o >> 4, a ^= s & i >> 4 ^ (e ^ s) & o >> 4, e = l, s = r, i = u, o = a, u ^= e & i >> 8 ^ s & o >> 8, a ^= s & i >> 8 ^ (e ^ s) & o >> 8, e = u ^ u >> 1, s = a ^ a >> 1;
|
|
1267
|
+
let f = t ^ n, c = s | 65535 ^ (f | e);
|
|
1268
|
+
return f = (f | f << 8) & 16711935, f = (f | f << 4) & 252645135, f = (f | f << 2) & 858993459, f = (f | f << 1) & 1431655765, c = (c | c << 8) & 16711935, c = (c | c << 4) & 252645135, c = (c | c << 2) & 858993459, c = (c | c << 1) & 1431655765, (c << 1 | f) >>> 0;
|
|
1269
1269
|
}
|
|
1270
|
-
function
|
|
1270
|
+
function Xt(t, n = 1e-7) {
|
|
1271
1271
|
if (t.length === 0) return [];
|
|
1272
1272
|
if (t.length === 1) return [t];
|
|
1273
|
-
const e = new
|
|
1273
|
+
const e = new ft(t.length);
|
|
1274
1274
|
t.forEach((o) => {
|
|
1275
|
-
const [
|
|
1276
|
-
e.add(
|
|
1275
|
+
const [l, r] = o.firstPoint;
|
|
1276
|
+
e.add(l - n, r - n, l + n, r + n);
|
|
1277
1277
|
}), e.finish();
|
|
1278
1278
|
const s = [], i = /* @__PURE__ */ new Set();
|
|
1279
|
-
return t.forEach((o,
|
|
1280
|
-
if (i.has(
|
|
1281
|
-
const
|
|
1282
|
-
let
|
|
1283
|
-
i.add(
|
|
1279
|
+
return t.forEach((o, l) => {
|
|
1280
|
+
if (i.has(l)) return;
|
|
1281
|
+
const r = [o];
|
|
1282
|
+
let u = l;
|
|
1283
|
+
i.add(l);
|
|
1284
1284
|
let a = t.length;
|
|
1285
1285
|
for (; ; ) {
|
|
1286
1286
|
if (a-- < 0)
|
|
1287
1287
|
throw new Error("Infinite loop detected");
|
|
1288
|
-
const f =
|
|
1289
|
-
|
|
1288
|
+
const f = r[r.length - 1].lastPoint, [c, h] = f, p = e.search(
|
|
1289
|
+
c - n,
|
|
1290
1290
|
h - n,
|
|
1291
|
-
|
|
1291
|
+
c + n,
|
|
1292
1292
|
h + n
|
|
1293
|
-
), d = (
|
|
1294
|
-
t[
|
|
1295
|
-
|
|
1296
|
-
d(
|
|
1297
|
-
]).sort(([, ,
|
|
1293
|
+
), d = (w) => Math.abs((u - w) % t.length), m = p.filter((w) => !i.has(w)).map((w) => [
|
|
1294
|
+
t[w],
|
|
1295
|
+
w,
|
|
1296
|
+
d(w)
|
|
1297
|
+
]).sort(([, , w], [, , F]) => d(w) - d(F));
|
|
1298
1298
|
if (m.length === 0) {
|
|
1299
|
-
s.push(
|
|
1299
|
+
s.push(r);
|
|
1300
1300
|
break;
|
|
1301
1301
|
}
|
|
1302
|
-
const [
|
|
1303
|
-
|
|
1302
|
+
const [x, g] = m[0];
|
|
1303
|
+
r.push(x), i.add(g), u = g;
|
|
1304
1304
|
}
|
|
1305
1305
|
}), s;
|
|
1306
1306
|
}
|
|
1307
|
-
class v extends
|
|
1307
|
+
class v extends ut {
|
|
1308
1308
|
constructor(e, s = [], { ignoreChecks: i = !1 } = {}) {
|
|
1309
1309
|
super();
|
|
1310
1310
|
C(this, "contour");
|
|
1311
1311
|
C(this, "holes");
|
|
1312
|
-
i ||
|
|
1312
|
+
i || Qn(e, s), this.contour = e, this.holes = s;
|
|
1313
1313
|
}
|
|
1314
1314
|
get boundingBox() {
|
|
1315
1315
|
return this.contour.boundingBox;
|
|
@@ -1332,8 +1332,8 @@ class v extends lt {
|
|
|
1332
1332
|
this.holes.map((s) => s.transform(e))
|
|
1333
1333
|
);
|
|
1334
1334
|
}
|
|
1335
|
-
contains(e) {
|
|
1336
|
-
return this.contour.contains(e) && !this.holes.some((
|
|
1335
|
+
contains(e, { strokeIsInside: s = !1 } = {}) {
|
|
1336
|
+
return this.contour.contains(e, { strokeIsInside: s }) && !this.holes.some((i) => i.contains(e, { strokeIsInside: s }));
|
|
1337
1337
|
}
|
|
1338
1338
|
intersects(e) {
|
|
1339
1339
|
return this.allLoops.some(
|
|
@@ -1341,266 +1341,326 @@ class v extends lt {
|
|
|
1341
1341
|
);
|
|
1342
1342
|
}
|
|
1343
1343
|
overlappingStrands(e) {
|
|
1344
|
-
const s = e instanceof v ? e.allLoops : [e], i = this.allLoops.flatMap((o) => s.flatMap((
|
|
1345
|
-
return
|
|
1344
|
+
const s = e instanceof v ? e.allLoops : [e], i = this.allLoops.flatMap((o) => s.flatMap((l) => o.overlappingSegments(l)));
|
|
1345
|
+
return Xt(i).map((o) => new B(o));
|
|
1346
1346
|
}
|
|
1347
1347
|
}
|
|
1348
|
-
function
|
|
1348
|
+
function Qn(t, n = []) {
|
|
1349
1349
|
if (!t) throw new Error("Figure must have a contour");
|
|
1350
|
-
for (const [e, s] of
|
|
1350
|
+
for (const [e, s] of it([t, ...n]))
|
|
1351
1351
|
if (e.intersects(s))
|
|
1352
1352
|
throw new Error("Loops in a figure must not intersect");
|
|
1353
1353
|
if (n.some(
|
|
1354
1354
|
(e) => !t.contains(e.firstPoint) && !t.onStroke(e.firstPoint)
|
|
1355
1355
|
))
|
|
1356
1356
|
throw new Error("Holes must be inside the contour");
|
|
1357
|
-
for (const [e, s] of
|
|
1357
|
+
for (const [e, s] of it(n))
|
|
1358
1358
|
if (e.contains(s.firstPoint))
|
|
1359
|
-
throw console.error(
|
|
1360
|
-
}
|
|
1361
|
-
const
|
|
1362
|
-
const
|
|
1359
|
+
throw console.error(It(e), It(s)), new Error("Holes must not be inside other holes");
|
|
1360
|
+
}
|
|
1361
|
+
const J = (t, n, e = 1e-7) => Math.abs(t - n) <= e, Wn = (t, n) => {
|
|
1362
|
+
const e = t.boundingBox, s = n.boundingBox;
|
|
1363
|
+
return J(e.xMin, s.xMin) && J(e.yMin, s.yMin) && J(e.xMax, s.xMax) && J(e.yMax, s.yMax);
|
|
1364
|
+
}, Jn = (t, n) => {
|
|
1365
|
+
if (t.segmentsCount !== n.segmentsCount || !Wn(t, n)) return !1;
|
|
1366
|
+
const e = t.segments, s = n.segments, i = e.length, o = (l, r) => {
|
|
1367
|
+
for (let u = 0; u < i; u += 1) {
|
|
1368
|
+
const a = (l + r * u + i) % i;
|
|
1369
|
+
if (!e[u].isSame(s[a])) return !1;
|
|
1370
|
+
}
|
|
1371
|
+
return !0;
|
|
1372
|
+
};
|
|
1373
|
+
for (let l = 0; l < i; l += 1)
|
|
1374
|
+
if (e[0].isSame(s[l]) && (o(l, 1) || o(l, -1)))
|
|
1375
|
+
return !0;
|
|
1376
|
+
return !1;
|
|
1377
|
+
}, Kn = (t) => {
|
|
1378
|
+
const n = [];
|
|
1379
|
+
return t.forEach((e) => {
|
|
1380
|
+
n.some((s) => Jn(e, s)) || n.push(e);
|
|
1381
|
+
}), n;
|
|
1382
|
+
}, Zn = (t) => {
|
|
1383
|
+
const n = t.map((i, o) => t.slice(o + 1).map((l, r) => [r + o + 1, l]).filter(([, l]) => i.boundingBox.overlaps(l.boundingBox)).map(([l]) => l)), e = [], s = Array(n.length);
|
|
1363
1384
|
return n.forEach((i, o) => {
|
|
1364
|
-
let
|
|
1365
|
-
|
|
1366
|
-
s[
|
|
1385
|
+
let l = s[o];
|
|
1386
|
+
l || (l = [], e.push(l)), l.push(t[o]), i.length && i.forEach((r) => {
|
|
1387
|
+
s[r] = l;
|
|
1367
1388
|
});
|
|
1368
1389
|
}), e;
|
|
1369
|
-
},
|
|
1370
|
-
const i = n.segments[0].midPoint, o = t.filter((
|
|
1390
|
+
}, Gt = (t) => t.map((n, e) => {
|
|
1391
|
+
const i = n.segments[0].midPoint, o = t.filter((l, r) => e === r ? !1 : l.contains(i));
|
|
1371
1392
|
return {
|
|
1372
1393
|
loop: n,
|
|
1373
1394
|
isIn: o
|
|
1374
1395
|
};
|
|
1375
|
-
}),
|
|
1396
|
+
}), te = (t, n) => t.flatMap(({ loop: e }) => ht(
|
|
1376
1397
|
n.filter(
|
|
1377
1398
|
({ loop: s, isIn: i }) => s === e || i.indexOf(e) !== -1
|
|
1378
1399
|
)
|
|
1379
|
-
)),
|
|
1380
|
-
const e = n.filter(({ isIn: i }) => i.length <= 1), s =
|
|
1381
|
-
|
|
1400
|
+
)), ne = (t, n) => {
|
|
1401
|
+
const e = n.filter(({ isIn: i }) => i.length <= 1), s = ht(
|
|
1402
|
+
Gt(t.map(({ loop: i }) => i))
|
|
1382
1403
|
);
|
|
1383
1404
|
return [e, ...s];
|
|
1384
|
-
},
|
|
1405
|
+
}, ht = (t) => {
|
|
1385
1406
|
if (!t.length) return [];
|
|
1386
1407
|
const n = t.filter(({ isIn: s }) => !s.length), e = t.filter(({ isIn: s }) => s.length > 1);
|
|
1387
|
-
return n.length === 1 && e.length === 0 ? [t] : n.length > 1 ?
|
|
1408
|
+
return n.length === 1 && e.length === 0 ? [t] : n.length > 1 ? te(n, t) : ne(e, t);
|
|
1388
1409
|
};
|
|
1389
1410
|
function X(t) {
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1411
|
+
const n = Kn(t);
|
|
1412
|
+
return Zn(n).map(Gt).flatMap(ht).map((s) => {
|
|
1413
|
+
if (s.length === 1) return new v(s[0].loop);
|
|
1414
|
+
s.sort((l, r) => l.isIn.length - r.isIn.length);
|
|
1415
|
+
const [i, ...o] = s.map(({ loop: l }) => l);
|
|
1416
|
+
return new v(i, o);
|
|
1395
1417
|
});
|
|
1396
1418
|
}
|
|
1397
|
-
function
|
|
1419
|
+
function ee(t, n) {
|
|
1398
1420
|
const e = [];
|
|
1399
1421
|
for (const s of t)
|
|
1400
1422
|
for (const i of n)
|
|
1401
1423
|
e.push([s, i]);
|
|
1402
1424
|
return e;
|
|
1403
1425
|
}
|
|
1404
|
-
function*
|
|
1405
|
-
const s = (r) => n.some((
|
|
1406
|
-
let
|
|
1426
|
+
function* vt(t, n, e) {
|
|
1427
|
+
const s = (r) => n.some((u) => P(u, r.lastPoint)), i = (r, u) => r.segmentType !== u.segmentType || !u.isOnSegment(r.firstPoint) || !u.isOnSegment(r.lastPoint) ? !1 : r.segmentType !== "LINE" ? u.isOnSegment(r.midPoint) : !0, o = (r) => e.some((u) => r.isSame(u) || i(r, u));
|
|
1428
|
+
let l = [];
|
|
1407
1429
|
for (const r of t)
|
|
1408
|
-
s(r) ? (
|
|
1409
|
-
|
|
1430
|
+
s(r) ? (l.push(r), yield new B(l, { ignoreChecks: !0 }), l = []) : o(r) ? (l.length && (yield new B(l, { ignoreChecks: !0 }), l = []), yield new B([r], { ignoreChecks: !0 })) : l.push(r);
|
|
1431
|
+
l.length && (yield new B(l, { ignoreChecks: !0 }));
|
|
1410
1432
|
}
|
|
1411
|
-
const
|
|
1412
|
-
const e = t.findIndex((o) =>
|
|
1433
|
+
const Bt = (t, n) => {
|
|
1434
|
+
const e = t.findIndex((o) => P(n, o.firstPoint)), s = t.slice(0, e);
|
|
1413
1435
|
return t.slice(e).concat(s);
|
|
1414
|
-
},
|
|
1436
|
+
}, kt = (t, n) => {
|
|
1415
1437
|
let e = t;
|
|
1416
|
-
const s = (
|
|
1438
|
+
const s = (r) => P(r.firstPoint, n.firstPoint) && P(r.lastPoint, n.lastPoint);
|
|
1417
1439
|
let i = t.findIndex(s);
|
|
1418
1440
|
if (i === -1) {
|
|
1419
|
-
const
|
|
1420
|
-
if (
|
|
1441
|
+
const r = t.map((u) => u.reverse());
|
|
1442
|
+
if (r.reverse(), i = r.findIndex(s), i === -1)
|
|
1421
1443
|
throw console.error(
|
|
1422
|
-
|
|
1444
|
+
r.map((u) => u.repr),
|
|
1423
1445
|
n.repr
|
|
1424
1446
|
), new Error("Failed to rotate to segment start");
|
|
1425
|
-
e =
|
|
1447
|
+
e = r;
|
|
1426
1448
|
}
|
|
1427
1449
|
const o = e.slice(0, i);
|
|
1428
1450
|
return e.slice(i).concat(o);
|
|
1429
1451
|
};
|
|
1430
|
-
function
|
|
1452
|
+
function se(t, n, e) {
|
|
1431
1453
|
return t.filter((s) => {
|
|
1432
|
-
const i = n.filter((
|
|
1454
|
+
const i = n.filter((r) => P(r.firstPoint, s) || P(r.lastPoint, s));
|
|
1433
1455
|
if (i.length % 2)
|
|
1434
1456
|
throw new Error("Bug in the intersection algo on non crossing point");
|
|
1435
|
-
const o = i.map((
|
|
1436
|
-
return !(o.every((
|
|
1457
|
+
const o = i.map((r) => e.contains(r.midPoint));
|
|
1458
|
+
return !(o.every((r) => r) || !o.some((r) => r));
|
|
1437
1459
|
});
|
|
1438
1460
|
}
|
|
1439
|
-
function
|
|
1440
|
-
let
|
|
1441
|
-
const
|
|
1442
|
-
if (t.segments.forEach((
|
|
1443
|
-
n.segments.forEach((
|
|
1444
|
-
const { intersections:
|
|
1445
|
-
|
|
1446
|
-
|
|
1461
|
+
function ie(t, n, e, s = !1) {
|
|
1462
|
+
let i = [];
|
|
1463
|
+
const o = [], l = new Array(t.segments.length).fill(0).map(() => []), r = new Array(n.segments.length).fill(0).map(() => []);
|
|
1464
|
+
if (t.segments.forEach((p, d) => {
|
|
1465
|
+
n.segments.forEach((m, x) => {
|
|
1466
|
+
const { intersections: g, overlaps: w } = Z(
|
|
1467
|
+
p,
|
|
1468
|
+
m,
|
|
1447
1469
|
e
|
|
1448
1470
|
);
|
|
1449
|
-
|
|
1450
|
-
const
|
|
1451
|
-
|
|
1452
|
-
|
|
1471
|
+
i.push(...g), l[d].push(...g), r[x].push(...g), o.push(...w);
|
|
1472
|
+
const F = w.flatMap((y) => [
|
|
1473
|
+
y.firstPoint,
|
|
1474
|
+
y.lastPoint
|
|
1453
1475
|
]);
|
|
1454
|
-
|
|
1476
|
+
i.push(...F), l[d].push(...F), r[x].push(...F);
|
|
1455
1477
|
});
|
|
1456
|
-
}),
|
|
1457
|
-
const
|
|
1458
|
-
let
|
|
1459
|
-
if (
|
|
1460
|
-
|
|
1461
|
-
|
|
1478
|
+
}), i = U(i, e), !i.length || i.length === 1) return null;
|
|
1479
|
+
const u = ([p, d]) => d.length ? p.splitAt(d) : [p];
|
|
1480
|
+
let a = N([t.segments, l]).flatMap(u), f = N([n.segments, r]).flatMap(u);
|
|
1481
|
+
if (i = se(
|
|
1482
|
+
i,
|
|
1483
|
+
a,
|
|
1462
1484
|
n
|
|
1463
|
-
), !
|
|
1464
|
-
if (
|
|
1465
|
-
const
|
|
1466
|
-
|
|
1467
|
-
c,
|
|
1468
|
-
h
|
|
1469
|
-
), a = Bt(
|
|
1485
|
+
), !i.length && !o.length) return null;
|
|
1486
|
+
if (o.length) {
|
|
1487
|
+
const p = o[0];
|
|
1488
|
+
a = kt(
|
|
1470
1489
|
a,
|
|
1471
|
-
|
|
1490
|
+
p
|
|
1491
|
+
), f = kt(
|
|
1492
|
+
f,
|
|
1493
|
+
p
|
|
1472
1494
|
);
|
|
1473
1495
|
} else {
|
|
1474
|
-
const
|
|
1475
|
-
|
|
1476
|
-
}
|
|
1477
|
-
let
|
|
1478
|
-
|
|
1479
|
-
c,
|
|
1480
|
-
s,
|
|
1481
|
-
i
|
|
1482
|
-
)
|
|
1483
|
-
), u = Array.from(
|
|
1484
|
-
Ft(
|
|
1496
|
+
const p = i[0];
|
|
1497
|
+
a = Bt(a, p), f = Bt(f, p);
|
|
1498
|
+
}
|
|
1499
|
+
let c = Array.from(
|
|
1500
|
+
vt(
|
|
1485
1501
|
a,
|
|
1486
|
-
|
|
1487
|
-
|
|
1502
|
+
i,
|
|
1503
|
+
o
|
|
1504
|
+
)
|
|
1505
|
+
), h = Array.from(
|
|
1506
|
+
vt(
|
|
1507
|
+
f,
|
|
1508
|
+
i,
|
|
1509
|
+
o
|
|
1488
1510
|
)
|
|
1489
1511
|
);
|
|
1490
|
-
return (!
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
) ||
|
|
1512
|
+
return (!P(
|
|
1513
|
+
h[0].lastPoint,
|
|
1514
|
+
c[0].lastPoint
|
|
1515
|
+
) || o.length > 0 && h[0].segmentsCount !== 1) && (h = h.map((p) => p.reverse()).reverse(), P(h[0].lastPoint, c[0].lastPoint) || (c = c.map((p) => p.reverse()).reverse())), N([c, h]).map(([p, d]) => {
|
|
1516
|
+
if (s) {
|
|
1517
|
+
if (((x) => x.segments.every(
|
|
1518
|
+
(g) => o.some(
|
|
1519
|
+
(w) => g.isSame(w) || g.segmentType === w.segmentType && w.isOnSegment(g.firstPoint) && w.isOnSegment(g.lastPoint) && (g.segmentType === "LINE" || w.isOnSegment(g.midPoint))
|
|
1520
|
+
)
|
|
1521
|
+
))(p))
|
|
1522
|
+
return [p, "same"];
|
|
1523
|
+
} else if (p.segmentsCount === 1 && o.some((m) => p.segments[0].isSame(m)))
|
|
1524
|
+
return [p, "same"];
|
|
1525
|
+
return [p, d];
|
|
1526
|
+
});
|
|
1494
1527
|
}
|
|
1495
|
-
function
|
|
1528
|
+
function Ot(t) {
|
|
1496
1529
|
let n = t[0];
|
|
1497
1530
|
for (const e of t.slice(1))
|
|
1498
1531
|
n = n.extend(e);
|
|
1499
|
-
if (!
|
|
1532
|
+
if (!P(n.firstPoint, n.lastPoint))
|
|
1500
1533
|
throw console.error(
|
|
1501
|
-
|
|
1502
|
-
|
|
1534
|
+
mt(n.firstPoint),
|
|
1535
|
+
mt(n.lastPoint)
|
|
1503
1536
|
), new Error("Bug in the intersection algo on non closing strand");
|
|
1504
|
-
return new
|
|
1537
|
+
return new _(n.segments);
|
|
1505
1538
|
}
|
|
1506
|
-
function
|
|
1539
|
+
function oe(t, n) {
|
|
1507
1540
|
const e = N([
|
|
1508
1541
|
n.slice(0, -1),
|
|
1509
1542
|
n.slice(1)
|
|
1510
|
-
]).map(([i, o]) =>
|
|
1543
|
+
]).map(([i, o]) => Ot(t.slice(i, o)));
|
|
1511
1544
|
let s = t.slice(
|
|
1512
1545
|
n[n.length - 1]
|
|
1513
1546
|
);
|
|
1514
|
-
return n[0] !== 0 && (s = s.concat(t.slice(0, n[0]))), e.push(
|
|
1547
|
+
return n[0] !== 0 && (s = s.concat(t.slice(0, n[0]))), e.push(Ot(s)), e;
|
|
1515
1548
|
}
|
|
1516
|
-
function
|
|
1549
|
+
function re(t) {
|
|
1517
1550
|
if (!t.length) return [];
|
|
1518
1551
|
const n = t.map((i) => i.firstPoint);
|
|
1519
1552
|
let e = t.map((i) => i.lastPoint);
|
|
1520
1553
|
e = e.slice(-1).concat(e.slice(0, -1));
|
|
1521
1554
|
const s = N([n, e]).flatMap(
|
|
1522
|
-
([i, o],
|
|
1555
|
+
([i, o], l) => P(i, o) ? [] : l
|
|
1523
1556
|
);
|
|
1524
1557
|
try {
|
|
1525
|
-
return
|
|
1558
|
+
return oe(t, s);
|
|
1526
1559
|
} catch {
|
|
1527
|
-
return
|
|
1560
|
+
return Xt(t.flatMap((o) => o.segments)).filter((o) => o.length > 1).filter((o) => P(o[0].firstPoint, o.at(-1).lastPoint)).map((o) => new _(o));
|
|
1528
1561
|
}
|
|
1529
1562
|
}
|
|
1530
1563
|
const _t = (t, n) => {
|
|
1531
1564
|
if (t.length === 0) return [n];
|
|
1532
1565
|
const e = t.at(-1);
|
|
1533
|
-
return
|
|
1534
|
-
},
|
|
1535
|
-
function
|
|
1566
|
+
return P(e.lastPoint, n.firstPoint) ? t.slice(0, -1).concat([e.extend(n)]) : P(e.lastPoint, n.lastPoint) ? t.slice(0, -1).concat([e.extend(n.reverse())]) : t.concat([n]);
|
|
1567
|
+
}, le = (t, n) => t.length === 0 ? [n] : P(t[0].firstPoint, n.lastPoint) ? [n.extend(t[0])].concat(t.slice(1)) : [n].concat(t);
|
|
1568
|
+
function pt(t, n, {
|
|
1536
1569
|
firstInside: e,
|
|
1537
|
-
secondInside: s
|
|
1570
|
+
secondInside: s,
|
|
1571
|
+
firstBoundaryInside: i = !1,
|
|
1572
|
+
secondBoundaryInside: o = !1
|
|
1538
1573
|
}) {
|
|
1539
|
-
const
|
|
1540
|
-
|
|
1541
|
-
|
|
1574
|
+
const l = ie(
|
|
1575
|
+
t,
|
|
1576
|
+
n,
|
|
1577
|
+
void 0,
|
|
1578
|
+
i || o
|
|
1579
|
+
);
|
|
1580
|
+
if (!l) {
|
|
1581
|
+
const f = t.segments[0].midPoint, c = n.contains(f, {
|
|
1582
|
+
strokeIsInside: o
|
|
1583
|
+
}), h = n.segments[0].midPoint, p = t.contains(h, {
|
|
1584
|
+
strokeIsInside: i
|
|
1585
|
+
});
|
|
1542
1586
|
return {
|
|
1543
1587
|
identical: !1,
|
|
1544
|
-
firstCurveInSecond:
|
|
1545
|
-
secondCurveInFirst:
|
|
1588
|
+
firstCurveInSecond: c,
|
|
1589
|
+
secondCurveInFirst: p
|
|
1546
1590
|
};
|
|
1547
1591
|
}
|
|
1548
|
-
if (
|
|
1592
|
+
if (l.every(([, f]) => f === "same"))
|
|
1549
1593
|
return { identical: !0 };
|
|
1550
|
-
let
|
|
1551
|
-
const
|
|
1552
|
-
let
|
|
1553
|
-
if (
|
|
1554
|
-
return
|
|
1555
|
-
const
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1594
|
+
let r = null, u = null;
|
|
1595
|
+
const a = l.flatMap(([f, c]) => {
|
|
1596
|
+
let h = [], p = 0;
|
|
1597
|
+
if (c === "same")
|
|
1598
|
+
return u === 1 ? (u = 1, f) : u === 2 || u === 0 ? (u = null, []) : u === null ? (r ? r = r.extend(f) : r = f, []) : (console.error("weird situation"), []);
|
|
1599
|
+
const d = f.segments[0].midPoint, m = n.contains(d, {
|
|
1600
|
+
strokeIsInside: o
|
|
1601
|
+
});
|
|
1602
|
+
(e === "keep" && m || e === "remove" && !m) && (p += 1, h = _t(h, f));
|
|
1603
|
+
const x = c.segments[0].midPoint, g = t.contains(x, {
|
|
1604
|
+
strokeIsInside: i
|
|
1605
|
+
});
|
|
1606
|
+
if (s === "keep" && g || s === "remove" && !g) {
|
|
1607
|
+
const w = c;
|
|
1608
|
+
p += 1, p === 2 && h.length ? (h = _t(h, w), r = null) : h = [w];
|
|
1561
1609
|
}
|
|
1562
|
-
return
|
|
1610
|
+
return u === null && p === 1 && r && (h = le(h, r)), p === 1 && (u = p, r = null), h.length ? h : (r = null, []);
|
|
1563
1611
|
});
|
|
1564
|
-
return
|
|
1612
|
+
return re(a);
|
|
1565
1613
|
}
|
|
1566
|
-
const
|
|
1567
|
-
const
|
|
1614
|
+
const ue = (t, n, e) => {
|
|
1615
|
+
const s = pt(t, n, {
|
|
1568
1616
|
firstInside: "remove",
|
|
1569
|
-
secondInside: "remove"
|
|
1617
|
+
secondInside: "remove",
|
|
1618
|
+
...e
|
|
1570
1619
|
});
|
|
1571
|
-
return Array.isArray(
|
|
1572
|
-
},
|
|
1573
|
-
const
|
|
1620
|
+
return Array.isArray(s) ? s : s.identical ? [t] : s.firstCurveInSecond ? [n] : s.secondCurveInFirst ? [t] : [t, n];
|
|
1621
|
+
}, tt = (t, n, e) => {
|
|
1622
|
+
const s = pt(t, n, {
|
|
1574
1623
|
firstInside: "remove",
|
|
1575
|
-
secondInside: "keep"
|
|
1624
|
+
secondInside: "keep",
|
|
1625
|
+
...e
|
|
1576
1626
|
});
|
|
1577
|
-
return Array.isArray(
|
|
1578
|
-
},
|
|
1579
|
-
const e =
|
|
1627
|
+
return Array.isArray(s) ? s : s.identical ? [] : s.firstCurveInSecond ? [] : s.secondCurveInFirst ? [t, n] : [t];
|
|
1628
|
+
}, dt = (t, n, e) => {
|
|
1629
|
+
const s = (e == null ? void 0 : e.firstBoundaryInside) ?? !1, i = (e == null ? void 0 : e.secondBoundaryInside) ?? !1, o = s || i, l = (u, a, f) => u.segments.every(
|
|
1630
|
+
(c) => a.contains(c.midPoint, { strokeIsInside: f })
|
|
1631
|
+
);
|
|
1632
|
+
if (o) {
|
|
1633
|
+
if (l(t, n, i))
|
|
1634
|
+
return [t];
|
|
1635
|
+
if (l(n, t, s))
|
|
1636
|
+
return [n];
|
|
1637
|
+
}
|
|
1638
|
+
const r = pt(t, n, {
|
|
1580
1639
|
firstInside: "keep",
|
|
1581
|
-
secondInside: "keep"
|
|
1640
|
+
secondInside: "keep",
|
|
1641
|
+
...e
|
|
1582
1642
|
});
|
|
1583
|
-
return Array.isArray(
|
|
1643
|
+
return Array.isArray(r) ? r : r.identical ? [t] : r.firstCurveInSecond ? [t] : r.secondCurveInFirst ? [n] : [];
|
|
1584
1644
|
};
|
|
1585
|
-
function
|
|
1645
|
+
function ce(t) {
|
|
1586
1646
|
const n = /* @__PURE__ */ new Map(), e = [];
|
|
1587
1647
|
return t.forEach((s, i) => {
|
|
1588
1648
|
let o;
|
|
1589
|
-
n.has(i) ? o = n.get(i) : (o = { current: [s], fusedWith: /* @__PURE__ */ new Set([i]) }, e.push(o)), t.slice(i + 1).forEach((
|
|
1590
|
-
const
|
|
1649
|
+
n.has(i) ? o = n.get(i) : (o = { current: [s], fusedWith: /* @__PURE__ */ new Set([i]) }, e.push(o)), t.slice(i + 1).forEach((l, r) => {
|
|
1650
|
+
const u = o.current, a = i + r + 1;
|
|
1591
1651
|
if (o.fusedWith.has(a)) return;
|
|
1592
|
-
let f = [
|
|
1593
|
-
if (n.has(a) && (f = n.get(a).current,
|
|
1652
|
+
let f = [l], c = !1;
|
|
1653
|
+
if (n.has(a) && (f = n.get(a).current, c = !0), !u.some(
|
|
1594
1654
|
(d) => f.some((m) => d.intersects(m))
|
|
1595
1655
|
)) return;
|
|
1596
1656
|
let p;
|
|
1597
|
-
|
|
1657
|
+
u.length > 1 || f.length > 1 ? p = G(u, f) : p = Qt(u[0], f[0]), o.fusedWith.add(a), o.current = p, c || n.set(a, o);
|
|
1598
1658
|
});
|
|
1599
1659
|
}), e.flatMap(({ current: s }) => s);
|
|
1600
1660
|
}
|
|
1601
|
-
function
|
|
1602
|
-
const e =
|
|
1603
|
-
([
|
|
1661
|
+
function Qt(t, n) {
|
|
1662
|
+
const e = ue(t.contour, n.contour), s = n.holes.flatMap((l) => tt(l, t.contour)), i = t.holes.flatMap((l) => tt(l, n.contour)), o = ee(t.holes, n.holes).flatMap(
|
|
1663
|
+
([l, r]) => dt(l, r)
|
|
1604
1664
|
);
|
|
1605
1665
|
return X([
|
|
1606
1666
|
...e,
|
|
@@ -1609,12 +1669,12 @@ function Gt(t, n) {
|
|
|
1609
1669
|
...o
|
|
1610
1670
|
]);
|
|
1611
1671
|
}
|
|
1612
|
-
function
|
|
1672
|
+
function nt(t, n) {
|
|
1613
1673
|
if (t.isFull && n.isFull)
|
|
1614
|
-
return X(
|
|
1674
|
+
return X(tt(t.contour, n.contour));
|
|
1615
1675
|
if (t.isFull) {
|
|
1616
|
-
const s =
|
|
1617
|
-
(o) =>
|
|
1676
|
+
const s = tt(t.contour, n.contour), i = n.holes.flatMap(
|
|
1677
|
+
(o) => dt(o, t.contour, { firstBoundaryInside: !0 })
|
|
1618
1678
|
);
|
|
1619
1679
|
return X([...s, ...i]);
|
|
1620
1680
|
} else if (n.isFull && !t.contour.intersects(n.contour))
|
|
@@ -1629,13 +1689,13 @@ function tt(t, n) {
|
|
|
1629
1689
|
]);
|
|
1630
1690
|
} else
|
|
1631
1691
|
return [t];
|
|
1632
|
-
let e =
|
|
1692
|
+
let e = nt(new v(t.contour), n);
|
|
1633
1693
|
return t.holes.forEach((s) => {
|
|
1634
|
-
e = e.flatMap((i) =>
|
|
1694
|
+
e = e.flatMap((i) => nt(i, new v(s)));
|
|
1635
1695
|
}), e;
|
|
1636
1696
|
}
|
|
1637
|
-
function
|
|
1638
|
-
const e =
|
|
1697
|
+
function ae(t, n) {
|
|
1698
|
+
const e = dt(t.contour, n.contour);
|
|
1639
1699
|
if (!e.length) return [];
|
|
1640
1700
|
let s = X(e);
|
|
1641
1701
|
return s = Q(
|
|
@@ -1650,42 +1710,42 @@ function G(t, n) {
|
|
|
1650
1710
|
if (!t.length) return n;
|
|
1651
1711
|
if (!n.length) return t;
|
|
1652
1712
|
if (t.length === 1 && n.length > 1 || n.length === 1 && t.length > 1)
|
|
1653
|
-
return
|
|
1713
|
+
return ce([...t, ...n]);
|
|
1654
1714
|
if (t.length > 1 && n.length > 1) {
|
|
1655
1715
|
let e = G([t[0]], n);
|
|
1656
1716
|
return t.slice(1).forEach((s) => {
|
|
1657
1717
|
e = G([s], e);
|
|
1658
1718
|
}), e;
|
|
1659
1719
|
}
|
|
1660
|
-
return t.length === 1 && n.length === 1 ?
|
|
1720
|
+
return t.length === 1 && n.length === 1 ? Qt(t[0], n[0]) : [];
|
|
1661
1721
|
}
|
|
1662
1722
|
function Q(t, n) {
|
|
1663
1723
|
if (!t.length) return [];
|
|
1664
1724
|
if (!n.length) return t;
|
|
1665
1725
|
if (t.length === 1 && n.length === 1)
|
|
1666
|
-
return
|
|
1726
|
+
return nt(t[0], n[0]);
|
|
1667
1727
|
if (t.length > 1)
|
|
1668
1728
|
return t.flatMap((s) => Q([s], n));
|
|
1669
|
-
let e =
|
|
1729
|
+
let e = nt(t[0], n[0]);
|
|
1670
1730
|
return n.slice(1).forEach((s) => {
|
|
1671
1731
|
e = Q(e, [s]);
|
|
1672
1732
|
}), e;
|
|
1673
1733
|
}
|
|
1674
|
-
function
|
|
1675
|
-
return !t.length || !n.length ? [] : t.length === 1 && n.length === 1 ?
|
|
1734
|
+
function lt(t, n) {
|
|
1735
|
+
return !t.length || !n.length ? [] : t.length === 1 && n.length === 1 ? ae(t[0], n[0]) : t.length > 1 ? t.flatMap((e) => lt([e], n)) : n.flatMap((e) => lt(t, [e]));
|
|
1676
1736
|
}
|
|
1677
|
-
class
|
|
1737
|
+
class O extends ut {
|
|
1678
1738
|
constructor(e = [], { ignoreChecks: s = !1 } = {}) {
|
|
1679
1739
|
super();
|
|
1680
1740
|
C(this, "figures");
|
|
1681
1741
|
C(this, "_boundingBox", null);
|
|
1682
|
-
s ||
|
|
1742
|
+
s || fe(e), this.figures = e;
|
|
1683
1743
|
}
|
|
1684
1744
|
get isEmpty() {
|
|
1685
1745
|
return this.figures.length === 0;
|
|
1686
1746
|
}
|
|
1687
1747
|
get boundingBox() {
|
|
1688
|
-
if (this.isEmpty) return new
|
|
1748
|
+
if (this.isEmpty) return new pn();
|
|
1689
1749
|
if (this._boundingBox === null) {
|
|
1690
1750
|
let e = this.figures[0].boundingBox;
|
|
1691
1751
|
for (const s of this.figures.slice(1))
|
|
@@ -1695,13 +1755,15 @@ class _ extends lt {
|
|
|
1695
1755
|
return this._boundingBox;
|
|
1696
1756
|
}
|
|
1697
1757
|
clone() {
|
|
1698
|
-
return new
|
|
1758
|
+
return new O(this.figures.map((e) => e.clone()));
|
|
1699
1759
|
}
|
|
1700
1760
|
transform(e) {
|
|
1701
|
-
return new
|
|
1761
|
+
return new O(this.figures.map((s) => s.transform(e)));
|
|
1702
1762
|
}
|
|
1703
|
-
contains(e) {
|
|
1704
|
-
return this.figures.some(
|
|
1763
|
+
contains(e, { strokeIsInside: s = !1 } = {}) {
|
|
1764
|
+
return this.figures.some(
|
|
1765
|
+
(i) => i.contains(e, { strokeIsInside: s })
|
|
1766
|
+
);
|
|
1705
1767
|
}
|
|
1706
1768
|
intersects(e) {
|
|
1707
1769
|
return this.figures.some(
|
|
@@ -1709,41 +1771,41 @@ class _ extends lt {
|
|
|
1709
1771
|
);
|
|
1710
1772
|
}
|
|
1711
1773
|
overlappingStrands(e) {
|
|
1712
|
-
return this.figures.flatMap((s) => e instanceof
|
|
1774
|
+
return this.figures.flatMap((s) => e instanceof O ? e.figures.flatMap(
|
|
1713
1775
|
(i) => s.overlappingStrands(i)
|
|
1714
1776
|
) : s.overlappingStrands(e));
|
|
1715
1777
|
}
|
|
1716
1778
|
fuse(e) {
|
|
1717
|
-
return new
|
|
1779
|
+
return new O(G(this.figures, e.figures));
|
|
1718
1780
|
}
|
|
1719
1781
|
cut(e) {
|
|
1720
|
-
return new
|
|
1782
|
+
return new O(Q(this.figures, e.figures));
|
|
1721
1783
|
}
|
|
1722
1784
|
intersect(e) {
|
|
1723
|
-
return new
|
|
1785
|
+
return new O(lt(this.figures, e.figures));
|
|
1724
1786
|
}
|
|
1725
1787
|
}
|
|
1726
|
-
function
|
|
1727
|
-
for (const [n, e] of
|
|
1788
|
+
function fe(t) {
|
|
1789
|
+
for (const [n, e] of it(t))
|
|
1728
1790
|
if (n.intersects(e))
|
|
1729
1791
|
throw new Error("Diagram figures must not intersect");
|
|
1730
1792
|
}
|
|
1731
1793
|
export {
|
|
1732
|
-
|
|
1794
|
+
O as D,
|
|
1733
1795
|
v as F,
|
|
1734
|
-
|
|
1796
|
+
_ as L,
|
|
1735
1797
|
B as S,
|
|
1736
|
-
|
|
1798
|
+
Z as a,
|
|
1737
1799
|
G as b,
|
|
1738
1800
|
Q as c,
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1801
|
+
Dt as d,
|
|
1802
|
+
Xt as e,
|
|
1803
|
+
de as f,
|
|
1804
|
+
Hn as g,
|
|
1805
|
+
It as h,
|
|
1806
|
+
lt as i,
|
|
1807
|
+
K as l,
|
|
1808
|
+
dn as p,
|
|
1809
|
+
vt as s
|
|
1748
1810
|
};
|
|
1749
|
-
//# sourceMappingURL=models-
|
|
1811
|
+
//# sourceMappingURL=models-DCkOI0hV.js.map
|