@vitavision/stage2d 0.10.0 → 0.11.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/README.md CHANGED
@@ -15,7 +15,7 @@ bun add @vitavision/stage2d @vitavision/ui
15
15
  child layer together (image, mask, measurement overlay, interactive handles) so they never
16
16
  drift apart, with `StageToolbar` / `StageReadout` as the in-canvas controls and `useStage()`
17
17
  as the way a layer reads the transform. The arithmetic behind it is pure and exported —
18
- `fitScale`, `fitView`, `toImage`, `toScreen`, `zoomAbout`, `clampView`, `frameRect`,
18
+ `fitScale`, `fitView` (both take `FitOptions`), `toImage`, `toScreen`, `zoomAbout`, `clampView`, `frameRect`,
19
19
  `preserveCenter`, `steppedScale`. See "The image stage" below. `ZoomPanCanvas` is its
20
20
  deprecated predecessor, still exported unchanged.
21
21
 
@@ -25,7 +25,11 @@ the stage would magnify it, then load the full image and keep it, and it turns p
25
25
  `StageLayersMenu` is a layers button for `StageToolbar`. Code outside the stage, such as an
26
26
  inspector's "frame this", drives it through `ImageStage`'s `ref` (`StageHandle`: `frame`,
27
27
  `fit`, `zoomTo`). `initialView="fit"` opens a `null` view at fit even when the image would fit
28
- at 1:1.
28
+ at 1:1. `fit={{ padding, upscale }}` gives every fit path (the initial fit, `fit()`, the `0` key, the
29
+ double-click toggle, the toolbar button, `data-fit`) a margin in CSS pixels and, with `upscale: false`, a cap
30
+ at 1:1. The transformed box carries `will-change: transform` (and `data-moving`) only while the view
31
+ moves and for 150 ms after: always on, Chromium keeps the layer at the raster scale it had when the hint
32
+ was applied and a zoomed-in image and its strokes stay blurry.
29
33
  `api/mapValues.ts` decodes the `VAM1` float32-plane wire format into indexable values
30
34
  (`decodePlane`, `valueAt`, `valuesAt`, `fractionOf`, `fetchPlane`) — it never draws;
31
35
  colour range and colormap stay the caller's decision.
@@ -85,9 +89,14 @@ ellipse being drawn, and `MarqueeRect` the rubber band; `useShapeDrag` turns a p
85
89
  image-space displacements with click slop, for select → drag → commit of manual shapes (`translatePoints`
86
90
  shifts flat coordinates).
87
91
 
92
+ **Ellipses**: `EllipseSet` draws many ellipses whose size is data (fitted rings, edge-bit dots, drawn ellipses) as
93
+ exact arcs in a few batched paths, with the states of `AreaSet`. It is picked like `AreaSet`: a press near an
94
+ outline picks that ellipse, else the smallest containing it; `pickable={false}` leaves a decorative layer out.
95
+ - **Pure functions:** `buildEllipseIndex`, `nearestEllipse`, `ellipsesInRect`, `pointInEllipse`, `ellipseBounds`, `ellipsePath`.
96
+
88
97
  **Hit-test**: `useStageHitTest()` answers "what is under the pointer" across layers, ranked by
89
98
  `STAGE_HIT_PRIORITY` (points above lines above areas above images). `PointSet`, `PolylineSet`,
90
- `AreaSet` and `GridLayer` answer it; `useStageHitLayer` registers any other layer. `ImageStage` also takes `panButton`,
99
+ `AreaSet`, `EllipseSet` and `GridLayer` answer it; `useStageHitLayer` registers any other layer. `ImageStage` also takes `panButton`,
91
100
  `doubleClickFit` and `touchPan`, and handles two-finger pinch.
92
101
 
93
102
  **Tool model**: `StageSurface` is the one full-frame press target per stage.
package/dist/index.d.ts CHANGED
@@ -148,14 +148,50 @@ export declare const MAX_SCALE = 32;
148
148
  * the frame edge or checking that a model's points do not run off the image.
149
149
  */
150
150
  export declare const MIN_SCALE_VS_FIT = 0.25;
151
- /** The scale at which the whole image is just visible inside `box`. */
152
- export declare function fitScale(box: Box, image: Box): number;
153
- /** Fit, centred — the view a viewer opens at and the one `0` returns to. */
154
- export declare function fitView(box: Box, image: Box): StageView;
155
- /** The whole image visible at 1:1 if it fits, otherwise fit — a sane opening view. */
156
- export declare function initialView(box: Box, image: Box): StageView;
157
- /** Whether `view` is (indistinguishably) the fit view for this box and image. */
158
- export declare function isFit(view: StageView, box: Box, image: Box): boolean;
151
+ /** How `fitScale` and `fitView` treat the margin and a small image. */
152
+ interface FitOptions {
153
+ /**
154
+ * A margin on each side of the fitted image, in CSS pixels. Defaults to 0: the image fills
155
+ * the box edge to edge. A margin that leaves no room (the box is smaller than twice the
156
+ * padding) is ignored.
157
+ */
158
+ padding?: number | undefined;
159
+ /**
160
+ * Whether fit may magnify a small image past 1:1. On by default; `false` caps the fit scale
161
+ * at 1, so a small image opens at its own size, centred.
162
+ */
163
+ upscale?: boolean | undefined;
164
+ }
165
+ /**
166
+ * The scale at which the whole image is just visible inside `box`.
167
+ *
168
+ * @param box - The viewport, in CSS pixels.
169
+ * @param image - The image, in image pixels.
170
+ * @param options - A margin and an upscale cap; the defaults fill the box edge to edge.
171
+ * @returns CSS pixels per image pixel; `1` for a degenerate box or image.
172
+ */
173
+ export declare function fitScale(box: Box, image: Box, options?: FitOptions): number;
174
+ /**
175
+ * Fit, centred: the view a viewer opens at and the one `0` returns to.
176
+ *
177
+ * @param box - The viewport, in CSS pixels.
178
+ * @param image - The image, in image pixels.
179
+ * @param options - A margin and an upscale cap; see `FitOptions`.
180
+ * @returns The view.
181
+ */
182
+ export declare function fitView(box: Box, image: Box, options?: FitOptions): StageView;
183
+ /**
184
+ * The whole image visible at 1:1 if it fits, otherwise fit — a sane opening view.
185
+ *
186
+ * @param box - The viewport, in CSS pixels.
187
+ * @param image - The image, in image pixels.
188
+ * @param options - Only `padding` matters here (the image must fit inside the margin to open
189
+ * at 1:1, and "otherwise fit" is the padded fit); it never magnifies, so `upscale` is moot.
190
+ * @returns The view.
191
+ */
192
+ export declare function initialView(box: Box, image: Box, options?: FitOptions): StageView;
193
+ /** Whether `view` is (indistinguishably) the fit view for this box, image and `FitOptions`. */
194
+ export declare function isFit(view: StageView, box: Box, image: Box, options?: FitOptions): boolean;
159
195
  /** Where the **centre of** image pixel `p` lands in the viewport. */
160
196
  export declare function toScreen(view: StageView, p: Point): Point;
161
197
  /**
@@ -210,7 +246,7 @@ export declare function frameRect(box: Box, image: Box, rect: Rect, pad?: number
210
246
  * that was *fit* re-fits instead, because fit is a relationship to the viewport rather than
211
247
  * a particular pair of numbers.
212
248
  */
213
- export declare function preserveCenter(view: StageView, from: Box, to: Box, image: Box, options?: ClampOptions): StageView;
249
+ export declare function preserveCenter(view: StageView, from: Box, to: Box, image: Box, options?: ClampOptions, fit?: FitOptions): StageView;
214
250
  /**
215
251
  * The next scale up or down the ladder from `scale`, so the readout lands on a round
216
252
  * percentage rather than wherever a multiplier happened to leave it.
@@ -344,10 +380,17 @@ interface ImageStageProps {
344
380
  label?: string;
345
381
  /**
346
382
  * How a `null` view opens: `"auto"` (the default) at 1:1 when the image fits the viewport
347
- * and fit otherwise; `"fit"` always fit, for a viewer that should show the whole frame
383
+ * (inside the `fit` margin) and fit otherwise; `"fit"` always fit, for a viewer that should show the whole frame
348
384
  * whatever its size.
349
385
  */
350
386
  initialView?: "auto" | "fit" | undefined;
387
+ /**
388
+ * The margin and upscale cap of every fit: `initialView="fit"`, the handle's and the
389
+ * context's `fit()`, the `0` key, the double-click toggle, the toolbar's Fit button, and
390
+ * `isFit` / `data-fit`. Defaults to filling the viewport edge to edge, upscaling freely.
391
+ * Each field is read by value, so an inline object does not re-fit the view.
392
+ */
393
+ fit?: FitOptions | undefined;
351
394
  /** The stage's controls for code outside it; see `StageHandle`. */
352
395
  ref?: Ref<StageHandle> | undefined;
353
396
  }
@@ -356,11 +399,15 @@ interface ImageStageProps {
356
399
  * size, so an overlay drawn in image coordinates stays registered with the photograph at
357
400
  * any zoom and window size. Layers read the transform through `useStage`.
358
401
  *
402
+ * The transformed box (`[data-stage]`) carries `will-change: transform` and `data-moving` while
403
+ * the view changes and for 150 ms after, so a pan stays on the compositor and the layer
404
+ * re-rasterises sharp once the view settles.
405
+ *
359
406
  * State is exposed on the viewport as `data-fit` (the view is fit), `data-panning` (a drag
360
407
  * is in progress) and `data-pan-mode` (the hand tool is on or space is held), each present
361
408
  * or absent.
362
409
  */
363
- export declare function ImageStage({ image, view, onView, children, toolbar, readout, banner, panTool, panButton, doubleClickFit, touchPan, className, style, onHover, onBackgroundClick, clamp, shortcuts, panKeys, label, initialView: opening, ref }: ImageStageProps): import("react").JSX.Element;
410
+ export declare function ImageStage({ image, view, onView, children, toolbar, readout, banner, panTool, panButton, doubleClickFit, touchPan, className, style, onHover, onBackgroundClick, clamp, shortcuts, panKeys, label, initialView: opening, fit: fitOptions, ref }: ImageStageProps): import("react").JSX.Element;
364
411
  //#endregion
365
412
  //#region src/components/stage/hitTest.d.ts
366
413
  /** What a layer is picked as, and so how it ranks against the layers around it. */
@@ -526,6 +573,13 @@ interface StageDrag {
526
573
  onEnd?: ((point: Point, event: PointerEvent, moved: boolean) => void) | undefined;
527
574
  /** The drag was interrupted (`pointercancel`) or the component unmounted mid-drag. */
528
575
  onCancel?: (() => void) | undefined;
576
+ /**
577
+ * Claim a touch that starts this gesture, as a mouse press is claimed: the stage neither
578
+ * pans nor pinches from it. Without it a touch is only watched (see `StageSurface`), so
579
+ * return `true` for a gesture a finger must own, such as moving a selected shape. Ignored for
580
+ * a mouse or pen.
581
+ */
582
+ claimsTouch?: boolean | undefined;
529
583
  }
530
584
  /**
531
585
  * Start a drag from a press on any element inside an `ImageStage`.
@@ -541,6 +595,12 @@ export declare function useStageDrag(): (event: PointerEvent$1<Element>, drag: S
541
595
  interface StagePress {
542
596
  /** Where, in image coordinates. */
543
597
  point: Point;
598
+ /** Where, in client coordinates, for anchoring a tooltip or a menu. */
599
+ client: Point;
600
+ /** The press is a touch: act on its release (see `StageSurface`), and expect a fingertip's tolerance. */
601
+ touch: boolean;
602
+ /** The hit-test tolerance for this pointer, in screen pixels: 12 for a touch, 6 otherwise. Pass it to `useStageHitTest`. */
603
+ radius: number;
544
604
  /** Shift was held. */
545
605
  shiftKey: boolean;
546
606
  /** Alt / Option was held. */
@@ -553,22 +613,42 @@ interface StageSurfaceProps {
553
613
  /**
554
614
  * What a press means. Return a `StageDrag` to claim it (a click is a drag that never
555
615
  * moved), or nothing to decline it: a declined press reaches the stage, which pans.
616
+ *
617
+ * **For a touch, act in `onEnd` when `moved` is `false` (a tap), not here.** The press may
618
+ * become a pan or the first finger of a pinch, so nothing should happen until the finger
619
+ * lifts. Return `claimsTouch: true` for a gesture the finger must own.
556
620
  */
557
621
  onPress: (press: StagePress) => StageDrag | null | undefined | void;
558
622
  /** The cursor over the image while no drag is in flight, e.g. `crosshair` for a draw tool. */
559
623
  cursor?: string | undefined;
560
- /** Where the pointer is over the image while no drag is in flight, for hover feedback. */
624
+ /** Where the mouse is over the image while no drag is in flight, for hover feedback. Not called for a touch. */
561
625
  onHover?: ((point: Point) => void) | undefined;
626
+ /**
627
+ * A double click or double tap on the surface. When given, the surface handles it and the
628
+ * stage's double-click-to-fit does not run; leave it out to keep the fit.
629
+ */
630
+ onDoubleClick?: ((point: Point) => void) | undefined;
562
631
  }
563
632
  /**
564
633
  * The stage's one full-frame press target. Put it inside an `ImageStage`, below the layers
565
634
  * that have their own small targets (handles, strokes). Each press is offered to `onPress`
566
635
  * unless the hand tool or a held space bar make it a pan; a declined press pans.
567
636
  *
568
- * The surface draws nothing. It carries `data-dragging` while a drag it started is in
569
- * flight.
637
+ * **Mouse and pen.** Only the left button comes here. The press is claimed and followed on
638
+ * `window`, so the stage does not pan from it.
639
+ *
640
+ * **Touch.** A touch is only *watched* unless its `StageDrag` sets `claimsTouch`: the surface
641
+ * neither stops the press nor captures the pointer, so the stage still pans (one-finger mode)
642
+ * and a second finger still pinches. The drag then sees:
643
+ * - `onMove`, only once the finger has left the tap slop;
644
+ * - `onEnd(point, event, moved)` on release, with `moved` `false` for a tap;
645
+ * - `onCancel` on `pointercancel`, or when a second finger lands (a pinch).
646
+ *
647
+ * A touch gesture that sets `claimsTouch: true` is claimed like a mouse press.
648
+ *
649
+ * The surface draws nothing. It carries `data-dragging` while a gesture it started is in flight.
570
650
  */
571
- export declare function StageSurface({ onPress, cursor, onHover }: StageSurfaceProps): import("react").JSX.Element;
651
+ export declare function StageSurface({ onPress, cursor, onHover, onDoubleClick }: StageSurfaceProps): import("react").JSX.Element;
572
652
  //#endregion
573
653
  //#region src/components/stage/StageToolbar.d.ts
574
654
  /** Props of `StageToolbar`. */
@@ -1290,6 +1370,17 @@ interface PolylineSetProps {
1290
1370
  * and to the layers below.
1291
1371
  */
1292
1372
  marquee?: boolean | undefined;
1373
+ /**
1374
+ * Whether the layer takes presses and hover. Defaults to `true` when any of `onItemPress`,
1375
+ * `onSelect`, `onHover`, `onHoverChange` or `marquee` is given. When `false` the layer
1376
+ * renders no press target at all: a press on a line falls through to whatever is below (a
1377
+ * draw tool's `StageSurface`, say), while `useStageHitTest` still finds the lines. Set it
1378
+ * `false` while a tool other than selection is active.
1379
+ *
1380
+ * A touch on an interactive layer is not claimed: the stage still pans and pinches, and the
1381
+ * line is selected when the finger lifts after a tap.
1382
+ */
1383
+ interactive?: boolean | undefined;
1293
1384
  /** CSS colour of the lines. Defaults to the overlay `feature` role: they are detected lines. */
1294
1385
  stroke?: string | undefined;
1295
1386
  /** CSS colour of a selected line. Defaults to the overlay `selection` role. */
@@ -1316,10 +1407,12 @@ interface PolylineSetProps {
1316
1407
  * - **Halo.** Every line has a halo, so it holds on any image.
1317
1408
  * - **Points.** Above `vertexScale`, the points of the hovered and selected lines are drawn.
1318
1409
  * - **Panning.** The hand tool and a held space bar still pan.
1410
+ * - **Tools.** Without a handler (or with `interactive={false}`) the layer takes no presses
1411
+ * and only answers `useStageHitTest`, so a draw tool's surface below receives them.
1319
1412
  *
1320
1413
  * The SVG carries `data-hovered` (the hovered id) and `data-sweeping` while a band is drawn.
1321
1414
  */
1322
- export declare function PolylineSet({ items, selected, dimmed, hovered, onHover, onHoverChange, onItemPress, onSelect, marquee, stroke, selectionStroke, hitWidth, vertexScale, label, layerId, priority }: PolylineSetProps): import("react").JSX.Element;
1415
+ export declare function PolylineSet({ items, selected, dimmed, hovered, onHover, onHoverChange, onItemPress, onSelect, marquee, interactive, stroke, selectionStroke, hitWidth, vertexScale, label, layerId, priority }: PolylineSetProps): import("react").JSX.Element;
1323
1416
  //#endregion
1324
1417
  //#region src/components/markerShapes.d.ts
1325
1418
  /** One kind of marker. */
@@ -1342,9 +1435,11 @@ interface MarkerShape {
1342
1435
  * @param y - Centre y, in image coordinates.
1343
1436
  * @param unit - Image pixels per screen pixel.
1344
1437
  * @param angle - The item's orientation in radians, `0` when it has none.
1438
+ * @param angle2 - The item's second angle in radians, `undefined` when it has none. Most
1439
+ * shapes ignore it; a glyph with two axes (a corner's two edge directions) reads it.
1345
1440
  * @returns Path commands, absolute at the start (`M x y …`) and self-contained.
1346
1441
  */
1347
- path: (x: number, y: number, unit: number, angle: number) => string;
1442
+ path: (x: number, y: number, unit: number, angle: number, angle2?: number) => string;
1348
1443
  }
1349
1444
  /**
1350
1445
  * A circle as two arcs, centred at `(x, y)`.
@@ -1497,6 +1592,8 @@ interface PointSetItem extends PointItem {
1497
1592
  role?: OverlayRole | undefined;
1498
1593
  /** Its orientation in radians, clockwise from +x; read by `directed`. */
1499
1594
  angle?: number | undefined;
1595
+ /** A second angle in radians, for a glyph with two axes. `MarkerShape.path` gets `undefined` without it. */
1596
+ angle2?: number | undefined;
1500
1597
  /** Text drawn beside it, when the zoom leaves room (points at least 24 screen px apart). */
1501
1598
  label?: string | undefined;
1502
1599
  }
@@ -1740,6 +1837,180 @@ interface AreaSetProps {
1740
1837
  */
1741
1838
  export declare function AreaSet({ items, role, hoveredId, onHoverChange, selectedIds, dimmed, onItemPress, labels, firstVertexTick, halo, selectionStroke, layerId, priority, label }: AreaSetProps): import("react").JSX.Element;
1742
1839
  //#endregion
1840
+ //#region src/components/ellipseIndex.d.ts
1841
+ /** An ellipse's identity. */
1842
+ type EllipseId = string | number;
1843
+ /** One ellipse. */
1844
+ interface Ellipse {
1845
+ /** Its identity, unique in the set. */
1846
+ id: EllipseId;
1847
+ /** Centre x, image pixels. */
1848
+ x: number;
1849
+ /** Centre y, image pixels. */
1850
+ y: number;
1851
+ /** Semi-axis along the rotated x axis, image pixels. */
1852
+ rx: number;
1853
+ /** Semi-axis along the rotated y axis, image pixels. */
1854
+ ry: number;
1855
+ /** Rotation of the `rx` axis, radians clockwise on screen (y points down). Defaults to 0. */
1856
+ angle?: number | undefined;
1857
+ }
1858
+ /**
1859
+ * An index built by `buildEllipseIndex`. Treat it as opaque and query it with `nearestEllipse`
1860
+ * and `ellipsesInRect`; its layout may change.
1861
+ */
1862
+ interface EllipseIndex {
1863
+ /** The ellipses, in the order given. */
1864
+ readonly items: readonly Ellipse[];
1865
+ /** The grid over their bounding boxes (an `AreaIndex` of boxes, one per ellipse). */
1866
+ readonly grid: AreaIndex;
1867
+ /** Per ellipse, its area `π·rx·ry`, used to prefer the smaller of nested ellipses; `NaN` for a degenerate one. */
1868
+ readonly size: Float64Array;
1869
+ }
1870
+ /** The ellipse `nearestEllipse` picked. */
1871
+ interface EllipseHit {
1872
+ /** Its id. */
1873
+ id: EllipseId;
1874
+ /** Its position in the array the index was built from. */
1875
+ index: number;
1876
+ /** Whether the query is inside the ellipse. */
1877
+ inside: boolean;
1878
+ /** The distance from the query to the ellipse's outline, in image pixels (also when inside). */
1879
+ distance: number;
1880
+ }
1881
+ /**
1882
+ * The axis-aligned bounding box of an ellipse.
1883
+ *
1884
+ * @param e - The ellipse.
1885
+ * @returns `[minX, minY, maxX, maxY]`, or `null` for a degenerate ellipse.
1886
+ */
1887
+ export declare function ellipseBounds(e: Ellipse): [number, number, number, number] | null;
1888
+ /**
1889
+ * Whether `(x, y)` is inside the ellipse (its outline counts as inside).
1890
+ *
1891
+ * @param e - The ellipse.
1892
+ * @param x - The query's x.
1893
+ * @param y - The query's y.
1894
+ * @returns `false` for a degenerate ellipse.
1895
+ */
1896
+ export declare function pointInEllipse(e: Ellipse, x: number, y: number): boolean;
1897
+ /**
1898
+ * An ellipse as an SVG path: two arcs, exactly, so it stays round at any zoom.
1899
+ *
1900
+ * @param cx - Centre x, image pixels.
1901
+ * @param cy - Centre y, image pixels.
1902
+ * @param rx - Semi-axis along the rotated x axis, image pixels.
1903
+ * @param ry - Semi-axis along the rotated y axis, image pixels.
1904
+ * @param angle - Rotation of the `rx` axis, radians clockwise on screen.
1905
+ * @returns Path data, or `""` for a degenerate ellipse (a non-finite value, or a radius not above zero).
1906
+ */
1907
+ export declare function ellipsePath(cx: number, cy: number, rx: number, ry: number, angle?: number): string;
1908
+ /**
1909
+ * Index a set of ellipses.
1910
+ *
1911
+ * @param items - The ellipses.
1912
+ * @param cell - The grid cell side in image pixels; see `buildAreaIndex` for the default.
1913
+ * @returns The index.
1914
+ */
1915
+ export declare function buildEllipseIndex(items: readonly Ellipse[], cell?: number): EllipseIndex;
1916
+ /**
1917
+ * The ellipse under a point: one whose outline passes within `radius`, or else one that
1918
+ * contains it.
1919
+ *
1920
+ * An outline is the more precise gesture, so it wins: among ellipses whose outline is within
1921
+ * `radius` the nearest is picked, and only without one the containing ellipse. Ties (equal
1922
+ * distance, or several containing ellipses) go to the smaller ellipse, so a ring drawn inside
1923
+ * another is picked rather than the outer one, then to the earlier one.
1924
+ *
1925
+ * @param index - The index.
1926
+ * @param p - The query, in image coordinates.
1927
+ * @param radius - How far from an outline the query still picks it, in image pixels.
1928
+ * @returns The ellipse, or `null`.
1929
+ */
1930
+ export declare function nearestEllipse(index: EllipseIndex, p: Point, radius: number): EllipseHit | null;
1931
+ /**
1932
+ * The ellipses any part of which is inside `rect`: the rectangle meets the outline, or lies
1933
+ * inside the ellipse, or contains it.
1934
+ *
1935
+ * @param index - The index.
1936
+ * @param rect - The band, in image coordinates. A negative extent is read as the box between
1937
+ * its corners.
1938
+ * @returns Their ids, in the order the ellipses were given.
1939
+ */
1940
+ export declare function ellipsesInRect(index: EllipseIndex, rect: Rect): EllipseId[];
1941
+ //#endregion
1942
+ //#region src/components/EllipseSet.d.ts
1943
+ /** One ellipse of an `EllipseSet`. */
1944
+ interface EllipseSetItem extends Ellipse {
1945
+ /** The overlay role it is painted in. Defaults to the layer's `role`. */
1946
+ role?: OverlayRole | undefined;
1947
+ /** Draw it dashed (4 3 screen px), so two kinds differ by more than colour. */
1948
+ dashed?: boolean | undefined;
1949
+ /** Opacity in [0, 1], rounded to a tenth so ellipses still share paths. Defaults to 1. */
1950
+ opacity?: number | undefined;
1951
+ }
1952
+ /** Props of `EllipseSet`. */
1953
+ interface EllipseSetProps {
1954
+ /** The ellipses, in image coordinates. */
1955
+ items: readonly EllipseSetItem[];
1956
+ /** The role of an item that names none. Defaults to `"feature"`. */
1957
+ role?: OverlayRole | undefined;
1958
+ /** The hovered id, when the app controls hover: its ellipses are drawn at 2 px. */
1959
+ hoveredId?: EllipseId | null | undefined;
1960
+ /** Called when the ellipse under the pointer changes. `null` when it leaves every ellipse. Not called when `pickable` is off. */
1961
+ onHoverChange?: ((id: EllipseId | null) => void) | undefined;
1962
+ /** The selected ids, drawn at 2.5 px in the selection colour. */
1963
+ selectedIds?: Iterable<EllipseId> | undefined;
1964
+ /** Ids drawn at 35 % opacity, as a set or a predicate. Pass a stable value: a new one re-batches the layer. */
1965
+ dimmed?: Iterable<EllipseId> | ((id: EllipseId) => boolean) | undefined;
1966
+ /**
1967
+ * A press landed on an ellipse. Setting it makes the layer claim presses on its ellipses,
1968
+ * so the stage does not pan from them. The event is the `pointerdown` (the `pointerup` for
1969
+ * a touch tap), so `useShapeDrag` can start a drag from it.
1970
+ *
1971
+ * A mounted `StageSurface` hears a press first; there, ask `useStageHitTest` what is
1972
+ * under it instead.
1973
+ */
1974
+ onItemPress?: ((id: EllipseId, event: StagePointerEvent) => void) | undefined;
1975
+ /**
1976
+ * Whether the layer takes part in the stage's hit-test. On by default. Turn it off for a
1977
+ * decorative layer (the ring outlines under a `PointSet` of centres), so it neither
1978
+ * hovers, nor claims presses, nor answers `useStageHitTest`.
1979
+ */
1980
+ pickable?: boolean | undefined;
1981
+ /** The id hit-tests report for this layer. Defaults to a generated one. */
1982
+ layerId?: string | undefined;
1983
+ /** Rank against other layers in hit-tests. Defaults to `STAGE_HIT_PRIORITY.area`. */
1984
+ priority?: number | undefined;
1985
+ /** Draw the dark band under every stroke. On by default. */
1986
+ halo?: boolean | undefined;
1987
+ /**
1988
+ * The smallest semi-axis, in screen pixels: a dot whose data size would vanish at the fitted
1989
+ * zoom is still drawn this large. Omit for none.
1990
+ */
1991
+ minRadius?: number | undefined;
1992
+ /** CSS colour of selected ellipses. Defaults to the overlay `selection` role. */
1993
+ selectionStroke?: string | undefined;
1994
+ /** Name the layer as an image for assistive technology. Without it the layer is decorative (`aria-hidden`). */
1995
+ label?: string | undefined;
1996
+ }
1997
+ /**
1998
+ * A batched set of ellipses inside an `ImageStage`.
1999
+ *
2000
+ * - **Geometry** is data: `rx`, `ry` and the centre are image pixels and scale with the image;
2001
+ * the stroke is a screen constant.
2002
+ * - **States** follow visual-language §5: 1.5 screen px (1 for `model` and `structure`), hover
2003
+ * 2, selected 2.5 in the selection colour, dimmed at 35 % opacity. Every stroke has a halo.
2004
+ * - **Batching** is by (role, dash, opacity, dimming): a thousand rings are a dozen elements.
2005
+ * - **Picking** goes through the stage's hit registry: a press within the pointer's tolerance of
2006
+ * an outline picks that ellipse, else the smallest ellipse containing the point.
2007
+ * `onHoverChange` and `onItemPress` here, and `useStageHitTest` for an app that arbitrates
2008
+ * between layers. `pickable={false}` turns it off.
2009
+ *
2010
+ * The SVG carries `data-ellipses` (the count) and `data-hovered` (the hovered id).
2011
+ */
2012
+ export declare function EllipseSet({ items, role, hoveredId, onHoverChange, selectedIds, dimmed, onItemPress, pickable, layerId, priority, halo, minRadius, selectionStroke, label }: EllipseSetProps): import("react").JSX.Element;
2013
+ //#endregion
1743
2014
  //#region src/components/GridLayer.d.ts
1744
2015
  /** One node of a `GridLayer`: a point with its lattice index. */
1745
2016
  interface GridNode extends PointSetItem {
@@ -2201,7 +2472,17 @@ interface ShapeEditorProps {
2201
2472
  *
2202
2473
  * - **Handles.** Eight handles resize the shape in its own frame: the dragged side follows the
2203
2474
  * pointer and the opposite side stays where it is, whatever the rotation. A shape stops at
2204
- * `minSize` rather than flipping. The interior moves it.
2475
+ * `minSize` rather than flipping. The interior moves it, and so does the band along its
2476
+ * outline (the pointer's tolerance: 6 px for a mouse, 12 px for a finger), which is how a thin
2477
+ * or rotated shape is grabbed. The band is as wide as the device's primary pointer needs
2478
+ * (`(pointer: coarse)`), so on a touch laptop whose primary pointer is fine, a touch 6 to
2479
+ * 12 px outside the outline reaches the layers below instead of the editor.
2480
+ * - **Press order.** One decision serves every part of the editor: the nearest handle first,
2481
+ * then the interior or outline band (move), then nothing. A small shape's interior does not
2482
+ * steal a press meant for a handle, and a press that hits none of them is not claimed, so
2483
+ * it reaches whatever is below, or the stage.
2484
+ * - **Touch.** A press that grabs the shape is claimed; a second finger landing during an edit
2485
+ * cancels it (the shape reverts, nothing is committed) and is left to the stage.
2205
2486
  * - **Rotation.** The handle past the top side turns the shape about its centre; hold Shift to
2206
2487
  * round to 15°.
2207
2488
  * - **Keyboard.** The shape is focusable: arrow keys move it by one image pixel (ten with Shift),
@@ -2358,5 +2639,5 @@ interface MaskEditorProps {
2358
2639
  /** Render and edit a binary raster mask within the enclosing ImageStage. */
2359
2640
  export declare function MaskEditor({ mask, onChange, onCommit, editable, brushRadius, mode, label, color }: MaskEditorProps): import("react").JSX.Element;
2360
2641
  //#endregion
2361
- export type { ArcPrimitive, Area, AreaHit, AreaId, AreaIndex, AreaSetItem, AreaSetProps, Box, BuiltinMarkerKind, CaliperPrimitive, CirclePrimitive, ClampOptions, Colormap, ContourEditorProps, DimensionGeometry, DimensionPrimitive, DraftShapeProps, DraftShapeSpec, GridEdgeStyle, GridLayerProps, GridNode, HeatmapLayerBaseProps, HeatmapLayerProps, HeatmapPlaneProps, HeatmapRgbaProps, HitCandidate, HitId, ImageLayerProps, ImageStageProps, ImageTier, LatticeAxis, LatticeEdge, LatticeNode, MarkerShape, MarqueeRectProps, MaskEditorProps, MeasureOverlayProps, MeasurePrimitive, OverlayRole, OverlayState, Point, PointHit, PointId, PointIndex, PointIndexOptions, PointItem, PointPrimitive, PointSetItem, PointSetProps, Polyline, PolylineHit, PolylineId, PolylineIndex, PolylinePrimitive, PolylineSelectMode, PolylineSetItem, PolylineSetProps, PrimitiveCommon, Rect, RectRoiEditorProps, RoiHandle, RotatedShape, SegmentPrimitive, ShapeDragHandlers, ShapeDragOptions, ShapeEditorProps, StageButtonProps, StageContext, StageDrag, StageHandle, StageHit, StageHitLayerOptions, StageHitOptions, StageHitTestApi, StageLayer, StageLayersMenuProps, StageMouseButton, StagePointerEvent, StagePress, StageReadoutProps, StageSurfaceProps, StageToolbarDividerProps, StageToolbarProps, StageView, ValuePlane, ValueRange, View, ZoomPanCanvasProps };
2642
+ export type { ArcPrimitive, Area, AreaHit, AreaId, AreaIndex, AreaSetItem, AreaSetProps, Box, BuiltinMarkerKind, CaliperPrimitive, CirclePrimitive, ClampOptions, Colormap, ContourEditorProps, DimensionGeometry, DimensionPrimitive, DraftShapeProps, DraftShapeSpec, Ellipse, EllipseHit, EllipseId, EllipseIndex, EllipseSetItem, EllipseSetProps, FitOptions, GridEdgeStyle, GridLayerProps, GridNode, HeatmapLayerBaseProps, HeatmapLayerProps, HeatmapPlaneProps, HeatmapRgbaProps, HitCandidate, HitId, ImageLayerProps, ImageStageProps, ImageTier, LatticeAxis, LatticeEdge, LatticeNode, MarkerShape, MarqueeRectProps, MaskEditorProps, MeasureOverlayProps, MeasurePrimitive, OverlayRole, OverlayState, Point, PointHit, PointId, PointIndex, PointIndexOptions, PointItem, PointPrimitive, PointSetItem, PointSetProps, Polyline, PolylineHit, PolylineId, PolylineIndex, PolylinePrimitive, PolylineSelectMode, PolylineSetItem, PolylineSetProps, PrimitiveCommon, Rect, RectRoiEditorProps, RoiHandle, RotatedShape, SegmentPrimitive, ShapeDragHandlers, ShapeDragOptions, ShapeEditorProps, StageButtonProps, StageContext, StageDrag, StageHandle, StageHit, StageHitLayerOptions, StageHitOptions, StageHitTestApi, StageLayer, StageLayersMenuProps, StageMouseButton, StagePointerEvent, StagePress, StageReadoutProps, StageSurfaceProps, StageToolbarDividerProps, StageToolbarProps, StageView, ValuePlane, ValueRange, View, ZoomPanCanvasProps };
2362
2643
  //# sourceMappingURL=index.d.ts.map