pantograph2d 0.7.0 → 0.8.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/Diagram-2450b2e6.js +1750 -0
- package/dist/Diagram-2450b2e6.js.map +1 -0
- package/dist/Diagram-57e17509.cjs +4 -0
- package/dist/Diagram-57e17509.cjs.map +1 -0
- package/dist/QuadraticBezier-e116a2d6.js +3647 -0
- package/dist/QuadraticBezier-e116a2d6.js.map +1 -0
- package/dist/QuadraticBezier-e3d7218b.cjs +9 -0
- package/dist/QuadraticBezier-e3d7218b.cjs.map +1 -0
- package/dist/api/svg.d.ts +1 -0
- package/dist/draw-27ac6dae.cjs +2 -0
- package/dist/draw-27ac6dae.cjs.map +1 -0
- package/dist/{draw-825692f1.js → draw-c7b2705c.js} +117 -109
- package/dist/draw-c7b2705c.js.map +1 -0
- package/dist/export/svg/api.d.ts +6 -0
- package/dist/{types/export → export}/svg/wrapSVG.d.ts +1 -1
- package/dist/{types/models → models}/exports.d.ts +2 -0
- package/dist/pantograph/drawShape.cjs +1 -1
- package/dist/pantograph/drawShape.cjs.map +1 -1
- package/dist/pantograph/drawShape.js +12 -11
- package/dist/pantograph/drawShape.js.map +1 -1
- package/dist/pantograph/models.cjs +1 -1
- package/dist/pantograph/models.js +15 -12
- package/dist/pantograph/models.js.map +1 -1
- package/dist/pantograph/svg.cjs +2 -0
- package/dist/pantograph/svg.cjs.map +1 -0
- package/dist/pantograph/svg.js +11 -0
- package/dist/pantograph/svg.js.map +1 -0
- package/dist/pantograph.cjs +2 -8
- package/dist/pantograph.cjs.map +1 -1
- package/dist/pantograph.js +405 -440
- package/dist/pantograph.js.map +1 -1
- package/dist/wrapSVG-02b823ac.cjs +8 -0
- package/dist/wrapSVG-02b823ac.cjs.map +1 -0
- package/dist/wrapSVG-0ec8a111.js +62 -0
- package/dist/wrapSVG-0ec8a111.js.map +1 -0
- package/package.json +31 -23
- package/dist/Diagram-8c3c5e1b.js +0 -5301
- package/dist/Diagram-8c3c5e1b.js.map +0 -1
- package/dist/Diagram-d8288579.cjs +0 -11
- package/dist/Diagram-d8288579.cjs.map +0 -1
- package/dist/draw-3ee546c3.cjs +0 -2
- package/dist/draw-3ee546c3.cjs.map +0 -1
- package/dist/draw-825692f1.js.map +0 -1
- /package/dist/{types/algorithms → algorithms}/boolean/figureBooleans.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/boolean/loopBooleans.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/boolean/strandBoolean.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/boolean/strandsBetweenIntersections.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/distances/arcArcDistance.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/distances/genericDistance.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/distances/index.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/distances/lineArcDistance.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/distances/lineLineDistance.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/filletSegments.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/intersections/arcArcIntersection.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/intersections/arcEllipseArcIntersection.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/intersections/arcsCubicBezierIntersection.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/intersections/arcsQuadraticBezierIntersection.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/intersections/bezierClip.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/intersections/cubicBezierCubicBezierIntersection.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/intersections/ellipseArcEllipseArcIntersection.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/intersections/ellipseEllipseIntersection.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/intersections/index.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/intersections/lineArcIntersection.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/intersections/lineBezierIntersection.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/intersections/lineEllipseArcIntersection.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/intersections/lineLineIntersection.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/intersections/quadraticBezierQuadraticBezierIntersection.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/intersections/rayIntersections.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/offsets/offsetFigure.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/offsets/offsetSegment.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/offsets/offsetStroke.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/optimisation/Brent.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/optimisation/DiRect.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/organiseLoops.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/simplify.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/solvers/solvePolynomials.d.ts +0 -0
- /package/dist/{types/algorithms → algorithms}/stitchSegments.d.ts +0 -0
- /package/dist/{types/api → api}/drawShape.d.ts +0 -0
- /package/dist/{types/api → api}/models.d.ts +0 -0
- /package/dist/{types/booleanOperations.d.ts → booleanOperations.d.ts} +0 -0
- /package/dist/{types/definitions.d.ts → definitions.d.ts} +0 -0
- /package/dist/{types/draw.d.ts → draw.d.ts} +0 -0
- /package/dist/{types/drawShape → drawShape}/drawCircle.d.ts +0 -0
- /package/dist/{types/drawShape → drawShape}/drawRect.d.ts +0 -0
- /package/dist/{types/export → export}/json/exportJSON.d.ts +0 -0
- /package/dist/{types/export → export}/json/jsonDiagram.d.ts +0 -0
- /package/dist/{types/export → export}/json/jsonFigure.d.ts +0 -0
- /package/dist/{types/export → export}/json/jsonLoop.d.ts +0 -0
- /package/dist/{types/export → export}/json/jsonSegment.d.ts +0 -0
- /package/dist/{types/export → export}/svg/exportSVG.d.ts +0 -0
- /package/dist/{types/export → export}/svg/svgDiagram.d.ts +0 -0
- /package/dist/{types/export → export}/svg/svgFigure.d.ts +0 -0
- /package/dist/{types/export → export}/svg/svgLoop.d.ts +0 -0
- /package/dist/{types/export → export}/svg/svgSegment.d.ts +0 -0
- /package/dist/{types/export → export}/svg/svgStrand.d.ts +0 -0
- /package/dist/{types/import → import}/json/importJSON.d.ts +0 -0
- /package/dist/{types/main.d.ts → main.d.ts} +0 -0
- /package/dist/{types/models → models}/BoundingBox.d.ts +0 -0
- /package/dist/{types/models → models}/Diagram.d.ts +0 -0
- /package/dist/{types/models → models}/Figure.d.ts +0 -0
- /package/dist/{types/models → models}/Loop.d.ts +0 -0
- /package/dist/{types/models → models}/Strand.d.ts +0 -0
- /package/dist/{types/models → models}/Stroke.d.ts +0 -0
- /package/dist/{types/models → models}/TransformationMatrix.d.ts +0 -0
- /package/dist/{types/models → models}/segments/Arc.d.ts +0 -0
- /package/dist/{types/models → models}/segments/CubicBezier.d.ts +0 -0
- /package/dist/{types/models → models}/segments/EllipseArc.d.ts +0 -0
- /package/dist/{types/models → models}/segments/Line.d.ts +0 -0
- /package/dist/{types/models → models}/segments/QuadraticBezier.d.ts +0 -0
- /package/dist/{types/models → models}/segments/Segment.d.ts +0 -0
- /package/dist/{types/models → models}/segments/utils/deCasteljau.d.ts +0 -0
- /package/dist/{types/models → models}/segments/utils/isSegment.d.ts +0 -0
- /package/dist/{types/models → models}/utils/Transformable.d.ts +0 -0
- /package/dist/{types/offsetOperations.d.ts → offsetOperations.d.ts} +0 -0
- /package/dist/{types/operations.d.ts → operations.d.ts} +0 -0
- /package/dist/{types/utils → utils}/allCombinations.d.ts +0 -0
- /package/dist/{types/utils → utils}/allPairs.d.ts +0 -0
- /package/dist/{types/utils → utils}/angularDistance.d.ts +0 -0
- /package/dist/{types/utils → utils}/listOfFigures.d.ts +0 -0
- /package/dist/{types/utils → utils}/projectPointOnLine.d.ts +0 -0
- /package/dist/{types/utils → utils}/range.d.ts +0 -0
- /package/dist/{types/utils → utils}/removeDuplicatePoints.d.ts +0 -0
- /package/dist/{types/utils → utils}/removeDuplicateValues.d.ts +0 -0
- /package/dist/{types/utils → utils}/unitAngle.d.ts +0 -0
- /package/dist/{types/utils → utils}/zip.d.ts +0 -0
- /package/dist/{types/vectorOperations.d.ts → vectorOperations.d.ts} +0 -0
package/dist/pantograph.js
CHANGED
|
@@ -1,616 +1,581 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var lt = Object.defineProperty;
|
|
2
|
+
var ut = (t, e, n) => e in t ? lt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var p = (t, e, n) => (ut(t, typeof e != "symbol" ? e + "" : e, n), n);
|
|
4
|
+
import { o as gt, D } from "./draw-c7b2705c.js";
|
|
5
|
+
import { d as Pe } from "./draw-c7b2705c.js";
|
|
6
|
+
import { F as d, L as P, D as g, f as B, s as ht, a as pt, c as dt, i as mt, S as C, l as Pt, p as wt, b as Mt, d as X, e as It } from "./Diagram-2450b2e6.js";
|
|
7
|
+
import { g as Me } from "./Diagram-2450b2e6.js";
|
|
8
|
+
import { r as St, z as bt, l as Lt, d as w, n as Y, s as E, a as vt, b as At, p as kt, c as j, L as S, A as b, e as M, t as Et, f as yt, B as Ft, E as Ct, Q as xt, C as Dt } from "./QuadraticBezier-e116a2d6.js";
|
|
9
|
+
import { s as Rt, a as Ot, b as Bt, c as $t, d as Gt, w as z } from "./wrapSVG-0ec8a111.js";
|
|
10
|
+
function I(t) {
|
|
11
|
+
if (t instanceof d)
|
|
7
12
|
return [t];
|
|
8
13
|
if (t instanceof P)
|
|
9
|
-
return [new
|
|
10
|
-
if (t instanceof
|
|
14
|
+
return [new d(t)];
|
|
15
|
+
if (t instanceof g)
|
|
11
16
|
return t.figures;
|
|
12
17
|
throw new Error("Unknown shape");
|
|
13
18
|
}
|
|
14
|
-
function
|
|
15
|
-
let
|
|
16
|
-
const r = [],
|
|
17
|
-
|
|
19
|
+
function tt(t, e, n = 1e-9) {
|
|
20
|
+
let s = [];
|
|
21
|
+
const r = [], i = new Array(e.segments.length).fill(0).map(() => []);
|
|
22
|
+
e.segments.forEach((c, f) => {
|
|
18
23
|
t.segments.forEach((a) => {
|
|
19
|
-
const { intersections: u, overlaps:
|
|
24
|
+
const { intersections: u, overlaps: m } = B(
|
|
20
25
|
c,
|
|
21
26
|
a,
|
|
22
|
-
|
|
27
|
+
n
|
|
23
28
|
);
|
|
24
|
-
|
|
25
|
-
const
|
|
29
|
+
s.push(...u), i[f].push(...u), r.push(...m);
|
|
30
|
+
const h = m.flatMap((l) => [
|
|
26
31
|
l.firstPoint,
|
|
27
32
|
l.lastPoint
|
|
28
33
|
]);
|
|
29
|
-
|
|
34
|
+
s.push(...h), i[f].push(...h);
|
|
30
35
|
});
|
|
31
|
-
}),
|
|
32
|
-
const o =
|
|
36
|
+
}), s = St(s, n);
|
|
37
|
+
const o = bt([e.segments, i]).flatMap(([c, f]) => f.length ? c.splitAt(f) : [c]);
|
|
33
38
|
return Array.from(
|
|
34
|
-
|
|
39
|
+
ht(
|
|
35
40
|
o,
|
|
36
|
-
|
|
41
|
+
s,
|
|
37
42
|
r
|
|
38
43
|
)
|
|
39
44
|
);
|
|
40
45
|
}
|
|
41
|
-
function
|
|
42
|
-
return
|
|
43
|
-
const
|
|
44
|
-
return
|
|
46
|
+
function $(t, e, n = !1) {
|
|
47
|
+
return tt(e, t).filter((r) => {
|
|
48
|
+
const i = r.segments[0].midPoint;
|
|
49
|
+
return e.onStroke(i) ? !n : !e.contains(i);
|
|
45
50
|
});
|
|
46
51
|
}
|
|
47
|
-
function G(t,
|
|
48
|
-
return
|
|
49
|
-
const
|
|
50
|
-
return
|
|
52
|
+
function G(t, e, n = !1) {
|
|
53
|
+
return tt(e, t).filter((r) => {
|
|
54
|
+
const i = r.segments[0].midPoint;
|
|
55
|
+
return e.onStroke(i) ? !n : e.contains(i);
|
|
51
56
|
});
|
|
52
57
|
}
|
|
53
|
-
function
|
|
54
|
-
const
|
|
58
|
+
function V(t, e, n = !1) {
|
|
59
|
+
const s = $(
|
|
55
60
|
t,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
), r =
|
|
59
|
-
(
|
|
61
|
+
e.contour,
|
|
62
|
+
n
|
|
63
|
+
), r = e.holes.flatMap(
|
|
64
|
+
(i) => G(t, i, n)
|
|
60
65
|
);
|
|
61
|
-
return [...
|
|
66
|
+
return [...s, ...r];
|
|
62
67
|
}
|
|
63
|
-
function _(t,
|
|
64
|
-
let
|
|
68
|
+
function _(t, e, n = !1) {
|
|
69
|
+
let s = G(
|
|
65
70
|
t,
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
e.contour,
|
|
72
|
+
n
|
|
68
73
|
);
|
|
69
|
-
return
|
|
70
|
-
|
|
71
|
-
(
|
|
74
|
+
return e.holes.forEach((r) => {
|
|
75
|
+
s = s.flatMap(
|
|
76
|
+
(i) => $(i, r, n)
|
|
72
77
|
);
|
|
73
|
-
}),
|
|
78
|
+
}), s;
|
|
74
79
|
}
|
|
75
|
-
function
|
|
76
|
-
return new
|
|
77
|
-
|
|
80
|
+
function Tt(t, e) {
|
|
81
|
+
return new g(
|
|
82
|
+
pt(I(t), I(e))
|
|
78
83
|
);
|
|
79
84
|
}
|
|
80
|
-
function
|
|
85
|
+
function y(t) {
|
|
81
86
|
return t.reduce(
|
|
82
|
-
(
|
|
83
|
-
new
|
|
87
|
+
(e, n) => Tt(e, n),
|
|
88
|
+
new g()
|
|
84
89
|
);
|
|
85
90
|
}
|
|
86
|
-
function
|
|
87
|
-
return new
|
|
88
|
-
|
|
91
|
+
function et(t, e) {
|
|
92
|
+
return new g(
|
|
93
|
+
dt(I(t), I(e))
|
|
89
94
|
);
|
|
90
95
|
}
|
|
91
|
-
function
|
|
92
|
-
return new
|
|
93
|
-
|
|
96
|
+
function oe(t, e) {
|
|
97
|
+
return new g(
|
|
98
|
+
mt(I(t), I(e))
|
|
94
99
|
);
|
|
95
100
|
}
|
|
96
|
-
function
|
|
97
|
-
if (
|
|
98
|
-
return
|
|
99
|
-
if (
|
|
100
|
-
return
|
|
101
|
-
let
|
|
102
|
-
return
|
|
103
|
-
|
|
104
|
-
}),
|
|
105
|
-
}
|
|
106
|
-
function
|
|
107
|
-
if (
|
|
108
|
-
return G(t,
|
|
109
|
-
if (
|
|
110
|
-
return _(t,
|
|
111
|
-
let
|
|
112
|
-
return
|
|
113
|
-
|
|
114
|
-
}),
|
|
115
|
-
}
|
|
116
|
-
function
|
|
101
|
+
function ae(t, e, n = !0) {
|
|
102
|
+
if (e instanceof P)
|
|
103
|
+
return $(t, e, n);
|
|
104
|
+
if (e instanceof d)
|
|
105
|
+
return V(t, e, n);
|
|
106
|
+
let s = [new C([...t.segments])];
|
|
107
|
+
return e.figures.forEach((r) => {
|
|
108
|
+
s = s.flatMap((i) => V(i, r, n));
|
|
109
|
+
}), s;
|
|
110
|
+
}
|
|
111
|
+
function ce(t, e, n = !1) {
|
|
112
|
+
if (e instanceof P)
|
|
113
|
+
return G(t, e, n);
|
|
114
|
+
if (e instanceof d)
|
|
115
|
+
return _(t, e, n);
|
|
116
|
+
let s = [new C([...t.segments])];
|
|
117
|
+
return e.figures.forEach((r) => {
|
|
118
|
+
s = s.flatMap((i) => _(i, r, n));
|
|
119
|
+
}), s;
|
|
120
|
+
}
|
|
121
|
+
function N(t) {
|
|
117
122
|
return t < 0 ? "before" : t > 1 ? "after" : "between";
|
|
118
123
|
}
|
|
119
|
-
const
|
|
120
|
-
if (
|
|
121
|
-
return t.distanceFrom(
|
|
122
|
-
if (
|
|
123
|
-
return t.distanceFrom(
|
|
124
|
+
const q = (t, e, n) => {
|
|
125
|
+
if (n === "before")
|
|
126
|
+
return t.distanceFrom(e.firstPoint);
|
|
127
|
+
if (n === "after")
|
|
128
|
+
return t.distanceFrom(e.lastPoint);
|
|
124
129
|
throw new Error("Invalid position");
|
|
125
130
|
};
|
|
126
|
-
function
|
|
127
|
-
const
|
|
128
|
-
if (
|
|
131
|
+
function Ut(t, e) {
|
|
132
|
+
const n = Lt(t, e);
|
|
133
|
+
if (n === "parallel")
|
|
129
134
|
return Math.min(
|
|
130
|
-
t.distanceFrom(
|
|
131
|
-
t.distanceFrom(
|
|
135
|
+
t.distanceFrom(e.firstPoint),
|
|
136
|
+
t.distanceFrom(e.lastPoint)
|
|
132
137
|
);
|
|
133
|
-
const { intersectionParam1:
|
|
134
|
-
if (
|
|
138
|
+
const { intersectionParam1: s, intersectionParam2: r } = n, i = N(s), o = N(r);
|
|
139
|
+
if (i === "between" && o === "between")
|
|
135
140
|
return 0;
|
|
136
|
-
if (
|
|
137
|
-
return
|
|
138
|
-
if (o === "between" &&
|
|
139
|
-
return
|
|
140
|
-
if (
|
|
141
|
-
return
|
|
142
|
-
if (
|
|
143
|
-
return
|
|
144
|
-
if (
|
|
145
|
-
return
|
|
146
|
-
if (
|
|
147
|
-
return
|
|
141
|
+
if (i === "between" && o !== "between")
|
|
142
|
+
return q(t, e, o);
|
|
143
|
+
if (o === "between" && i !== "between")
|
|
144
|
+
return q(e, t, i);
|
|
145
|
+
if (i === "before" && o === "before")
|
|
146
|
+
return w(t.firstPoint, e.firstPoint);
|
|
147
|
+
if (i === "after" && o === "after")
|
|
148
|
+
return w(t.lastPoint, e.lastPoint);
|
|
149
|
+
if (i === "before" && o === "after")
|
|
150
|
+
return w(t.firstPoint, e.lastPoint);
|
|
151
|
+
if (i === "after" && o === "before")
|
|
152
|
+
return w(t.lastPoint, e.firstPoint);
|
|
148
153
|
throw new Error("Invalid position");
|
|
149
154
|
}
|
|
150
|
-
function
|
|
151
|
-
if (
|
|
155
|
+
function J(t, e) {
|
|
156
|
+
if (Pt(t, e).length > 0)
|
|
152
157
|
return 0;
|
|
153
|
-
const
|
|
154
|
-
if (t.isOnSegment(
|
|
155
|
-
const
|
|
156
|
-
if (Math.abs(
|
|
158
|
+
const n = wt(t, e.center);
|
|
159
|
+
if (t.isOnSegment(n)) {
|
|
160
|
+
const s = w(n, e.center);
|
|
161
|
+
if (Math.abs(s - e.radius) < t.precision && e.isOnSegment(n))
|
|
157
162
|
return 0;
|
|
158
|
-
if (
|
|
159
|
-
const r =
|
|
160
|
-
E(
|
|
161
|
-
),
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
if (s - e.radius > t.precision) {
|
|
164
|
+
const r = Y(
|
|
165
|
+
E(n, e.center)
|
|
166
|
+
), i = vt(
|
|
167
|
+
e.center,
|
|
168
|
+
At(r, e.radius)
|
|
164
169
|
);
|
|
165
|
-
if (
|
|
166
|
-
return
|
|
170
|
+
if (e.isOnSegment(i))
|
|
171
|
+
return w(i, n);
|
|
167
172
|
}
|
|
168
173
|
}
|
|
169
174
|
return Math.min(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
t.distanceFrom(
|
|
173
|
-
t.distanceFrom(
|
|
175
|
+
e.distanceFrom(t.firstPoint),
|
|
176
|
+
e.distanceFrom(t.lastPoint),
|
|
177
|
+
t.distanceFrom(e.firstPoint),
|
|
178
|
+
t.distanceFrom(e.lastPoint)
|
|
174
179
|
);
|
|
175
180
|
}
|
|
176
|
-
const
|
|
177
|
-
const
|
|
178
|
-
if (t.isValidParameter(
|
|
181
|
+
const zt = (t, e) => {
|
|
182
|
+
const n = t.angleToParam(e.firstAngle);
|
|
183
|
+
if (t.isValidParameter(n))
|
|
179
184
|
return !0;
|
|
180
|
-
const
|
|
181
|
-
return !!t.isValidParameter(
|
|
185
|
+
const s = t.angleToParam(e.lastAngle);
|
|
186
|
+
return !!t.isValidParameter(s);
|
|
182
187
|
};
|
|
183
|
-
function
|
|
184
|
-
if (
|
|
188
|
+
function Vt(t, e) {
|
|
189
|
+
if (Mt(t, e, !0).length > 0)
|
|
185
190
|
return 0;
|
|
186
|
-
const
|
|
187
|
-
if (
|
|
188
|
-
return Math.abs(t.radius -
|
|
189
|
-
const
|
|
190
|
-
let
|
|
191
|
-
r &&
|
|
192
|
-
const o = r ?
|
|
193
|
-
return t.isValidParameter(c) &&
|
|
194
|
-
t.distanceFrom(
|
|
195
|
-
t.distanceFrom(
|
|
196
|
-
|
|
197
|
-
|
|
191
|
+
const n = w(t.center, e.center);
|
|
192
|
+
if (n < t.precision && zt(t, e))
|
|
193
|
+
return Math.abs(t.radius - e.radius);
|
|
194
|
+
const s = Y(E(e.center, t.center)), r = n - Math.abs(t.radius - e.radius) < t.precision;
|
|
195
|
+
let i = kt(s);
|
|
196
|
+
r && e.radius > t.radius && (i += Math.PI);
|
|
197
|
+
const o = r ? i : i + Math.PI, c = t.angleToParam(i), f = e.angleToParam(o);
|
|
198
|
+
return t.isValidParameter(c) && e.isValidParameter(f) ? w(t.paramPoint(c), e.paramPoint(f)) : Math.min(
|
|
199
|
+
t.distanceFrom(e.firstPoint),
|
|
200
|
+
t.distanceFrom(e.lastPoint),
|
|
201
|
+
e.distanceFrom(t.firstPoint),
|
|
202
|
+
e.distanceFrom(t.lastPoint)
|
|
198
203
|
);
|
|
199
204
|
}
|
|
200
|
-
function
|
|
201
|
-
let
|
|
202
|
-
for (;
|
|
203
|
-
const
|
|
205
|
+
function _t(t, e, n) {
|
|
206
|
+
let s = 0, r = t.length - 1;
|
|
207
|
+
for (; s <= r; ) {
|
|
208
|
+
const i = Math.floor((s + r) / 2), o = n(t[i], e);
|
|
204
209
|
if (o < 0)
|
|
205
|
-
|
|
210
|
+
s = i + 1;
|
|
206
211
|
else if (o > 0)
|
|
207
|
-
r =
|
|
212
|
+
r = i - 1;
|
|
208
213
|
else
|
|
209
|
-
return
|
|
214
|
+
return i;
|
|
210
215
|
}
|
|
211
|
-
return -(
|
|
216
|
+
return -(s + 1);
|
|
212
217
|
}
|
|
213
|
-
function
|
|
214
|
-
const
|
|
215
|
-
|
|
218
|
+
function Nt(t, e, n) {
|
|
219
|
+
const s = _t(t, e, n);
|
|
220
|
+
s < 0 ? t.splice(-(s + 1), 0, e) : t.splice(s, 0, e);
|
|
216
221
|
}
|
|
217
|
-
class
|
|
222
|
+
class qt {
|
|
218
223
|
constructor() {
|
|
224
|
+
p(this, "buckets");
|
|
219
225
|
this.buckets = [];
|
|
220
226
|
}
|
|
221
|
-
addInterval(
|
|
222
|
-
const
|
|
223
|
-
|
|
227
|
+
addInterval(e) {
|
|
228
|
+
const n = this.buckets[e.rectangle.diagonalBucketIndex];
|
|
229
|
+
n === void 0 ? this.buckets[e.rectangle.diagonalBucketIndex] = [e] : Nt(n, e, (s, r) => s.value - r.value);
|
|
224
230
|
}
|
|
225
|
-
removeInterval(
|
|
226
|
-
const
|
|
227
|
-
if (
|
|
231
|
+
removeInterval(e) {
|
|
232
|
+
const n = this.buckets[e.rectangle.diagonalBucketIndex];
|
|
233
|
+
if (n === void 0)
|
|
228
234
|
throw new Error("Interval not found");
|
|
229
|
-
|
|
235
|
+
n.shift();
|
|
230
236
|
}
|
|
231
237
|
getBottomRightHullIntervals() {
|
|
232
|
-
const
|
|
233
|
-
for (let
|
|
234
|
-
const
|
|
235
|
-
if (!
|
|
238
|
+
const e = [];
|
|
239
|
+
for (let n = this.buckets.length - 1; n >= 0; n--) {
|
|
240
|
+
const s = this.buckets[n];
|
|
241
|
+
if (!s === void 0)
|
|
236
242
|
continue;
|
|
237
|
-
const r =
|
|
243
|
+
const r = s[0];
|
|
238
244
|
if (r !== void 0) {
|
|
239
|
-
if (!
|
|
240
|
-
|
|
245
|
+
if (!e.length) {
|
|
246
|
+
e.push(r);
|
|
241
247
|
continue;
|
|
242
248
|
}
|
|
243
|
-
for (;
|
|
244
|
-
|
|
245
|
-
for (;
|
|
246
|
-
const
|
|
247
|
-
if (o.value + (
|
|
248
|
-
|
|
249
|
+
for (; e.length && e[e.length - 1].value >= r.value; )
|
|
250
|
+
e.pop();
|
|
251
|
+
for (; e.length >= 2; ) {
|
|
252
|
+
const i = e[e.length - 1], o = e[e.length - 2], c = (r.value - o.value) / ((r.rectangle.diagonal - o.rectangle.diagonal) * 2);
|
|
253
|
+
if (o.value + (i.rectangle.diagonal - o.rectangle.diagonal) / 2 * c < i.value)
|
|
254
|
+
e.pop();
|
|
249
255
|
else
|
|
250
256
|
break;
|
|
251
257
|
}
|
|
252
|
-
|
|
258
|
+
e.push(r);
|
|
253
259
|
}
|
|
254
260
|
}
|
|
255
|
-
return
|
|
261
|
+
return e;
|
|
256
262
|
}
|
|
257
263
|
}
|
|
258
|
-
class
|
|
259
|
-
constructor(
|
|
260
|
-
|
|
264
|
+
class Jt {
|
|
265
|
+
constructor(e, n) {
|
|
266
|
+
p(this, "diagonal");
|
|
267
|
+
p(this, "diagonalBucketIndex");
|
|
268
|
+
p(this, "xLength");
|
|
269
|
+
p(this, "yLength");
|
|
270
|
+
p(this, "index");
|
|
271
|
+
this.x = e, this.y = n, this.xLength = Math.pow(3, -e), this.yLength = Math.pow(3, -n), this.diagonal = Math.sqrt(
|
|
261
272
|
this.xLength * this.xLength + this.yLength * this.yLength
|
|
262
|
-
), this.diagonalBucketIndex =
|
|
273
|
+
), this.diagonalBucketIndex = e + n, this.index = `${e},${n}`;
|
|
263
274
|
}
|
|
264
275
|
}
|
|
265
|
-
class
|
|
266
|
-
constructor(
|
|
267
|
-
this
|
|
268
|
-
|
|
269
|
-
this
|
|
276
|
+
class Qt {
|
|
277
|
+
constructor(e, n = 1e-8, s = 1e3, r = 1e-6) {
|
|
278
|
+
p(this, "rectangles");
|
|
279
|
+
p(this, "buckets");
|
|
280
|
+
p(this, "fMin");
|
|
281
|
+
p(this, "argMin");
|
|
282
|
+
p(this, "tol");
|
|
283
|
+
this.fcn = e, this.endTolerance = n, this.maxIterations = s, this.epsilon = r, this.fcn = e, this.epsilon = r, this.endTolerance = n, this.maxIterations = s, this.rectangles = /* @__PURE__ */ new Map(), this.buckets = new qt();
|
|
284
|
+
const i = [0.5, 0.5], o = this.rect(0, 0), c = this.fcn(i);
|
|
285
|
+
this.buckets.addInterval(new k(i, c, o)), this.fMin = c, this.argMin = i, this.tol = o.diagonal;
|
|
270
286
|
}
|
|
271
|
-
registerInterval(
|
|
272
|
-
this.buckets.addInterval(
|
|
287
|
+
registerInterval(e) {
|
|
288
|
+
this.buckets.addInterval(e), e.value <= this.fMin && (this.fMin = e.value, this.argMin = e.center, this.tol = e.rectangle.diagonal);
|
|
273
289
|
}
|
|
274
|
-
rect(
|
|
275
|
-
const
|
|
276
|
-
return this.rectangles.has(
|
|
290
|
+
rect(e, n) {
|
|
291
|
+
const s = `${e},${n}`;
|
|
292
|
+
return this.rectangles.has(s) || this.rectangles.set(s, new Jt(e, n)), this.rectangles.get(s);
|
|
277
293
|
}
|
|
278
|
-
splitInterval(
|
|
279
|
-
let
|
|
280
|
-
const [
|
|
281
|
-
return
|
|
282
|
-
new k(
|
|
283
|
-
new k(
|
|
284
|
-
new k(r, this.fcn(r),
|
|
294
|
+
splitInterval(e) {
|
|
295
|
+
let n, s, r;
|
|
296
|
+
const [i, o] = e.center;
|
|
297
|
+
return e.rectangle.x <= e.rectangle.y ? (n = this.rect(e.rectangle.x + 1, e.rectangle.y), s = [i - n.xLength, o], r = [i + n.xLength, o]) : (n = this.rect(e.rectangle.x, e.rectangle.y + 1), s = [i, o - n.yLength], r = [i, o + n.yLength]), [
|
|
298
|
+
new k(s, this.fcn(s), n),
|
|
299
|
+
new k(e.center, e.value, n),
|
|
300
|
+
new k(r, this.fcn(r), n)
|
|
285
301
|
];
|
|
286
302
|
}
|
|
287
303
|
single_iteration() {
|
|
288
|
-
const
|
|
289
|
-
for (;
|
|
290
|
-
const
|
|
291
|
-
if ((this.fMin -
|
|
292
|
-
|
|
304
|
+
const e = this.buckets.getBottomRightHullIntervals();
|
|
305
|
+
for (; e.length >= 2; ) {
|
|
306
|
+
const n = e[0], s = e[1], r = (s.value - n.value) / ((s.rectangle.diagonal - n.rectangle.diagonal) / 2), i = n.value - r * s.value / 2;
|
|
307
|
+
if ((this.fMin - i) / Math.abs(this.fMin) < this.epsilon)
|
|
308
|
+
e.shift();
|
|
293
309
|
else
|
|
294
310
|
break;
|
|
295
311
|
}
|
|
296
|
-
|
|
297
|
-
this.buckets.removeInterval(
|
|
312
|
+
e.forEach((n) => {
|
|
313
|
+
this.buckets.removeInterval(n);
|
|
298
314
|
});
|
|
299
|
-
for (const
|
|
300
|
-
const [
|
|
301
|
-
this.registerInterval(
|
|
315
|
+
for (const n of e) {
|
|
316
|
+
const [s, r, i] = this.splitInterval(n);
|
|
317
|
+
this.registerInterval(s), this.registerInterval(r), this.registerInterval(i);
|
|
302
318
|
}
|
|
303
319
|
}
|
|
304
320
|
run() {
|
|
305
|
-
let
|
|
306
|
-
for (; this.tol > this.endTolerance / 2 && (this.single_iteration(),
|
|
321
|
+
let e = 0;
|
|
322
|
+
for (; this.tol > this.endTolerance / 2 && (this.single_iteration(), e++, !(e > this.maxIterations)); )
|
|
307
323
|
;
|
|
308
324
|
return {
|
|
309
325
|
fMin: this.fMin,
|
|
310
326
|
argMin: this.argMin,
|
|
311
327
|
tol: this.tol,
|
|
312
|
-
iterations:
|
|
328
|
+
iterations: e
|
|
313
329
|
};
|
|
314
330
|
}
|
|
315
331
|
}
|
|
316
332
|
class k {
|
|
317
|
-
constructor(
|
|
318
|
-
this.center =
|
|
333
|
+
constructor(e, n, s) {
|
|
334
|
+
this.center = e, this.value = n, this.rectangle = s;
|
|
319
335
|
}
|
|
320
336
|
}
|
|
321
|
-
function
|
|
322
|
-
return new
|
|
337
|
+
function Zt(t, e = 1e-8, n = 1e3, s = 1e-6) {
|
|
338
|
+
return new Qt(
|
|
323
339
|
t,
|
|
324
|
-
n,
|
|
325
340
|
e,
|
|
326
|
-
|
|
341
|
+
n,
|
|
342
|
+
s
|
|
327
343
|
).run();
|
|
328
344
|
}
|
|
329
|
-
function
|
|
330
|
-
const
|
|
331
|
-
const
|
|
332
|
-
return j(
|
|
333
|
-
},
|
|
334
|
-
return Math.sqrt(
|
|
345
|
+
function Ht(t, e, n = 1e-9) {
|
|
346
|
+
const s = Zt((r) => {
|
|
347
|
+
const i = t.paramPoint(r[0]), o = e.paramPoint(r[1]);
|
|
348
|
+
return j(i, o);
|
|
349
|
+
}, n);
|
|
350
|
+
return Math.sqrt(s.fMin);
|
|
335
351
|
}
|
|
336
|
-
function
|
|
337
|
-
return t instanceof
|
|
352
|
+
function Wt(t, e) {
|
|
353
|
+
return t instanceof S && e instanceof S ? Ut(t, e) : t instanceof S && e instanceof b ? J(t, e) : t instanceof b && e instanceof S ? J(e, t) : t instanceof b && e instanceof b ? Vt(t, e) : Ht(t, e);
|
|
338
354
|
}
|
|
339
355
|
const T = 1e-8;
|
|
340
|
-
function
|
|
341
|
-
const
|
|
342
|
-
offset:
|
|
356
|
+
function R(t, e, n = !0) {
|
|
357
|
+
const s = t.map((a) => ({
|
|
358
|
+
offset: gt(a, e),
|
|
343
359
|
original: a
|
|
344
360
|
})), r = [];
|
|
345
|
-
let
|
|
361
|
+
let i = n ? null : s.at(-1), o = n ? s.at(-1) : null;
|
|
346
362
|
if (r.length === 1)
|
|
347
363
|
return r;
|
|
348
364
|
const c = (a) => {
|
|
349
|
-
|
|
350
|
-
new
|
|
351
|
-
) : r.push(a.offset) :
|
|
365
|
+
i ? a.offset instanceof D ? M(a.offset.firstPoint, a.offset.lastPoint) || r.push(
|
|
366
|
+
new S(a.offset.firstPoint, a.offset.lastPoint)
|
|
367
|
+
) : r.push(a.offset) : i = a;
|
|
352
368
|
}, f = function* () {
|
|
353
|
-
for (const a of
|
|
369
|
+
for (const a of s.slice(0, -1))
|
|
354
370
|
yield a;
|
|
355
|
-
if (!
|
|
371
|
+
if (!i)
|
|
356
372
|
throw new Error("Bug in the offset algorithm");
|
|
357
|
-
yield
|
|
373
|
+
yield i;
|
|
358
374
|
};
|
|
359
375
|
for (const a of f()) {
|
|
360
376
|
if (!o) {
|
|
361
377
|
o = a;
|
|
362
378
|
continue;
|
|
363
379
|
}
|
|
364
|
-
const u = o.offset.lastPoint,
|
|
365
|
-
if (
|
|
380
|
+
const u = o.offset.lastPoint, m = a.offset.firstPoint;
|
|
381
|
+
if (M(u, m)) {
|
|
366
382
|
c(o), o = a;
|
|
367
383
|
continue;
|
|
368
384
|
}
|
|
369
|
-
let
|
|
385
|
+
let h = [];
|
|
370
386
|
if (!(o.offset instanceof D) && !(a.offset instanceof D)) {
|
|
371
|
-
const { intersections:
|
|
387
|
+
const { intersections: L, overlaps: x } = B(
|
|
372
388
|
o.offset,
|
|
373
389
|
a.offset,
|
|
374
390
|
T / 100
|
|
375
391
|
);
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
...
|
|
392
|
+
h = [
|
|
393
|
+
...L,
|
|
394
|
+
...x.flatMap((v) => [v.firstPoint, v.lastPoint])
|
|
379
395
|
];
|
|
380
396
|
}
|
|
381
|
-
if (
|
|
382
|
-
let
|
|
383
|
-
if (
|
|
384
|
-
const
|
|
385
|
-
(
|
|
397
|
+
if (h.length > 0) {
|
|
398
|
+
let L = h[0];
|
|
399
|
+
if (h.length > 1) {
|
|
400
|
+
const ct = o == null ? void 0 : o.original.lastPoint, U = h.map(
|
|
401
|
+
(ft) => j(ft, ct)
|
|
386
402
|
);
|
|
387
|
-
|
|
403
|
+
L = h[U.indexOf(Math.min(...U))];
|
|
388
404
|
}
|
|
389
|
-
const
|
|
390
|
-
|
|
391
|
-
])[0],
|
|
392
|
-
if (!
|
|
405
|
+
const x = o.offset.splitAt([
|
|
406
|
+
L
|
|
407
|
+
])[0], v = a.offset.splitAt([L]).at(-1);
|
|
408
|
+
if (!v)
|
|
393
409
|
throw new Error("Bug in the splitting algo in offset");
|
|
394
410
|
c({
|
|
395
|
-
offset:
|
|
411
|
+
offset: x,
|
|
396
412
|
original: o.original
|
|
397
|
-
}), o = { offset:
|
|
413
|
+
}), o = { offset: v, original: a.original };
|
|
398
414
|
continue;
|
|
399
415
|
}
|
|
400
|
-
const l = o.original.lastPoint,
|
|
401
|
-
E(
|
|
416
|
+
const l = o.original.lastPoint, A = yt(
|
|
417
|
+
E(m, l),
|
|
402
418
|
E(u, l)
|
|
403
|
-
) > 0,
|
|
404
|
-
c(o), r.push(
|
|
419
|
+
) > 0, at = new b(u, m, l, A);
|
|
420
|
+
c(o), r.push(at), o = a;
|
|
405
421
|
}
|
|
406
422
|
return o && c(o), r;
|
|
407
423
|
}
|
|
408
|
-
function
|
|
409
|
-
const
|
|
410
|
-
const
|
|
411
|
-
|
|
424
|
+
function nt(t) {
|
|
425
|
+
const e = /* @__PURE__ */ new Map(), n = (s, r) => {
|
|
426
|
+
const i = e.get(s) || [];
|
|
427
|
+
e.set(s, [...i, ...r]);
|
|
412
428
|
};
|
|
413
|
-
return t.forEach((
|
|
414
|
-
t.slice(r + 1).forEach((
|
|
415
|
-
const { intersections: c, overlaps: f } =
|
|
429
|
+
return t.forEach((s, r) => {
|
|
430
|
+
t.slice(r + 1).forEach((i, o) => {
|
|
431
|
+
const { intersections: c, overlaps: f } = B(s, i, T), a = [
|
|
416
432
|
...c,
|
|
417
433
|
...f.flatMap((u) => [u.firstPoint, u.lastPoint])
|
|
418
434
|
].filter((u) => {
|
|
419
|
-
const
|
|
420
|
-
return !(
|
|
435
|
+
const m = M(u, s.firstPoint) || M(u, s.lastPoint), h = M(u, i.firstPoint) || M(u, i.lastPoint);
|
|
436
|
+
return !(m && h);
|
|
421
437
|
});
|
|
422
|
-
a.length && (
|
|
438
|
+
a.length && (n(r, a), n(o + r + 1, a));
|
|
423
439
|
});
|
|
424
|
-
}),
|
|
425
|
-
}
|
|
426
|
-
function
|
|
427
|
-
return
|
|
428
|
-
if (!t.has(
|
|
429
|
-
return
|
|
430
|
-
const r = t.get(
|
|
431
|
-
return r ?
|
|
440
|
+
}), e;
|
|
441
|
+
}
|
|
442
|
+
function st(t, e) {
|
|
443
|
+
return e.flatMap((n, s) => {
|
|
444
|
+
if (!t.has(s))
|
|
445
|
+
return n;
|
|
446
|
+
const r = t.get(s);
|
|
447
|
+
return r ? n.splitAt(r) : n;
|
|
432
448
|
});
|
|
433
449
|
}
|
|
434
|
-
function
|
|
435
|
-
return t.filter((
|
|
450
|
+
function it(t, e, n) {
|
|
451
|
+
return t.filter((s) => !e.segments.some((i) => Wt(i, s) < Math.abs(n) - T));
|
|
436
452
|
}
|
|
437
|
-
function
|
|
438
|
-
const
|
|
439
|
-
if (
|
|
440
|
-
return new
|
|
441
|
-
const r =
|
|
453
|
+
function F(t, e) {
|
|
454
|
+
const n = t.clockwise ? e : -e, s = R(t.segments, n);
|
|
455
|
+
if (s.length < 2)
|
|
456
|
+
return new g();
|
|
457
|
+
const r = nt(s);
|
|
442
458
|
if (!r.size) {
|
|
443
|
-
const a = new P(
|
|
444
|
-
return new
|
|
459
|
+
const a = new P(s);
|
|
460
|
+
return new g([new d(a)]);
|
|
445
461
|
}
|
|
446
|
-
const
|
|
462
|
+
const i = st(
|
|
447
463
|
r,
|
|
448
|
-
|
|
449
|
-
), o =
|
|
464
|
+
s
|
|
465
|
+
), o = it(i, t, e);
|
|
450
466
|
if (!o.length)
|
|
451
|
-
return new
|
|
452
|
-
const f =
|
|
453
|
-
return f.length ? new
|
|
467
|
+
return new g();
|
|
468
|
+
const f = X(o).filter((a) => a.length > 1).filter((a) => M(a[0].firstPoint, a.at(-1).lastPoint)).map((a) => new P(a));
|
|
469
|
+
return f.length ? new g(f.map((a) => new d(a))) : new g();
|
|
454
470
|
}
|
|
455
|
-
function
|
|
456
|
-
const
|
|
471
|
+
function Kt(t, e, n = "round") {
|
|
472
|
+
const s = e / 2, r = R(t.segments, s, !1), i = R(t.segments, -s, !1).map(
|
|
457
473
|
(l) => l.reverse()
|
|
458
474
|
);
|
|
459
|
-
|
|
460
|
-
const o = (l,
|
|
475
|
+
i.reverse();
|
|
476
|
+
const o = (l, A) => n === "round" ? Et(
|
|
461
477
|
l.lastPoint,
|
|
462
|
-
|
|
478
|
+
A.firstPoint,
|
|
463
479
|
l.tangentAtLastPoint
|
|
464
|
-
) : new
|
|
480
|
+
) : new S(l.lastPoint, A.firstPoint), c = [
|
|
465
481
|
...r,
|
|
466
482
|
o(
|
|
467
483
|
r[r.length - 1],
|
|
468
|
-
|
|
484
|
+
i[0]
|
|
469
485
|
),
|
|
470
|
-
...
|
|
486
|
+
...i,
|
|
471
487
|
o(
|
|
472
|
-
|
|
488
|
+
i[i.length - 1],
|
|
473
489
|
r[0]
|
|
474
490
|
)
|
|
475
|
-
], f =
|
|
491
|
+
], f = nt(c);
|
|
476
492
|
if (!f.size) {
|
|
477
493
|
const l = new P(c);
|
|
478
|
-
return new
|
|
494
|
+
return new g([new d(l)]);
|
|
479
495
|
}
|
|
480
|
-
const a =
|
|
496
|
+
const a = st(
|
|
481
497
|
f,
|
|
482
498
|
c
|
|
483
|
-
), u =
|
|
499
|
+
), u = it(a, t, s);
|
|
484
500
|
if (!u.length)
|
|
485
|
-
return new
|
|
486
|
-
const
|
|
487
|
-
return
|
|
488
|
-
}
|
|
489
|
-
function
|
|
490
|
-
const
|
|
491
|
-
const r =
|
|
492
|
-
|
|
501
|
+
return new g();
|
|
502
|
+
const h = X(u).filter((l) => l.length > 1).filter((l) => M(l[0].firstPoint, l.at(-1).lastPoint)).map((l) => new P(l));
|
|
503
|
+
return h.length ? new g(h.map((l) => new d(l))) : new g();
|
|
504
|
+
}
|
|
505
|
+
function Xt(t, e) {
|
|
506
|
+
const n = t.map((s) => {
|
|
507
|
+
const r = y(
|
|
508
|
+
s.holes.map((i) => F(i, e))
|
|
493
509
|
);
|
|
494
|
-
return
|
|
510
|
+
return et(F(s.contour, e), r);
|
|
495
511
|
});
|
|
496
|
-
return
|
|
512
|
+
return y(n);
|
|
497
513
|
}
|
|
498
|
-
function
|
|
499
|
-
const
|
|
500
|
-
(r) =>
|
|
501
|
-
r.allLoops.map((
|
|
514
|
+
function Yt(t, e) {
|
|
515
|
+
const n = Math.abs(e / 2), s = t.map(
|
|
516
|
+
(r) => y(
|
|
517
|
+
r.allLoops.map((i) => et(F(i, n), F(i, -n)))
|
|
502
518
|
)
|
|
503
519
|
);
|
|
504
|
-
return
|
|
505
|
-
}
|
|
506
|
-
function an(t, n) {
|
|
507
|
-
return Ht(S(t), n);
|
|
508
|
-
}
|
|
509
|
-
function cn(t, n, { endCap: e = "round" } = {}) {
|
|
510
|
-
return t instanceof C ? Jt(t, n, e) : Wt(S(t), n);
|
|
511
|
-
}
|
|
512
|
-
function w([t, n]) {
|
|
513
|
-
return `${t} ${n}`;
|
|
514
|
-
}
|
|
515
|
-
function U(t) {
|
|
516
|
-
if (t instanceof M)
|
|
517
|
-
return `L ${w(t.lastPoint)}`;
|
|
518
|
-
if (t instanceof v)
|
|
519
|
-
return `A ${t.radius} ${t.radius} 0 ${t.angularLength > Math.PI ? "1" : "0"} ${t.clockwise ? "0" : "1"} ${w(t.lastPoint)}`;
|
|
520
|
-
if (t instanceof nt)
|
|
521
|
-
return `A ${t.majorRadius} ${t.minorRadius} ${t.tiltAngle * Dt} ${t.deltaAngle > Math.PI ? "1" : "0"} ${t.clockwise ? "0" : "1"} ${w(t.lastPoint)}`;
|
|
522
|
-
if (t instanceof et)
|
|
523
|
-
return `Q ${[
|
|
524
|
-
w(t.controlPoint),
|
|
525
|
-
w(t.lastPoint)
|
|
526
|
-
].join(" ")}`;
|
|
527
|
-
if (t instanceof it)
|
|
528
|
-
return `C ${[
|
|
529
|
-
w(t.firstControlPoint),
|
|
530
|
-
w(t.lastControlPoint),
|
|
531
|
-
w(t.lastPoint)
|
|
532
|
-
].join(" ")}`;
|
|
533
|
-
throw new Error("Unknown segment type");
|
|
520
|
+
return y(s);
|
|
534
521
|
}
|
|
535
|
-
function
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
</g>`;
|
|
547
|
-
}
|
|
548
|
-
function Yt(t) {
|
|
549
|
-
const n = `M ${t.firstPoint.join(" ")}`, e = t.segments.map(U).join(" ");
|
|
550
|
-
return `${n} ${e}`;
|
|
551
|
-
}
|
|
552
|
-
function Kt(t, n = 1) {
|
|
553
|
-
const e = t.xMin - n, i = t.yMin - n;
|
|
554
|
-
return `${e} ${i} ${t.width + 2 * n} ${t.height + 2 * n}`;
|
|
555
|
-
}
|
|
556
|
-
function Z(t, n, e = 1, i) {
|
|
557
|
-
const r = Kt(n, e), s = i ? `width="${n.width + 2 * e}${i}" height="${n.height + 2 * e}${i}"` : "";
|
|
558
|
-
return `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
559
|
-
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="${r}" fill="none" stroke="black" stroke-width="0.2%" vector-effect="non-scaling-stroke" ${s}>
|
|
560
|
-
${t}
|
|
561
|
-
</svg>`;
|
|
562
|
-
}
|
|
563
|
-
function J(t) {
|
|
564
|
-
if (t instanceof h)
|
|
565
|
-
return Xt(t);
|
|
566
|
-
if (t instanceof p)
|
|
567
|
-
return lt(t);
|
|
522
|
+
function fe(t, e) {
|
|
523
|
+
return Xt(I(t), e);
|
|
524
|
+
}
|
|
525
|
+
function le(t, e, { endCap: n = "round" } = {}) {
|
|
526
|
+
return t instanceof C ? Kt(t, e, n) : Yt(I(t), e);
|
|
527
|
+
}
|
|
528
|
+
function Q(t) {
|
|
529
|
+
if (t instanceof g)
|
|
530
|
+
return Rt(t);
|
|
531
|
+
if (t instanceof d)
|
|
532
|
+
return Ot(t);
|
|
568
533
|
if (t instanceof P)
|
|
569
|
-
return `<path d="${
|
|
534
|
+
return `<path d="${Bt(t)}" />`;
|
|
570
535
|
if (t instanceof C)
|
|
571
|
-
return `<path d="${
|
|
572
|
-
if (
|
|
573
|
-
return `<path d="${`M ${t.firstPoint.join(" ")}`} ${
|
|
536
|
+
return `<path d="${$t(t)}" />`;
|
|
537
|
+
if (It(t))
|
|
538
|
+
return `<path d="${`M ${t.firstPoint.join(" ")}`} ${Gt(
|
|
574
539
|
t
|
|
575
540
|
)}" />`;
|
|
576
541
|
throw new Error("Unknown shape type");
|
|
577
542
|
}
|
|
578
|
-
const
|
|
543
|
+
const Z = (t) => "shape" in t ? t.shape : t, H = (t, e) => {
|
|
579
544
|
if (!("shape" in t))
|
|
580
|
-
return
|
|
581
|
-
const { color:
|
|
582
|
-
return
|
|
583
|
-
},
|
|
584
|
-
function
|
|
585
|
-
margin:
|
|
586
|
-
unit:
|
|
587
|
-
viewBox:
|
|
545
|
+
return e;
|
|
546
|
+
const { color: n } = t;
|
|
547
|
+
return n ? `<g stroke="${n}">${e}</g>` : e;
|
|
548
|
+
}, W = (t) => new Ft(t.xMin, -t.yMax, t.xMax, -t.yMin);
|
|
549
|
+
function ue(t, {
|
|
550
|
+
margin: e = 1,
|
|
551
|
+
unit: n = null,
|
|
552
|
+
viewBox: s
|
|
588
553
|
} = {}) {
|
|
589
554
|
if (Array.isArray(t)) {
|
|
590
|
-
const
|
|
591
|
-
`), c =
|
|
592
|
-
return
|
|
555
|
+
const i = t.map((f) => Z(f).mirror()), o = i.map((f, a) => H(t[a], Q(f))).join(`
|
|
556
|
+
`), c = i.slice(1).reduce((f, a) => f.merge(a.boundingBox), i[0].boundingBox);
|
|
557
|
+
return z(o, s ? W(s) : c, e, n);
|
|
593
558
|
}
|
|
594
|
-
const r =
|
|
595
|
-
return
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
559
|
+
const r = Z(t).mirror();
|
|
560
|
+
return z(
|
|
561
|
+
H(t, Q(r)),
|
|
562
|
+
s ? W(s) : r.boundingBox,
|
|
563
|
+
e,
|
|
564
|
+
n
|
|
600
565
|
);
|
|
601
566
|
}
|
|
602
|
-
const
|
|
567
|
+
const rt = (t) => {
|
|
603
568
|
if (t.type === "LINE")
|
|
604
|
-
return new
|
|
569
|
+
return new S(t.firstPoint, t.lastPoint);
|
|
605
570
|
if (t.type === "ARC")
|
|
606
|
-
return new
|
|
571
|
+
return new b(
|
|
607
572
|
t.firstPoint,
|
|
608
573
|
t.lastPoint,
|
|
609
574
|
t.center,
|
|
610
575
|
t.clockwise
|
|
611
576
|
);
|
|
612
577
|
if (t.type === "ELLIPSE_ARC")
|
|
613
|
-
return new
|
|
578
|
+
return new Ct(
|
|
614
579
|
t.firstPoint,
|
|
615
580
|
t.lastPoint,
|
|
616
581
|
t.center,
|
|
@@ -621,66 +586,66 @@ const ut = (t) => {
|
|
|
621
586
|
{ angleUnits: "rad" }
|
|
622
587
|
);
|
|
623
588
|
if (t.type === "QUADRATIC_BEZIER")
|
|
624
|
-
return new
|
|
589
|
+
return new xt(
|
|
625
590
|
t.firstPoint,
|
|
626
591
|
t.lastPoint,
|
|
627
592
|
t.controlPoint
|
|
628
593
|
);
|
|
629
594
|
if (t.type === "CUBIC_BEZIER")
|
|
630
|
-
return new
|
|
595
|
+
return new Dt(
|
|
631
596
|
t.firstPoint,
|
|
632
597
|
t.lastPoint,
|
|
633
598
|
t.firstControlPoint,
|
|
634
599
|
t.lastControlPoint
|
|
635
600
|
);
|
|
636
601
|
throw new Error("Unknown segment type");
|
|
637
|
-
},
|
|
638
|
-
const
|
|
639
|
-
return new P(
|
|
640
|
-
},
|
|
641
|
-
const
|
|
642
|
-
return new
|
|
602
|
+
}, O = (t) => {
|
|
603
|
+
const e = t.segments.map(rt);
|
|
604
|
+
return new P(e);
|
|
605
|
+
}, ot = (t) => {
|
|
606
|
+
const e = O(t.contour), n = t.holes.map(O);
|
|
607
|
+
return new d(e, n);
|
|
643
608
|
}, jt = (t) => {
|
|
644
|
-
const
|
|
645
|
-
return new
|
|
609
|
+
const e = t.figures.map(ot);
|
|
610
|
+
return new g(e);
|
|
646
611
|
};
|
|
647
|
-
function
|
|
612
|
+
function ge(t) {
|
|
648
613
|
if (t.type === "DIAGRAM")
|
|
649
614
|
return jt(t);
|
|
650
615
|
if (t.type === "FIGURE")
|
|
651
|
-
return
|
|
616
|
+
return ot(t);
|
|
652
617
|
if (t.type === "LOOP")
|
|
653
|
-
return
|
|
618
|
+
return O(t);
|
|
654
619
|
if (t.type === "LINE" || t.type === "ARC" || t.type === "ELLIPSE_ARC" || t.type === "CUBIC_BEZIER")
|
|
655
|
-
return
|
|
620
|
+
return rt(t);
|
|
656
621
|
throw new Error("Unknown shape type");
|
|
657
622
|
}
|
|
658
|
-
const
|
|
659
|
-
function
|
|
660
|
-
const
|
|
661
|
-
return [
|
|
623
|
+
const K = Math.PI / 180, te = 180 / Math.PI;
|
|
624
|
+
function he(t, e) {
|
|
625
|
+
const n = Math.cos(e * K) * t, s = Math.sin(e * K) * t;
|
|
626
|
+
return [n, s];
|
|
662
627
|
}
|
|
663
|
-
function
|
|
664
|
-
const
|
|
665
|
-
return [
|
|
628
|
+
function pe([t, e]) {
|
|
629
|
+
const n = Math.sqrt(t * t + e * e), s = Math.atan2(e, t) * te;
|
|
630
|
+
return [n, s];
|
|
666
631
|
}
|
|
667
632
|
export {
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
633
|
+
K as DEG2RAD,
|
|
634
|
+
te as RAD2DEG,
|
|
635
|
+
pe as cartesianToPolar,
|
|
636
|
+
ce as confineStrand,
|
|
637
|
+
et as cut,
|
|
638
|
+
Pe as draw,
|
|
639
|
+
ae as eraseStrand,
|
|
640
|
+
Me as exportJSON,
|
|
641
|
+
ue as exportSVG,
|
|
642
|
+
Tt as fuse,
|
|
643
|
+
y as fuseAll,
|
|
644
|
+
ge as importJSON,
|
|
645
|
+
oe as intersect,
|
|
646
|
+
fe as offset,
|
|
647
|
+
le as outlineStroke,
|
|
648
|
+
he as polarToCartesian,
|
|
649
|
+
Q as svgBody
|
|
685
650
|
};
|
|
686
651
|
//# sourceMappingURL=pantograph.js.map
|