@vitavision/stage2d 0.7.1 → 0.8.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
@@ -18,10 +18,43 @@ as the way a layer reads the transform. The arithmetic behind it is pure and exp
18
18
  `fitScale`, `fitView`, `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
+
22
+ `ImageLayer` draws the photograph at its natural size. It can show a `preview` tier until
23
+ the stage would magnify it, then load the full image and keep it, and it turns pixelated past
24
+ `pixelatedAbove`. `StageButton` takes a `hint` and a `shortcut` for a richer tooltip, and
25
+ `StageLayersMenu` is a layers button for `StageToolbar`. Code outside the stage, such as an
26
+ inspector's "frame this", drives it through `ImageStage`'s `ref` (`StageHandle`: `frame`,
27
+ `fit`, `zoomTo`). `initialView="fit"` opens a `null` view at fit even when the image would fit
28
+ at 1:1.
21
29
  `api/mapValues.ts` decodes the `VAM1` float32-plane wire format into indexable values
22
30
  (`decodePlane`, `valueAt`, `valuesAt`, `fractionOf`, `fetchPlane`) — it never draws;
23
31
  colour range and colormap stay the caller's decision.
24
32
 
33
+ **Region of interest**: `RectRoiEditor` is an editable axis-aligned region.
34
+ - Eight handles resize it and the interior moves it; with `draw`, a drag on the image draws a
35
+ new one.
36
+ - It stays inside `bounds` (the image by default) and is never smaller than `minSize`.
37
+ - `onValueChange` follows the drag, and `onCommit` fires once the gesture ends.
38
+ - Arrow keys move it, and Alt + arrows resize it.
39
+
40
+ Its arithmetic (`resizeRect`, `moveRect`, `clampRect`, `rectFromCorners`, `sameRect`) is
41
+ exported and tested without a DOM.
42
+
43
+ **Selectable lines**: `PolylineSet` draws many polylines (contours, segments, matches) as a few
44
+ batched paths and picks through a spatial index, not the DOM.
45
+ - **States:** hover, selection and dimming follow the visual-language states.
46
+ - **Selecting:** click selects, ⌘/Ctrl-click toggles, and Shift-drag or `marquee` draws a
47
+ rubber band.
48
+ - **Pure functions:** `buildPolylineIndex`, `nearestPolyline`, `polylinesInRect` and
49
+ `polylinePath` are pure; hit-testing is microseconds at 100k segments
50
+ (`docs/measurements/u4-polyline-set.md`).
51
+
52
+ **Tool model**: `StageSurface` is the one full-frame press target per stage.
53
+ - **Claiming:** its `onPress` returns a drag to claim a press, or nothing to let the stage pan.
54
+ - **Drags:** `useStageDrag` starts a window-level drag from any element, e.g. a handle.
55
+ - **Why window-level:** two full-frame layers would be one that always wins, and pointer
56
+ capture routes moves to the pressed element.
57
+
25
58
  **Annotation layers** — `ContourEditor` edits ordered source-image pixel-center
26
59
  vertices; `MaskEditor` paints or erases a row-major binary mask with a bounded
27
60
  source-pixel brush. Both are controlled layers for `ImageStage`: the caller owns
@@ -54,7 +87,7 @@ const [view, setView] = useState<StageView | null>(null); // null = "open at a s
54
87
  readout={<StageReadout cursor={cursor} />}
55
88
  onHover={setCursor}
56
89
  >
57
- <img src={url} className="h-full w-full" />
90
+ <ImageLayer src={fullUrl} preview={{ src: previewUrl, width: 1024 }} alt={filename} />
58
91
  <MeasureOverlay nativeWidth={1280} nativeHeight={1024} primitives={overlay} strokeScale={view?.scale ?? 1} />
59
92
  <MyInteractiveLayer />
60
93
  </ImageStage>