@vitavision/stage2d 0.8.1 → 0.10.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 +41 -0
- package/dist/index.d.ts +1083 -3
- package/dist/index.js +2815 -68
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/AreaSet.tsx +312 -0
- package/src/components/DraftShape.tsx +175 -0
- package/src/components/GridLayer.tsx +209 -0
- package/src/components/HeatmapLayer.tsx +211 -0
- package/src/components/PointSet.tsx +366 -0
- package/src/components/PolylineSet.tsx +39 -0
- package/src/components/ShapeEditor.tsx +290 -0
- package/src/components/areaIndex.ts +361 -0
- package/src/components/gridEdges.ts +70 -0
- package/src/components/heatmapRaster.ts +84 -0
- package/src/components/labelLod.ts +90 -0
- package/src/components/markerShapes.ts +119 -0
- package/src/components/pointIndex.ts +320 -0
- package/src/components/polylineIndex.ts +4 -3
- package/src/components/shapeEdit.ts +232 -0
- package/src/components/stage/ImageStage.tsx +264 -59
- package/src/components/stage/gesture.ts +81 -0
- package/src/components/stage/hitContext.ts +16 -0
- package/src/components/stage/hitTest.ts +181 -0
- package/src/components/stage/useStageHitTest.ts +127 -0
- package/src/components/useShapeDrag.ts +104 -0
- package/src/index.ts +96 -0
package/README.md
CHANGED
|
@@ -49,6 +49,47 @@ batched paths and picks through a spatial index, not the DOM.
|
|
|
49
49
|
`polylinePath` are pure; hit-testing is microseconds at 100k segments
|
|
50
50
|
(`docs/measurements/u4-polyline-set.md`).
|
|
51
51
|
|
|
52
|
+
**Points**: `PointSet` draws many points (corners, ring centres, keypoints, labelled landmarks) as
|
|
53
|
+
a few batched paths, with a marker per kind (`dot`, `plus`, `cross`, `square`, `hollow`,
|
|
54
|
+
`directed`, or your own path generator) and the same states as `PolylineSet`, plus a ring on the
|
|
55
|
+
selected. Labels appear where points are 24 screen px apart.
|
|
56
|
+
- **Pointer:** `onHoverChange` and `onItemPress` come from the stage's pointer handling and the
|
|
57
|
+
layer's index, not from per-point elements.
|
|
58
|
+
- **Pure functions:** `buildPointIndex`, `nearestPoint`, `pointsInRect` and `thinPoints`
|
|
59
|
+
(`docs/measurements/l6-2a-points-hit-test.md`).
|
|
60
|
+
|
|
61
|
+
**Areas**: `AreaSet` draws many closed regions (marker quads, drawn polygons, region annotations) as a
|
|
62
|
+
few batched paths, each an outline with its 12 % fill, in a role (`feature`, `model`, `structure`).
|
|
63
|
+
- **Pointer:** a press near an outline picks that region, else the smallest region containing it;
|
|
64
|
+
`onHoverChange` and `onItemPress` as `PointSet`.
|
|
65
|
+
- **Quads:** `firstVertexTick` ticks corner 0; labels sit at the centre, where regions are 24 screen px apart.
|
|
66
|
+
- **Pure functions:** `buildAreaIndex`, `nearestArea`, `areasInRect`, `pointInPolygon`, `areaPath`
|
|
67
|
+
(`docs/measurements/l6-2b-areas-grid-heatmap.md`).
|
|
68
|
+
|
|
69
|
+
**Grids**: `GridLayer` draws a detected lattice: nodes `{ id, i, j, x, y }` as a `PointSet` (`plus` by default)
|
|
70
|
+
and the edges between lattice neighbours as two batched paths, each axis restyled through `edges`.
|
|
71
|
+
`indexLabels` labels nodes with `i,j`. `latticeEdges(nodes)` is the pure neighbour search.
|
|
72
|
+
|
|
73
|
+
**Heatmaps**: `HeatmapLayer` draws a `ValuePlane` through a `colormap` (`(t) => [r, g, b]`; the
|
|
74
|
+
`@vitavision/charts` maps fit) or an `rgba` buffer as one image, rasterised in an effect, placed over the
|
|
75
|
+
image (or `rect`), pixelated from 4 CSS px per cell. `rasterizePlane` and `planeRange` are pure.
|
|
76
|
+
|
|
77
|
+
**Rotated shapes**: `ShapeEditor` edits `{ cx, cy, width, height, rotation }` as a rectangle or an ellipse:
|
|
78
|
+
eight handles resize in the shape's own frame (the opposite side stays put), a rotation handle turns it, the
|
|
79
|
+
interior moves it, arrow keys nudge it. **Rotation is radians, clockwise on screen** (Konva's degrees are
|
|
80
|
+
`deg * Math.PI / 180`; `shapeFromCorner` converts Konva's rotate-about-the-corner `Rect`). The arithmetic
|
|
81
|
+
(`resizeShape`, `rotateShape`, `moveShape`, `shapeHandlePoint`, …) is pure.
|
|
82
|
+
|
|
83
|
+
**Drawing and moving**: `DraftShape` is the dashed preview of a point, line, polyline, polygon, rectangle or
|
|
84
|
+
ellipse being drawn, and `MarqueeRect` the rubber band; `useShapeDrag` turns a press on an item into
|
|
85
|
+
image-space displacements with click slop, for select → drag → commit of manual shapes (`translatePoints`
|
|
86
|
+
shifts flat coordinates).
|
|
87
|
+
|
|
88
|
+
**Hit-test**: `useStageHitTest()` answers "what is under the pointer" across layers, ranked by
|
|
89
|
+
`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`,
|
|
91
|
+
`doubleClickFit` and `touchPan`, and handles two-finger pinch.
|
|
92
|
+
|
|
52
93
|
**Tool model**: `StageSurface` is the one full-frame press target per stage.
|
|
53
94
|
- **Claiming:** its `onPress` returns a drag to claim a press, or nothing to let the stage pan.
|
|
54
95
|
- **Drags:** `useStageDrag` starts a window-level drag from any element, e.g. a handle.
|