@oh-just-another/scene 0.58.0 → 0.60.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/CHANGELOG.md +57 -0
- package/README.md +36 -21
- package/dist/.tsbuildinfo +1 -1
- package/dist/anchors.d.ts.map +1 -1
- package/dist/anchors.js +2 -1
- package/dist/anchors.js.map +1 -1
- package/dist/brush-outline.d.ts +21 -0
- package/dist/brush-outline.d.ts.map +1 -0
- package/dist/brush-outline.js +142 -0
- package/dist/brush-outline.js.map +1 -0
- package/dist/constants.d.ts +78 -8
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +78 -8
- package/dist/constants.js.map +1 -1
- package/dist/edge-curve.d.ts +1 -3
- package/dist/edge-curve.d.ts.map +1 -1
- package/dist/edge-curve.js +3 -18
- package/dist/edge-curve.js.map +1 -1
- package/dist/edge-geometry.d.ts +18 -3
- package/dist/edge-geometry.d.ts.map +1 -1
- package/dist/edge-geometry.js +29 -47
- package/dist/edge-geometry.js.map +1 -1
- package/dist/edge.d.ts +19 -8
- package/dist/edge.d.ts.map +1 -1
- package/dist/edge.js +17 -1
- package/dist/edge.js.map +1 -1
- package/dist/elbow-link.d.ts +2 -2
- package/dist/elbow-link.d.ts.map +1 -1
- package/dist/elbow-link.js +4 -8
- package/dist/elbow-link.js.map +1 -1
- package/dist/elbow-router.d.ts +1 -1
- package/dist/elbow-router.d.ts.map +1 -1
- package/dist/elbow-router.js +1 -5
- package/dist/elbow-router.js.map +1 -1
- package/dist/ellipse.d.ts +8 -0
- package/dist/ellipse.d.ts.map +1 -0
- package/dist/ellipse.js +10 -0
- package/dist/ellipse.js.map +1 -0
- package/dist/heading.d.ts +4 -4
- package/dist/heading.js +2 -2
- package/dist/hydrate.d.ts +46 -0
- package/dist/hydrate.d.ts.map +1 -0
- package/dist/hydrate.js +59 -0
- package/dist/hydrate.js.map +1 -0
- package/dist/index.d.ts +14 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -5
- package/dist/index.js.map +1 -1
- package/dist/layout.d.ts +1 -6
- package/dist/layout.d.ts.map +1 -1
- package/dist/layout.js +15 -21
- package/dist/layout.js.map +1 -1
- package/dist/order.d.ts +10 -0
- package/dist/order.d.ts.map +1 -0
- package/dist/order.js +5 -0
- package/dist/order.js.map +1 -0
- package/dist/outline.d.ts +1 -1
- package/dist/outline.d.ts.map +1 -1
- package/dist/outline.js +11 -24
- package/dist/outline.js.map +1 -1
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +11 -24
- package/dist/queries.js.map +1 -1
- package/dist/scene.d.ts +7 -1
- package/dist/scene.d.ts.map +1 -1
- package/dist/scene.js +15 -2
- package/dist/scene.js.map +1 -1
- package/dist/shape-transform.d.ts +14 -0
- package/dist/shape-transform.d.ts.map +1 -0
- package/dist/shape-transform.js +33 -0
- package/dist/shape-transform.js.map +1 -0
- package/dist/shape.d.ts +52 -8
- package/dist/shape.d.ts.map +1 -1
- package/dist/shape.js +8 -0
- package/dist/shape.js.map +1 -1
- package/dist/snap.d.ts +2 -2
- package/dist/snap.js +5 -5
- package/dist/snap.js.map +1 -1
- package/dist/style.d.ts +2 -2
- package/dist/text-runs.d.ts +44 -0
- package/dist/text-runs.d.ts.map +1 -0
- package/dist/text-runs.js +139 -0
- package/dist/text-runs.js.map +1 -0
- package/dist/viewport.d.ts +16 -30
- package/dist/viewport.d.ts.map +1 -1
- package/dist/viewport.js +6 -13
- package/dist/viewport.js.map +1 -1
- package/package.json +5 -4
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { vec2 } from "@oh-just-another/math";
|
|
2
|
+
import { req } from "@oh-just-another/types";
|
|
3
|
+
import { BRUSH_OUTLINE_ARC_STEP, BRUSH_OUTLINE_MITER_LIMIT } from "./constants.js";
|
|
4
|
+
/**
|
|
5
|
+
* The single closed outline polygon of a variable-width brush stroke: the left
|
|
6
|
+
* offset side forward, a round end cap, the right offset side back, a round start
|
|
7
|
+
* cap. Filling this ONE simple polygon (nonzero winding) paints every pixel
|
|
8
|
+
* exactly once — unlike per-segment quads + joint discs, whose overlaps
|
|
9
|
+
* double-blend at `opacity < 1` (dark blotches at the joins).
|
|
10
|
+
*
|
|
11
|
+
* Round joins/caps are approximated by arc points at {@link BRUSH_OUTLINE_ARC_STEP}
|
|
12
|
+
* spacing. Convex corners round outward with an arc; concave corners take the
|
|
13
|
+
* miter (offset-line intersection), clamped to {@link BRUSH_OUTLINE_MITER_LIMIT}
|
|
14
|
+
* half-widths (bevel beyond that) so the polygon stays simple — the WebGL2 earcut
|
|
15
|
+
* fill needs a non-self-intersecting boundary.
|
|
16
|
+
*
|
|
17
|
+
* `points` carry per-vertex half-width. Returns `[]` for `< 2` points (callers
|
|
18
|
+
* draw a single dot as an ellipse). Output is a closed loop in the same local
|
|
19
|
+
* space as `points` (no duplicated closing point; the caller closes the path).
|
|
20
|
+
*/
|
|
21
|
+
export const brushOutline = (points) => {
|
|
22
|
+
const n = points.length;
|
|
23
|
+
if (n < 2)
|
|
24
|
+
return [];
|
|
25
|
+
const pos = (i) => {
|
|
26
|
+
const q = req(points[i]);
|
|
27
|
+
return { x: q.x, y: q.y };
|
|
28
|
+
};
|
|
29
|
+
const halfWidth = (i) => req(points[i]).width;
|
|
30
|
+
// Per-segment unit direction and LEFT normal (perp = (-dy, dx)).
|
|
31
|
+
const dir = [];
|
|
32
|
+
const nrm = [];
|
|
33
|
+
for (let i = 0; i < n - 1; i++) {
|
|
34
|
+
const raw = vec2.sub(pos(i + 1), pos(i));
|
|
35
|
+
const d = vec2.lengthSq(raw) > 0 ? vec2.normalize(raw) : { x: 1, y: 0 };
|
|
36
|
+
dir.push(d);
|
|
37
|
+
nrm.push(vec2.perp(d));
|
|
38
|
+
}
|
|
39
|
+
const left = [];
|
|
40
|
+
const right = [];
|
|
41
|
+
for (let i = 0; i < n; i++) {
|
|
42
|
+
const w = halfWidth(i);
|
|
43
|
+
const c = pos(i);
|
|
44
|
+
if (i === 0) {
|
|
45
|
+
const nn = req(nrm[0]);
|
|
46
|
+
left.push(vec2.add(c, vec2.mul(nn, w)));
|
|
47
|
+
right.push(vec2.sub(c, vec2.mul(nn, w)));
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (i === n - 1) {
|
|
51
|
+
const nn = req(nrm[n - 2]);
|
|
52
|
+
left.push(vec2.add(c, vec2.mul(nn, w)));
|
|
53
|
+
right.push(vec2.sub(c, vec2.mul(nn, w)));
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const nPrev = req(nrm[i - 1]);
|
|
57
|
+
const nNext = req(nrm[i]);
|
|
58
|
+
const turn = vec2.cross(req(dir[i - 1]), req(dir[i]));
|
|
59
|
+
if (Math.abs(turn) < 1e-9) {
|
|
60
|
+
// Collinear — one offset point per side is enough.
|
|
61
|
+
left.push(vec2.add(c, vec2.mul(nPrev, w)));
|
|
62
|
+
right.push(vec2.sub(c, vec2.mul(nPrev, w)));
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
// turn > 0: left turn → left side concave (miter), right side convex (arc).
|
|
66
|
+
// turn < 0: right turn → left side convex (arc), right side concave (miter).
|
|
67
|
+
if (turn > 0) {
|
|
68
|
+
left.push(...miterSide(c, nPrev, nNext, w, 1));
|
|
69
|
+
right.push(...arcSide(c, nPrev, nNext, w, -1));
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
left.push(...arcSide(c, nPrev, nNext, w, 1));
|
|
73
|
+
right.push(...miterSide(c, nPrev, nNext, w, -1));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Round caps: half-turn arcs from the +normal offset to the -normal offset,
|
|
77
|
+
// bulging past the endpoint along the stroke direction (+dir at the end,
|
|
78
|
+
// -dir at the start). The −π sweep passes through that direction.
|
|
79
|
+
const endCap = capArc(pos(n - 1), req(nrm[n - 2]), halfWidth(n - 1), false);
|
|
80
|
+
const startCap = capArc(pos(0), req(nrm[0]), halfWidth(0), true);
|
|
81
|
+
const outline = [];
|
|
82
|
+
for (const p of left)
|
|
83
|
+
outline.push(p);
|
|
84
|
+
for (const p of endCap)
|
|
85
|
+
outline.push(p);
|
|
86
|
+
for (let i = right.length - 1; i >= 0; i--)
|
|
87
|
+
outline.push(req(right[i]));
|
|
88
|
+
for (const p of startCap)
|
|
89
|
+
outline.push(p);
|
|
90
|
+
return outline;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Concave corner: the miter point where the two offset lines meet, on the
|
|
94
|
+
* `sign` side (+1 = left/+normal, -1 = right/-normal). Beyond the miter limit
|
|
95
|
+
* (a very sharp turn) fall back to a bevel (the two segment-offset points) so the
|
|
96
|
+
* outline can't grow a long spike.
|
|
97
|
+
*/
|
|
98
|
+
const miterSide = (c, nPrev, nNext, w, sign) => {
|
|
99
|
+
const m = vec2.normalize(vec2.add(nPrev, nNext));
|
|
100
|
+
const cos = vec2.dot(m, nPrev); // cos of half the turn angle
|
|
101
|
+
if (cos > 1e-3 && 1 / cos <= BRUSH_OUTLINE_MITER_LIMIT) {
|
|
102
|
+
return [vec2.add(c, vec2.mul(m, sign * (w / cos)))];
|
|
103
|
+
}
|
|
104
|
+
return [vec2.add(c, vec2.mul(nPrev, sign * w)), vec2.add(c, vec2.mul(nNext, sign * w))];
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Convex corner: an arc of radius `w` around `c` from the previous offset
|
|
108
|
+
* direction to the next, sampled the short way. `sign` picks the side (+1 =
|
|
109
|
+
* +normal, -1 = -normal).
|
|
110
|
+
*/
|
|
111
|
+
const arcSide = (c, nPrev, nNext, w, sign) => arc(c, w, vec2.angle(vec2.mul(nPrev, sign)), vec2.angle(vec2.mul(nNext, sign)));
|
|
112
|
+
/**
|
|
113
|
+
* A round cap: the half-turn arc of radius `w` from the +normal offset to the
|
|
114
|
+
* -normal offset. `fromOpposite` starts at the -normal side (for the START cap,
|
|
115
|
+
* which the outline reaches from the reversed right side); the −π sweep makes it
|
|
116
|
+
* bulge along the stroke direction rather than back across the body.
|
|
117
|
+
*/
|
|
118
|
+
const capArc = (c, nrm, w, fromOpposite) => {
|
|
119
|
+
const a0 = vec2.angle(nrm) + (fromOpposite ? Math.PI : 0);
|
|
120
|
+
return arc(c, w, a0, a0 - Math.PI);
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Sample a circular arc of `radius` around `c` from angle `a0` to `a1` inclusive,
|
|
124
|
+
* taking the shorter signed sweep, at {@link BRUSH_OUTLINE_ARC_STEP} spacing.
|
|
125
|
+
* A `±π` sweep (a cap) keeps its given sign so the half-circle bulges the right
|
|
126
|
+
* way.
|
|
127
|
+
*/
|
|
128
|
+
const arc = (c, radius, a0, a1) => {
|
|
129
|
+
let delta = a1 - a0;
|
|
130
|
+
while (delta > Math.PI + 1e-9)
|
|
131
|
+
delta -= 2 * Math.PI;
|
|
132
|
+
while (delta < -Math.PI - 1e-9)
|
|
133
|
+
delta += 2 * Math.PI;
|
|
134
|
+
const steps = Math.max(1, Math.ceil(Math.abs(delta) / BRUSH_OUTLINE_ARC_STEP));
|
|
135
|
+
const out = [];
|
|
136
|
+
for (let k = 0; k <= steps; k++) {
|
|
137
|
+
const a = a0 + (delta * k) / steps;
|
|
138
|
+
out.push({ x: c.x + radius * Math.cos(a), y: c.y + radius * Math.sin(a) });
|
|
139
|
+
}
|
|
140
|
+
return out;
|
|
141
|
+
};
|
|
142
|
+
//# sourceMappingURL=brush-outline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brush-outline.js","sourceRoot":"","sources":["../src/brush-outline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAa,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAEnF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,YAAY,GA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AAO,KAAK,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI;QAAE,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;IACpD,OAAO,KAAK,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI;QAAE,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;IACrD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC;IAC/E,MAAM,GAAG,GAAW,EAAE,CAAC;IACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QACnC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -14,18 +14,16 @@
|
|
|
14
14
|
*/
|
|
15
15
|
export declare const SNAP_PROBE_CULL_RADIUS = 1000;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* spacing `resolveSnapSpacing` returns for legacy/custom viewports that omit
|
|
20
|
-
* `gridSize`. Tune this to change the default grid; range 4–64.
|
|
17
|
+
* Fixed grid spacing in world units: the step `renderGrid` paints and the
|
|
18
|
+
* step snap-to-grid rounds to. Tune to change the grid density; range 4–64.
|
|
21
19
|
*/
|
|
22
20
|
export declare const DEFAULT_GRID_SPACING = 20;
|
|
23
21
|
/**
|
|
24
22
|
* Padding (world units) the elbow router inflates obstacle bboxes
|
|
25
23
|
* by before searching. Larger values keep edges visibly clear of
|
|
26
24
|
* shapes; smaller values let the router squeeze through tight
|
|
27
|
-
* spaces. 20 px matches the
|
|
28
|
-
*
|
|
25
|
+
* spaces. 20 px matches the grid spacing for diagrams that snap to
|
|
26
|
+
* the grid.
|
|
29
27
|
*/
|
|
30
28
|
export declare const ELBOW_OBSTACLE_MARGIN = 20;
|
|
31
29
|
/**
|
|
@@ -35,11 +33,31 @@ export declare const ELBOW_OBSTACLE_MARGIN = 20;
|
|
|
35
33
|
* `inflate` arithmetic without admitting real crossings.
|
|
36
34
|
*/
|
|
37
35
|
export declare const ELBOW_OBSTACLE_INTERIOR_EPSILON = 0.5;
|
|
36
|
+
/**
|
|
37
|
+
* Longest stub (world px) the orthogonal heuristic fallback in
|
|
38
|
+
* `getLinkPath` adds before bending when an endpoint is anchored to a
|
|
39
|
+
* named side. Bigger values push the first bend further from the shape;
|
|
40
|
+
* reasonable range 24–64.
|
|
41
|
+
*/
|
|
42
|
+
export declare const ELBOW_STUB_MAX = 40;
|
|
43
|
+
/**
|
|
44
|
+
* Shortest stub (world px) for the same fallback — keeps the exit
|
|
45
|
+
* visible even when the endpoints are nearly on top of each other.
|
|
46
|
+
* Reasonable range 4–16.
|
|
47
|
+
*/
|
|
48
|
+
export declare const ELBOW_STUB_MIN = 8;
|
|
49
|
+
/**
|
|
50
|
+
* The stub scales as endpoint distance divided by this factor, clamped
|
|
51
|
+
* to [ELBOW_STUB_MIN, ELBOW_STUB_MAX]. Larger divisors give shorter
|
|
52
|
+
* stubs on mid-range spans. Reasonable range 2–8.
|
|
53
|
+
*/
|
|
54
|
+
export declare const ELBOW_STUB_DISTANCE_DIVISOR = 4;
|
|
38
55
|
/**
|
|
39
56
|
* Per-turn cost added in the elbow A* so the router minimises BENDS first,
|
|
40
57
|
* distance second (lexicographic — far larger than any plausible canvas
|
|
41
|
-
* distance). Keeps routes stable: small shape moves
|
|
42
|
-
* equal-distance alternatives, and the path takes the
|
|
58
|
+
* distance). Keeps routes stable: small shape moves stay on the same
|
|
59
|
+
* choice between equal-distance alternatives, and the path takes the
|
|
60
|
+
* fewest corners.
|
|
43
61
|
*/
|
|
44
62
|
export declare const ELBOW_BEND_PENALTY = 100000;
|
|
45
63
|
/**
|
|
@@ -183,4 +201,56 @@ export declare const TEXT_LINE_HEIGHT_FACTOR = 1.2;
|
|
|
183
201
|
export declare const FRAME_HEADER_HEIGHT = 24;
|
|
184
202
|
export declare const FRAME_HEADER_PADDING_X = 8;
|
|
185
203
|
export declare const FRAME_HEADER_FONT_SIZE = 12;
|
|
204
|
+
/**
|
|
205
|
+
* --- Layout defaults ---
|
|
206
|
+
*
|
|
207
|
+
* Used by the built-in layout functions (`gridLayout`, `stackLayout`,
|
|
208
|
+
* `wrapLayout`, `treeLayout`) when the caller's spec omits the value.
|
|
209
|
+
*
|
|
210
|
+
* - `DEFAULT_LAYOUT_GAP` — cell/sibling gap (world px) for grid, stack and
|
|
211
|
+
* wrap layouts. Larger = more breathing room between shapes. Range: 8–48.
|
|
212
|
+
* - `DEFAULT_TREE_RANK_SEP` — vertical distance (world px) between successive
|
|
213
|
+
* depth levels in the tree layout. Larger = taller tree. Range: 40–160.
|
|
214
|
+
* - `DEFAULT_TREE_NODE_SEP` — horizontal distance (world px) between siblings
|
|
215
|
+
* in the tree layout. Larger = wider tree. Range: 12–64.
|
|
216
|
+
*/
|
|
217
|
+
export declare const DEFAULT_LAYOUT_GAP = 16;
|
|
218
|
+
export declare const DEFAULT_TREE_RANK_SEP = 80;
|
|
219
|
+
export declare const DEFAULT_TREE_NODE_SEP = 24;
|
|
220
|
+
/**
|
|
221
|
+
* --- Outline sampling ---
|
|
222
|
+
*
|
|
223
|
+
* - `DEFAULT_OUTLINE_SAMPLES` — fixed density `findNearestOutlinePoint` walks
|
|
224
|
+
* the outline at when resolving the nearest ratio to a world point. Good
|
|
225
|
+
* enough for visual snap; bump it for sub-pixel accuracy at high zoom.
|
|
226
|
+
* Range: 32–256.
|
|
227
|
+
* - `FLOATING_OUTLINE_SAMPLES` — segments the outline is sampled into when
|
|
228
|
+
* intersecting it with the floating-endpoint ray. Smooth enough for
|
|
229
|
+
* ellipses at high zoom without being a hot-loop cost (resolved once per
|
|
230
|
+
* edge per frame). Range: 48–256.
|
|
231
|
+
*/
|
|
232
|
+
export declare const DEFAULT_OUTLINE_SAMPLES = 64;
|
|
233
|
+
export declare const FLOATING_OUTLINE_SAMPLES = 96;
|
|
234
|
+
/**
|
|
235
|
+
* Fallback scene dimensions, in pixels, for a scene with no explicit
|
|
236
|
+
* viewport size — a freshly imported document whose source carries no
|
|
237
|
+
* canvas size, or an empty export region. Just needs to be non-degenerate.
|
|
238
|
+
* Range: a few hundred to ~2000.
|
|
239
|
+
*/
|
|
240
|
+
export declare const FALLBACK_SCENE_WIDTH = 800;
|
|
241
|
+
export declare const FALLBACK_SCENE_HEIGHT = 600;
|
|
242
|
+
/**
|
|
243
|
+
* Max angular step (radians) between sampled points along a brush-outline round
|
|
244
|
+
* join or cap arc. Smaller = smoother curves / more points; larger = coarser /
|
|
245
|
+
* cheaper. ~0.35 rad (20°) keeps joins visually round without flooding the
|
|
246
|
+
* polygon. Range: 0.2–0.6.
|
|
247
|
+
*/
|
|
248
|
+
export declare const BRUSH_OUTLINE_ARC_STEP = 0.35;
|
|
249
|
+
/**
|
|
250
|
+
* Miter limit for a brush-outline concave corner: when the miter point would run
|
|
251
|
+
* more than this many half-widths from the vertex (a very sharp turn), fall back
|
|
252
|
+
* to a bevel (two offset points) so the outline can't spike into a long spar.
|
|
253
|
+
* Range: 1.5–4.
|
|
254
|
+
*/
|
|
255
|
+
export declare const BRUSH_OUTLINE_MITER_LIMIT = 2.5;
|
|
186
256
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B,MAAM,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC;;;;GAIG;AACH,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAE7C;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,SAAS,CAAC;AAEzC;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAE7C;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,qBAAqB,IAAI,CAAC;AACvC,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAC5C,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC;;;;;;;GAOG;AAEH,wEAAwE;AACxE,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,6BAA6B,MAAM,CAAC;AACjD,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,qBAAqB,KAAK,CAAC;AACxC,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAE3C;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,MAAM,CAAC;AACxC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,MAAM,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -14,18 +14,16 @@
|
|
|
14
14
|
*/
|
|
15
15
|
export const SNAP_PROBE_CULL_RADIUS = 1000;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* spacing `resolveSnapSpacing` returns for legacy/custom viewports that omit
|
|
20
|
-
* `gridSize`. Tune this to change the default grid; range 4–64.
|
|
17
|
+
* Fixed grid spacing in world units: the step `renderGrid` paints and the
|
|
18
|
+
* step snap-to-grid rounds to. Tune to change the grid density; range 4–64.
|
|
21
19
|
*/
|
|
22
20
|
export const DEFAULT_GRID_SPACING = 20;
|
|
23
21
|
/**
|
|
24
22
|
* Padding (world units) the elbow router inflates obstacle bboxes
|
|
25
23
|
* by before searching. Larger values keep edges visibly clear of
|
|
26
24
|
* shapes; smaller values let the router squeeze through tight
|
|
27
|
-
* spaces. 20 px matches the
|
|
28
|
-
*
|
|
25
|
+
* spaces. 20 px matches the grid spacing for diagrams that snap to
|
|
26
|
+
* the grid.
|
|
29
27
|
*/
|
|
30
28
|
export const ELBOW_OBSTACLE_MARGIN = 20;
|
|
31
29
|
/**
|
|
@@ -35,11 +33,31 @@ export const ELBOW_OBSTACLE_MARGIN = 20;
|
|
|
35
33
|
* `inflate` arithmetic without admitting real crossings.
|
|
36
34
|
*/
|
|
37
35
|
export const ELBOW_OBSTACLE_INTERIOR_EPSILON = 0.5;
|
|
36
|
+
/**
|
|
37
|
+
* Longest stub (world px) the orthogonal heuristic fallback in
|
|
38
|
+
* `getLinkPath` adds before bending when an endpoint is anchored to a
|
|
39
|
+
* named side. Bigger values push the first bend further from the shape;
|
|
40
|
+
* reasonable range 24–64.
|
|
41
|
+
*/
|
|
42
|
+
export const ELBOW_STUB_MAX = 40;
|
|
43
|
+
/**
|
|
44
|
+
* Shortest stub (world px) for the same fallback — keeps the exit
|
|
45
|
+
* visible even when the endpoints are nearly on top of each other.
|
|
46
|
+
* Reasonable range 4–16.
|
|
47
|
+
*/
|
|
48
|
+
export const ELBOW_STUB_MIN = 8;
|
|
49
|
+
/**
|
|
50
|
+
* The stub scales as endpoint distance divided by this factor, clamped
|
|
51
|
+
* to [ELBOW_STUB_MIN, ELBOW_STUB_MAX]. Larger divisors give shorter
|
|
52
|
+
* stubs on mid-range spans. Reasonable range 2–8.
|
|
53
|
+
*/
|
|
54
|
+
export const ELBOW_STUB_DISTANCE_DIVISOR = 4;
|
|
38
55
|
/**
|
|
39
56
|
* Per-turn cost added in the elbow A* so the router minimises BENDS first,
|
|
40
57
|
* distance second (lexicographic — far larger than any plausible canvas
|
|
41
|
-
* distance). Keeps routes stable: small shape moves
|
|
42
|
-
* equal-distance alternatives, and the path takes the
|
|
58
|
+
* distance). Keeps routes stable: small shape moves stay on the same
|
|
59
|
+
* choice between equal-distance alternatives, and the path takes the
|
|
60
|
+
* fewest corners.
|
|
43
61
|
*/
|
|
44
62
|
export const ELBOW_BEND_PENALTY = 100000;
|
|
45
63
|
/**
|
|
@@ -183,4 +201,56 @@ export const TEXT_LINE_HEIGHT_FACTOR = 1.2;
|
|
|
183
201
|
export const FRAME_HEADER_HEIGHT = 24;
|
|
184
202
|
export const FRAME_HEADER_PADDING_X = 8;
|
|
185
203
|
export const FRAME_HEADER_FONT_SIZE = 12;
|
|
204
|
+
/**
|
|
205
|
+
* --- Layout defaults ---
|
|
206
|
+
*
|
|
207
|
+
* Used by the built-in layout functions (`gridLayout`, `stackLayout`,
|
|
208
|
+
* `wrapLayout`, `treeLayout`) when the caller's spec omits the value.
|
|
209
|
+
*
|
|
210
|
+
* - `DEFAULT_LAYOUT_GAP` — cell/sibling gap (world px) for grid, stack and
|
|
211
|
+
* wrap layouts. Larger = more breathing room between shapes. Range: 8–48.
|
|
212
|
+
* - `DEFAULT_TREE_RANK_SEP` — vertical distance (world px) between successive
|
|
213
|
+
* depth levels in the tree layout. Larger = taller tree. Range: 40–160.
|
|
214
|
+
* - `DEFAULT_TREE_NODE_SEP` — horizontal distance (world px) between siblings
|
|
215
|
+
* in the tree layout. Larger = wider tree. Range: 12–64.
|
|
216
|
+
*/
|
|
217
|
+
export const DEFAULT_LAYOUT_GAP = 16;
|
|
218
|
+
export const DEFAULT_TREE_RANK_SEP = 80;
|
|
219
|
+
export const DEFAULT_TREE_NODE_SEP = 24;
|
|
220
|
+
/**
|
|
221
|
+
* --- Outline sampling ---
|
|
222
|
+
*
|
|
223
|
+
* - `DEFAULT_OUTLINE_SAMPLES` — fixed density `findNearestOutlinePoint` walks
|
|
224
|
+
* the outline at when resolving the nearest ratio to a world point. Good
|
|
225
|
+
* enough for visual snap; bump it for sub-pixel accuracy at high zoom.
|
|
226
|
+
* Range: 32–256.
|
|
227
|
+
* - `FLOATING_OUTLINE_SAMPLES` — segments the outline is sampled into when
|
|
228
|
+
* intersecting it with the floating-endpoint ray. Smooth enough for
|
|
229
|
+
* ellipses at high zoom without being a hot-loop cost (resolved once per
|
|
230
|
+
* edge per frame). Range: 48–256.
|
|
231
|
+
*/
|
|
232
|
+
export const DEFAULT_OUTLINE_SAMPLES = 64;
|
|
233
|
+
export const FLOATING_OUTLINE_SAMPLES = 96;
|
|
234
|
+
/**
|
|
235
|
+
* Fallback scene dimensions, in pixels, for a scene with no explicit
|
|
236
|
+
* viewport size — a freshly imported document whose source carries no
|
|
237
|
+
* canvas size, or an empty export region. Just needs to be non-degenerate.
|
|
238
|
+
* Range: a few hundred to ~2000.
|
|
239
|
+
*/
|
|
240
|
+
export const FALLBACK_SCENE_WIDTH = 800;
|
|
241
|
+
export const FALLBACK_SCENE_HEIGHT = 600;
|
|
242
|
+
/**
|
|
243
|
+
* Max angular step (radians) between sampled points along a brush-outline round
|
|
244
|
+
* join or cap arc. Smaller = smoother curves / more points; larger = coarser /
|
|
245
|
+
* cheaper. ~0.35 rad (20°) keeps joins visually round without flooding the
|
|
246
|
+
* polygon. Range: 0.2–0.6.
|
|
247
|
+
*/
|
|
248
|
+
export const BRUSH_OUTLINE_ARC_STEP = 0.35;
|
|
249
|
+
/**
|
|
250
|
+
* Miter limit for a brush-outline concave corner: when the miter point would run
|
|
251
|
+
* more than this many half-widths from the vertex (a very sharp turn), fall back
|
|
252
|
+
* to a bevel (two offset points) so the outline can't spike into a long spar.
|
|
253
|
+
* Range: 1.5–4.
|
|
254
|
+
*/
|
|
255
|
+
export const BRUSH_OUTLINE_MITER_LIMIT = 2.5;
|
|
186
256
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants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H,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAC"}
|
package/dist/edge-curve.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Vec2 } from "@oh-just-another/types";
|
|
2
2
|
/**
|
|
3
3
|
* Curved (bezier) link geometry — the single source of truth for the curve
|
|
4
4
|
* shape so the renderer (draws cubic beziers) and hit-testing / bounds
|
|
@@ -27,8 +27,6 @@ export declare const cubicWithEndTangents: (from: Vec2, to: Vec2, dirFrom: Vec2,
|
|
|
27
27
|
* a waypointed curve (the bends define the shape).
|
|
28
28
|
*/
|
|
29
29
|
export declare const catmullRomBeziers: (pts: readonly Vec2[]) => BezierSegment[];
|
|
30
|
-
/** Point on a cubic bezier at parameter `t` (0..1). de Casteljau / Bernstein. */
|
|
31
|
-
export declare const cubicAt: (p0: Vec2, c1: Vec2, c2: Vec2, p1: Vec2, t: number) => Vec2;
|
|
32
30
|
/**
|
|
33
31
|
* Flatten a `start` + cubic-segment list into a dense point list (for
|
|
34
32
|
* hit-testing / bounds). Includes `start` then `perSegment` samples per cubic.
|
package/dist/edge-curve.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edge-curve.d.ts","sourceRoot":"","sources":["../src/edge-curve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"edge-curve.d.ts","sourceRoot":"","sources":["../src/edge-curve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,IAAI,EAAE,MAAM,wBAAwB,CAAC;AASxD;;;;;;GAMG;AAEH,+EAA+E;AAC/E,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;CACnB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,MAAM,IAAI,EACV,IAAI,IAAI,EACR,SAAS,IAAI,EACb,OAAO,IAAI,KACV,aAQF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,SAAS,IAAI,EAAE,KAAG,aAAa,EAerE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,IAAI,EACX,UAAU,SAAS,aAAa,EAAE,EAClC,mBAAmC,KAClC,IAAI,EAUN,CAAC"}
|
package/dist/edge-curve.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
+
import { req } from "@oh-just-another/types";
|
|
2
|
+
import { bezier } from "@oh-just-another/math";
|
|
1
3
|
import { CURVE_CATMULL_TENSION, CURVE_END_TANGENT_MAX_PX, CURVE_END_TANGENT_RATIO, CURVE_FLATTEN_SEGMENTS, } from "./constants.js";
|
|
2
|
-
const req = (v) => {
|
|
3
|
-
if (v === undefined)
|
|
4
|
-
throw new Error("packages/scene: index out of range");
|
|
5
|
-
return v;
|
|
6
|
-
};
|
|
7
4
|
/**
|
|
8
5
|
* Cubic bezier from `from` to `to` that LEAVES `from` along `dirFrom` and
|
|
9
6
|
* ENTERS `to` along `-dirTo` (both unit outward directions). This makes a
|
|
@@ -42,18 +39,6 @@ export const catmullRomBeziers = (pts) => {
|
|
|
42
39
|
}
|
|
43
40
|
return segs;
|
|
44
41
|
};
|
|
45
|
-
/** Point on a cubic bezier at parameter `t` (0..1). de Casteljau / Bernstein. */
|
|
46
|
-
export const cubicAt = (p0, c1, c2, p1, t) => {
|
|
47
|
-
const u = 1 - t;
|
|
48
|
-
const a = u * u * u;
|
|
49
|
-
const b = 3 * u * u * t;
|
|
50
|
-
const c = 3 * u * t * t;
|
|
51
|
-
const d = t * t * t;
|
|
52
|
-
return {
|
|
53
|
-
x: a * p0.x + b * c1.x + c * c2.x + d * p1.x,
|
|
54
|
-
y: a * p0.y + b * c1.y + c * c2.y + d * p1.y,
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
42
|
/**
|
|
58
43
|
* Flatten a `start` + cubic-segment list into a dense point list (for
|
|
59
44
|
* hit-testing / bounds). Includes `start` then `perSegment` samples per cubic.
|
|
@@ -63,7 +48,7 @@ export const flattenSegments = (start, segments, perSegment = CURVE_FLATTEN_SEGM
|
|
|
63
48
|
let prev = start;
|
|
64
49
|
for (const s of segments) {
|
|
65
50
|
for (let i = 1; i <= perSegment; i++) {
|
|
66
|
-
out.push(cubicAt(prev, s.c1, s.c2, s.to, i / perSegment));
|
|
51
|
+
out.push(bezier.cubicAt(prev, s.c1, s.c2, s.to, i / perSegment));
|
|
67
52
|
}
|
|
68
53
|
prev = s.to;
|
|
69
54
|
}
|
package/dist/edge-curve.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edge-curve.js","sourceRoot":"","sources":["../src/edge-curve.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"edge-curve.js","sourceRoot":"","sources":["../src/edge-curve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAa,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAiBxB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,IAAU,EACV,EAAQ,EACR,OAAa,EACb,KAAW,EACI,EAAE;IACjB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACtD,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,uBAAuB,EAAE,wBAAwB,CAAC,CAAC;IAC7E,OAAO;QACL,EAAE,EAAE,EAAE,CAAC,EAAE,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AE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;YAChE,EAAE,EAAE,EAAE;SACP,CAAC,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,KAAW,EACX,QAAkC,EAClC,UAAU,GAAG,sBAAsB,EAC3B,EAAE;IACV,MAAM,GAAG,GAAW,CAAC,KAAK,CAAC,CAAC;IAC5B,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;YACrC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;QACnE,CAAC;QACD,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC;IACd,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
package/dist/edge-geometry.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Bounds, type Vec2 } from "@oh-just-another/types";
|
|
2
2
|
import { type BezierSegment } from "./edge-curve.js";
|
|
3
3
|
import type { Link, LinkEndpoint } from "./edge.js";
|
|
4
4
|
import type { Scene } from "./scene.js";
|
|
@@ -33,8 +33,8 @@ export declare const getSelfLoopSpec: (scene: Scene, edge: Link) => SelfLoopSpec
|
|
|
33
33
|
* scale automatically.
|
|
34
34
|
*
|
|
35
35
|
* Returns `null` when an `anchor` endpoint references a shape id that
|
|
36
|
-
* isn't
|
|
37
|
-
*
|
|
36
|
+
* isn't in the scene. Callers usually drop the edge from the render
|
|
37
|
+
* pass in that case.
|
|
38
38
|
*
|
|
39
39
|
* `toward` is only consulted for `floating` endpoints — it's the world
|
|
40
40
|
* point of the *other* endpoint, which the floating side aims at. When
|
|
@@ -53,6 +53,21 @@ export declare const getLinkEndpointWorld: (scene: Scene, endpoint: LinkEndpoint
|
|
|
53
53
|
* an edge with custom bends.
|
|
54
54
|
*/
|
|
55
55
|
export declare const getLinkPath: (scene: Scene, edge: Link) => readonly Vec2[] | null;
|
|
56
|
+
/**
|
|
57
|
+
* Side-aware orthogonal elbow between two points, used as the headless
|
|
58
|
+
* fallback whenever no A*-routed `routedPoints` exist (e.g. `getLinkPath`
|
|
59
|
+
* outside the editor's reroute pass). Pure and deterministic — the single
|
|
60
|
+
* implementation of the ortho-fallback heuristic (the real, obstacle-aware
|
|
61
|
+
* router lives in `elbow-link.ts` / `elbow-router.ts`, which depend on this
|
|
62
|
+
* module and so can't be reused here without a cycle).
|
|
63
|
+
*
|
|
64
|
+
* `fromDir` / `toDir` are the outward exit unit vectors for a named-side
|
|
65
|
+
* anchor (see {@link exitDirectionFor}), or `null` for corner / center /
|
|
66
|
+
* free-point ends. With a direction we add a small stub before bending
|
|
67
|
+
* toward the other endpoint; without either, we fall back to a single
|
|
68
|
+
* longest-axis-first elbow.
|
|
69
|
+
*/
|
|
70
|
+
export declare const straightElbowFallback: (from: Vec2, to: Vec2, fromDir: Vec2 | null, toDir: Vec2 | null) => Vec2[];
|
|
56
71
|
/**
|
|
57
72
|
* Cubic-bezier representation of a curved (bezier) edge: the start point and
|
|
58
73
|
* the list of cubic segments. A no-waypoint span is a single cubic whose
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edge-geometry.d.ts","sourceRoot":"","sources":["../src/edge-geometry.ts"],"names":[],"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