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