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