@vitavision/stage2d 0.12.0 → 0.13.2
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 +3 -6
- package/dist/index.d.ts +669 -57
- package/dist/index.js +5455 -3621
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/api/mapValues.ts +1 -4
- package/src/components/AreaSet.tsx +32 -9
- package/src/components/ContourEditor.tsx +325 -40
- package/src/components/DatumEditor.tsx +261 -0
- package/src/components/DraftShape.tsx +37 -5
- package/src/components/EllipseSet.tsx +3 -3
- package/src/components/GridLayer.tsx +8 -3
- package/src/components/HeatmapLayer.tsx +1 -1
- package/src/components/MaskEditor.tsx +57 -9
- package/src/components/MeasureOverlay.tsx +353 -92
- package/src/components/PointSet.tsx +23 -12
- package/src/components/PolylineSet.tsx +83 -27
- package/src/components/RectRoiEditor.tsx +189 -93
- package/src/components/ShapeEditor.tsx +25 -10
- package/src/components/areaBatching.ts +23 -3
- package/src/components/areaIndex.ts +2 -1
- package/src/components/contourArc.ts +268 -0
- package/src/components/datumEdit.ts +149 -0
- package/src/components/labelLod.ts +3 -7
- package/src/components/markerShapes.ts +2 -5
- package/src/components/measureGeometry.ts +46 -28
- package/src/components/measureHit.ts +383 -0
- package/src/components/overlayRole.ts +1 -1
- package/src/components/pointIndex.ts +14 -5
- package/src/components/polylineIndex.ts +3 -3
- package/src/components/shapeEdit.ts +38 -5
- package/src/components/stage/CompareLayer.tsx +231 -0
- package/src/components/stage/ImageLayer.tsx +56 -24
- package/src/components/stage/ImageStage.tsx +33 -38
- package/src/components/stage/StageSurface.tsx +34 -34
- package/src/components/stage/StageToolbar.tsx +35 -37
- package/src/components/stage/compareStyle.ts +155 -0
- package/src/components/stage/gesture.ts +5 -0
- package/src/components/stage/hitTest.ts +19 -0
- package/src/components/stage/useStageHitTest.ts +17 -12
- package/src/components/stage/view.ts +3 -15
- package/src/components/useShapeDrag.ts +2 -4
- package/src/index.ts +34 -65
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { CSSProperties, ComponentPropsWithRef, PointerEvent as PointerEvent$1, ReactNode, Ref } from "react";
|
|
2
2
|
import { MeasureTone } from "@vitavision/ui";
|
|
3
3
|
//#region src/components/measureGeometry.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* The arithmetic behind `MeasureOverlay`: everything that can be silently wrong, factored
|
|
6
|
-
* out so it can be tested without a DOM.
|
|
7
|
-
*
|
|
8
|
-
* Every primitive `MeasureOverlay` draws is given in **source-image pixel coordinates** —
|
|
9
|
-
* the same frame `ZoomPanCanvas`'s `nativeWidth`/`nativeHeight` describe, and the same one
|
|
10
|
-
* `api/mapValues.ts`'s `u`/`v` fractions index into. Nothing here measures the DOM or knows
|
|
11
|
-
* about zoom directly; `strokeWidthFor` is the one function that turns a *scale factor* a
|
|
12
|
-
* caller already knows (or computes once from a `ZoomPanCanvas` `View`) into a stroke width
|
|
13
|
-
* that reads as constant on screen.
|
|
14
|
-
*/
|
|
15
4
|
/** A 2D point — in image pixels unless a signature says otherwise. */
|
|
16
5
|
interface Point {
|
|
17
6
|
/** Horizontal coordinate, increasing rightward. */
|
|
@@ -40,6 +29,18 @@ export declare function strokeWidthFor(strokeScale: number, screenPixels?: numbe
|
|
|
40
29
|
export declare function rotatePoint(x: number, y: number, angle: number): Point;
|
|
41
30
|
/** `M x,y L x,y … Z` through `points`, or `""` for fewer than two of them. */
|
|
42
31
|
export declare function polygonPath(points: readonly Point[]): string;
|
|
32
|
+
/**
|
|
33
|
+
* Many unconnected segments as one SVG path: `M x1 y1 L x2 y2` per segment.
|
|
34
|
+
*
|
|
35
|
+
* One path draws thousands of ticks for the cost of one element. A segment with a
|
|
36
|
+
* non-finite coordinate is skipped rather than written, since a single `NaN` in path data
|
|
37
|
+
* stops the browser drawing every segment after it.
|
|
38
|
+
*
|
|
39
|
+
* @param points - `[x1, y1, x2, y2, …]`, four numbers per segment. A trailing partial
|
|
40
|
+
* segment is ignored.
|
|
41
|
+
* @returns The path data; `""` without a whole segment.
|
|
42
|
+
*/
|
|
43
|
+
export declare function segmentsPath(points: ArrayLike<number>): string;
|
|
43
44
|
/** The two line segments of a cross mark centred on `(x, y)`, each `2·size` long. */
|
|
44
45
|
export declare function crossSegments(x: number, y: number, size: number): [[Point, Point], [Point, Point]];
|
|
45
46
|
/**
|
|
@@ -307,7 +308,10 @@ interface StageContext {
|
|
|
307
308
|
toViewport: (image: Point) => Point;
|
|
308
309
|
/** The image-pixel length that covers `css` screen pixels — for screen-constant geometry. */
|
|
309
310
|
imageLength: (css: number) => number;
|
|
310
|
-
/**
|
|
311
|
+
/**
|
|
312
|
+
* Put a rect (image coordinates) on screen with a margin: `pad` is a fraction of the rect's
|
|
313
|
+
* own width and height added on each side (default 0.15).
|
|
314
|
+
*/
|
|
311
315
|
frame: (rect: Rect, pad?: number) => void;
|
|
312
316
|
/** Fit the whole image. */
|
|
313
317
|
fit: () => void;
|
|
@@ -331,7 +335,10 @@ interface StageContext {
|
|
|
331
335
|
* measured. Layers inside the stage use `useStage` instead.
|
|
332
336
|
*/
|
|
333
337
|
interface StageHandle {
|
|
334
|
-
/**
|
|
338
|
+
/**
|
|
339
|
+
* Put a rect (image coordinates) on screen with a margin: `pad` is a fraction of the rect's
|
|
340
|
+
* own width and height added on each side (default 0.15).
|
|
341
|
+
*/
|
|
335
342
|
frame: (rect: Rect, pad?: number) => void;
|
|
336
343
|
/** Fit the whole image. */
|
|
337
344
|
fit: () => void;
|
|
@@ -381,7 +388,8 @@ interface ImageStageProps {
|
|
|
381
388
|
panButton?: StageMouseButton | readonly StageMouseButton[] | undefined;
|
|
382
389
|
/**
|
|
383
390
|
* Whether a double-click toggles fit and the previous view. On by default; turn it off in
|
|
384
|
-
* an app whose tools use double-click, such as closing a polygon.
|
|
391
|
+
* an app whose tools use double-click, such as closing a polygon. A double-click a layer
|
|
392
|
+
* takes through the hit-test (an editable `ContourEditor` inserting a vertex) never toggles.
|
|
385
393
|
*/
|
|
386
394
|
doubleClickFit?: boolean | undefined;
|
|
387
395
|
/**
|
|
@@ -407,6 +415,14 @@ interface ImageStageProps {
|
|
|
407
415
|
clamp?: ClampOptions;
|
|
408
416
|
/** Keyboard zoom/pan shortcuts. On by default; the stage takes focus to receive them. */
|
|
409
417
|
shortcuts?: boolean;
|
|
418
|
+
/**
|
|
419
|
+
* Whether the viewport is a tab stop (`tabIndex={0}`, `role="application"`). Defaults to
|
|
420
|
+
* `shortcuts`. Off, the viewport is a plain `role="group"` that takes no focus, for an app that
|
|
421
|
+
* owns the keyboard on an element around the stage and would otherwise have two nested tab
|
|
422
|
+
* stops. With `shortcuts` on and `focusable` off the keys still work while focus is on an
|
|
423
|
+
* element inside the stage, such as an editor's handle.
|
|
424
|
+
*/
|
|
425
|
+
focusable?: boolean | undefined;
|
|
410
426
|
/**
|
|
411
427
|
* Whether the arrow keys pan. On by default, and worth turning off in an app where the
|
|
412
428
|
* arrows have a better job — stepping through a list of findings, say. The zoom keys
|
|
@@ -443,8 +459,11 @@ interface ImageStageProps {
|
|
|
443
459
|
* State is exposed on the viewport as `data-fit` (the view is fit), `data-panning` (a drag
|
|
444
460
|
* is in progress) and `data-pan-mode` (the hand tool is on or space is held), each present
|
|
445
461
|
* or absent.
|
|
462
|
+
*
|
|
463
|
+
* The viewport is a `role="application"` tab stop named by `label`. With `focusable` off (the
|
|
464
|
+
* default when `shortcuts` is off) it is a `role="group"` and takes no focus.
|
|
446
465
|
*/
|
|
447
|
-
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;
|
|
466
|
+
export declare function ImageStage({ image, view, onView, children, toolbar, readout, banner, panTool, panButton, doubleClickFit, touchPan, className, style, onHover, onBackgroundClick, clamp, shortcuts, focusable, panKeys, label, initialView: opening, fit: fitOptions, ref }: ImageStageProps): import("react").JSX.Element;
|
|
448
467
|
//#endregion
|
|
449
468
|
//#region src/components/stage/hitTest.d.ts
|
|
450
469
|
/** What a layer is picked as, and so how it ranks against the layers around it. */
|
|
@@ -535,6 +554,12 @@ interface StageHitLayerOptions {
|
|
|
535
554
|
* decline one. For a touch tap this is the `pointerup`.
|
|
536
555
|
*/
|
|
537
556
|
onPress?: ((id: HitId, event: StagePointerEvent) => boolean | void) | undefined;
|
|
557
|
+
/**
|
|
558
|
+
* A double-click landed on an item, at `point` in image coordinates, and nothing above it
|
|
559
|
+
* claimed it. The stage offers a double-click to its layers before its own double-click to
|
|
560
|
+
* fit, so a layer that handles one keeps the view where it is. Return `false` to decline it.
|
|
561
|
+
*/
|
|
562
|
+
onDoubleClick?: ((id: HitId, point: Point) => boolean | void) | undefined;
|
|
538
563
|
}
|
|
539
564
|
/**
|
|
540
565
|
* Register a layer with the stage's hit-test. The callbacks may change every render; the
|
|
@@ -546,6 +571,67 @@ interface StageHitLayerOptions {
|
|
|
546
571
|
*/
|
|
547
572
|
export declare function useStageHitLayer(options: StageHitLayerOptions): string;
|
|
548
573
|
//#endregion
|
|
574
|
+
//#region src/components/stage/compareStyle.d.ts
|
|
575
|
+
/** How two images are compared. */
|
|
576
|
+
type CompareMode = "checker" | "wipe" | "difference";
|
|
577
|
+
/** Which way the wipe's divider runs: `vertical` splits left from right, `horizontal` top from bottom. */
|
|
578
|
+
type CompareOrientation = "vertical" | "horizontal";
|
|
579
|
+
//#endregion
|
|
580
|
+
//#region src/components/stage/CompareLayer.d.ts
|
|
581
|
+
/** Props of `CompareLayer`. */
|
|
582
|
+
interface CompareLayerProps {
|
|
583
|
+
/** Image A's URL: the reference. It is the stage's size. */
|
|
584
|
+
a: string;
|
|
585
|
+
/** Image B's URL: compared with A. The same size as A. */
|
|
586
|
+
b: string;
|
|
587
|
+
/**
|
|
588
|
+
* How they are compared.
|
|
589
|
+
* - `checker`: alternate squares of A and B, `cell` image pixels across, A at the top-left.
|
|
590
|
+
* - `wipe`: A before the divider and B after it; drag the divider, or focus it and use the keys.
|
|
591
|
+
* - `difference`: the per-channel difference of the two, brightened by `gain`. Identical pixels
|
|
592
|
+
* are black. It is computed on the sRGB-encoded values the browser composites, not on linear
|
|
593
|
+
* light, so treat it as a picture of where the images differ, not as a measurement.
|
|
594
|
+
*/
|
|
595
|
+
mode: CompareMode;
|
|
596
|
+
/** The wipe's divider, as the fraction of the image before it (0 to 1), when the app controls it. */
|
|
597
|
+
split?: number | undefined;
|
|
598
|
+
/** The divider's starting place when the layer controls it. Defaults to 0.5. */
|
|
599
|
+
defaultSplit?: number | undefined;
|
|
600
|
+
/** Called as the divider is dragged or moved by a key, with the new fraction. */
|
|
601
|
+
onSplitChange?: ((split: number) => void) | undefined;
|
|
602
|
+
/** `vertical` (the default) puts A left of the divider; `horizontal` puts A above it. */
|
|
603
|
+
orientation?: CompareOrientation | undefined;
|
|
604
|
+
/** The checkerboard's square, in image pixels. Defaults to 32. */
|
|
605
|
+
cell?: number | undefined;
|
|
606
|
+
/** How much the difference is brightened: 1 shows it as it is, 4 makes a small one visible. Defaults to 1. */
|
|
607
|
+
gain?: number | undefined;
|
|
608
|
+
/** What the comparison shows, for assistive technology. */
|
|
609
|
+
alt: string;
|
|
610
|
+
/** The two images' names, for the divider's value and its tags. Defaults to `["A", "B"]`. */
|
|
611
|
+
labels?: readonly [string, string] | undefined;
|
|
612
|
+
/** The zoom (CSS pixels per image pixel) from which pixels are drawn as blocks. Defaults to 4. */
|
|
613
|
+
pixelatedAbove?: number | undefined;
|
|
614
|
+
/** Merged onto the layer's wrapper with `cn`. */
|
|
615
|
+
className?: string | undefined;
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Two same-size images compared inside an `ImageStage`: as a checkerboard, a wipe or their
|
|
619
|
+
* difference (`mode`).
|
|
620
|
+
*
|
|
621
|
+
* - **Wipe.** The divider is a line one and a half screen pixels wide with a knob kept in the
|
|
622
|
+
* middle of the part of it on screen. Drag the line or the knob; the press is claimed, so the
|
|
623
|
+
* stage does not pan from it.
|
|
624
|
+
* - **Keyboard.** The knob is a slider (0 to 100, the share of A): arrow keys move it 1 % (10 %
|
|
625
|
+
* with Shift), Page Up and Page Down 10 %, Home and End to either edge. The keys do not reach
|
|
626
|
+
* the stage, so they do not pan it.
|
|
627
|
+
* - **Pixels.** Past `pixelatedAbove` both images are drawn as blocks, as `ImageLayer` does.
|
|
628
|
+
*
|
|
629
|
+
* The images are one picture to assistive technology (`role="img"`, named by `alt`); the knob is
|
|
630
|
+
* outside it, so it stays reachable. The wrapper carries `data-mode`, and `data-pixelated` while
|
|
631
|
+
* pixelated; the knob carries `data-dragging` during a drag.
|
|
632
|
+
*/
|
|
633
|
+
export declare function CompareLayer({ a, b, mode, split, defaultSplit, onSplitChange, orientation, cell, gain, alt, labels, pixelatedAbove, className }: CompareLayerProps): import("react").JSX.Element;
|
|
634
|
+
//#endregion
|
|
549
635
|
//#region src/components/stage/ImageLayer.d.ts
|
|
550
636
|
/**
|
|
551
637
|
* The photograph, as a stage layer.
|
|
@@ -559,7 +645,8 @@ export declare function useStageHitLayer(options: StageHitLayerOptions): string;
|
|
|
559
645
|
* until it would be magnified — until the screen shows more pixels than it has. Past that
|
|
560
646
|
* point the full image is requested, and it stays once loaded, so zooming back out does
|
|
561
647
|
* not swap back. The preview stays underneath while the full image loads, so the frame
|
|
562
|
-
* never goes blank.
|
|
648
|
+
* never goes blank. When the full image is costly to produce, the app can leave its URL
|
|
649
|
+
* out and supply it when `onFullNeeded` says the same rule has tripped.
|
|
563
650
|
* - **Pixelated past a zoom.** Above about 4× the browser's smoothing paints detail the
|
|
564
651
|
* sensor never recorded; on a metrology bench the sensor's own samples are what is worth
|
|
565
652
|
* looking at.
|
|
@@ -571,16 +658,19 @@ interface ImageTier {
|
|
|
571
658
|
/** Its width in pixels. The full image's width is the stage's own. */
|
|
572
659
|
width: number;
|
|
573
660
|
}
|
|
574
|
-
/**
|
|
575
|
-
interface
|
|
576
|
-
/** The full-resolution image's URL. */
|
|
577
|
-
src: string;
|
|
578
|
-
/** A smaller tier to show first; without one, `src` is shown from the start. */
|
|
579
|
-
preview?: ImageTier | undefined;
|
|
661
|
+
/** What every `ImageLayer` takes, whichever tiers it is given. */
|
|
662
|
+
interface ImageLayerBaseProps {
|
|
580
663
|
/** The image's description, for assistive technology. `""` marks it decorative. */
|
|
581
664
|
alt: string;
|
|
582
665
|
/** The zoom (CSS pixels per image pixel) from which pixels are drawn as blocks. Defaults to 4. */
|
|
583
666
|
pixelatedAbove?: number | undefined;
|
|
667
|
+
/**
|
|
668
|
+
* Called once per `preview.src` when the full image is first wanted: the stage would magnify
|
|
669
|
+
* the preview. An app whose full image is costly to make or fetch leaves `src` out and
|
|
670
|
+
* passes it from here; the full image is shown as soon as `src` arrives. Not called without
|
|
671
|
+
* a `preview`.
|
|
672
|
+
*/
|
|
673
|
+
onFullNeeded?: (() => void) | undefined;
|
|
584
674
|
/** Called when the full image has loaded. */
|
|
585
675
|
onLoad?: (() => void) | undefined;
|
|
586
676
|
/** Called when the full image fails to load. */
|
|
@@ -588,15 +678,34 @@ interface ImageLayerProps {
|
|
|
588
678
|
/** Merged onto both images with `cn`. */
|
|
589
679
|
className?: string | undefined;
|
|
590
680
|
}
|
|
681
|
+
/**
|
|
682
|
+
* Props of `ImageLayer`: the full image's `src`, a `preview` tier, or both. With a `preview`,
|
|
683
|
+
* `src` may be left out until `onFullNeeded` asks for it.
|
|
684
|
+
*/
|
|
685
|
+
type ImageLayerProps = ImageLayerBaseProps & ({
|
|
686
|
+
/** The full-resolution image's URL. */
|
|
687
|
+
src: string;
|
|
688
|
+
/** A smaller tier to show first; without one, `src` is shown from the start. */
|
|
689
|
+
preview?: ImageTier | undefined;
|
|
690
|
+
} | {
|
|
691
|
+
/** The full-resolution image's URL, once known. Until then the preview stands in. */
|
|
692
|
+
src?: string | undefined;
|
|
693
|
+
/** A smaller tier to show first. */
|
|
694
|
+
preview: ImageTier;
|
|
695
|
+
});
|
|
591
696
|
/**
|
|
592
697
|
* The photograph at its natural size inside an `ImageStage`, with an optional preview tier
|
|
593
698
|
* and pixelated rendering past `pixelatedAbove`. It takes no pointer events, so presses reach
|
|
594
699
|
* the stage and the layers above.
|
|
595
700
|
*
|
|
701
|
+
* With a `preview`, the full image is wanted once the stage would magnify the preview, and
|
|
702
|
+
* `onFullNeeded` says so; `src` can be supplied then rather than up front.
|
|
703
|
+
*
|
|
596
704
|
* Each image carries `data-tier` (`preview` or `full`); the full image carries `data-loaded`
|
|
597
|
-
* once it has loaded,
|
|
705
|
+
* once it has loaded, the preview carries `data-wants-full` from the moment the full image is
|
|
706
|
+
* wanted until it has loaded, and both carry `data-pixelated` while pixelated.
|
|
598
707
|
*/
|
|
599
|
-
export declare function ImageLayer({ src, preview, alt, pixelatedAbove, onLoad, onError, className }: ImageLayerProps): import("react").JSX.Element;
|
|
708
|
+
export declare function ImageLayer({ src, preview, alt, pixelatedAbove, onFullNeeded, onLoad, onError, className }: ImageLayerProps): import("react").JSX.Element;
|
|
600
709
|
//#endregion
|
|
601
710
|
//#region src/components/stage/StageSurface.d.ts
|
|
602
711
|
/** What a drag does as the pointer moves and when it is released, in image coordinates. */
|
|
@@ -749,8 +858,16 @@ export declare function StageButton({ label, pressed, hint, shortcut, className,
|
|
|
749
858
|
interface StageLayer {
|
|
750
859
|
/** Its identity, passed back to `onVisibleChange`. */
|
|
751
860
|
id: string;
|
|
752
|
-
/**
|
|
753
|
-
|
|
861
|
+
/**
|
|
862
|
+
* Its name in the menu: text, or richer content such as a name and a count. It names the
|
|
863
|
+
* menu item for assistive technology, so keep its text meaningful.
|
|
864
|
+
*/
|
|
865
|
+
label: ReactNode;
|
|
866
|
+
/**
|
|
867
|
+
* A CSS colour shown as a small dot before the label, matching the layer's colour on the
|
|
868
|
+
* canvas. Decorative (`aria-hidden`), so the label must name the layer on its own.
|
|
869
|
+
*/
|
|
870
|
+
swatch?: string | undefined;
|
|
754
871
|
/** Whether it is shown. */
|
|
755
872
|
visible: boolean;
|
|
756
873
|
/** Shown but not switchable, e.g. a layer that has nothing to draw yet. */
|
|
@@ -764,16 +881,18 @@ interface StageLayersMenuProps {
|
|
|
764
881
|
layers: readonly StageLayer[];
|
|
765
882
|
/** Called with a layer's id and its new visibility. */
|
|
766
883
|
onVisibleChange: (id: string, visible: boolean) => void;
|
|
767
|
-
/** The trigger's accessible name and
|
|
884
|
+
/** The trigger's accessible name and tooltip. Defaults to "Layers". */
|
|
768
885
|
label?: string | undefined;
|
|
886
|
+
/** The heading over the menu's items. Defaults to `label`. */
|
|
887
|
+
heading?: ReactNode;
|
|
769
888
|
}
|
|
770
889
|
/**
|
|
771
890
|
* A `StageButton`-shaped trigger opening a menu of layer toggles, for `StageToolbar`'s
|
|
772
|
-
* children. Each layer is a `menuitemcheckbox
|
|
773
|
-
* next. The trigger shows as pressed while any layer
|
|
774
|
-
* says so before the menu is opened.
|
|
891
|
+
* children. Each layer is a `menuitemcheckbox`, with its `swatch` as a dot before its label;
|
|
892
|
+
* toggling one keeps the menu open for the next. The trigger shows as pressed while any layer
|
|
893
|
+
* is hidden, so a canvas missing a layer says so before the menu is opened.
|
|
775
894
|
*/
|
|
776
|
-
export declare function StageLayersMenu({ layers, onVisibleChange, label }: StageLayersMenuProps): import("react").JSX.Element;
|
|
895
|
+
export declare function StageLayersMenu({ layers, onVisibleChange, label, heading }: StageLayersMenuProps): import("react").JSX.Element;
|
|
777
896
|
/** Props of `StageToolbarDivider`. */
|
|
778
897
|
interface StageToolbarDividerProps {
|
|
779
898
|
/** Merged onto the divider with `cn`. */
|
|
@@ -998,7 +1117,7 @@ export declare function fetchPlane(url: string): Promise<ValuePlane>;
|
|
|
998
1117
|
//#endregion
|
|
999
1118
|
//#region src/components/overlayRole.d.ts
|
|
1000
1119
|
/**
|
|
1001
|
-
* The overlay grammar's roles and states
|
|
1120
|
+
* The overlay grammar's roles and states for layers that paint
|
|
1002
1121
|
* through SVG attributes rather than class names.
|
|
1003
1122
|
*/
|
|
1004
1123
|
/**
|
|
@@ -1170,8 +1289,31 @@ interface PolylinePrimitive extends PrimitiveCommon {
|
|
|
1170
1289
|
/** Text drawn just above the first point. */
|
|
1171
1290
|
label?: string;
|
|
1172
1291
|
}
|
|
1173
|
-
/**
|
|
1174
|
-
|
|
1292
|
+
/**
|
|
1293
|
+
* Many unconnected segments drawn as one element, e.g. the tick marks of a shape model whose
|
|
1294
|
+
* points are stored in no particular order, so that a `polyline` cannot join them. Thousands
|
|
1295
|
+
* of segments cost one path, not one element each.
|
|
1296
|
+
*/
|
|
1297
|
+
interface SegmentsPrimitive extends PrimitiveCommon {
|
|
1298
|
+
/** Discriminant. */
|
|
1299
|
+
kind: "segments";
|
|
1300
|
+
/**
|
|
1301
|
+
* `[x1, y1, x2, y2, …]` in image coordinates: four numbers per segment. A trailing partial
|
|
1302
|
+
* segment is ignored, and a segment with a non-finite coordinate is skipped.
|
|
1303
|
+
*/
|
|
1304
|
+
points: number[];
|
|
1305
|
+
/** Verdict colour. Defaults to the neutral tone. */
|
|
1306
|
+
tone?: MeasureTone;
|
|
1307
|
+
/** A short dash pattern. */
|
|
1308
|
+
dashed?: boolean;
|
|
1309
|
+
/** Text drawn just above the first segment's start. */
|
|
1310
|
+
label?: string;
|
|
1311
|
+
}
|
|
1312
|
+
/**
|
|
1313
|
+
* Anything `MeasureOverlay` can draw, discriminated by `kind`. Kinds are added in minor
|
|
1314
|
+
* releases, so code that switches over `kind` should keep a default case.
|
|
1315
|
+
*/
|
|
1316
|
+
type MeasurePrimitive = PointPrimitive | SegmentPrimitive | SegmentsPrimitive | CirclePrimitive | ArcPrimitive | CaliperPrimitive | DimensionPrimitive | PolylinePrimitive;
|
|
1175
1317
|
/** Props of `MeasureOverlay`. */
|
|
1176
1318
|
interface MeasureOverlayProps {
|
|
1177
1319
|
/** The source image's pixel width — the overlay's `viewBox`, and every primitive's frame. */
|
|
@@ -1187,6 +1329,40 @@ interface MeasureOverlayProps {
|
|
|
1187
1329
|
* pixels) this is simply `useStage().view.scale`. See `strokeWidthFor`.
|
|
1188
1330
|
*/
|
|
1189
1331
|
strokeScale: number;
|
|
1332
|
+
/**
|
|
1333
|
+
* Which primitives get a halo: a dark band under the mark (2 screen px wider, at 60 %
|
|
1334
|
+
* opacity) and behind its label's glyphs (3 screen px), so it holds on a bright part of the
|
|
1335
|
+
* image as well as a dark one.
|
|
1336
|
+
* - `"role"` (the default): primitives that carry a `role`.
|
|
1337
|
+
* - `"all"`: every primitive, verdict tones included.
|
|
1338
|
+
* - `"none"`: none.
|
|
1339
|
+
*/
|
|
1340
|
+
halo?: "role" | "all" | "none" | undefined;
|
|
1341
|
+
/**
|
|
1342
|
+
* The hovered primitive's `id`, when the app controls hover (a table beside the stage hovers
|
|
1343
|
+
* rows too). That primitive is drawn in the hover state unless it is selected. Without it, a
|
|
1344
|
+
* pickable overlay tracks the pointer's hover itself.
|
|
1345
|
+
*/
|
|
1346
|
+
hoveredId?: string | null | undefined;
|
|
1347
|
+
/**
|
|
1348
|
+
* Called when the primitive under the pointer changes: its `id`, or `null` when the pointer
|
|
1349
|
+
* leaves every primitive. Only primitives with an `id` are picked.
|
|
1350
|
+
*
|
|
1351
|
+
* Setting this or `onItemPress` makes the overlay pickable: it answers the stage's hit-test,
|
|
1352
|
+
* so it must then sit inside an `ImageStage`. Its SVG still takes no pointer events.
|
|
1353
|
+
*/
|
|
1354
|
+
onHoverChange?: ((id: string | null) => void) | undefined;
|
|
1355
|
+
/**
|
|
1356
|
+
* A press landed on a primitive with an `id`: the nearest within the pointer's tolerance, the
|
|
1357
|
+
* later one on a tie. The press is claimed, so the stage does not pan from it. Return `false`
|
|
1358
|
+
* to decline it: the press then goes to the next layer under the pointer, or to the stage.
|
|
1359
|
+
* The event is the `pointerdown` (the `pointerup` for a touch tap).
|
|
1360
|
+
*/
|
|
1361
|
+
onItemPress?: ((id: string, event: StagePointerEvent) => boolean | void) | undefined;
|
|
1362
|
+
/** The id hit-tests report for this layer. Defaults to a generated one. */
|
|
1363
|
+
layerId?: string | undefined;
|
|
1364
|
+
/** Rank against other layers in hit-tests. Defaults to `STAGE_HIT_PRIORITY.line`. */
|
|
1365
|
+
priority?: number | undefined;
|
|
1190
1366
|
/** Merged onto the `<svg>` with `cn`. */
|
|
1191
1367
|
className?: string;
|
|
1192
1368
|
}
|
|
@@ -1200,10 +1376,57 @@ interface MeasureOverlayProps {
|
|
|
1200
1376
|
*
|
|
1201
1377
|
* A primitive's colour is its `role` (overlay grammar) if given, else its verdict `tone`.
|
|
1202
1378
|
* Its `state` follows the overlay grammar: `hover` thickens it, `selected` thickens it and
|
|
1203
|
-
* rings it in the selection colour, and `dimmed` fades it.
|
|
1204
|
-
*
|
|
1379
|
+
* rings it in the selection colour, and `dimmed` fades it. A primitive with a `role` is drawn
|
|
1380
|
+
* over a halo, and so is its label; `halo` widens or drops that.
|
|
1381
|
+
*
|
|
1382
|
+
* **Picking.** With `onHoverChange` or `onItemPress` the overlay answers the stage's hit-test
|
|
1383
|
+
* (`useStageHitTest` finds its primitives too): the pointer picks the nearest primitive with
|
|
1384
|
+
* an `id`, a dot, a filled circle and a caliper box by their inside, every other kind by its
|
|
1385
|
+
* strokes. The hovered one is drawn in the hover state.
|
|
1386
|
+
*
|
|
1387
|
+
* Each primitive is a `<g>` carrying `data-kind`, plus `data-id` and `data-state` (`hover`
|
|
1388
|
+
* while hovered) when given; its halo is the `<g data-halo>` inside it. The SVG carries
|
|
1389
|
+
* `data-hovered` (the hovered id).
|
|
1390
|
+
*/
|
|
1391
|
+
export declare function MeasureOverlay({ nativeWidth, nativeHeight, primitives, strokeScale, halo, hoveredId, onHoverChange, onItemPress, layerId, priority, className }: MeasureOverlayProps): import("react").JSX.Element;
|
|
1392
|
+
//#endregion
|
|
1393
|
+
//#region src/components/measureHit.d.ts
|
|
1394
|
+
/**
|
|
1395
|
+
* How far a point is from a primitive as drawn, in image pixels.
|
|
1396
|
+
*
|
|
1397
|
+
* - A dot, a filled circle and a caliper box are areas: the distance is 0 anywhere inside.
|
|
1398
|
+
* - Every other kind is a line: the distance to its nearest stroke (a cross's arms, a
|
|
1399
|
+
* circle's or an arc's rim, a dimension's three lines, a caliper's direction arrow).
|
|
1400
|
+
* - Labels are not part of a primitive's shape.
|
|
1401
|
+
*
|
|
1402
|
+
* @param primitive - The primitive.
|
|
1403
|
+
* @param point - The point, in image coordinates.
|
|
1404
|
+
* @param strokeScale - The image-to-screen scale the overlay is drawn at, which sizes a dot,
|
|
1405
|
+
* a cross and an arrow head.
|
|
1406
|
+
* @returns The distance; `Infinity` for a primitive that draws nothing (a zero sweep, an empty
|
|
1407
|
+
* polyline, a kind this version does not know).
|
|
1205
1408
|
*/
|
|
1206
|
-
export declare function
|
|
1409
|
+
export declare function measurePrimitiveDistance(primitive: MeasurePrimitive, point: Point, strokeScale: number): number;
|
|
1410
|
+
/**
|
|
1411
|
+
* The primitive nearest to `point` within `radius`, among those with an `id`.
|
|
1412
|
+
*
|
|
1413
|
+
* The primitives are gridded by bounding box once per `primitives` array, and the grid is
|
|
1414
|
+
* kept while that array lives, so a hover over thousands of primitives measures only those
|
|
1415
|
+
* near the pointer. Pass a new array when the primitives change (as React state does): one
|
|
1416
|
+
* edited in place keeps its old grid.
|
|
1417
|
+
*
|
|
1418
|
+
* @param primitives - The primitives, bottom to top, as `MeasureOverlay` draws them.
|
|
1419
|
+
* @param point - The point, in image coordinates.
|
|
1420
|
+
* @param radius - The search radius, in image pixels.
|
|
1421
|
+
* @param strokeScale - The image-to-screen scale the overlay is drawn at.
|
|
1422
|
+
* @returns The nearest primitive's id and distance, or `null`. A tie goes to the later
|
|
1423
|
+
* primitive, which is drawn on top. A primitive with a NaN coordinate is never picked,
|
|
1424
|
+
* except a `segments` one, whose bad segments are skipped as they are when drawn.
|
|
1425
|
+
*/
|
|
1426
|
+
export declare function nearestMeasurePrimitive(primitives: readonly MeasurePrimitive[], point: Point, radius: number, strokeScale: number): {
|
|
1427
|
+
id: string;
|
|
1428
|
+
distance: number;
|
|
1429
|
+
} | null;
|
|
1207
1430
|
//#endregion
|
|
1208
1431
|
//#region src/components/stage/useScreenPx.d.ts
|
|
1209
1432
|
/**
|
|
@@ -1219,10 +1442,16 @@ export declare function MeasureOverlay({ nativeWidth, nativeHeight, primitives,
|
|
|
1219
1442
|
export declare function useScreenPx(): (css: number) => number;
|
|
1220
1443
|
//#endregion
|
|
1221
1444
|
//#region src/components/ContourEditor.d.ts
|
|
1222
|
-
/** An ordered, closed
|
|
1445
|
+
/** An ordered contour, closed or open, drawn in source-image pixel-center coordinates. */
|
|
1223
1446
|
interface ContourEditorProps {
|
|
1224
|
-
/** Ordered vertices; the final vertex connects back to the first. */
|
|
1447
|
+
/** Ordered vertices; on a closed contour the final vertex connects back to the first. */
|
|
1225
1448
|
points: Point[];
|
|
1449
|
+
/**
|
|
1450
|
+
* Whether the last vertex joins the first. Defaults to `true`, a closed polygon; `false`
|
|
1451
|
+
* draws an open polyline (a centreline, an edge piece), which keeps at least two vertices
|
|
1452
|
+
* where a closed contour keeps three.
|
|
1453
|
+
*/
|
|
1454
|
+
closed?: boolean | undefined;
|
|
1226
1455
|
/** Receives a complete replacement point list after each edit. */
|
|
1227
1456
|
onChange: (points: Point[]) => void;
|
|
1228
1457
|
/** Called at the end of a pointer or keyboard edit; useful for history snapshots. */
|
|
@@ -1240,13 +1469,190 @@ interface ContourEditorProps {
|
|
|
1240
1469
|
* for polygons in the area convention, which may lie exactly on the image border.
|
|
1241
1470
|
*/
|
|
1242
1471
|
bounds?: Rect | undefined;
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1472
|
+
/** The id hit-tests report for this contour, whose items are segment indices. Defaults to a generated one. */
|
|
1473
|
+
layerId?: string | undefined;
|
|
1474
|
+
/** Rank against other layers in hit-tests. Defaults to `STAGE_HIT_PRIORITY.line`. */
|
|
1475
|
+
priority?: number | undefined;
|
|
1476
|
+
/**
|
|
1477
|
+
* What a press does while `editable`:
|
|
1478
|
+
* - `"vertex"` (the default): vertices are dragged, nudged, inserted and deleted.
|
|
1479
|
+
* - `"brush"`: a drag pushes the contour with a soft round brush of `brushRadius`, centred
|
|
1480
|
+
* where the press landed; `onChange` follows the drag and `onCommit` ends it.
|
|
1481
|
+
* - `"erase"`: a drag along the contour marks a stretch of it, and the release reports what
|
|
1482
|
+
* is left through `onErase`.
|
|
1483
|
+
*
|
|
1484
|
+
* In `"brush"` and `"erase"` the editor covers the image with its own press target
|
|
1485
|
+
* (`data-tool-surface`) and shows the brush's footprint under the pointer; a press whose
|
|
1486
|
+
* brush does not reach the contour is declined, so the stage pans.
|
|
1487
|
+
*/
|
|
1488
|
+
mode?: "vertex" | "brush" | "erase" | undefined;
|
|
1489
|
+
/** The brush's radius in `"brush"` and `"erase"` mode, in image pixels. Defaults to 20. */
|
|
1490
|
+
brushRadius?: number | undefined;
|
|
1491
|
+
/**
|
|
1492
|
+
* Called when an erase drag is released, with the pieces of the contour that are left (each
|
|
1493
|
+
* an open polyline, see `eraseArc`) and the erased stretch as arc lengths: from `start`
|
|
1494
|
+
* forward to `end`, past the first vertex of a closed contour when `start > end`. The editor
|
|
1495
|
+
* does not change `points` itself. Erasing a stretch of a closed contour leaves **one open
|
|
1496
|
+
* piece**: to keep editing it, pass it back as `points` with `closed={false}`.
|
|
1497
|
+
*/
|
|
1498
|
+
onErase?: ((pieces: Point[][], range: {
|
|
1499
|
+
start: number;
|
|
1500
|
+
end: number;
|
|
1501
|
+
}) => void) | undefined;
|
|
1502
|
+
}
|
|
1503
|
+
/**
|
|
1504
|
+
* The index of the segment closest to `point`: segment `i` runs from vertex `i` to the next.
|
|
1505
|
+
*
|
|
1506
|
+
* @param points - The contour's vertices.
|
|
1507
|
+
* @param point - The point, in image coordinates.
|
|
1508
|
+
* @param closed - Whether the last vertex joins the first, which adds the closing segment
|
|
1509
|
+
* (index `points.length - 1`). Defaults to `true`.
|
|
1510
|
+
* @returns The segment's index; 0 for a contour with no segment.
|
|
1511
|
+
*/
|
|
1512
|
+
export declare function nearestContourSegment(points: Point[], point: Point, closed?: boolean): number;
|
|
1513
|
+
/**
|
|
1514
|
+
* Edit contour vertices over an ImageStage using its shared source-image transform.
|
|
1515
|
+
*
|
|
1516
|
+
* - **Vertices.** Each vertex is a focusable button: drag it (once the pointer has moved
|
|
1517
|
+
* 3 screen pixels, so a jittery click edits nothing), nudge it with the arrow keys (Shift for
|
|
1518
|
+
* a tenth of a pixel), delete it with Delete or Backspace (a closed contour keeps three
|
|
1519
|
+
* vertices, an open one two), or insert one after it with Insert.
|
|
1520
|
+
* - **Open or closed.** `closed` (the default) draws a polygon; `closed={false}` an open
|
|
1521
|
+
* polyline with no segment from the last vertex back to the first.
|
|
1522
|
+
* - **Outline.** The outline takes no presses, so a press on it reaches the layers below, or
|
|
1523
|
+
* pans. While `editable` in `"vertex"` mode, the contour answers the stage's hit-test
|
|
1524
|
+
* (`STAGE_HIT_PRIORITY.line` by default, segment indices as ids), and a double-click near the
|
|
1525
|
+
* outline inserts a vertex on the nearest segment; the stage's double-click to fit does not
|
|
1526
|
+
* run then.
|
|
1527
|
+
* - **Brush and erase.** In `"brush"` mode a drag pushes the contour with a soft round brush
|
|
1528
|
+
* (`deformContour`, from the contour as it was at the press, held inside `bounds`); in
|
|
1529
|
+
* `"erase"` mode a drag along the contour previews the stretch it removes, dashed, and the
|
|
1530
|
+
* release calls `onErase`. Both start only past the click slop. The vertex handles are
|
|
1531
|
+
* hidden in these modes.
|
|
1532
|
+
*
|
|
1533
|
+
* The SVG carries `data-mode` while editable; the tool surface is `data-tool-surface`, and the
|
|
1534
|
+
* stretch an erase would remove is `data-erase-preview`.
|
|
1535
|
+
*/
|
|
1536
|
+
export declare function ContourEditor({ points, closed, onChange, onCommit, editable, label, stroke, bounds, layerId, priority, mode, brushRadius, onErase }: ContourEditorProps): import("react").JSX.Element;
|
|
1537
|
+
//#endregion
|
|
1538
|
+
//#region src/components/contourArc.d.ts
|
|
1539
|
+
/**
|
|
1540
|
+
* The cumulative arc length at each vertex.
|
|
1541
|
+
*
|
|
1542
|
+
* @param points - The path's vertices.
|
|
1543
|
+
* @param closed - Whether the last vertex joins the first. Defaults to `false`.
|
|
1544
|
+
* @returns `s[i]`, the length of the path from the first vertex to vertex `i`, so `s[0]` is 0.
|
|
1545
|
+
* A closed path has one more entry: its whole length, back at the first vertex. The last
|
|
1546
|
+
* entry is always the path's length. An empty path gives `[]`.
|
|
1547
|
+
*/
|
|
1548
|
+
export declare function arcLengths(points: readonly Point[], closed?: boolean): number[];
|
|
1549
|
+
/**
|
|
1550
|
+
* The point at arc length `s`.
|
|
1551
|
+
*
|
|
1552
|
+
* @param points - The path's vertices.
|
|
1553
|
+
* @param s - The distance along the path, in image pixels. On an open path it is clamped to
|
|
1554
|
+
* `[0, length]`; on a closed path it wraps around.
|
|
1555
|
+
* @param closed - Whether the last vertex joins the first. Defaults to `false`.
|
|
1556
|
+
* @returns The point. An empty path gives `NaN` coordinates.
|
|
1557
|
+
*/
|
|
1558
|
+
export declare function pointAtArc(points: readonly Point[], s: number, closed?: boolean): Point;
|
|
1559
|
+
/**
|
|
1560
|
+
* The nearest place on the path to a point.
|
|
1561
|
+
*
|
|
1562
|
+
* @param points - The path's vertices.
|
|
1563
|
+
* @param p - The point, in image coordinates.
|
|
1564
|
+
* @param closed - Whether the last vertex joins the first. Defaults to `false`.
|
|
1565
|
+
* @returns `s`, the arc length of the nearest place (the first one, on a tie); `point`, the
|
|
1566
|
+
* place itself; and `distance`, how far `p` is from it. An empty path gives `s` 0, a `NaN`
|
|
1567
|
+
* point and an infinite distance.
|
|
1568
|
+
*/
|
|
1569
|
+
export declare function projectToArc(points: readonly Point[], p: Point, closed?: boolean): {
|
|
1570
|
+
s: number;
|
|
1571
|
+
point: Point;
|
|
1572
|
+
distance: number;
|
|
1573
|
+
};
|
|
1574
|
+
/**
|
|
1575
|
+
* The stretch of the path between two arc lengths, as a polyline: the place at `s0`, every
|
|
1576
|
+
* vertex strictly between, and the place at `s1`.
|
|
1577
|
+
*
|
|
1578
|
+
* @param points - The path's vertices.
|
|
1579
|
+
* @param s0 - Where the stretch starts.
|
|
1580
|
+
* @param s1 - Where it ends.
|
|
1581
|
+
* @param closed - Whether the last vertex joins the first. Defaults to `false`. On an open
|
|
1582
|
+
* path both ends are clamped to it and the stretch always runs forward (`s0` and `s1` are
|
|
1583
|
+
* swapped when `s0 > s1`). On a closed path an end outside `[0, length]` wraps, and with
|
|
1584
|
+
* `s0 > s1` the stretch runs forward past the first vertex and on to `s1`.
|
|
1585
|
+
* @returns The stretch, at least its two ends (the same point twice for an empty stretch).
|
|
1586
|
+
* An empty path gives `[]`.
|
|
1587
|
+
*/
|
|
1588
|
+
export declare function subPath(points: readonly Point[], s0: number, s1: number, closed?: boolean): Point[];
|
|
1589
|
+
/**
|
|
1590
|
+
* The unit normal at arc length `s`: the tangent of the segment there, turned a quarter turn
|
|
1591
|
+
* by `(tx, ty) → (-ty, tx)`. With image `y` pointing down that turn is **clockwise on
|
|
1592
|
+
* screen**: on a path running left to right the normal points down, and on a closed contour
|
|
1593
|
+
* whose vertices run clockwise on screen it points inward.
|
|
1594
|
+
*
|
|
1595
|
+
* @param points - The path's vertices.
|
|
1596
|
+
* @param s - The distance along the path, clamped or wrapped as in `pointAtArc`. At a vertex
|
|
1597
|
+
* the segment that starts there is used (at the end of an open path, the last one).
|
|
1598
|
+
* @param closed - Whether the last vertex joins the first. Defaults to `false`.
|
|
1599
|
+
* @returns A unit vector, or `{ x: 0, y: 0 }` for a path with no length.
|
|
1600
|
+
*/
|
|
1601
|
+
export declare function normalAtArc(points: readonly Point[], s: number, closed?: boolean): Point;
|
|
1602
|
+
/**
|
|
1603
|
+
* Push part of a path with a soft round brush: every vertex within `radius` of `centre`
|
|
1604
|
+
* moves by `delta` scaled by a falloff of `0.5 · (1 + cos(π · d / radius))`, `d` being its
|
|
1605
|
+
* distance from `centre` — the whole `delta` at the centre, nothing at the rim, smooth in
|
|
1606
|
+
* between. Each segment that passes within `radius` of `centre` is first divided so its
|
|
1607
|
+
* vertices are at most `radius / 4` apart, so the brush bends the path rather than dragging
|
|
1608
|
+
* a long segment's two ends.
|
|
1609
|
+
*
|
|
1610
|
+
* @param points - The path's vertices.
|
|
1611
|
+
* @param centre - The brush's centre, in image coordinates.
|
|
1612
|
+
* @param delta - How far its centre pushes, in image pixels.
|
|
1613
|
+
* @param radius - The brush's radius, in image pixels. Zero or less leaves the path as it is.
|
|
1614
|
+
* @param closed - Whether the last vertex joins the first. Defaults to `false`; a closed
|
|
1615
|
+
* path's closing segment is divided like the others, its new vertices appended at the end.
|
|
1616
|
+
* @returns A new list of vertices.
|
|
1617
|
+
*/
|
|
1618
|
+
export declare function deformContour(points: readonly Point[], centre: Point, delta: Point, radius: number, closed?: boolean): Point[];
|
|
1619
|
+
/**
|
|
1620
|
+
* The pieces of a path left after erasing the stretch between two arc lengths.
|
|
1621
|
+
*
|
|
1622
|
+
* @param points - The path's vertices.
|
|
1623
|
+
* @param s0 - Where the erased stretch starts.
|
|
1624
|
+
* @param s1 - Where it ends.
|
|
1625
|
+
* @param closed - Whether the last vertex joins the first. Defaults to `false`. On an open
|
|
1626
|
+
* path the ends are clamped and ordered as in `subPath`, and up to two pieces remain: before
|
|
1627
|
+
* the stretch and after it. On a closed path the stretch runs forward from `s0` to `s1`
|
|
1628
|
+
* (past the first vertex when `s0 > s1`), and what remains is **one open piece**, from `s1`
|
|
1629
|
+
* on around to `s0`; erasing an empty stretch (`s0` equal to `s1`) cuts the contour open there.
|
|
1630
|
+
* @returns The pieces, each an open polyline of at least two points. A piece with no length
|
|
1631
|
+
* (the erased stretch reached an open path's end) is left out.
|
|
1632
|
+
*/
|
|
1633
|
+
export declare function eraseArc(points: readonly Point[], s0: number, s1: number, closed?: boolean): Point[][];
|
|
1248
1634
|
//#endregion
|
|
1249
1635
|
//#region src/components/RectRoiEditor.d.ts
|
|
1636
|
+
/**
|
|
1637
|
+
* What `RectRoiEditor`'s `ref` exposes: a new region drawn from a press the app's own target
|
|
1638
|
+
* received, for an app whose one `StageSurface` decides what a press means.
|
|
1639
|
+
*/
|
|
1640
|
+
interface RectRoiEditorHandle {
|
|
1641
|
+
/**
|
|
1642
|
+
* Draw a new region from a press: call it from a `pointerdown` handler, such as a layer's
|
|
1643
|
+
* `onItemPress`. The press is claimed (the stage does not pan) and followed on `window`; a
|
|
1644
|
+
* drag shorter than the click slop, or a box smaller than `minSize`, draws nothing. Another
|
|
1645
|
+
* event type (a touch tap reported on release) does nothing. Works whether or not `draw` is
|
|
1646
|
+
* set, and does nothing while `editable` is off or the stage is in pan mode.
|
|
1647
|
+
*/
|
|
1648
|
+
startDraw(event: StagePointerEvent): void;
|
|
1649
|
+
/**
|
|
1650
|
+
* The same draw as a `StageDrag`, to return from `StageSurface`'s `onPress`. It claims a
|
|
1651
|
+
* touch, so a finger draws instead of panning. While `editable` is off it is an empty drag:
|
|
1652
|
+
* the press is claimed and nothing is drawn.
|
|
1653
|
+
*/
|
|
1654
|
+
drawDrag(press: StagePress): StageDrag;
|
|
1655
|
+
}
|
|
1250
1656
|
/** Props of `RectRoiEditor`. */
|
|
1251
1657
|
interface RectRoiEditorProps {
|
|
1252
1658
|
/** The region in image coordinates, or `null` for none. */
|
|
@@ -1262,6 +1668,20 @@ interface RectRoiEditorProps {
|
|
|
1262
1668
|
* region tool is active: in draw mode the layer claims presses that would otherwise pan.
|
|
1263
1669
|
*/
|
|
1264
1670
|
draw?: boolean | undefined;
|
|
1671
|
+
/**
|
|
1672
|
+
* Whether `draw` puts a full-frame draw target (`data-draw-surface`) in this layer. Defaults
|
|
1673
|
+
* to `true`. Turn it off when the app's own `StageSurface` decides what a press means, so
|
|
1674
|
+
* other layers can sit between the target and the region's handles, and start the draw from
|
|
1675
|
+
* there with the `ref`'s `drawDrag` or `startDraw`.
|
|
1676
|
+
*/
|
|
1677
|
+
drawSurface?: boolean | undefined;
|
|
1678
|
+
/**
|
|
1679
|
+
* What a press inside the region does. `"move"` (the default) moves it. `"none"` leaves the
|
|
1680
|
+
* inside to the layers below (a press there selects what lies under the region, say): only
|
|
1681
|
+
* the handles and the band along the outline grab the region. The region stays focusable and
|
|
1682
|
+
* the arrow keys still move it.
|
|
1683
|
+
*/
|
|
1684
|
+
interior?: "move" | "none" | undefined;
|
|
1265
1685
|
/**
|
|
1266
1686
|
* The area the region must stay in, in the stage's centre convention. Defaults to
|
|
1267
1687
|
* `{ x: -0.5, y: -0.5, width, height }` of the image: its full extent, so a region that
|
|
@@ -1274,22 +1694,40 @@ interface RectRoiEditorProps {
|
|
|
1274
1694
|
label?: string | undefined;
|
|
1275
1695
|
/** CSS colour of the outline and handles. Defaults to the overlay `selection` role. */
|
|
1276
1696
|
stroke?: string | undefined;
|
|
1697
|
+
/** CSS colour of the tint inside the region. Defaults to `stroke`. */
|
|
1698
|
+
fill?: string | undefined;
|
|
1699
|
+
/** Opacity of the tint inside the region, 0 to 1. Defaults to 0.06; `0` draws no tint. */
|
|
1700
|
+
fillOpacity?: number | undefined;
|
|
1701
|
+
/** Draw from the app's own press target; see `RectRoiEditorHandle`. */
|
|
1702
|
+
ref?: Ref<RectRoiEditorHandle> | undefined;
|
|
1277
1703
|
}
|
|
1278
1704
|
/**
|
|
1279
1705
|
* An editable axis-aligned region inside an `ImageStage`.
|
|
1280
1706
|
*
|
|
1281
|
-
* - **Handles.** The eight handles resize the region, and the interior moves it
|
|
1282
|
-
*
|
|
1283
|
-
*
|
|
1707
|
+
* - **Handles.** The eight handles resize the region, and the interior moves it, as does the
|
|
1708
|
+
* band along the outline (the pointer's tolerance: 6 px for a mouse, 12 px for a finger). A
|
|
1709
|
+
* handle dragged through the opposite edge flips the box.
|
|
1710
|
+
* - **Press order.** One decision serves every part of the editor: the nearest handle first,
|
|
1711
|
+
* then the outline band, then the interior (unless `interior` is `"none"`). A small region's
|
|
1712
|
+
* interior does not steal a press meant for a handle, and a press that grabs nothing is not
|
|
1713
|
+
* claimed.
|
|
1714
|
+
* - **Click slop.** A press becomes an edit only once the pointer has moved 3 screen pixels, so
|
|
1715
|
+
* a jittery click calls neither `onValueChange` nor `onCommit`. An interrupted drag
|
|
1716
|
+
* (`pointercancel`) puts the region back and commits nothing.
|
|
1717
|
+
* - **Drawing.** With `draw`, a drag elsewhere on the image draws a new region; with
|
|
1718
|
+
* `drawSurface={false}` the app starts it through the `ref`.
|
|
1284
1719
|
* - **Keyboard.** The region is focusable: arrow keys move it by one image pixel (ten with
|
|
1285
1720
|
* Shift), and with Alt they grow or shrink it from the bottom-right corner.
|
|
1286
1721
|
* - **Limits.** The region stays inside `bounds` and never gets smaller than `minSize`.
|
|
1287
1722
|
* - **Rendering.** Handles and the outline are a constant size on screen at every zoom.
|
|
1288
1723
|
* - **Panning.** A press with the hand tool, or with space held, still pans.
|
|
1289
1724
|
*
|
|
1290
|
-
*
|
|
1725
|
+
* Data attributes, for styling and tests: the SVG carries `data-editable`, and `data-drawing`
|
|
1726
|
+
* while a draw is in progress; the full-frame draw target is `data-draw-surface`; the region's
|
|
1727
|
+
* focusable inside is `data-roi-interior`; the band along its outline is `data-roi-band`; and
|
|
1728
|
+
* each handle is `data-handle`, one of `nw`, `n`, `ne`, `e`, `se`, `s`, `sw`, `w`.
|
|
1291
1729
|
*/
|
|
1292
|
-
export declare function RectRoiEditor({ value, onValueChange, onCommit, editable, draw, bounds, minSize, label, stroke }: RectRoiEditorProps): import("react").JSX.Element;
|
|
1730
|
+
export declare function RectRoiEditor({ value, onValueChange, onCommit, editable, draw, drawSurface, interior, bounds, minSize, label, stroke, fill, fillOpacity, ref }: RectRoiEditorProps): import("react").JSX.Element;
|
|
1293
1731
|
//#endregion
|
|
1294
1732
|
//#region src/components/polylineIndex.d.ts
|
|
1295
1733
|
/** A polyline's identity. */
|
|
@@ -1390,6 +1828,25 @@ interface PolylineSetItem extends Polyline {
|
|
|
1390
1828
|
}
|
|
1391
1829
|
/** How a gesture combines with the current selection. */
|
|
1392
1830
|
type PolylineSelectMode = "replace" | "toggle" | "add";
|
|
1831
|
+
/**
|
|
1832
|
+
* What `PolylineSet`'s `ref` exposes: a rubber band started from a press somewhere else, such
|
|
1833
|
+
* as the app's `StageSurface` or a region editor's inside. It works whether or not the layer
|
|
1834
|
+
* is `interactive`, and ends in `onSelect` like a band started on the set itself.
|
|
1835
|
+
*/
|
|
1836
|
+
interface PolylineSetHandle {
|
|
1837
|
+
/**
|
|
1838
|
+
* Start a band from a `pointerdown`: the press is claimed (the stage does not pan) and
|
|
1839
|
+
* followed on `window`. `mode` defaults to `"add"` with ⌘/Ctrl held and `"replace"` without.
|
|
1840
|
+
* Another event type (a touch tap reported on release) does nothing, and so does a press
|
|
1841
|
+
* while the stage is in pan mode.
|
|
1842
|
+
*/
|
|
1843
|
+
startSweep(event: StagePointerEvent, mode?: "replace" | "add"): void;
|
|
1844
|
+
/**
|
|
1845
|
+
* The same band as a `StageDrag`, to return from `StageSurface`'s `onPress`. `mode` defaults
|
|
1846
|
+
* from the press's ⌘/Ctrl. It claims a touch, so a finger sweeps instead of panning.
|
|
1847
|
+
*/
|
|
1848
|
+
sweepDrag(press: StagePress, mode?: "replace" | "add"): StageDrag;
|
|
1849
|
+
}
|
|
1393
1850
|
/** Props of `PolylineSet`. */
|
|
1394
1851
|
interface PolylineSetProps {
|
|
1395
1852
|
/** The polylines, in image coordinates. */
|
|
@@ -1427,6 +1884,13 @@ interface PolylineSetProps {
|
|
|
1427
1884
|
* and to the layers below.
|
|
1428
1885
|
*/
|
|
1429
1886
|
marquee?: boolean | undefined;
|
|
1887
|
+
/**
|
|
1888
|
+
* Whether `marquee` puts a full-frame sweep target (`data-marquee-surface`) in this layer.
|
|
1889
|
+
* Defaults to `true`. Off, a press on a line still starts a band, and a press on bare image
|
|
1890
|
+
* reaches the layers below: the app starts a band from there with the `ref`'s `sweepDrag`
|
|
1891
|
+
* or `startSweep`, so a band can begin anywhere without this layer covering the others.
|
|
1892
|
+
*/
|
|
1893
|
+
marqueeSurface?: boolean | undefined;
|
|
1430
1894
|
/**
|
|
1431
1895
|
* Whether the layer takes presses and hover. Defaults to `true` when any of `onItemPress`,
|
|
1432
1896
|
* `onSelect`, `onHover`, `onHoverChange` or `marquee` is given. When `false` the layer
|
|
@@ -1446,30 +1910,45 @@ interface PolylineSetProps {
|
|
|
1446
1910
|
hitWidth?: number | undefined;
|
|
1447
1911
|
/** The zoom from which a hovered or selected line's points are drawn. Defaults to 3. */
|
|
1448
1912
|
vertexScale?: number | undefined;
|
|
1913
|
+
/**
|
|
1914
|
+
* CSS colour of the point dots. Defaults to the overlay `label` role, a near-white that stands
|
|
1915
|
+
* apart from both the line colours and the selection colour, so the points of a selected line
|
|
1916
|
+
* show on it. Each dot sits on a dark halo.
|
|
1917
|
+
*/
|
|
1918
|
+
vertexColor?: string | undefined;
|
|
1919
|
+
/** Diameter of a point dot, in screen pixels, without its 1 px halo. Defaults to 4. */
|
|
1920
|
+
vertexSize?: number | undefined;
|
|
1449
1921
|
/** The layer's accessible name. Defaults to "Lines". */
|
|
1450
1922
|
label?: string | undefined;
|
|
1451
1923
|
/** The id hit-tests report for this layer. Defaults to a generated one. */
|
|
1452
1924
|
layerId?: string | undefined;
|
|
1453
1925
|
/** Rank against other layers in hit-tests. Defaults to `STAGE_HIT_PRIORITY.line`. */
|
|
1454
1926
|
priority?: number | undefined;
|
|
1927
|
+
/** Start a rubber band from a press elsewhere; see `PolylineSetHandle`. */
|
|
1928
|
+
ref?: Ref<PolylineSetHandle> | undefined;
|
|
1455
1929
|
}
|
|
1456
1930
|
/**
|
|
1457
1931
|
* A selectable set of polylines inside an `ImageStage`.
|
|
1458
1932
|
*
|
|
1459
|
-
* - **States
|
|
1933
|
+
* - **States**:
|
|
1460
1934
|
* - default 1.5 screen px;
|
|
1461
1935
|
* - hover 2 px;
|
|
1462
1936
|
* - selected 2.5 px in `selectionStroke`;
|
|
1463
1937
|
* - dimmed at 35 % opacity.
|
|
1464
1938
|
* - **Halo.** Every line has a halo, so it holds on any image.
|
|
1465
|
-
* - **Points.** Above `vertexScale`, the points of the hovered and selected lines are drawn
|
|
1939
|
+
* - **Points.** Above `vertexScale`, the points of the hovered and selected lines are drawn as
|
|
1940
|
+
* `vertexColor` dots on a dark halo, so they show on a selected line too.
|
|
1466
1941
|
* - **Panning.** The hand tool and a held space bar still pan.
|
|
1467
1942
|
* - **Tools.** Without a handler (or with `interactive={false}`) the layer takes no presses
|
|
1468
1943
|
* and only answers `useStageHitTest`, so a draw tool's surface below receives them.
|
|
1944
|
+
* - **Sweeps from elsewhere.** The `ref`'s `startSweep` and `sweepDrag` start a band from a
|
|
1945
|
+
* press another target received; with `marqueeSurface={false}` the layer keeps no
|
|
1946
|
+
* full-frame target of its own.
|
|
1469
1947
|
*
|
|
1470
|
-
* The SVG carries `data-hovered` (the hovered id) and `data-sweeping` while a band is drawn
|
|
1948
|
+
* The SVG carries `data-hovered` (the hovered id) and `data-sweeping` while a band is drawn;
|
|
1949
|
+
* the point dots are `data-points`.
|
|
1471
1950
|
*/
|
|
1472
|
-
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;
|
|
1951
|
+
export declare function PolylineSet({ items, selected, dimmed, hovered, onHover, onHoverChange, onItemPress, onSelect, marquee, marqueeSurface, interactive, stroke, selectionStroke, hitWidth, vertexScale, vertexColor, vertexSize, label, layerId, priority, ref }: PolylineSetProps): import("react").JSX.Element;
|
|
1473
1952
|
//#endregion
|
|
1474
1953
|
//#region src/components/markerShapes.d.ts
|
|
1475
1954
|
/** One kind of marker. */
|
|
@@ -1705,7 +2184,7 @@ interface PointSetProps {
|
|
|
1705
2184
|
*
|
|
1706
2185
|
* - **Markers** by kind, from the overlay grammar: `dot`, `plus` (corner), `cross`, `square`,
|
|
1707
2186
|
* `hollow` (predicted), `directed`. Add your own through `markers`.
|
|
1708
|
-
* - **States
|
|
2187
|
+
* - **States**: default 1.5 screen px, hover 2, selected 2.5 in the
|
|
1709
2188
|
* selection colour with a ring, dimmed at 35 % opacity. Every mark has a halo.
|
|
1710
2189
|
* - **Labels** only where points are at least 24 screen px apart, at most 200 at a time.
|
|
1711
2190
|
* - **Picking** goes through the stage's hit registry: `onHoverChange` and `onItemPress` here,
|
|
@@ -1918,7 +2397,7 @@ interface AreaSetProps {
|
|
|
1918
2397
|
* `stroke` / `fill` colours (`fillOpacity`, `fillRule`, `paintOrder` and `selectionFill` tune the fill).
|
|
1919
2398
|
* Rings are wound alike before they are batched, so overlapping regions never cut a hole in
|
|
1920
2399
|
* each other.
|
|
1921
|
-
* - **States
|
|
2400
|
+
* - **States**: default 1.5 screen px (1 for `model` and
|
|
1922
2401
|
* `structure`), hover 2, selected 2.5 in the selection colour, dimmed at 35 % opacity. Every
|
|
1923
2402
|
* outline has a halo. A region has no ring: its outline at 2.5 px is the mark.
|
|
1924
2403
|
* - **Labels** at the centre of a region, only where regions are at least 24 screen px apart,
|
|
@@ -2093,7 +2572,7 @@ interface EllipseSetProps {
|
|
|
2093
2572
|
*
|
|
2094
2573
|
* - **Geometry** is data: `rx`, `ry` and the centre are image pixels and scale with the image;
|
|
2095
2574
|
* the stroke is a screen constant.
|
|
2096
|
-
* - **States
|
|
2575
|
+
* - **States**: 1.5 screen px (1 for `model` and `structure`), hover
|
|
2097
2576
|
* 2, selected 2.5 in the selection colour, dimmed at 35 % opacity. Every stroke has a halo.
|
|
2098
2577
|
* - **Batching** is by (role, dash, opacity, dimming): a thousand rings are a dozen elements.
|
|
2099
2578
|
* - **Picking** goes through the stage's hit registry: a press within the pointer's tolerance of
|
|
@@ -2481,6 +2960,14 @@ export declare function resizeShape(shape: RotatedShape, handle: RoiHandle, to:
|
|
|
2481
2960
|
* @returns The rotated shape: the same centre and size, `rotation` in `(-π, π]`.
|
|
2482
2961
|
*/
|
|
2483
2962
|
export declare function rotateShape(shape: RotatedShape, to: Point, snap?: number): RotatedShape;
|
|
2963
|
+
/**
|
|
2964
|
+
* An angle rounded to the nearest multiple of a step: what Shift does to a rotation.
|
|
2965
|
+
*
|
|
2966
|
+
* @param angle - Radians.
|
|
2967
|
+
* @param step - The step, in radians (`Math.PI / 12` for 15°). 0 or less leaves the angle as it is.
|
|
2968
|
+
* @returns The rounded angle. It is not brought into `(-π, π]`; pass it through `normalizeAngle` for that.
|
|
2969
|
+
*/
|
|
2970
|
+
export declare function snapAngle(angle: number, step: number): number;
|
|
2484
2971
|
/**
|
|
2485
2972
|
* Move the shape.
|
|
2486
2973
|
*
|
|
@@ -2575,6 +3062,8 @@ interface ShapeEditorProps {
|
|
|
2575
3062
|
* then the interior or outline band (move), then nothing. A small shape's interior does not
|
|
2576
3063
|
* steal a press meant for a handle, and a press that hits none of them is not claimed, so
|
|
2577
3064
|
* it reaches whatever is below, or the stage.
|
|
3065
|
+
* - **Click slop.** A press becomes an edit only once the pointer has moved 3 screen pixels
|
|
3066
|
+
* from where it landed, so a jittery click changes nothing and commits nothing.
|
|
2578
3067
|
* - **Touch.** A press that grabs the shape is claimed; a second finger landing during an edit
|
|
2579
3068
|
* cancels it (the shape reverts, nothing is committed) and is left to the stage.
|
|
2580
3069
|
* - **Rotation.** The handle past the top side turns the shape about its centre; hold Shift to
|
|
@@ -2593,6 +3082,129 @@ interface ShapeEditorProps {
|
|
|
2593
3082
|
*/
|
|
2594
3083
|
export declare function ShapeEditor({ kind, value, onValueChange, onCommit, editable, rotatable, minSize, label, stroke }: ShapeEditorProps): import("react").JSX.Element;
|
|
2595
3084
|
//#endregion
|
|
3085
|
+
//#region src/components/datumEdit.d.ts
|
|
3086
|
+
/** A frame on the image: where it starts, and which way its i axis points. */
|
|
3087
|
+
interface Datum {
|
|
3088
|
+
/** The origin, in image coordinates. */
|
|
3089
|
+
origin: Point;
|
|
3090
|
+
/** The i axis's direction: radians, clockwise on screen from the image's `+x`. */
|
|
3091
|
+
angle: number;
|
|
3092
|
+
}
|
|
3093
|
+
/** The origin ring's radius, in screen pixels. */
|
|
3094
|
+
export declare const DATUM_RING_PX = 7;
|
|
3095
|
+
/** The i axis's length when nothing else is given, in screen pixels; the j axis is half of it. */
|
|
3096
|
+
export declare const DATUM_ARM_PX = 40;
|
|
3097
|
+
/** The rotation handle's radius at the end of the i axis, in screen pixels. */
|
|
3098
|
+
export declare const DATUM_HANDLE_PX = 5;
|
|
3099
|
+
/**
|
|
3100
|
+
* The ends of a datum's axes.
|
|
3101
|
+
*
|
|
3102
|
+
* @param d - The datum.
|
|
3103
|
+
* @param armLength - The i axis's length, in image pixels; the j axis is half of it. For a
|
|
3104
|
+
* screen-constant glyph pass `useScreenPx()(40)`.
|
|
3105
|
+
* @returns The end of the i axis and of the j axis, in image coordinates.
|
|
3106
|
+
*/
|
|
3107
|
+
export declare function datumAxes(d: Datum, armLength: number): {
|
|
3108
|
+
i: Point;
|
|
3109
|
+
j: Point;
|
|
3110
|
+
};
|
|
3111
|
+
/** How `moveDatum` places the origin. */
|
|
3112
|
+
interface MoveDatumOptions {
|
|
3113
|
+
/** Round the origin to a grid of this many image pixels; 0 or omitted for none. */
|
|
3114
|
+
grid?: number | undefined;
|
|
3115
|
+
/** Keep the origin inside this rectangle (edges included), on the last grid line inside it when there is a grid. */
|
|
3116
|
+
bounds?: Rect | undefined;
|
|
3117
|
+
}
|
|
3118
|
+
/**
|
|
3119
|
+
* Move a datum's origin to `to`, keeping its angle.
|
|
3120
|
+
*
|
|
3121
|
+
* @param d - The datum.
|
|
3122
|
+
* @param to - The new origin, in image coordinates.
|
|
3123
|
+
* @param options - A grid to round to, then bounds to stay inside.
|
|
3124
|
+
* @returns The moved datum.
|
|
3125
|
+
*/
|
|
3126
|
+
export declare function moveDatum(d: Datum, to: Point, options?: MoveDatumOptions): Datum;
|
|
3127
|
+
/**
|
|
3128
|
+
* Turn a datum about its origin so that its i axis points at `to`.
|
|
3129
|
+
*
|
|
3130
|
+
* @param d - The datum.
|
|
3131
|
+
* @param to - The pointer, in image coordinates. At the origin itself the angle is kept.
|
|
3132
|
+
* @param snap - Round the angle to a multiple of this many radians; 0 for none.
|
|
3133
|
+
* @returns The turned datum, its angle in `(-π, π]`.
|
|
3134
|
+
*/
|
|
3135
|
+
export declare function rotateDatum(d: Datum, to: Point, snap?: number): Datum;
|
|
3136
|
+
/** What `datumPress` reads besides the press. */
|
|
3137
|
+
interface DatumPressOptions {
|
|
3138
|
+
/** The i axis's length, in screen pixels. Defaults to 40. */
|
|
3139
|
+
armLength?: number | undefined;
|
|
3140
|
+
/** Whether the arm can be grabbed to turn the datum. Defaults to `true`. */
|
|
3141
|
+
rotatable?: boolean | undefined;
|
|
3142
|
+
}
|
|
3143
|
+
/**
|
|
3144
|
+
* What a press on a datum grabs, decided once for the whole glyph.
|
|
3145
|
+
*
|
|
3146
|
+
* The origin is its ring (7 screen px); the arm is the i axis from the ring out to its handle.
|
|
3147
|
+
* Each is within reach when the press is within `radius` screen pixels of it, and the nearer
|
|
3148
|
+
* one wins; a tie goes to the origin.
|
|
3149
|
+
*
|
|
3150
|
+
* @param d - The datum.
|
|
3151
|
+
* @param point - The press, in image coordinates.
|
|
3152
|
+
* @param scale - The view scale: screen pixels per image pixel.
|
|
3153
|
+
* @param radius - The pointer's tolerance in screen pixels: 12 for a touch, 6 for a mouse.
|
|
3154
|
+
* @param options - The arm's length, and whether it can be grabbed.
|
|
3155
|
+
* @returns `"origin"` (move), `"arm"` (turn), or `null`: the press belongs to whatever is below.
|
|
3156
|
+
*/
|
|
3157
|
+
export declare function datumPress(d: Datum, point: Point, scale: number, radius: number, options?: DatumPressOptions): "origin" | "arm" | null;
|
|
3158
|
+
//#endregion
|
|
3159
|
+
//#region src/components/DatumEditor.d.ts
|
|
3160
|
+
/** Props of `DatumEditor`. */
|
|
3161
|
+
interface DatumEditorProps {
|
|
3162
|
+
/** The datum, when the app controls it. `angle` is in radians, clockwise on screen from `+x`. */
|
|
3163
|
+
value?: Datum | undefined;
|
|
3164
|
+
/** The starting datum when the editor controls it. Defaults to the image's centre, pointing along `+x`. */
|
|
3165
|
+
defaultValue?: Datum | undefined;
|
|
3166
|
+
/** Called with the datum as it changes: on every move of a drag, and on each key press. */
|
|
3167
|
+
onValueChange?: ((value: Datum) => void) | undefined;
|
|
3168
|
+
/** Called once a gesture ends (a drag released, a key pressed): the moment to save or re-run. */
|
|
3169
|
+
onCommit?: ((value: Datum) => void) | undefined;
|
|
3170
|
+
/** Accept moves and turns, by pointer and keyboard. Defaults to `true`. */
|
|
3171
|
+
editable?: boolean | undefined;
|
|
3172
|
+
/** Show the rotation handle and accept `[` / `]`. Defaults to `true`; off for a datum that must keep its angle. */
|
|
3173
|
+
rotatable?: boolean | undefined;
|
|
3174
|
+
/** The step a turn rounds to, in radians: while Shift is held, or always with `snapAlways`. Defaults to π/12 (15°); 0 never rounds. */
|
|
3175
|
+
angleSnap?: number | undefined;
|
|
3176
|
+
/** Round every turn to `angleSnap`, not only while Shift is held. Defaults to `false`. */
|
|
3177
|
+
snapAlways?: boolean | undefined;
|
|
3178
|
+
/** Round the origin to a grid of this many image pixels as it moves. Defaults to 0: no grid. */
|
|
3179
|
+
originSnap?: number | undefined;
|
|
3180
|
+
/** The rectangle the origin stays inside, in image coordinates. Defaults to the image. */
|
|
3181
|
+
bounds?: Rect | undefined;
|
|
3182
|
+
/** The i axis's length in screen pixels; the j axis is half of it. Defaults to 40. */
|
|
3183
|
+
armLength?: number | undefined;
|
|
3184
|
+
/** The datum's accessible name. Defaults to "Datum". */
|
|
3185
|
+
label?: string | undefined;
|
|
3186
|
+
/** CSS colour of the glyph. Defaults to the overlay `model` role. */
|
|
3187
|
+
stroke?: string | undefined;
|
|
3188
|
+
/** Merged onto the `<svg>` with `cn`. */
|
|
3189
|
+
className?: string | undefined;
|
|
3190
|
+
}
|
|
3191
|
+
/**
|
|
3192
|
+
* An editable datum inside an `ImageStage`: a ring at the origin with its i axis (an arm ending
|
|
3193
|
+
* in a rotation handle) and its j axis (half as long, a quarter turn clockwise from i).
|
|
3194
|
+
*
|
|
3195
|
+
* - **Pointer.** Drag the ring to move the origin; drag the arm or its handle to turn the datum
|
|
3196
|
+
* about the origin. A press grabs whichever is nearer, and nothing happens until the pointer
|
|
3197
|
+
* has moved 3 px, so a click does not nudge it. Hold Shift to round the angle to `angleSnap`
|
|
3198
|
+
* (15°), or set `snapAlways`. `originSnap` rounds the origin to a grid; `bounds` keeps it in.
|
|
3199
|
+
* - **Keyboard.** The origin is a focusable button: arrow keys move it one image pixel (ten with
|
|
3200
|
+
* Shift; one grid step with `originSnap`), and `[` / `]` turn it by 1° (15° with Shift).
|
|
3201
|
+
* - **Rendering.** Every part is a constant size on screen at every zoom, over a halo.
|
|
3202
|
+
* - **Panning.** A press away from the glyph, or with the hand tool or space held, still pans.
|
|
3203
|
+
*
|
|
3204
|
+
* The SVG carries `data-editable`, and `data-dragging` (`origin` or `arm`) during a drag.
|
|
3205
|
+
*/
|
|
3206
|
+
export declare function DatumEditor({ value, defaultValue, onValueChange, onCommit, editable, rotatable, angleSnap, snapAlways, originSnap, bounds, armLength, label, stroke, className }: DatumEditorProps): import("react").JSX.Element;
|
|
3207
|
+
//#endregion
|
|
2596
3208
|
//#region src/components/DraftShape.d.ts
|
|
2597
3209
|
/**
|
|
2598
3210
|
* The shape being drawn.
|
|
@@ -2759,5 +3371,5 @@ interface MaskEditorProps {
|
|
|
2759
3371
|
*/
|
|
2760
3372
|
export declare function MaskEditor({ mask, onChange, onCommit, editable, brushRadius, mode, label, color }: MaskEditorProps): import("react").JSX.Element;
|
|
2761
3373
|
//#endregion
|
|
2762
|
-
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, StageViewChange, ValuePlane, ValueRange, View, ZoomPanCanvasProps };
|
|
3374
|
+
export type { ArcPrimitive, Area, AreaHit, AreaId, AreaIndex, AreaSetItem, AreaSetProps, Box, BuiltinMarkerKind, CaliperPrimitive, CirclePrimitive, ClampOptions, Colormap, CompareLayerProps, CompareMode, CompareOrientation, ContourEditorProps, Datum, DatumEditorProps, DatumPressOptions, DimensionGeometry, DimensionPrimitive, DraftShapeProps, DraftShapeSpec, Ellipse, EllipseHit, EllipseId, EllipseIndex, EllipseSetItem, EllipseSetProps, FitOptions, GridEdgeStyle, GridLayerProps, GridNode, HeatmapLayerBaseProps, HeatmapLayerProps, HeatmapPlaneProps, HeatmapRgbaProps, HitCandidate, HitId, ImageLayerBaseProps, ImageLayerProps, ImageStageProps, ImageTier, LatticeAxis, LatticeEdge, LatticeNode, MarkerShape, MarqueeRectProps, MaskEditorProps, MeasureOverlayProps, MeasurePrimitive, MoveDatumOptions, OverlayRole, OverlayState, Point, PointHit, PointId, PointIndex, PointIndexOptions, PointItem, PointPrimitive, PointSetItem, PointSetProps, Polyline, PolylineHit, PolylineId, PolylineIndex, PolylinePrimitive, PolylineSelectMode, PolylineSetHandle, PolylineSetItem, PolylineSetProps, PrimitiveCommon, Rect, RectRoiEditorHandle, RectRoiEditorProps, RoiHandle, RotatedShape, SegmentPrimitive, SegmentsPrimitive, ShapeDragHandlers, ShapeDragOptions, ShapeEditorProps, StageButtonProps, StageContext, StageDrag, StageHandle, StageHit, StageHitLayerOptions, StageHitOptions, StageHitTestApi, StageLayer, StageLayersMenuProps, StageMouseButton, StagePointerEvent, StagePress, StageReadoutProps, StageSurfaceProps, StageToolbarDividerProps, StageToolbarProps, StageView, StageViewChange, ValuePlane, ValueRange, View, ZoomPanCanvasProps };
|
|
2763
3375
|
//# sourceMappingURL=index.d.ts.map
|