@vitavision/stage2d 0.10.0 → 0.12.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 +12 -3
- package/dist/index.d.ts +437 -36
- package/dist/index.js +1406 -338
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/AreaSet.tsx +83 -52
- package/src/components/ContourEditor.tsx +12 -3
- package/src/components/DraftShape.tsx +56 -11
- package/src/components/EllipseSet.tsx +292 -0
- package/src/components/MaskEditor.tsx +22 -9
- package/src/components/PointSet.tsx +19 -9
- package/src/components/PolylineSet.tsx +56 -15
- package/src/components/RectRoiEditor.tsx +5 -4
- package/src/components/ShapeEditor.tsx +117 -37
- package/src/components/areaBatching.ts +111 -0
- package/src/components/areaIndex.ts +7 -4
- package/src/components/ellipseIndex.ts +279 -0
- package/src/components/markerShapes.ts +3 -1
- package/src/components/shapeEdit.ts +67 -1
- package/src/components/stage/ImageStage.tsx +250 -127
- package/src/components/stage/StageSurface.tsx +117 -17
- package/src/components/stage/gesture.ts +15 -0
- package/src/components/stage/touchWatch.ts +85 -0
- package/src/components/stage/useCoarsePointer.ts +30 -0
- package/src/components/stage/view.ts +88 -20
- package/src/index.ts +20 -0
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
|
|
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.
|