@weasel-js/core 0.7.2 → 1.0.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 +541 -0
- package/dist/{DrawCommand-CJtqqt8H.d.ts → DrawCommand-DCmiNkBj.d.ts} +38 -170
- package/dist/{chunk-CQNKCG34.js → chunk-6SHZHXXR.js} +47 -10
- package/dist/chunk-6SHZHXXR.js.map +1 -0
- package/dist/{chunk-5F3PIERN.js → chunk-D2C6K6FO.js} +1420 -652
- package/dist/chunk-D2C6K6FO.js.map +1 -0
- package/dist/chunk-DCIU3SRK.js +505 -0
- package/dist/chunk-DCIU3SRK.js.map +1 -0
- package/dist/chunk-IO5Z75X4.js +167 -0
- package/dist/chunk-IO5Z75X4.js.map +1 -0
- package/dist/{chunk-VOVKONXA.js → chunk-UB6A6L77.js} +3 -3
- package/dist/{chunk-VOVKONXA.js.map → chunk-UB6A6L77.js.map} +1 -1
- package/dist/{chunk-BGGZ4CVF.js → chunk-Z3KNFTTS.js} +6 -6
- package/dist/chunk-Z3KNFTTS.js.map +1 -0
- package/dist/clipboard.d.ts +2 -2
- package/dist/clone.d.ts +1 -1
- package/dist/{geometry-D9BDMiQi.d.ts → geometry-DVeZ2i-c.d.ts} +1 -1
- package/dist/{grid-CaSK9bHV.d.ts → grid-XcFQVS0f.d.ts} +1 -1
- package/dist/{index-DOYRTfP0.d.ts → index-ChM3ZJ2v.d.ts} +278 -93
- package/dist/index.d.ts +442 -57
- package/dist/index.js +6 -6
- package/dist/insert.d.ts +2 -2
- package/dist/insert.js +5 -5
- package/dist/insert.js.map +1 -1
- package/dist/move.d.ts +3 -3
- package/dist/move.js +2 -2
- package/dist/{options-DMWeTELe.d.ts → options-wAvCnOZd.d.ts} +1 -1
- package/dist/paint-types-CnLIzqq1.d.ts +261 -0
- package/dist/patterns-builtin.d.ts +57 -2
- package/dist/patterns-builtin.js +1 -97
- package/dist/patterns-builtin.js.map +1 -1
- package/dist/{pointSnapToGrid-C3EruUwt.d.ts → pointSnapToGrid-BuDZWBrL.d.ts} +2 -2
- package/dist/renderer.d.ts +25 -8
- package/dist/renderer.js +6 -6
- package/dist/resize.d.ts +3 -3
- package/dist/resize.js +2 -2
- package/dist/routing.d.ts +7 -7
- package/dist/routing.js +1 -1
- package/dist/{types-Dcaa0tPq.d.ts → types-BhJJ2OCM.d.ts} +9 -1
- package/dist/{types-Cpb4hii1.d.ts → types-DUpI7Apc.d.ts} +3 -95
- package/dist/{viewToMat3-D4lrBigW.d.ts → viewToMat3-BvaWCN99.d.ts} +1 -1
- package/package.json +6 -6
- package/dist/chunk-5F3PIERN.js.map +0 -1
- package/dist/chunk-BGGZ4CVF.js.map +0 -1
- package/dist/chunk-CQNKCG34.js.map +0 -1
- package/dist/chunk-SYM6RAM4.js +0 -232
- package/dist/chunk-SYM6RAM4.js.map +0 -1
- package/dist/chunk-Y52N27PF.js +0 -39
- package/dist/chunk-Y52N27PF.js.map +0 -1
- package/dist/registerTexture-BzHTLhD9.d.ts +0 -25
- /package/dist/{types-B6MMiodD.d.ts → path-B6MMiodD.d.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as Path } from './
|
|
2
|
-
import {
|
|
1
|
+
import { P as Path } from './path-B6MMiodD.js';
|
|
2
|
+
import { F as FillStyle, S as Stroke, a as TextureHandle } from './paint-types-CnLIzqq1.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 2D affine matrix utilities. Column-major 9-element Float32Array, matching
|
|
@@ -19,6 +19,13 @@ declare function identity(): Mat3;
|
|
|
19
19
|
declare function multiply(out: Mat3, m: Mat3): Mat3;
|
|
20
20
|
declare function translate(m: Mat3, tx: number, ty: number): Mat3;
|
|
21
21
|
declare function scale(m: Mat3, sx: number, sy: number): Mat3;
|
|
22
|
+
/**
|
|
23
|
+
* Inverse of an affine matrix. Returns identity for a singular matrix
|
|
24
|
+
* (determinant 0) — a degenerate transform collapses every point onto a
|
|
25
|
+
* line, so there is no meaningful inverse and callers get an unmapped
|
|
26
|
+
* space rather than NaNs propagating into a shader uniform.
|
|
27
|
+
*/
|
|
28
|
+
declare function invert(m: Mat3): Mat3;
|
|
22
29
|
declare function apply(m: Mat3, x: number, y: number): [number, number];
|
|
23
30
|
/**
|
|
24
31
|
* Map screen pixel coords (0..width on X, 0..height on Y, top-left origin)
|
|
@@ -31,177 +38,11 @@ declare const mat3: {
|
|
|
31
38
|
multiply: typeof multiply;
|
|
32
39
|
translate: typeof translate;
|
|
33
40
|
scale: typeof scale;
|
|
41
|
+
invert: typeof invert;
|
|
34
42
|
apply: typeof apply;
|
|
35
43
|
screenToClip: typeof screenToClip;
|
|
36
44
|
};
|
|
37
45
|
|
|
38
|
-
/**
|
|
39
|
-
* FillStyle and Stroke types — the unified shape for "what color or texture
|
|
40
|
-
* paints these pixels," modeled on SVG's paint-server concept.
|
|
41
|
-
*
|
|
42
|
-
* - `FillStyle` is a tagged union: solid color, pattern, or gradient. Used
|
|
43
|
-
* wherever a kit option previously took `fillStyle: string`.
|
|
44
|
-
* - `Stroke` pairs a `FillStyle` with structural stroke parameters (width, dash,
|
|
45
|
-
* line cap/join, alignment).
|
|
46
|
-
* - These types are consumed by the GL renderer's DrawCommand path fills
|
|
47
|
-
* and strokes.
|
|
48
|
-
*
|
|
49
|
-
* The 2D `applyPaint` / `applyStroke` / `renderFilledRegion` helpers that
|
|
50
|
-
* formerly lived alongside these types were deleted with the 2D backend in
|
|
51
|
-
* Step 10. `alignedStrokeRect` survives as a pure geometry helper used by
|
|
52
|
-
* path tessellation and the selection overlay.
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Color/texture strategy for fills (and, via `Stroke.paint`, strokes).
|
|
57
|
-
*
|
|
58
|
-
* `fill` is optional and defaults to `'solid'` — `{ color: '#abc' }` is
|
|
59
|
-
* equivalent to `{ fill: 'solid', color: '#abc' }`. Pattern paints must set
|
|
60
|
-
* `fill: 'pattern'` explicitly.
|
|
61
|
-
*
|
|
62
|
-
* The `'pattern'` variant's payload is a `TextureHandle` (registered via
|
|
63
|
-
* `registerTexture()`). The kit-level factory `createTilePattern` (and the
|
|
64
|
-
* `patterns-builtin` catalog: `hatch`, `crosshatch`, `dots`, `chunks`)
|
|
65
|
-
* produces these handles by rendering a tile to an `OffscreenCanvas` and
|
|
66
|
-
* registering the resulting `ImageBitmap` as a GL texture.
|
|
67
|
-
*/
|
|
68
|
-
type FillStyle = {
|
|
69
|
-
fill?: 'solid';
|
|
70
|
-
color: string;
|
|
71
|
-
opacity?: number;
|
|
72
|
-
} | {
|
|
73
|
-
fill: 'pattern';
|
|
74
|
-
pattern: TextureHandle;
|
|
75
|
-
opacity?: number;
|
|
76
|
-
} | {
|
|
77
|
-
fill: 'linear-gradient';
|
|
78
|
-
from: {
|
|
79
|
-
x: number;
|
|
80
|
-
y: number;
|
|
81
|
-
};
|
|
82
|
-
to: {
|
|
83
|
-
x: number;
|
|
84
|
-
y: number;
|
|
85
|
-
};
|
|
86
|
-
stops: GradStop[];
|
|
87
|
-
opacity?: number;
|
|
88
|
-
} | {
|
|
89
|
-
fill: 'radial-gradient';
|
|
90
|
-
center: {
|
|
91
|
-
x: number;
|
|
92
|
-
y: number;
|
|
93
|
-
};
|
|
94
|
-
radius: number;
|
|
95
|
-
stops: GradStop[];
|
|
96
|
-
opacity?: number;
|
|
97
|
-
} | {
|
|
98
|
-
fill: 'conic-gradient';
|
|
99
|
-
center: {
|
|
100
|
-
x: number;
|
|
101
|
-
y: number;
|
|
102
|
-
};
|
|
103
|
-
angle: number;
|
|
104
|
-
stops: GradStop[];
|
|
105
|
-
opacity?: number;
|
|
106
|
-
};
|
|
107
|
-
/** A single color stop within a gradient. `offset` is in 0..1. */
|
|
108
|
-
interface GradStop {
|
|
109
|
-
offset: number;
|
|
110
|
-
color: string;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Where a stroke sits relative to the geometric edge it strokes.
|
|
114
|
-
*
|
|
115
|
-
* - `'center'` (default): canvas-native — half the stroke width sits inside
|
|
116
|
-
* the geometry, half outside.
|
|
117
|
-
* - `'inner'`: the entire stroke lies inside the geometry. The outer edge of
|
|
118
|
-
* the stroke coincides with the geometric edge.
|
|
119
|
-
* - `'outer'`: the entire stroke lies outside the geometry. The inner edge
|
|
120
|
-
* of the stroke coincides with the geometric edge.
|
|
121
|
-
*
|
|
122
|
-
* Mirrors the (proposed) SVG `stroke-alignment` property. Honoring `inner`
|
|
123
|
-
* or `outer` is the renderer's responsibility — for axis-aligned rects, the
|
|
124
|
-
* kit shifts coordinates by `width / 2`. For arbitrary paths, renderers
|
|
125
|
-
* typically use a stencil mask of the stroked path against the geometry.
|
|
126
|
-
*/
|
|
127
|
-
type StrokeAlign = 'center' | 'inner' | 'outer';
|
|
128
|
-
/** Stroke style: a FillStyle plus structural line parameters. */
|
|
129
|
-
interface Stroke {
|
|
130
|
-
paint: FillStyle;
|
|
131
|
-
width?: number;
|
|
132
|
-
/** Per `CanvasRenderingContext2D.setLineDash` — empty/omitted = solid. */
|
|
133
|
-
dash?: number[];
|
|
134
|
-
cap?: 'butt' | 'round' | 'square';
|
|
135
|
-
join?: 'miter' | 'round' | 'bevel';
|
|
136
|
-
/**
|
|
137
|
-
* Miter join fallback threshold. When the miter length exceeds
|
|
138
|
-
* `miterLimit * width / 2`, the join falls back to a bevel. Default 10
|
|
139
|
-
* (matching Canvas2D). SVG's default is 4; consumers that want SVG
|
|
140
|
-
* fidelity should set this explicitly when constructing strokes from
|
|
141
|
-
* SVG sources where the attribute was omitted.
|
|
142
|
-
*/
|
|
143
|
-
miterLimit?: number;
|
|
144
|
-
/** Where the stroke sits relative to the geometric edge. Default `'center'`. */
|
|
145
|
-
align?: StrokeAlign;
|
|
146
|
-
/**
|
|
147
|
-
* Per-anchor RGBA, flat (length = 4 × countPathAnchors(path)). Each
|
|
148
|
-
* value in 0..1. Arc-length interpolated across the tessellated ribbon
|
|
149
|
-
* between consecutive anchors. When set, `paint` is still required —
|
|
150
|
-
* its `opacity` (and color, as a placeholder) flow through the shader.
|
|
151
|
-
*/
|
|
152
|
-
vertexColors?: number[];
|
|
153
|
-
/**
|
|
154
|
-
* Per-anchor stroke width (length = `countPathAnchors(path)`). When set,
|
|
155
|
-
* the tessellator interpolates half-widths along each segment to produce
|
|
156
|
-
* a tapered ribbon. `width` is used as the fallback for any anchor whose
|
|
157
|
-
* entry is missing or non-finite. Pressure-driven pencil strokes use
|
|
158
|
-
* this; pair with `pressureToWidth` to derive widths from stylus input.
|
|
159
|
-
*
|
|
160
|
-
* Joins between adjacent segments whose widths differ by more than
|
|
161
|
-
* `varyingWidthJoinThreshold` (default 1.5×) are forced to bevel
|
|
162
|
-
* regardless of the `join` setting — miter math is unstable when widths
|
|
163
|
-
* vary across the corner; smooth round joins with mismatched widths
|
|
164
|
-
* are a future enhancement.
|
|
165
|
-
*/
|
|
166
|
-
vertexWidths?: number[];
|
|
167
|
-
/**
|
|
168
|
-
* Max width ratio (greater / lesser) at which a non-bevel join is
|
|
169
|
-
* preserved when `vertexWidths` causes adjacent segments to differ.
|
|
170
|
-
* Beyond this ratio the join falls back to bevel. Default 1.5. Ignored
|
|
171
|
-
* when `vertexWidths` is absent.
|
|
172
|
-
*/
|
|
173
|
-
varyingWidthJoinThreshold?: number;
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Inflate (positive) or deflate (negative) a rect to honor `align` when
|
|
177
|
-
* stroking it. Returns the rect to pass to a stroked-rect renderer. `width`
|
|
178
|
-
* is the stroke width (defaults to 1 to match canvas).
|
|
179
|
-
*
|
|
180
|
-
* Pure geometry helper — no rendering side effects. Used by path
|
|
181
|
-
* tessellation and the selection overlay to produce a rect whose
|
|
182
|
-
* center-aligned stroke visually coincides with the requested
|
|
183
|
-
* inner/outer-aligned stroke of the original rect.
|
|
184
|
-
*/
|
|
185
|
-
declare function alignedStrokeRect(rect: {
|
|
186
|
-
x: number;
|
|
187
|
-
y: number;
|
|
188
|
-
width: number;
|
|
189
|
-
height: number;
|
|
190
|
-
}, align: StrokeAlign, width?: number): {
|
|
191
|
-
x: number;
|
|
192
|
-
y: number;
|
|
193
|
-
width: number;
|
|
194
|
-
height: number;
|
|
195
|
-
};
|
|
196
|
-
/** Region a fill is clipped to. */
|
|
197
|
-
interface Region {
|
|
198
|
-
x: number;
|
|
199
|
-
y: number;
|
|
200
|
-
w: number;
|
|
201
|
-
h: number;
|
|
202
|
-
shape: 'rectangle' | 'circle';
|
|
203
|
-
}
|
|
204
|
-
|
|
205
46
|
/**
|
|
206
47
|
* Typography for `TextPose` and friends. Every field is optional; consumers
|
|
207
48
|
* pass `{}` or override the few they care about. Defaults live in
|
|
@@ -248,6 +89,19 @@ interface TextStyle {
|
|
|
248
89
|
underline?: boolean;
|
|
249
90
|
/** Default `false`. */
|
|
250
91
|
strikethrough?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Outline painted over the glyph fill. Omitted (the default) means no
|
|
94
|
+
* outline — there is no such thing as a default text stroke.
|
|
95
|
+
*
|
|
96
|
+
* Only glyphs on the outline tier are stroked: above
|
|
97
|
+
* `textOutlineMinScreenSize` a glyph is a real `PolygonPath`, so it gets
|
|
98
|
+
* the ordinary tessellated ribbon with real joins, caps and miters, in any
|
|
99
|
+
* paint. Below it a glyph is a sampled distance field with no geometry to
|
|
100
|
+
* stroke, and it renders unstroked rather than approximated. `width` is in
|
|
101
|
+
* world units, like every other stroke in the kit — it does not scale with
|
|
102
|
+
* `fontSize`.
|
|
103
|
+
*/
|
|
104
|
+
stroke?: Stroke;
|
|
251
105
|
}
|
|
252
106
|
/** `TextStyle` with all fields filled in from defaults — what the renderer actually consumes. */
|
|
253
107
|
interface ResolvedTextStyle {
|
|
@@ -264,6 +118,9 @@ interface ResolvedTextStyle {
|
|
|
264
118
|
letterSpacing: number;
|
|
265
119
|
underline: boolean;
|
|
266
120
|
strikethrough: boolean;
|
|
121
|
+
/** Absent means no outline — unlike the other fields, this one has no
|
|
122
|
+
* default to fall back to. See {@link TextStyle.stroke}. */
|
|
123
|
+
stroke?: Stroke;
|
|
267
124
|
}
|
|
268
125
|
/** Default resolved style used when a `TextPose` omits `style`. */
|
|
269
126
|
declare const DEFAULT_TEXT_STYLE: ResolvedTextStyle;
|
|
@@ -290,6 +147,10 @@ interface StyledRun {
|
|
|
290
147
|
fontFamily?: string;
|
|
291
148
|
fontSize?: number;
|
|
292
149
|
fill?: FillStyle;
|
|
150
|
+
/** Outline over this run's glyphs. Overrides the node style's stroke;
|
|
151
|
+
* absent inherits it. Only painted on the outline tier — see
|
|
152
|
+
* {@link TextStyle.stroke}. */
|
|
153
|
+
stroke?: Stroke;
|
|
293
154
|
letterSpacing?: number;
|
|
294
155
|
underline?: boolean;
|
|
295
156
|
strikethrough?: boolean;
|
|
@@ -330,6 +191,9 @@ interface ResolvedRun {
|
|
|
330
191
|
fontWeight: number;
|
|
331
192
|
fontStyle: 'normal' | 'italic';
|
|
332
193
|
fill: FillStyle;
|
|
194
|
+
/** Outline over this run's glyphs, or absent for none. Painted only on the
|
|
195
|
+
* outline tier — a distance field has no geometry to stroke. */
|
|
196
|
+
stroke?: Stroke;
|
|
333
197
|
/** Extra advance added after each glyph of this run, in world units. */
|
|
334
198
|
letterSpacing: number;
|
|
335
199
|
/** Draw a rule below this run's baseline. Additive over the node style. */
|
|
@@ -497,6 +361,10 @@ interface ImageDrawCommand {
|
|
|
497
361
|
w: number;
|
|
498
362
|
h: number;
|
|
499
363
|
opacity?: number;
|
|
364
|
+
/** Magnification filter. `'linear'` (default) smooths; `'nearest'` shows
|
|
365
|
+
* device pixels as hard squares — required by anything magnifying a
|
|
366
|
+
* framebuffer readback, where blur destroys the point of the readback. */
|
|
367
|
+
sampling?: 'linear' | 'nearest';
|
|
500
368
|
}
|
|
501
369
|
/**
|
|
502
370
|
* Custom shader draw command. The renderer generates a quad over `bounds`
|
|
@@ -521,4 +389,4 @@ interface ShaderDrawCommand {
|
|
|
521
389
|
};
|
|
522
390
|
}
|
|
523
391
|
|
|
524
|
-
export { type DrawCommand as D, type
|
|
392
|
+
export { type DrawCommand as D, type GroupDrawCommand as G, type ImageDrawCommand as I, type Mat3 as M, type PathDrawCommand as P, type ResolvedTextStyle as R, type ShaderProgramHandle as S, type TextDrawCommand as T, type ShaderDrawCommand as a, type ShaderUniform as b, type SolidPaint as c, type StyledRun as d, type TextStyle as e, type TextVerticalAlign as f, DEFAULT_TEXT_STYLE as g, type ResolvedRun as h, fontString as i, markdownToRuns as j, resolveRuns as k, resolveTextStyle as l, mat3 as m, runsToMarkdown as n, runsToPlainText as o, registerProgram as r, toRuns as t, verticalAlignOffset as v };
|
|
@@ -47,7 +47,7 @@ var PIXELS = {
|
|
|
47
47
|
units: { px: 1 }
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
// src/
|
|
50
|
+
// src/core/geometry/path.ts
|
|
51
51
|
var PATH_M = 0;
|
|
52
52
|
var PATH_L = 1;
|
|
53
53
|
var PATH_C = 2;
|
|
@@ -637,6 +637,28 @@ var ROTATED_POSE_DESCRIPTOR = {
|
|
|
637
637
|
lerp: RECT_POSE_DESCRIPTOR.lerp,
|
|
638
638
|
getRotation: (p) => p.rotation
|
|
639
639
|
};
|
|
640
|
+
function remapRotatedLeaf(pose, src, dst) {
|
|
641
|
+
const sx = src.width === 0 ? 1 : dst.width / src.width;
|
|
642
|
+
const sy = src.height === 0 ? 1 : dst.height / src.height;
|
|
643
|
+
const theta = pose.rotation ?? 0;
|
|
644
|
+
const cos = Math.cos(theta);
|
|
645
|
+
const sin = Math.sin(theta);
|
|
646
|
+
const ux = sx * cos, uy = sy * sin;
|
|
647
|
+
const vx = -sx * sin, vy = sy * cos;
|
|
648
|
+
const width = pose.width * Math.hypot(ux, uy);
|
|
649
|
+
const height = pose.height * Math.hypot(vx, vy);
|
|
650
|
+
const rotation = Math.atan2(uy, ux);
|
|
651
|
+
const cxNew = dst.x + (pose.x + pose.width / 2 - src.x) * sx;
|
|
652
|
+
const cyNew = dst.y + (pose.y + pose.height / 2 - src.y) * sy;
|
|
653
|
+
return {
|
|
654
|
+
...pose,
|
|
655
|
+
x: cxNew - width / 2,
|
|
656
|
+
y: cyNew - height / 2,
|
|
657
|
+
width,
|
|
658
|
+
height,
|
|
659
|
+
rotation
|
|
660
|
+
};
|
|
661
|
+
}
|
|
640
662
|
|
|
641
663
|
// src/features/paths/poseDescriptor.ts
|
|
642
664
|
var pathPoseDescriptor = {
|
|
@@ -779,9 +801,24 @@ function pointToGridCell(point, spacing, unitSystem, origin = { x: 0, y: 0 }) {
|
|
|
779
801
|
};
|
|
780
802
|
}
|
|
781
803
|
|
|
782
|
-
// src/core/viewport/
|
|
783
|
-
|
|
784
|
-
|
|
804
|
+
// src/core/viewport/pxExtent.ts
|
|
805
|
+
var MIN_SCALE = 1e-9;
|
|
806
|
+
function pxExtent(px, scale) {
|
|
807
|
+
return {
|
|
808
|
+
x: px / Math.max(MIN_SCALE, Math.abs(scale.x)),
|
|
809
|
+
y: px / Math.max(MIN_SCALE, Math.abs(scale.y))
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
function scaleDelta(dx, dy, scale) {
|
|
813
|
+
return { x: dx * scale.x, y: dy * scale.y };
|
|
814
|
+
}
|
|
815
|
+
function withinPxBox(dx, dy, px, scale) {
|
|
816
|
+
const s = scaleDelta(dx, dy, scale);
|
|
817
|
+
return Math.abs(s.x) <= px && Math.abs(s.y) <= px;
|
|
818
|
+
}
|
|
819
|
+
function withinPxRadius(dx, dy, px, scale) {
|
|
820
|
+
const s = scaleDelta(dx, dy, scale);
|
|
821
|
+
return s.x * s.x + s.y * s.y <= px * px;
|
|
785
822
|
}
|
|
786
823
|
|
|
787
824
|
// src/interactions/gestures/shared/strategies/guides.ts
|
|
@@ -794,7 +831,7 @@ function guideSnapStrategy(getGuides, options = {}) {
|
|
|
794
831
|
snap(pose) {
|
|
795
832
|
const guides = getGuides();
|
|
796
833
|
if (guides.length === 0) return null;
|
|
797
|
-
const
|
|
834
|
+
const tol = getView ? pxExtent(tolerance, getView().scale) : { x: tolerance, y: tolerance };
|
|
798
835
|
const o = proj.getOrigin(pose);
|
|
799
836
|
let bestDx = 0;
|
|
800
837
|
let bestAbsDx = Infinity;
|
|
@@ -804,14 +841,14 @@ function guideSnapStrategy(getGuides, options = {}) {
|
|
|
804
841
|
if (g.axis === "x") {
|
|
805
842
|
const d = g.offset - o.x;
|
|
806
843
|
const ad = Math.abs(d);
|
|
807
|
-
if (ad <=
|
|
844
|
+
if (ad <= tol.x && ad < bestAbsDx) {
|
|
808
845
|
bestAbsDx = ad;
|
|
809
846
|
bestDx = d;
|
|
810
847
|
}
|
|
811
848
|
} else {
|
|
812
849
|
const d = g.offset - o.y;
|
|
813
850
|
const ad = Math.abs(d);
|
|
814
|
-
if (ad <=
|
|
851
|
+
if (ad <= tol.y && ad < bestAbsDy) {
|
|
815
852
|
bestAbsDy = ad;
|
|
816
853
|
bestDy = d;
|
|
817
854
|
}
|
|
@@ -826,6 +863,6 @@ function guideSnapStrategy(getGuides, options = {}) {
|
|
|
826
863
|
};
|
|
827
864
|
}
|
|
828
865
|
|
|
829
|
-
export { AUTO_POSE_DESCRIPTOR, DEFAULT_FLATTEN_TOLERANCE, DEFAULT_GUIDE_TOLERANCE_PX, IMPERIAL_INCHES, METRIC_MM, PATH_C, PATH_CMD_LENGTHS, PATH_L, PATH_M, PATH_Q, PATH_Z, PIXELS, PathBuilder, RECT_ORIGIN_PROJECTION, RECT_POSE_DESCRIPTOR, ROTATED_POSE_DESCRIPTOR, boundsOfPath, ellipsePath, flattenCubic, flattenCubicWithArcLen, flattenQuadratic, flattenQuadraticWithArcLen, formatUnit, gridSnapStrategy, guideSnapStrategy, linePath,
|
|
830
|
-
//# sourceMappingURL=chunk-
|
|
831
|
-
//# sourceMappingURL=chunk-
|
|
866
|
+
export { AUTO_POSE_DESCRIPTOR, DEFAULT_FLATTEN_TOLERANCE, DEFAULT_GUIDE_TOLERANCE_PX, IMPERIAL_INCHES, METRIC_MM, PATH_C, PATH_CMD_LENGTHS, PATH_L, PATH_M, PATH_Q, PATH_Z, PIXELS, PathBuilder, RECT_ORIGIN_PROJECTION, RECT_POSE_DESCRIPTOR, ROTATED_POSE_DESCRIPTOR, boundsOfPath, ellipsePath, flattenCubic, flattenCubicWithArcLen, flattenQuadratic, flattenQuadraticWithArcLen, formatUnit, gridSnapStrategy, guideSnapStrategy, linePath, pathPoseDescriptor, pointInPath, pointToGridCell, polygonFromPoints, pxExtent, rectPath, regularPolygonPath, remapRotatedLeaf, resolveUnit, scaleDelta, scalePathToBounds, starPath, strokeHitTest, transformPath, translatePath, translatePolygonInPlace, withinPxBox, withinPxRadius };
|
|
867
|
+
//# sourceMappingURL=chunk-6SHZHXXR.js.map
|
|
868
|
+
//# sourceMappingURL=chunk-6SHZHXXR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/units.ts","../src/core/geometry/path.ts","../src/features/paths/bounds.ts","../src/features/paths/flatten.ts","../src/features/paths/hitTest.ts","../src/features/paths/builder.ts","../src/features/paths/transformPath.ts","../src/features/paths/transform.ts","../src/interactions/actions/resize/geometry.ts","../src/features/paths/poseDescriptor.ts","../src/interactions/actions/resize/autoPoseDescriptor.ts","../src/interactions/gestures/shared/strategies/grid.ts","../src/core/viewport/pxExtent.ts","../src/interactions/gestures/shared/strategies/guides.ts"],"names":["ex","ey","COORD_COUNT"],"mappings":";;;AA+BO,SAAS,WAAA,CAAY,GAAc,UAAA,EAAiC;AACzE,EAAA,IAAI,OAAO,CAAA,KAAM,QAAA,EAAU,OAAO,CAAA;AAClC,EAAA,IAAI,CAAC,UAAA,EAAY;AACf,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,mCAAA,EAAsC,CAAA,CAAE,KAAK,CAAA,SAAA,EAAY,EAAE,IAAI,CAAA,yBAAA;AAAA,KACjE;AAAA,EACF;AACA,EAAA,MAAM,MAAA,GAAS,UAAA,CAAW,KAAA,CAAM,CAAA,CA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AE,CAAA;AAAA,IACpC;AAAA,GACF;AACF","file":"chunk-6SHZHXXR.js","sourcesContent":["/**\n * Units — a tiny customizable unit system for canvas-kit APIs.\n *\n * The kit stores all coordinates as bare numbers in a single base unit\n * chosen by the consumer app. To make API call sites self-documenting,\n * the public surface accepts `UnitValue` — either a bare number (interpreted\n * as base units) or a `{ value, unit }` tag that's resolved against a\n * `UnitSystem` at the API boundary. Internals never see units.\n *\n * Linear factors only. No per-axis units. No mixed-unit arithmetic.\n */\n\n/** A unit name (e.g. `'in'`, `'ft'`, `'mm'`). Looked up in a `UnitSystem`. */\nexport type Unit = string;\n\n/** Conversion table mapping unit names to factors against a base unit. */\nexport interface UnitSystem {\n /** Name of the base unit, e.g. 'in'. All conversions resolve to this. */\n base: Unit;\n /** Factor to multiply a value in `unit` by to get base units. base unit's factor is 1. */\n units: Record<Unit, number>;\n}\n\n/** Value at a unit-aware API boundary: bare number (in base units) or `{ value, unit }` tag. */\nexport type UnitValue = number | { value: number; unit: Unit };\n\n/**\n * Resolve a UnitValue to a number in base units.\n * - bare number: returned as-is (assumed base)\n * - tagged: looks up factor; throws if unit not in unit system\n */\nexport function resolveUnit(v: UnitValue, unitSystem?: UnitSystem): number {\n if (typeof v === 'number') return v;\n if (!unitSystem) {\n throw new Error(\n `resolveUnit: tagged value { value: ${v.value}, unit: '${v.unit}' } requires a UnitSystem`,\n );\n }\n const factor = unitSystem.units[v.unit];\n if (factor === undefined) {\n const known = Object.keys(unitSystem.units).join(', ') || '(none)';\n throw new Error(\n `resolveUnit: unknown unit '${v.unit}' (system base: '${unitSystem.base}', known units: ${known})`,\n );\n }\n return v.value * factor;\n}\n\n/**\n * Format a base-unit number as a string in the named display unit.\n * e.g. formatUnit(36, 'ft', IMPERIAL_INCHES) => '3ft'\n * Default precision: 2. Trailing zeros trimmed.\n */\nexport function formatUnit(\n baseValue: number,\n displayUnit: Unit,\n unitSystem: UnitSystem,\n opts?: { precision?: number; suffix?: boolean },\n): string {\n const factor = unitSystem.units[displayUnit];\n if (factor === undefined) {\n const known = Object.keys(unitSystem.units).join(', ') || '(none)';\n throw new Error(\n `formatUnit: unknown unit '${displayUnit}' (system base: '${unitSystem.base}', known units: ${known})`,\n );\n }\n const precision = opts?.precision ?? 2;\n const suffix = opts?.suffix ?? true;\n const display = baseValue / factor;\n // Trim trailing zeros (and a dangling decimal point) without losing precision.\n let s = display.toFixed(precision);\n if (s.includes('.')) {\n s = s.replace(/0+$/, '').replace(/\\.$/, '');\n }\n return suffix ? `${s}${displayUnit}` : s;\n}\n\n/** Imperial unit system with base 'in'. */\nexport const IMPERIAL_INCHES: UnitSystem = {\n base: 'in',\n units: { in: 1, ft: 12, yd: 36, mi: 63360 },\n};\n\n/** Metric unit system with base 'mm'. */\nexport const METRIC_MM: UnitSystem = {\n base: 'mm',\n units: { mm: 1, cm: 10, m: 1000, km: 1_000_000 },\n};\n\n/** Pixel unit system — sole unit is the base. */\nexport const PIXELS: UnitSystem = {\n base: 'px',\n units: { px: 1 },\n};\n","/**\n * Path data model. Vector-graphics primitive used kit-wide as the canonical\n * shape (replacing per-shape ad-hoc poses). SVG-style command stream so we\n * cover lines, polygons, beziers, and multi-contour shapes (think the inner\n * hole of an \"O\") under one type.\n *\n * Storage: command codes in a `Uint8Array`, parameters in a `Float32Array`.\n * Each command consumes a fixed number of float coords from the parameter\n * array; the parser walks both arrays in lockstep. This keeps interaction\n * hot loops monomorphic and keeps GC pressure low under heavy edits.\n *\n * Two path subtypes are distinguished at the type level so common-case\n * machinery (selection AABBs, area-select intersection, hit-testing rect\n * silhouettes) can short-circuit on `RectPath` without paying the polygon\n * kernel cost. Polymorphic kernels accept either via the `Path` union and\n * dispatch on `kind`.\n */\n\n/** Command code: moveTo. */\nexport const PATH_M = 0;\n/** Command code: lineTo. */\nexport const PATH_L = 1;\n/** Command code: cubic bezier (`bezierCurveTo`). */\nexport const PATH_C = 2;\n/** Command code: quadratic bezier (`quadraticCurveTo`). */\nexport const PATH_Q = 3;\n/** Command code: close subpath. */\nexport const PATH_Z = 4;\n\n/** Float coords consumed by each command, indexed by command code. */\nexport const PATH_CMD_LENGTHS: readonly number[] = [2, 2, 6, 4, 0];\n\n/** Fill rule used by polygon path hit-testing and `ctx.fill()`. */\nexport type PathFillRule = 'nonzero' | 'evenodd';\n\n/**\n * Polygon path with arbitrary contours and optional bezier segments.\n * Multi-contour: each `M` opens a new subpath; `Z` closes the current one.\n * Open subpaths (no `Z`) render as polylines and don't contribute to fills.\n */\nexport interface PolygonPath {\n kind: 'polygon';\n commands: Uint8Array;\n coords: Float32Array;\n fillRule: PathFillRule;\n}\n\n/**\n * Axis-aligned rectangle. Fast path for the (very common) case where the\n * shape is just a rect — preserves O(1) bounds and hit-test, avoids the\n * polygon kernel entirely. Promote to `PolygonPath` only when the shape\n * grows beyond what a rect can express.\n */\nexport interface RectPath {\n kind: 'rect';\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** Canonical path shape — either an axis-aligned rect (fast path) or a polygon command stream. */\nexport type Path = PolygonPath | RectPath;\n","/**\n * AABB bounds of a `Path`. Returned as `RectPath` for direct reuse with the\n * rect fast path machinery (selection AABB, area-select intersection).\n *\n * `RectPath` is its own bounds — O(1). For `PolygonPath`, walk segment by\n * segment, computing the tight bound per segment:\n *\n * - `M` / `L`: just the endpoint.\n * - `Q`: quadratic Bezier — endpoints plus axis-aligned extrema (one\n * possible inflection per axis).\n * - `C`: cubic Bezier — endpoints plus axis-aligned extrema (up to two\n * possible inflections per axis, found via the quadratic formula on\n * the derivative).\n *\n * Control points are NOT included directly; they're used only to compute\n * extrema that actually lie on the curve. This avoids the classic \"AABB\n * extends past where the curve visibly reaches\" bug for curved paths whose\n * control points poke outside the visible extent.\n *\n * Empty paths (no commands) return a zero-size rect anchored at the\n * origin — the convention used elsewhere in the kit for missing geometry.\n */\n\nimport { cubicBounds, elevateQuadraticToCubic } from '@weasel-js/geom';\nimport {\n PATH_C,\n PATH_L,\n PATH_M,\n PATH_Q,\n PATH_Z,\n type Path,\n type RectPath,\n} from './types';\n\n/** AABB of a `Path`, returned as a `RectPath` for direct reuse with rect-fast-path machinery. */\nexport function boundsOfPath(path: Path): RectPath {\n if (path.kind === 'rect') return path;\n\n const { commands, coords } = path;\n if (commands.length === 0) {\n return { kind: 'rect', x: 0, y: 0, width: 0, height: 0 };\n }\n\n let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;\n let ci = 0;\n let seen = false;\n // Pen position carried across segments — needed because curves are\n // defined relative to the previous endpoint, which is itself the start\n // of the next segment but not re-encoded in `coords`.\n let px = 0, py = 0;\n\n const include = (x: number, y: number) => {\n if (x < minX) minX = x;\n if (x > maxX) maxX = x;\n if (y < minY) minY = y;\n if (y > maxY) maxY = y;\n seen = true;\n };\n\n for (let i = 0; i < commands.length; i++) {\n const cmd = commands[i];\n switch (cmd) {\n case PATH_M:\n case PATH_L: {\n const x = coords[ci], y = coords[ci + 1];\n include(x, y);\n px = x; py = y;\n ci += 2;\n break;\n }\n case PATH_C: {\n const x1 = coords[ci], y1 = coords[ci + 1];\n const x2 = coords[ci + 2], y2 = coords[ci + 3];\n const x3 = coords[ci + 4], y3 = coords[ci + 5];\n const [bMinX, bMinY, bMaxX, bMaxY] = cubicBounds(px, py, x1, y1, x2, y2, x3, y3);\n include(bMinX, bMinY);\n include(bMaxX, bMaxY);\n px = x3; py = y3;\n ci += 6;\n break;\n }\n case PATH_Q: {\n const qx1 = coords[ci], qy1 = coords[ci + 1];\n const qx2 = coords[ci + 2], qy2 = coords[ci + 3];\n const [c1x, c1y, c2x, c2y] = elevateQuadraticToCubic(px, py, qx1, qy1, qx2, qy2);\n const [bMinX, bMinY, bMaxX, bMaxY] = cubicBounds(px, py, c1x, c1y, c2x, c2y, qx2, qy2);\n include(bMinX, bMinY);\n include(bMaxX, bMaxY);\n px = qx2; py = qy2;\n ci += 4;\n break;\n }\n case PATH_Z:\n break;\n default:\n throw new Error(`boundsOfPath: unknown command ${cmd}`);\n }\n }\n\n if (!seen) return { kind: 'rect', x: 0, y: 0, width: 0, height: 0 };\n return { kind: 'rect', x: minX, y: minY, width: maxX - minX, height: maxY - minY };\n}\n\n","/**\n * Bezier flattening — subdivide cubic and quadratic segments into polyline\n * approximations within a flatness tolerance. Used by hit-testing and\n * (eventually) any kernel that doesn't want to special-case curves.\n *\n * The flatness metric is the maximum perpendicular distance from any\n * control point to the chord between endpoints. When that distance falls\n * below `tolerance`, the segment is \"flat enough\" and emitted as a single\n * line segment.\n *\n * Tolerance is in world units. 0.5 is a sensible default for screen-rate\n * rendering at 1× zoom; consumers that zoom in heavily should pass a\n * tighter tolerance.\n */\n\nexport const DEFAULT_FLATTEN_TOLERANCE = 0.5;\n\n/** Distance from point P to line AB (perpendicular). */\nfunction distPointToLine(px: number, py: number, ax: number, ay: number, bx: number, by: number): number {\n const dx = bx - ax;\n const dy = by - ay;\n const len2 = dx * dx + dy * dy;\n if (len2 === 0) {\n const ex = px - ax;\n const ey = py - ay;\n return Math.sqrt(ex * ex + ey * ey);\n }\n const cross = (px - ax) * dy - (py - ay) * dx;\n return Math.abs(cross) / Math.sqrt(len2);\n}\n\n/**\n * Recursively subdivide a cubic bezier (P0..P3) and append `lineTo`-style\n * vertices to `out` (interleaved x,y). The starting endpoint is *not*\n * appended — callers usually emitted it as the segment's previous vertex.\n */\nexport function flattenCubic(\n x0: number, y0: number,\n x1: number, y1: number,\n x2: number, y2: number,\n x3: number, y3: number,\n tolerance: number,\n out: number[],\n): void {\n const d1 = distPointToLine(x1, y1, x0, y0, x3, y3);\n const d2 = distPointToLine(x2, y2, x0, y0, x3, y3);\n if (Math.max(d1, d2) <= tolerance) {\n out.push(x3, y3);\n return;\n }\n // De Casteljau split at t=0.5\n const x01 = (x0 + x1) * 0.5, y01 = (y0 + y1) * 0.5;\n const x12 = (x1 + x2) * 0.5, y12 = (y1 + y2) * 0.5;\n const x23 = (x2 + x3) * 0.5, y23 = (y2 + y3) * 0.5;\n const x012 = (x01 + x12) * 0.5, y012 = (y01 + y12) * 0.5;\n const x123 = (x12 + x23) * 0.5, y123 = (y12 + y23) * 0.5;\n const x0123 = (x012 + x123) * 0.5, y0123 = (y012 + y123) * 0.5;\n flattenCubic(x0, y0, x01, y01, x012, y012, x0123, y0123, tolerance, out);\n flattenCubic(x0123, y0123, x123, y123, x23, y23, x3, y3, tolerance, out);\n}\n\n/** Recursively subdivide a quadratic bezier (P0, P1, P2). */\nexport function flattenQuadratic(\n x0: number, y0: number,\n x1: number, y1: number,\n x2: number, y2: number,\n tolerance: number,\n out: number[],\n): void {\n const d = distPointToLine(x1, y1, x0, y0, x2, y2);\n if (d <= tolerance) {\n out.push(x2, y2);\n return;\n }\n const x01 = (x0 + x1) * 0.5, y01 = (y0 + y1) * 0.5;\n const x12 = (x1 + x2) * 0.5, y12 = (y1 + y2) * 0.5;\n const x012 = (x01 + x12) * 0.5, y012 = (y01 + y12) * 0.5;\n flattenQuadratic(x0, y0, x01, y01, x012, y012, tolerance, out);\n flattenQuadratic(x012, y012, x12, y12, x2, y2, tolerance, out);\n}\n\n/**\n * Like `flattenCubic` but also appends, for each new flattened point, its\n * arc-length fraction `t` (relative to the polyline distance accumulated so\n * far inside this curve) to `arcOut`. Caller then post-processes the segment's\n * `arcOut` range by dividing each by the segment's total flattened arc length\n * to yield t ∈ (0, 1].\n *\n * The returned values are *cumulative distance from the segment start*, not\n * normalized fractions. Two-pass design (accumulate, then divide) keeps the\n * recursive splitter simple — it doesn't need to know the total length up\n * front.\n */\nexport function flattenCubicWithArcLen(\n x0: number, y0: number,\n x1: number, y1: number,\n x2: number, y2: number,\n x3: number, y3: number,\n tolerance: number,\n out: number[],\n arcOut: number[],\n): number {\n return flattenCubicArcRec(x0, y0, x1, y1, x2, y2, x3, y3, tolerance, out, arcOut, 0);\n}\n\nfunction flattenCubicArcRec(\n x0: number, y0: number,\n x1: number, y1: number,\n x2: number, y2: number,\n x3: number, y3: number,\n tolerance: number,\n out: number[],\n arcOut: number[],\n accum: number,\n): number {\n const d1 = distPointToLine(x1, y1, x0, y0, x3, y3);\n const d2 = distPointToLine(x2, y2, x0, y0, x3, y3);\n if (Math.max(d1, d2) <= tolerance) {\n const lastX = out.length >= 2 ? out[out.length - 2] : x0;\n const lastY = out.length >= 2 ? out[out.length - 1] : y0;\n const seg = Math.hypot(x3 - lastX, y3 - lastY);\n accum += seg;\n out.push(x3, y3);\n arcOut.push(accum);\n return accum;\n }\n const x01 = (x0 + x1) * 0.5, y01 = (y0 + y1) * 0.5;\n const x12 = (x1 + x2) * 0.5, y12 = (y1 + y2) * 0.5;\n const x23 = (x2 + x3) * 0.5, y23 = (y2 + y3) * 0.5;\n const x012 = (x01 + x12) * 0.5, y012 = (y01 + y12) * 0.5;\n const x123 = (x12 + x23) * 0.5, y123 = (y12 + y23) * 0.5;\n const x0123 = (x012 + x123) * 0.5, y0123 = (y012 + y123) * 0.5;\n accum = flattenCubicArcRec(x0, y0, x01, y01, x012, y012, x0123, y0123, tolerance, out, arcOut, accum);\n accum = flattenCubicArcRec(x0123, y0123, x123, y123, x23, y23, x3, y3, tolerance, out, arcOut, accum);\n return accum;\n}\n\nexport function flattenQuadraticWithArcLen(\n x0: number, y0: number,\n x1: number, y1: number,\n x2: number, y2: number,\n tolerance: number,\n out: number[],\n arcOut: number[],\n): number {\n return flattenQuadraticArcRec(x0, y0, x1, y1, x2, y2, tolerance, out, arcOut, 0);\n}\n\nfunction flattenQuadraticArcRec(\n x0: number, y0: number,\n x1: number, y1: number,\n x2: number, y2: number,\n tolerance: number,\n out: number[],\n arcOut: number[],\n accum: number,\n): number {\n const d = distPointToLine(x1, y1, x0, y0, x2, y2);\n if (d <= tolerance) {\n const lastX = out.length >= 2 ? out[out.length - 2] : x0;\n const lastY = out.length >= 2 ? out[out.length - 1] : y0;\n const seg = Math.hypot(x2 - lastX, y2 - lastY);\n accum += seg;\n out.push(x2, y2);\n arcOut.push(accum);\n return accum;\n }\n const x01 = (x0 + x1) * 0.5, y01 = (y0 + y1) * 0.5;\n const x12 = (x1 + x2) * 0.5, y12 = (y1 + y2) * 0.5;\n const x012 = (x01 + x12) * 0.5, y012 = (y01 + y12) * 0.5;\n accum = flattenQuadraticArcRec(x0, y0, x01, y01, x012, y012, tolerance, out, arcOut, accum);\n accum = flattenQuadraticArcRec(x012, y012, x12, y12, x2, y2, tolerance, out, arcOut, accum);\n return accum;\n}\n\n","/**\n * Point-in-path hit-testing. `RectPath` short-circuits to AABB compare\n * (O(1)). `PolygonPath` walks the command stream, flattening any bezier\n * segments to line segments, then runs ray-casting (even-odd) or\n * winding-number (non-zero) per the path's `fillRule`.\n *\n * Open subpaths (no `Z`) are skipped for filled hit-testing — they have\n * no enclosed area. For open polylines (strokes), use `strokeHitTest`\n * which computes point-to-segment distance against the flattened\n * polyline and returns true within a configurable threshold.\n */\n\nimport { flattenCubic, flattenQuadratic, DEFAULT_FLATTEN_TOLERANCE } from './flatten';\nimport {\n PATH_C,\n PATH_L,\n PATH_M,\n PATH_Q,\n PATH_Z,\n type Path,\n type PolygonPath,\n} from './types';\n\n/** Options for `pointInPath`. */\nexport interface PointInPathOptions {\n /** Bezier flattening tolerance in world units. Default 0.5. */\n tolerance?: number;\n}\n\n/** Filled-region hit-test for a `Path`. Rect short-circuits to AABB; polygons run ray-cast / winding per `fillRule`. */\nexport function pointInPath(\n path: Path,\n x: number,\n y: number,\n opts: PointInPathOptions = {},\n): boolean {\n if (path.kind === 'rect') {\n return x >= path.x && x <= path.x + path.width && y >= path.y && y <= path.y + path.height;\n }\n return pointInPolygonPath(path, x, y, opts.tolerance ?? DEFAULT_FLATTEN_TOLERANCE);\n}\n\nfunction pointInPolygonPath(path: PolygonPath, x: number, y: number, tolerance: number): boolean {\n const { commands, coords, fillRule } = path;\n if (commands.length === 0) return false;\n\n // Walk the command stream; flatten beziers into per-subpath vertex arrays.\n // For each closed subpath, accumulate winding/crossings against (x, y).\n let crossings = 0;\n let winding = 0;\n\n let subStartX = 0, subStartY = 0;\n let curX = 0, curY = 0;\n let subVerts: number[] = []; // flat [x, y, x, y, ...] for current subpath\n let subOpen = false;\n\n const flushSubpath = (closed: boolean) => {\n if (closed && subVerts.length >= 4) {\n // Close the subpath back to its start.\n subVerts.push(subStartX, subStartY);\n // Now subVerts is a closed polyline; tally crossings/winding.\n for (let i = 0; i < subVerts.length - 2; i += 2) {\n const ax = subVerts[i], ay = subVerts[i + 1];\n const bx = subVerts[i + 2], by = subVerts[i + 3];\n if (segmentCrossesRayRight(x, y, ax, ay, bx, by)) {\n crossings++;\n if (ay <= y && by > y) winding++;\n else if (by <= y && ay > y) winding--;\n }\n }\n }\n subVerts = [];\n subOpen = false;\n };\n\n let ci = 0;\n for (let i = 0; i < commands.length; i++) {\n const cmd = commands[i];\n switch (cmd) {\n case PATH_M: {\n if (subOpen) flushSubpath(false);\n subStartX = coords[ci]; subStartY = coords[ci + 1];\n curX = subStartX; curY = subStartY;\n subVerts.push(curX, curY);\n subOpen = true;\n ci += 2;\n break;\n }\n case PATH_L: {\n curX = coords[ci]; curY = coords[ci + 1];\n subVerts.push(curX, curY);\n ci += 2;\n break;\n }\n case PATH_C: {\n const x1 = coords[ci], y1 = coords[ci + 1];\n const x2 = coords[ci + 2], y2 = coords[ci + 3];\n const x3 = coords[ci + 4], y3 = coords[ci + 5];\n flattenCubic(curX, curY, x1, y1, x2, y2, x3, y3, tolerance, subVerts);\n curX = x3; curY = y3;\n ci += 6;\n break;\n }\n case PATH_Q: {\n const x1 = coords[ci], y1 = coords[ci + 1];\n const x2 = coords[ci + 2], y2 = coords[ci + 3];\n flattenQuadratic(curX, curY, x1, y1, x2, y2, tolerance, subVerts);\n curX = x2; curY = y2;\n ci += 4;\n break;\n }\n case PATH_Z: {\n flushSubpath(true);\n curX = subStartX; curY = subStartY;\n break;\n }\n default:\n throw new Error(`pointInPath: unknown command ${cmd}`);\n }\n }\n if (subOpen) flushSubpath(false);\n\n return fillRule === 'evenodd' ? (crossings & 1) === 1 : winding !== 0;\n}\n\n/**\n * Does the rightward horizontal ray from (x, y) cross segment (ax,ay)→(bx,by)?\n * Standard half-open rule (segments touching from above count, from below\n * don't) — avoids double-counting at shared vertices.\n */\nfunction segmentCrossesRayRight(\n x: number, y: number,\n ax: number, ay: number,\n bx: number, by: number,\n): boolean {\n if ((ay > y) === (by > y)) return false;\n const xCross = ax + ((y - ay) / (by - ay)) * (bx - ax);\n return x < xCross;\n}\n\n/** Options for {@link strokeHitTest}. */\nexport interface StrokeHitTestOptions {\n /** Bezier flattening tolerance in world units. Default 0.5. */\n tolerance?: number;\n}\n\n/**\n * Stroke-distance hit-test. Returns true when (x, y) lies within\n * `threshold` world units of the path's outline — i.e. when a stroke\n * of total width `2 * threshold` drawn along the path would cover the\n * point.\n *\n * Works for both closed and open subpaths — unlike {@link pointInPath},\n * which only tests filled regions. Use this for picking on open\n * polylines / curves and for adding stroke-clickability to closed\n * shapes (logical OR with `pointInPath` when both behaviors are\n * desired).\n *\n * `threshold` is typically the stroke's half-width plus a small slop\n * (e.g. `strokeWidth / 2 + 4`). Cap segments are approximated by the\n * threshold radius around each anchor — the test treats every flattened\n * segment as a capsule of width `2 * threshold`.\n */\nexport function strokeHitTest(\n path: Path,\n x: number,\n y: number,\n threshold: number,\n opts: StrokeHitTestOptions = {},\n): boolean {\n const t2 = threshold * threshold;\n if (path.kind === 'rect') {\n const { x: rx, y: ry, width: w, height: h } = path;\n return (\n pointSegmentDist2(x, y, rx, ry, rx + w, ry) <= t2\n || pointSegmentDist2(x, y, rx + w, ry, rx + w, ry + h) <= t2\n || pointSegmentDist2(x, y, rx + w, ry + h, rx, ry + h) <= t2\n || pointSegmentDist2(x, y, rx, ry + h, rx, ry) <= t2\n );\n }\n return polylineWithinThreshold(path, x, y, t2, opts.tolerance ?? DEFAULT_FLATTEN_TOLERANCE);\n}\n\nfunction polylineWithinThreshold(\n path: PolygonPath,\n px: number, py: number,\n t2: number,\n tolerance: number,\n): boolean {\n const { commands, coords } = path;\n if (commands.length === 0) return false;\n\n // Reuse pointInPath's command-stream + flatten walk; check distance from\n // (px, py) to each emitted segment instead of accumulating crossings.\n let subStartX = 0, subStartY = 0;\n let curX = 0, curY = 0;\n let subVerts: number[] = [];\n let subOpen = false;\n\n const checkSegments = (closed: boolean): boolean => {\n if (closed && subVerts.length >= 4) subVerts.push(subStartX, subStartY);\n for (let i = 0; i < subVerts.length - 2; i += 2) {\n if (pointSegmentDist2(px, py, subVerts[i], subVerts[i + 1], subVerts[i + 2], subVerts[i + 3]) <= t2) {\n return true;\n }\n }\n return false;\n };\n\n let ci = 0;\n for (let i = 0; i < commands.length; i++) {\n const cmd = commands[i];\n switch (cmd) {\n case PATH_M: {\n if (subOpen) {\n if (checkSegments(false)) return true;\n subVerts = [];\n }\n subStartX = coords[ci]; subStartY = coords[ci + 1];\n curX = subStartX; curY = subStartY;\n subVerts.push(curX, curY);\n subOpen = true;\n ci += 2;\n break;\n }\n case PATH_L: {\n curX = coords[ci]; curY = coords[ci + 1];\n subVerts.push(curX, curY);\n ci += 2;\n break;\n }\n case PATH_C: {\n const x1 = coords[ci], y1 = coords[ci + 1];\n const x2 = coords[ci + 2], y2 = coords[ci + 3];\n const x3 = coords[ci + 4], y3 = coords[ci + 5];\n flattenCubic(curX, curY, x1, y1, x2, y2, x3, y3, tolerance, subVerts);\n curX = x3; curY = y3;\n ci += 6;\n break;\n }\n case PATH_Q: {\n const x1 = coords[ci], y1 = coords[ci + 1];\n const x2 = coords[ci + 2], y2 = coords[ci + 3];\n flattenQuadratic(curX, curY, x1, y1, x2, y2, tolerance, subVerts);\n curX = x2; curY = y2;\n ci += 4;\n break;\n }\n case PATH_Z: {\n if (checkSegments(true)) return true;\n subVerts = [];\n subOpen = false;\n curX = subStartX; curY = subStartY;\n break;\n }\n default:\n throw new Error(`strokeHitTest: unknown command ${cmd}`);\n }\n }\n if (subOpen && checkSegments(false)) return true;\n return false;\n}\n\n/** Squared distance from (px, py) to the closest point on segment (ax,ay)→(bx,by). */\nfunction pointSegmentDist2(\n px: number, py: number,\n ax: number, ay: number,\n bx: number, by: number,\n): number {\n const dx = bx - ax;\n const dy = by - ay;\n const len2 = dx * dx + dy * dy;\n if (len2 === 0) {\n const ex = px - ax, ey = py - ay;\n return ex * ex + ey * ey;\n }\n let t = ((px - ax) * dx + (py - ay) * dy) / len2;\n if (t < 0) t = 0; else if (t > 1) t = 1;\n const cx = ax + t * dx;\n const cy = ay + t * dy;\n const ex = px - cx, ey = py - cy;\n return ex * ex + ey * ey;\n}\n","/**\n * Fluent builder for `PolygonPath`. Hides the `Uint8Array` / `Float32Array`\n * encoding behind move/line/curve/close calls and a final `build()`. Use\n * this to construct paths in tests and demos; production callers that need\n * to mutate large paths in place should reach for the raw arrays directly.\n *\n * Numeric capacity grows by doubling — typical for amortized O(1) push.\n *\n * Also exposes `rectPath` / `polygonFromPoints` shortcuts for the common\n * cases. `rectPath` returns the lighter `RectPath` subtype, not a polygon.\n */\n\nimport {\n PATH_C,\n PATH_L,\n PATH_M,\n PATH_Q,\n PATH_Z,\n type PathFillRule,\n type PolygonPath,\n type RectPath,\n} from './types';\n\n/** Fluent builder for `PolygonPath`; hides the `Uint8Array`/`Float32Array` encoding behind move/line/curve/close calls. */\nexport class PathBuilder {\n private cmds: number[] = [];\n private xs: number[] = [];\n private fillRule: PathFillRule = 'nonzero';\n\n /** Seed a builder with an existing `PolygonPath`. Useful for extending\n * an in-flight path with another segment (e.g. appending a cubic to\n * the end of a curve in response to a user action) without hand-\n * reaching into the `commands` / `coords` typed arrays.\n *\n * ```ts\n * const next = PathBuilder.fromPath(current).curveTo(...).build();\n * ```\n */\n static fromPath(path: PolygonPath): PathBuilder {\n const b = new PathBuilder();\n b.cmds = Array.from(path.commands);\n b.xs = Array.from(path.coords);\n b.fillRule = path.fillRule;\n return b;\n }\n\n setFillRule(rule: PathFillRule): this {\n this.fillRule = rule;\n return this;\n }\n\n moveTo(x: number, y: number): this {\n this.cmds.push(PATH_M);\n this.xs.push(x, y);\n return this;\n }\n\n lineTo(x: number, y: number): this {\n this.cmds.push(PATH_L);\n this.xs.push(x, y);\n return this;\n }\n\n /** Cubic bezier to (x, y) with control points (x1, y1) and (x2, y2). */\n curveTo(x1: number, y1: number, x2: number, y2: number, x: number, y: number): this {\n this.cmds.push(PATH_C);\n this.xs.push(x1, y1, x2, y2, x, y);\n return this;\n }\n\n /** Quadratic bezier to (x, y) with control point (x1, y1). */\n quadTo(x1: number, y1: number, x: number, y: number): this {\n this.cmds.push(PATH_Q);\n this.xs.push(x1, y1, x, y);\n return this;\n }\n\n close(): this {\n this.cmds.push(PATH_Z);\n return this;\n }\n\n build(): PolygonPath {\n return {\n kind: 'polygon',\n commands: new Uint8Array(this.cmds),\n coords: new Float32Array(this.xs),\n fillRule: this.fillRule,\n };\n }\n}\n\n/** Construct a `RectPath` (the fast-path subtype). */\nexport function rectPath(x: number, y: number, width: number, height: number): RectPath {\n return { kind: 'rect', x, y, width, height };\n}\n\n/** Build a closed polygon from a flat list of points. */\nexport function polygonFromPoints(\n points: readonly { x: number; y: number }[],\n opts: { fillRule?: PathFillRule } = {},\n): PolygonPath {\n if (points.length === 0) {\n return {\n kind: 'polygon',\n commands: new Uint8Array(),\n coords: new Float32Array(),\n fillRule: opts.fillRule ?? 'nonzero',\n };\n }\n const b = new PathBuilder();\n if (opts.fillRule) b.setFillRule(opts.fillRule);\n b.moveTo(points[0].x, points[0].y);\n for (let i = 1; i < points.length; i++) b.lineTo(points[i].x, points[i].y);\n b.close();\n return b.build();\n}\n\n/** Cubic-Bezier kappa for circular-quadrant approximation (<1% max error). */\nconst ELLIPSE_KAPPA = 0.5522847498307936;\n\n/** Closed ellipse inscribed in `bounds`, as a 4-cubic-Bezier `PolygonPath`.\n * Matches the geometry `useEllipseTool`'s overlay paints. */\nexport function ellipsePath(\n bounds: { x: number; y: number; width: number; height: number },\n): PolygonPath {\n const cx = bounds.x + bounds.width / 2;\n const cy = bounds.y + bounds.height / 2;\n const rx = bounds.width / 2;\n const ry = bounds.height / 2;\n const ox = rx * ELLIPSE_KAPPA;\n const oy = ry * ELLIPSE_KAPPA;\n const b = new PathBuilder();\n b.moveTo(cx + rx, cy);\n b.curveTo(cx + rx, cy + oy, cx + ox, cy + ry, cx, cy + ry);\n b.curveTo(cx - ox, cy + ry, cx - rx, cy + oy, cx - rx, cy);\n b.curveTo(cx - rx, cy - oy, cx - ox, cy - ry, cx, cy - ry);\n b.curveTo(cx + ox, cy - ry, cx + rx, cy - oy, cx + rx, cy);\n b.close();\n return b.build();\n}\n\n/** Closed regular n-gon centered at `center`, circumscribed by `radius`.\n * `rotation` is in radians; default 0 puts the first vertex on the +x axis. */\nexport function regularPolygonPath(\n center: { x: number; y: number },\n radius: number,\n sides: number,\n rotation = 0,\n): PolygonPath {\n const b = new PathBuilder();\n for (let i = 0; i < sides; i++) {\n const a = rotation + (i / sides) * Math.PI * 2;\n const x = center.x + radius * Math.cos(a);\n const y = center.y + radius * Math.sin(a);\n if (i === 0) b.moveTo(x, y); else b.lineTo(x, y);\n }\n b.close();\n return b.build();\n}\n\n/** Closed n-pointed star centered at `center`, alternating `outerRadius` and\n * `innerRadius` (default `outerRadius / 2`). `rotation` is in radians. */\nexport function starPath(\n center: { x: number; y: number },\n outerRadius: number,\n points = 5,\n innerRadius: number = outerRadius / 2,\n rotation = 0,\n): PolygonPath {\n const b = new PathBuilder();\n const n = points * 2;\n for (let i = 0; i < n; i++) {\n const a = rotation + (i / n) * Math.PI * 2;\n const r = i % 2 === 0 ? outerRadius : innerRadius;\n const x = center.x + r * Math.cos(a);\n const y = center.y + r * Math.sin(a);\n if (i === 0) b.moveTo(x, y); else b.lineTo(x, y);\n }\n b.close();\n return b.build();\n}\n\n/** Open 2-vertex polyline from `a` to `b` — strokeable, not fillable. */\nexport function linePath(\n a: { x: number; y: number },\n b: { x: number; y: number },\n): PolygonPath {\n const pb = new PathBuilder();\n pb.moveTo(a.x, a.y);\n pb.lineTo(b.x, b.y);\n return pb.build();\n}\n","import { type Mat3, transformCoords } from '@weasel-js/geom';\nimport { PathBuilder } from './builder';\nimport { type Path, type PolygonPath } from './types';\n\n/** Apply an affine `Mat3` to a path's geometry.\n *\n * Axis-aligned maps (no rotation/shear, i.e. `m[1] === 0 && m[2] === 0`) keep a\n * `RectPath` a rect — the four corners stay axis-aligned, so we transform the\n * two diagonal corners and normalize negative extent (mirror). Rotation or\n * shear promotes the rect's four corners to a `PolygonPath`. Polygon paths map\n * every coord via the kernel's `transformCoords`, preserving the command stream\n * and `fillRule`. Never mutates the input.\n *\n * `Mat3` here is the 6-tuple `number[]` from `@weasel-js/geom` (DOMMatrix order:\n * `[a, b, c, d, e, f]` where `x' = a·x + c·y + e`, `y' = b·x + d·y + f`),\n * not the renderer's 9-element `Float32Array`. */\nexport function transformPath(path: Path, m: Mat3): Path {\n const [a, b, c, d, e, f] = m;\n if (path.kind === 'rect') {\n if (b === 0 && c === 0) {\n // Pure scale + translate — corners remain axis-aligned.\n const x0 = a * path.x + e;\n const y0 = d * path.y + f;\n const x1 = a * (path.x + path.width) + e;\n const y1 = d * (path.y + path.height) + f;\n return {\n kind: 'rect',\n x: Math.min(x0, x1),\n y: Math.min(y0, y1),\n width: Math.abs(x1 - x0),\n height: Math.abs(y1 - y0),\n };\n }\n // Rotation / shear — promote to polygon with the four rect corners.\n const poly = new PathBuilder()\n .moveTo(path.x, path.y)\n .lineTo(path.x + path.width, path.y)\n .lineTo(path.x + path.width, path.y + path.height)\n .lineTo(path.x, path.y + path.height)\n .close()\n .build();\n return transformPolygon(poly, m);\n }\n return transformPolygon(path, m);\n}\n\nfunction transformPolygon(path: PolygonPath, m: Mat3): PolygonPath {\n // transformCoords returns Float64Array; PolygonPath.coords is Float32Array.\n const mapped = transformCoords(path.coords, m);\n return { ...path, coords: Float32Array.from(mapped) };\n}\n","/**\n * In-place and copy-out path transforms. Translation is the most common —\n * called every pointermove during a drag — so the polygon variant mutates\n * the float buffer directly to keep allocation pressure off the GC.\n *\n * `scalePathToBounds` is for the resize interaction: given the path's\n * current AABB and the desired new AABB, scales every coordinate\n * proportionally. Degenerate source bounds (zero width/height) collapse\n * the corresponding axis to the new origin — preferable to dividing by\n * zero or refusing to resize.\n */\n\nimport { boxToBox } from '@weasel-js/geom';\nimport { boundsOfPath } from './bounds';\nimport { transformPath } from './transformPath';\nimport { PATH_C, PATH_L, PATH_M, PATH_Q, PATH_Z, type Path, type PolygonPath, type RectPath } from './types';\n\n/**\n * Translate a path by (dx, dy). Returns a new instance — the kit's pose\n * model treats poses as immutable to keep React state-update semantics\n * predictable. Polygon coords are copied into a fresh `Float32Array`.\n */\nexport function translatePath(path: Path, dx: number, dy: number): Path {\n if (path.kind === 'rect') {\n return { kind: 'rect', x: path.x + dx, y: path.y + dy, width: path.width, height: path.height };\n }\n return translatePolygonCopy(path, dx, dy);\n}\n\nfunction translatePolygonCopy(path: PolygonPath, dx: number, dy: number): PolygonPath {\n const next = new Float32Array(path.coords.length);\n const { commands, coords } = path;\n let ci = 0;\n for (let i = 0; i < commands.length; i++) {\n const len = COORD_COUNT[commands[i]];\n for (let k = 0; k < len; k += 2) {\n next[ci + k] = coords[ci + k] + dx;\n next[ci + k + 1] = coords[ci + k + 1] + dy;\n }\n ci += len;\n }\n return { kind: 'polygon', commands: path.commands, coords: next, fillRule: path.fillRule };\n}\n\n/**\n * Translate a polygon path's coords *in place*. Returns the same\n * `PolygonPath` reference. Use only for transient overlay buffers — never\n * for committed scene state, which must remain immutable for React.\n */\nexport function translatePolygonInPlace(path: PolygonPath, dx: number, dy: number): PolygonPath {\n const { commands, coords } = path;\n let ci = 0;\n for (let i = 0; i < commands.length; i++) {\n const len = COORD_COUNT[commands[i]];\n for (let k = 0; k < len; k += 2) {\n coords[ci + k] += dx;\n coords[ci + k + 1] += dy;\n }\n ci += len;\n }\n return path;\n}\n\n/**\n * Scale a path's coords so its current AABB maps to `target`. Resize\n * interactions use this to make a polygon follow a corner-handle drag.\n *\n * Degenerate source axes (width or height == 0) collapse to `target.x` /\n * `target.y` — every coord on that axis becomes the new origin. Avoids\n * division by zero without throwing.\n */\nexport function scalePathToBounds(path: Path, target: RectPath): Path {\n if (path.kind === 'rect') {\n return { kind: 'rect', x: target.x, y: target.y, width: target.width, height: target.height };\n }\n const src = boundsOfPath(path);\n return scalePolygon(path, src, target);\n}\n\nfunction scalePolygon(path: PolygonPath, src: RectPath, dst: RectPath): PolygonPath {\n const m = boxToBox(src.x, src.y, src.width, src.height, dst.x, dst.y, dst.width, dst.height);\n // src/dst are axis-aligned, so the polygon stays a polygon after this pure scale+translate.\n return transformPath(path, m) as PolygonPath;\n}\n\nconst COORD_COUNT: Readonly<Record<number, number>> = {\n [PATH_M]: 2,\n [PATH_L]: 2,\n [PATH_C]: 6,\n [PATH_Q]: 4,\n [PATH_Z]: 0,\n};\n","import type { ResizePose, RotatedPose } from '../../gestures/types';\n\n/**\n * Bridges arbitrary `TPose` shapes into the resize hook's bounds-driven math.\n * The hook reads bounds via `getBounds`, runs anchor-relative math on those\n * bounds, then asks `remapBounds` to project the result back into TPose.\n *\n * `remapBounds(pose, src, dst)` is a single operation that subsumes both\n * \"set my own AABB to dst\" (single-leaf resize) and \"scale me as a leaf\n * inside parent's src→dst rect\" (group resize) — they're the same affine\n * map. For rect-shaped poses the default geometry interprets the pose as\n * its own bounds; for Path or polygon poses the consumer supplies a\n * projection that knows how to read and rewrite the underlying geometry.\n */\nexport interface PoseProjection<TPose> {\n getBounds(pose: TPose): ResizePose;\n remapBounds(pose: TPose, src: ResizePose, dst: ResizePose): TPose;\n /** Translate the pose by (dx, dy). Optional — when omitted, callers fall\n * back to a translation derived from `remapBounds` (origin shifted, no\n * scale). Path-shaped poses should provide this for performance. */\n translate?(pose: TPose, dx: number, dy: number): TPose;\n /** True iff any portion of the pose's geometry intersects `rect`. Optional\n * — when omitted, area-select and similar callers test against `getBounds`\n * AABB (looser, but correct for axis-aligned rect poses). */\n intersectsRect?(pose: TPose, rect: ResizePose): boolean;\n /** Interpolate between two poses. Optional — animation helpers fall back to\n * rect-shape lerp when omitted (which fails for non-rect poses). */\n lerp?(a: TPose, b: TPose, t: number): TPose;\n /** Read the pose's rotation in radians. Pivot is the AABB center\n * (`getBounds(pose)` center). Default 0 when omitted — descriptor\n * declares \"this pose has no rotation.\" When supplied and non-zero,\n * `useResize` projects the drag delta into the leaf's local frame,\n * runs anchor math there, and translates the resulting pose so the\n * diagonally opposite world-space corner is pinned. */\n getRotation?(pose: TPose): number;\n /** True iff this pose shape can carry a rotation. Consulted by the\n * rotation affordance to decide whether to render the rotate cursor /\n * drag-band over a selection. When omitted, the kit assumes `true` for\n * back-compat — descriptors whose poses lack `x/y/width/height/rotation`\n * fields (e.g. polygon Paths) should return `false` so the affordance\n * hides instead of exposing a non-functional rotate cursor. */\n supportsRotation?(pose: TPose): boolean;\n}\n\n/** AABB-vs-AABB overlap. Exported for callers building a default\n * `intersectsRect` from `getBounds`. */\nexport function aabbIntersectsRect(b: ResizePose, r: ResizePose): boolean {\n return b.x < r.x + r.width && b.x + b.width > r.x && b.y < r.y + r.height && b.y + b.height > r.y;\n}\n\n/** Identity geometry for `TPose extends ResizePose`. Treats the pose as its\n * own bounds and remaps via affine scale against `src`/`dst`. */\nexport const RECT_POSE_DESCRIPTOR: PoseProjection<ResizePose> = {\n getBounds: (p) => p,\n remapBounds: (p, src, dst) => {\n const sx = src.width === 0 ? 1 : dst.width / src.width;\n const sy = src.height === 0 ? 1 : dst.height / src.height;\n return {\n ...p,\n x: dst.x + (p.x - src.x) * sx,\n y: dst.y + (p.y - src.y) * sy,\n width: p.width * sx,\n height: p.height * sy,\n };\n },\n translate: (p, dx, dy) => ({ ...p, x: p.x + dx, y: p.y + dy }),\n intersectsRect: (p, r) => aabbIntersectsRect(p, r),\n lerp: (a, b, t) => ({\n ...a,\n x: a.x + (b.x - a.x) * t,\n y: a.y + (b.y - a.y) * t,\n width: a.width + (b.width - a.width) * t,\n height: a.height + (b.height - a.height) * t,\n }),\n};\n\n/** Identity geometry for `RotatedPose`. Inherits rect-shape projection\n * from `RECT_POSE_DESCRIPTOR` (the `RotatedPose extends ResizePose`\n * subtype lets the rect descriptor's methods apply directly; `remapBounds`\n * preserves the `rotation` field via `...p` spread). Adds `getRotation` so\n * `useResize` knows to take the rotation-aware math path. */\nexport const ROTATED_POSE_DESCRIPTOR: PoseProjection<RotatedPose> = {\n getBounds: RECT_POSE_DESCRIPTOR.getBounds as PoseProjection<RotatedPose>['getBounds'],\n remapBounds: RECT_POSE_DESCRIPTOR.remapBounds as PoseProjection<RotatedPose>['remapBounds'],\n translate: RECT_POSE_DESCRIPTOR.translate as PoseProjection<RotatedPose>['translate'],\n intersectsRect: RECT_POSE_DESCRIPTOR.intersectsRect as PoseProjection<RotatedPose>['intersectsRect'],\n lerp: RECT_POSE_DESCRIPTOR.lerp as PoseProjection<RotatedPose>['lerp'],\n getRotation: (p) => p.rotation,\n};\n\n/**\n * Remap a **rotated** leaf inside a group resize.\n *\n * The naive `remapBounds` scales a leaf's axis-aligned `width`/`height` by the\n * group's per-axis factors and carries `rotation` through untouched. That is\n * right when `src`/`dst` are already expressed in the leaf's own frame — the\n * single-leaf resize path, where the drag delta was projected into that frame\n * before the anchor math ran. In a group resize they are world-frame, so the\n * leaf's local axes do not line up with the axes being scaled: at 90° a\n * horizontal stretch should grow the leaf's `height`, and the naive map grows\n * its `width`.\n *\n * What this computes is the group affine applied to the leaf's local frame,\n * with the shear dropped — the pose model is `{x, y, width, height, rotation}`\n * and cannot represent the parallelogram a non-uniform scale of a rotated box\n * actually produces. The centre moves exactly; each local axis takes the\n * length of its own image; the rotation follows the image of the local x-axis.\n *\n * Degenerates to the naive map at `rotation === 0`, and to a plain uniform\n * scale when `sx === sy`, both exactly.\n */\nexport function remapRotatedLeaf<TPose extends RotatedPose>(\n pose: TPose,\n src: ResizePose,\n dst: ResizePose,\n): TPose {\n const sx = src.width === 0 ? 1 : dst.width / src.width;\n const sy = src.height === 0 ? 1 : dst.height / src.height;\n const theta = pose.rotation ?? 0;\n const cos = Math.cos(theta);\n const sin = Math.sin(theta);\n\n // Images of the leaf's local unit axes under the group's diagonal scale.\n const ux = sx * cos, uy = sy * sin;\n const vx = -sx * sin, vy = sy * cos;\n\n const width = pose.width * Math.hypot(ux, uy);\n const height = pose.height * Math.hypot(vx, vy);\n const rotation = Math.atan2(uy, ux);\n\n // The centre is a point, so it takes the group affine directly.\n const cxNew = dst.x + (pose.x + pose.width / 2 - src.x) * sx;\n const cyNew = dst.y + (pose.y + pose.height / 2 - src.y) * sy;\n\n return {\n ...pose,\n x: cxNew - width / 2,\n y: cyNew - height / 2,\n width,\n height,\n rotation,\n };\n}\n","import { boundsOfPath } from './bounds';\nimport { pointInPath } from './hitTest';\nimport { translatePath } from './transform';\nimport { PATH_C, PATH_L, PATH_M, PATH_Q, PATH_Z, type Path, type PolygonPath } from './types';\nimport { aabbIntersectsRect, type PoseProjection } from 'interactions/actions/resize/geometry';\nimport type { ResizePose } from 'interactions/gestures/types';\n\n/**\n * `PoseProjection` for `Path` poses — wires `useResize` to operate\n * on `Path` directly. `getBounds` defers to the same `boundsOfPath` kernel\n * the rest of the kit uses; `remapBounds` does an affine scale of every\n * coord against `src`/`dst`. Degenerate axes (zero src extent) collapse to\n * the new origin so resize from a flat edge doesn't produce NaN.\n *\n * Mirrors `scalePathToBounds` but takes `src` explicitly: the resize hook\n * knows the group's origin AABB and uses it for every leaf, instead of\n * each leaf scaling against its own AABB (which would ignore group context).\n */\nexport const pathPoseDescriptor: PoseProjection<Path> = {\n getBounds: (path) => boundsOfPath(path),\n remapBounds: (path, src, dst) => {\n const sx = src.width === 0 ? 0 : dst.width / src.width;\n const sy = src.height === 0 ? 0 : dst.height / src.height;\n if (path.kind === 'rect') {\n return {\n kind: 'rect',\n x: dst.x + (path.x - src.x) * sx,\n y: dst.y + (path.y - src.y) * sy,\n width: path.width * sx,\n height: path.height * sy,\n };\n }\n return remapPolygon(path, src, dst, sx, sy);\n },\n translate: (path, dx, dy) => translatePath(path, dx, dy),\n // WHY: AABB pre-test is cheap; only fall through to per-corner pointInPath\n // when the rect is fully inside the AABB (silhouette test).\n intersectsRect: (path, rect) => {\n const b = boundsOfPath(path);\n if (!aabbIntersectsRect(b, rect)) return false;\n if (path.kind === 'rect') return true;\n // Sample the rect's four corners; any inside the polygon ⇒ overlap.\n if (\n pointInPath(path, rect.x, rect.y) ||\n pointInPath(path, rect.x + rect.width, rect.y) ||\n pointInPath(path, rect.x, rect.y + rect.height) ||\n pointInPath(path, rect.x + rect.width, rect.y + rect.height)\n ) return true;\n // Conservative fallback: AABB overlap counts. Tighter edge-vs-edge test\n // would be the next step; defer until a demo demands it.\n return true;\n },\n lerp: (a, b, t) => {\n if (a.kind === 'rect' && b.kind === 'rect') {\n return {\n kind: 'rect',\n x: a.x + (b.x - a.x) * t,\n y: a.y + (b.y - a.y) * t,\n width: a.width + (b.width - a.width) * t,\n height: a.height + (b.height - a.height) * t,\n };\n }\n if (a.kind === 'polygon' && b.kind === 'polygon' && a.coords.length === b.coords.length) {\n const next = new Float32Array(a.coords.length);\n for (let i = 0; i < a.coords.length; i++) {\n next[i] = a.coords[i] + (b.coords[i] - a.coords[i]) * t;\n }\n return { kind: 'polygon', commands: a.commands, coords: next, fillRule: a.fillRule };\n }\n throw new Error('pathPoseDescriptor.lerp: incompatible path shapes');\n },\n // Path poses carry no x/y/width/height/rotation fields — the kit's\n // `wrapWithPoseRotation` helper has nothing to bind a rotation to, and\n // `remapBounds` would drop a synthetic rotation field on every commit.\n // Returning false here hides the rotation affordance for Path consumers\n // so the rotate cursor doesn't appear without a working interaction.\n supportsRotation: () => false,\n};\n\nfunction remapPolygon(path: PolygonPath, src: ResizePose, dst: ResizePose, sx: number, sy: number): PolygonPath {\n const next = new Float32Array(path.coords.length);\n const { commands, coords } = path;\n let ci = 0;\n for (let i = 0; i < commands.length; i++) {\n const len = COORD_COUNT[commands[i]];\n for (let k = 0; k < len; k += 2) {\n next[ci + k] = dst.x + (coords[ci + k] - src.x) * sx;\n next[ci + k + 1] = dst.y + (coords[ci + k + 1] - src.y) * sy;\n }\n ci += len;\n }\n return { kind: 'polygon', commands: path.commands, coords: next, fillRule: path.fillRule };\n}\n\nconst COORD_COUNT: Readonly<Record<number, number>> = {\n [PATH_M]: 2,\n [PATH_L]: 2,\n [PATH_C]: 6,\n [PATH_Q]: 4,\n [PATH_Z]: 0,\n};\n","import type { Path } from 'features/paths/types';\nimport { pathPoseDescriptor } from 'features/paths/poseDescriptor';\nimport { RECT_POSE_DESCRIPTOR, type PoseProjection } from './geometry';\n\n/** True for Path-shaped poses (`{kind: 'polygon' | 'rect'}`). Useful for\n * callers that need to fork between `pathPoseDescriptor` and\n * `RECT_POSE_DESCRIPTOR` without forcing the consumer to wire `geometry`\n * explicitly. */\nexport function isPathLike(p: unknown): p is Path {\n return !!p && typeof p === 'object' && 'kind' in p\n && ((p as { kind: unknown }).kind === 'polygon' || (p as { kind: unknown }).kind === 'rect');\n}\n\n/** Per-call dispatch: if the pose looks like a Path, route to\n * `pathPoseDescriptor`; otherwise treat as a plain rect pose. Avoids forcing\n * demos with Path TPose to wire `geometry={pathPoseDescriptor}` explicitly.\n * `getRotation` surfaces a `pose.rotation` field on non-Path poses so demos\n * using rect-with-rotation shapes (e.g. `RotatedPose`) don't have to wire\n * `geometry={ROTATED_POSE_DESCRIPTOR}` just to get rotated selection chrome\n * and rotation-aware corner hit-tests. */\nexport const AUTO_POSE_DESCRIPTOR: PoseProjection<unknown> = {\n getBounds: (p) => isPathLike(p)\n ? pathPoseDescriptor.getBounds(p)\n : RECT_POSE_DESCRIPTOR.getBounds(p as { x: number; y: number; width: number; height: number }),\n remapBounds: (p, src, dst) => isPathLike(p)\n ? pathPoseDescriptor.remapBounds(p, src, dst)\n : RECT_POSE_DESCRIPTOR.remapBounds(p as { x: number; y: number; width: number; height: number }, src, dst),\n translate: (p, dx, dy) => isPathLike(p)\n ? pathPoseDescriptor.translate!(p, dx, dy)\n : RECT_POSE_DESCRIPTOR.translate!(p as { x: number; y: number; width: number; height: number }, dx, dy),\n intersectsRect: (p, rect) => isPathLike(p)\n ? pathPoseDescriptor.intersectsRect!(p, rect)\n : RECT_POSE_DESCRIPTOR.intersectsRect!(p as { x: number; y: number; width: number; height: number }, rect),\n getRotation: (p) => {\n if (isPathLike(p)) return 0;\n const r = (p as { rotation?: unknown }).rotation;\n return typeof r === 'number' ? r : 0;\n },\n // Path-shaped poses can't carry rotation (see `pathPoseDescriptor`).\n // Everything else flows through `wrapWithPoseRotation`'s x/y/w/h gate at\n // paint time, so report `true` and let the wrapper no-op for poses\n // missing AABB fields.\n supportsRotation: (p) => !isPathLike(p),\n};\n","import type { SnapStrategy } from '../../types';\nimport { resolveUnit, type UnitSystem, type UnitValue } from 'core/units';\nimport type { DebugSink } from '../../../../debug/types';\nimport { isPathLike } from 'interactions/actions/resize/autoPoseDescriptor';\nimport { boundsOfPath } from 'features/paths/bounds';\nimport { translatePath } from 'features/paths/transform';\nimport type { Path } from 'features/paths/types';\n\n/**\n * Projection used by `gridSnapStrategy` when `TPose` doesn't expose `{x,y}`\n * directly (Path, polygon, etc.). The strategy reads the snap point via\n * `getOrigin`, rounds it to the grid, then asks `translate` to move the\n * pose by the resulting delta.\n */\nexport interface OriginProjection<TPose> {\n getOrigin(pose: TPose): { x: number; y: number };\n translate(pose: TPose, dx: number, dy: number): TPose;\n}\n\n/** Identity projection for `TPose extends { x; y }`. */\nexport const RECT_ORIGIN_PROJECTION: OriginProjection<{ x: number; y: number }> = {\n getOrigin: (p) => ({ x: p.x, y: p.y }),\n translate: (p, dx, dy) => ({ ...p, x: p.x + dx, y: p.y + dy }),\n};\n\n/** Per-call dispatch: routes Path-shaped poses to the path origin/translate\n * helpers and everything else to `RECT_ORIGIN_PROJECTION`. Default for\n * `gridSnapStrategy` so consumers with Path TPose don't have to thread\n * `pathOriginProjection` explicitly. */\nexport const AUTO_ORIGIN_PROJECTION: OriginProjection<unknown> = {\n getOrigin: (p) => {\n if (isPathLike(p)) {\n const b = boundsOfPath(p as Path);\n return { x: b.x, y: b.y };\n }\n const r = p as { x: number; y: number };\n return { x: r.x, y: r.y };\n },\n translate: (p, dx, dy) => {\n if (isPathLike(p)) return translatePath(p as Path, dx, dy);\n const r = p as { x: number; y: number };\n return { ...r, x: r.x + dx, y: r.y + dy };\n },\n};\n\n/** Snap-strategy that rounds the pose's origin to the nearest multiple of\n * `spacing` (resolved through `unitSystem`). For non-rect TPose pass an\n * `OriginProjection` so the strategy knows how to read/write the origin. */\nexport function gridSnapStrategy<TPose>(\n spacing: UnitValue,\n unitSystem?: UnitSystem,\n): SnapStrategy<TPose>;\nexport function gridSnapStrategy<TPose>(\n spacing: UnitValue,\n opts: { unitSystem?: UnitSystem; debug?: DebugSink },\n): SnapStrategy<TPose>;\nexport function gridSnapStrategy<TPose>(\n spacing: UnitValue,\n opts: { unitSystem?: UnitSystem; origin: OriginProjection<TPose>; debug?: DebugSink },\n): SnapStrategy<TPose>;\n/** Snap-strategy that rounds the pose's origin to the nearest multiple of\n * `spacing` (resolved through `unitSystem`). For non-rect TPose pass an\n * `OriginProjection` so the strategy knows how to read/write the origin. */\nexport function gridSnapStrategy<TPose>(\n spacing: UnitValue,\n arg?: UnitSystem | { unitSystem?: UnitSystem; origin?: OriginProjection<TPose>; debug?: DebugSink },\n): SnapStrategy<TPose> {\n const isOpts =\n typeof arg === 'object' &&\n arg !== null &&\n ('origin' in arg || 'debug' in arg || 'unitSystem' in arg) &&\n !('base' in arg);\n const optsArg = isOpts\n ? (arg as { unitSystem?: UnitSystem; origin?: OriginProjection<TPose>; debug?: DebugSink })\n : null;\n const unitSystem = optsArg ? optsArg.unitSystem : (arg as UnitSystem | undefined);\n const proj: OriginProjection<TPose> = optsArg && optsArg.origin\n ? optsArg.origin\n : (AUTO_ORIGIN_PROJECTION as unknown as OriginProjection<TPose>);\n const debug: DebugSink | undefined = optsArg ? optsArg.debug : undefined;\n const c = resolveUnit(spacing, unitSystem);\n return {\n snap(pose) {\n const o = proj.getOrigin(pose);\n const sx = Math.round(o.x / c) * c;\n const sy = Math.round(o.y / c) * c;\n debug?.recordSnapCandidate({ x: sx, y: sy }, true);\n return proj.translate(pose, sx - o.x, sy - o.y);\n },\n };\n}\n\n/**\n * Compute the integer cell `{col, row}` that contains `point`, given a grid\n * `spacing` and optional `origin` and `unitSystem`. Pair with\n * `createCellHighlightLayer` (its `getCell` callback) to draw a snap-target\n * preview that uses the same spacing as `gridSnapStrategy` — so the visual\n * and behavioral grids stay in lockstep:\n *\n * const SPACING = 20;\n * const snap = gridSnapStrategy(SPACING);\n * // visual grid:\n * createGridLayer({ spacing: SPACING, bounds: () => ... });\n * // hover-preview overlay:\n * createCellHighlightLayer({\n * spacing: SPACING,\n * getCell: () => hoverPoint && pointToGridCell(hoverPoint, SPACING),\n * });\n */\nexport function pointToGridCell(\n point: { x: number; y: number },\n spacing: UnitValue,\n unitSystem?: UnitSystem,\n origin: { x: number; y: number } = { x: 0, y: 0 },\n): { col: number; row: number } {\n const s = resolveUnit(spacing, unitSystem);\n return {\n col: Math.floor((point.x - origin.x) / s),\n row: Math.floor((point.y - origin.y) / s),\n };\n}\n","/**\n * Screen-pixel lengths in world units, per axis.\n *\n * Chrome declares its hit zones in screen pixels — an 8px handle stays 8px at\n * every zoom, because it paints in screen space. Converting one such length to\n * world units with a single scalar (see `meanScale`) is exact only under\n * uniform zoom; per-axis it is too generous on one axis and too mean on the\n * other, so the pickable region stops matching the painted one.\n *\n * Prefer {@link withinPxBox} / {@link withinPxRadius}, which compare in screen\n * space and so can't drift from the paint at all. {@link pxExtent} is for the\n * cases that must stay in world units — a tolerance handed to geometry that\n * doesn't know about the view.\n */\n\nexport interface Scale2 {\n x: number;\n y: number;\n}\n\n/** Guard against a degenerate axis: a zero scale would send the extent to\n * infinity and make every point a hit. */\nconst MIN_SCALE = 1e-9;\n\n/** One screen-pixel length as world-space extents, per axis. */\nexport function pxExtent(px: number, scale: Scale2): { x: number; y: number } {\n return {\n x: px / Math.max(MIN_SCALE, Math.abs(scale.x)),\n y: px / Math.max(MIN_SCALE, Math.abs(scale.y)),\n };\n}\n\n/** World delta → screen delta. Only the scale participates: translation\n * cancels in a difference, and the kit's views carry no skew. */\nexport function scaleDelta(dx: number, dy: number, scale: Scale2): { x: number; y: number } {\n return { x: dx * scale.x, y: dy * scale.y };\n}\n\n/**\n * Is a world-space delta inside a screen-space square of half-extent `px`?\n *\n * The square is axis-aligned **on screen**, which is what a handle painted in\n * screen space actually is — so this stays true under non-uniform zoom and\n * under a rotated target, where an axis-aligned world-space test is a rotated\n * rectangle on screen.\n */\nexport function withinPxBox(dx: number, dy: number, px: number, scale: Scale2): boolean {\n const s = scaleDelta(dx, dy, scale);\n return Math.abs(s.x) <= px && Math.abs(s.y) <= px;\n}\n\n/** Is a world-space delta inside a screen-space circle of radius `px`? */\nexport function withinPxRadius(dx: number, dy: number, px: number, scale: Scale2): boolean {\n const s = scaleDelta(dx, dy, scale);\n return s.x * s.x + s.y * s.y <= px * px;\n}\n","import type { SnapStrategy } from '../../types';\nimport type { Guide } from 'features/guides/types';\nimport type { View } from 'core/viewport/view';\nimport { pxExtent } from 'core/viewport/pxExtent';\nimport type { OriginProjection } from './grid';\nimport { RECT_ORIGIN_PROJECTION } from './grid';\n\n/** Default snap tolerance (screen pixels). */\nexport const DEFAULT_GUIDE_TOLERANCE_PX = 6;\n\n/** Options for `guideSnapStrategy`. */\nexport interface GuideSnapOptions<TPose> {\n /**\n * Tolerance, in screen pixels (CSS px) when `getView` is provided, or in\n * world units otherwise. Defaults to `DEFAULT_GUIDE_TOLERANCE_PX`.\n */\n tolerance?: number;\n /**\n * Read the active view transform. When supplied, `tolerance` is interpreted\n * in screen pixels and divided by `view.scale` so the trigger zone stays\n * the same on screen as the user zooms in/out. Without it, `tolerance`\n * is treated as world units.\n */\n getView?: () => View;\n /**\n * Projection used when `TPose` doesn't expose `{x, y}` directly (Path,\n * polygon, etc.) — same contract as `gridSnapStrategy`. Defaults to the\n * rect-pose identity projection.\n */\n origin?: OriginProjection<TPose>;\n}\n\n/**\n * Snap-strategy that snaps the pose's origin to the nearest guide line on\n * each axis when within tolerance. Each axis is considered independently:\n * a vertical guide (`axis: 'x'`) constrains X, a horizontal guide\n * (`axis: 'y'`) constrains Y. When multiple guides are within range on the\n * same axis, the closest wins.\n *\n * Pair with `useGuides` for storage and `createGuidesLayer` for rendering.\n *\n * **Composition:** combining with `gridSnapStrategy` is left to the\n * consumer in v1 — typically by picking one based on a modifier key, or\n * by stacking two move/resize/insert behaviors in priority order.\n */\nexport function guideSnapStrategy<TPose extends { x: number; y: number }>(\n getGuides: () => readonly Guide[],\n options?: Omit<GuideSnapOptions<TPose>, 'origin'>,\n): SnapStrategy<TPose>;\nexport function guideSnapStrategy<TPose>(\n getGuides: () => readonly Guide[],\n options: GuideSnapOptions<TPose> & { origin: OriginProjection<TPose> },\n): SnapStrategy<TPose>;\nexport function guideSnapStrategy<TPose>(\n getGuides: () => readonly Guide[],\n options: GuideSnapOptions<TPose> = {},\n): SnapStrategy<TPose> {\n const tolerance = options.tolerance ?? DEFAULT_GUIDE_TOLERANCE_PX;\n const getView = options.getView;\n const proj: OriginProjection<TPose> =\n options.origin ?? (RECT_ORIGIN_PROJECTION as unknown as OriginProjection<TPose>);\n\n return {\n snap(pose) {\n const guides = getGuides();\n if (guides.length === 0) return null;\n\n // Convert tolerance to world units, per axis: a guide on the x axis is\n // matched by a horizontal distance, so it answers to `scale.x` alone.\n // With no view, treat tolerance as already-world.\n const tol = getView ? pxExtent(tolerance, getView().scale) : { x: tolerance, y: tolerance };\n\n const o = proj.getOrigin(pose);\n\n let bestDx = 0;\n let bestAbsDx = Infinity;\n let bestDy = 0;\n let bestAbsDy = Infinity;\n\n for (const g of guides) {\n if (g.axis === 'x') {\n const d = g.offset - o.x;\n const ad = Math.abs(d);\n if (ad <= tol.x && ad < bestAbsDx) {\n bestAbsDx = ad;\n bestDx = d;\n }\n } else {\n const d = g.offset - o.y;\n const ad = Math.abs(d);\n if (ad <= tol.y && ad < bestAbsDy) {\n bestAbsDy = ad;\n bestDy = d;\n }\n }\n }\n\n if (bestAbsDx === Infinity && bestAbsDy === Infinity) return null;\n const dx = bestAbsDx === Infinity ? 0 : bestDx;\n const dy = bestAbsDy === Infinity ? 0 : bestDy;\n if (dx === 0 && dy === 0) return null;\n return proj.translate(pose, dx, dy);\n },\n };\n}\n"]}
|