@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/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
|
-
/**
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
/**
|
|
@@ -167,6 +203,11 @@ export declare function toScreen(view: StageView, p: Point): Point;
|
|
|
167
203
|
export declare function toImage(view: StageView, p: Point): Point;
|
|
168
204
|
/** Whether an image coordinate is inside the image, in the pixel-centre convention. */
|
|
169
205
|
export declare function insideImage(p: Point, image: Box): boolean;
|
|
206
|
+
/**
|
|
207
|
+
* An image coordinate held to the image's extent, `[-0.5, w - 0.5] x [-0.5, h - 0.5]` in the
|
|
208
|
+
* pixel-centre convention: the point on the frame's edge nearest to `p`.
|
|
209
|
+
*/
|
|
210
|
+
export declare function clampToImage(p: Point, image: Box): Point;
|
|
170
211
|
/** A length in image pixels that covers `css` screen pixels at this view. */
|
|
171
212
|
export declare function imageLengthFor(view: StageView, css: number): number;
|
|
172
213
|
/**
|
|
@@ -178,6 +219,15 @@ export declare function imageLengthFor(view: StageView, css: number): number;
|
|
|
178
219
|
export declare function zoomAbout(view: StageView, scale: number, anchor: Point): StageView;
|
|
179
220
|
/** The scale range `clampView` and `scaleRange` allow. */
|
|
180
221
|
interface ClampOptions {
|
|
222
|
+
/**
|
|
223
|
+
* How far the image may be panned. `"cover"` (the default): an axis the image overflows
|
|
224
|
+
* keeps the viewport covered, and an axis it does not fill is centred. `"center"`: any
|
|
225
|
+
* image point may be brought to the viewport's centre and no further, on both axes and at
|
|
226
|
+
* every scale — so a zoom about the pointer keeps the pointer's pixel under it while the
|
|
227
|
+
* image is still smaller than the viewport, and an edge or corner can be worked on in the
|
|
228
|
+
* middle of the screen.
|
|
229
|
+
*/
|
|
230
|
+
panBounds?: "cover" | "center" | undefined;
|
|
181
231
|
/** Lowest scale, as a multiple of fit. Defaults to `MIN_SCALE_VS_FIT`. */
|
|
182
232
|
minScaleVsFit?: number;
|
|
183
233
|
/** Highest scale, in CSS pixels per image pixel. Defaults to `MAX_SCALE`. */
|
|
@@ -188,10 +238,11 @@ export declare function scaleRange(box: Box, image: Box, options?: ClampOptions)
|
|
|
188
238
|
/**
|
|
189
239
|
* Keep the view legal: scale inside its range, and the image never dragged off screen.
|
|
190
240
|
*
|
|
191
|
-
*
|
|
192
|
-
* where a drag put it — free-floating pixels in a grey
|
|
193
|
-
* visible handle to get back
|
|
194
|
-
* covered.
|
|
241
|
+
* With the default `panBounds: "cover"`, an axis where the scaled image is smaller than the
|
|
242
|
+
* viewport is centred rather than left where a drag put it — free-floating pixels in a grey
|
|
243
|
+
* field is a way to be lost with no visible handle to get back — and an axis where it is
|
|
244
|
+
* larger is held so the viewport stays covered. With `"center"`, each axis only keeps some
|
|
245
|
+
* image point at or past the viewport's centre.
|
|
195
246
|
*/
|
|
196
247
|
export declare function clampView(view: StageView, box: Box, image: Box, options?: ClampOptions): StageView;
|
|
197
248
|
/**
|
|
@@ -210,7 +261,7 @@ export declare function frameRect(box: Box, image: Box, rect: Rect, pad?: number
|
|
|
210
261
|
* that was *fit* re-fits instead, because fit is a relationship to the viewport rather than
|
|
211
262
|
* a particular pair of numbers.
|
|
212
263
|
*/
|
|
213
|
-
export declare function preserveCenter(view: StageView, from: Box, to: Box, image: Box, options?: ClampOptions): StageView;
|
|
264
|
+
export declare function preserveCenter(view: StageView, from: Box, to: Box, image: Box, options?: ClampOptions, fit?: FitOptions): StageView;
|
|
214
265
|
/**
|
|
215
266
|
* The next scale up or down the ladder from `scale`, so the readout lands on a round
|
|
216
267
|
* percentage rather than wherever a multiplier happened to leave it.
|
|
@@ -224,6 +275,20 @@ export declare function formatScale(scale: number): string;
|
|
|
224
275
|
type StageMouseButton = "left" | "middle" | "right";
|
|
225
276
|
//#endregion
|
|
226
277
|
//#region src/components/stage/ImageStage.d.ts
|
|
278
|
+
/** Why a view was reported through `ImageStage`'s `onView`. */
|
|
279
|
+
interface StageViewChange {
|
|
280
|
+
/**
|
|
281
|
+
* What moved the view:
|
|
282
|
+
* - `"gesture"`: a wheel zoom, a drag or touch pan, a pinch, a double-click.
|
|
283
|
+
* - `"key"`: a keyboard shortcut or pan key.
|
|
284
|
+
* - `"command"`: a call to the handle or the context (`fit`, `zoomTo`, `frame`, `setView`),
|
|
285
|
+
* which includes the toolbar's buttons.
|
|
286
|
+
* - `"measure"`: the opening view, and a resize re-anchoring the view.
|
|
287
|
+
*/
|
|
288
|
+
cause: "gesture" | "key" | "command" | "measure";
|
|
289
|
+
/** The measured viewport, in CSS pixels, at the moment of the change. */
|
|
290
|
+
box: Box;
|
|
291
|
+
}
|
|
227
292
|
/** What `useStage` returns: the transform of the enclosing `ImageStage`, and its controls. */
|
|
228
293
|
interface StageContext {
|
|
229
294
|
/** The view in effect — the controlled `view`, or the opening view while that is `null`. */
|
|
@@ -290,8 +355,13 @@ interface ImageStageProps {
|
|
|
290
355
|
* view is kept on first measure, only clamped to the legal range.
|
|
291
356
|
*/
|
|
292
357
|
view: StageView | null;
|
|
293
|
-
/**
|
|
294
|
-
|
|
358
|
+
/**
|
|
359
|
+
* Called with every view change: gestures, keys, toolbar, and viewport resizes. The second
|
|
360
|
+
* argument says why and carries the measured viewport; a one-argument callback ignores it.
|
|
361
|
+
* A `null` `view` that the stage has already measured is re-opened and reported again, with
|
|
362
|
+
* cause `"measure"`.
|
|
363
|
+
*/
|
|
364
|
+
onView: (view: StageView, change: StageViewChange) => void;
|
|
295
365
|
/** Layers, each `absolute inset-0` and sized by the stage. */
|
|
296
366
|
children: ReactNode;
|
|
297
367
|
/** Rendered floating over the bottom-left, outside the transform. */
|
|
@@ -328,8 +398,11 @@ interface ImageStageProps {
|
|
|
328
398
|
style?: CSSProperties;
|
|
329
399
|
/** Where the pointer is over the image, in image pixels, or `null` when it is outside. */
|
|
330
400
|
onHover?: (point: Point | null) => void;
|
|
331
|
-
/**
|
|
332
|
-
|
|
401
|
+
/**
|
|
402
|
+
* A press on the background that was not a pan — how a layer hears "deselect". `point` is
|
|
403
|
+
* where it landed, in image coordinates (the pixel-centre convention, unclamped).
|
|
404
|
+
*/
|
|
405
|
+
onBackgroundClick?: (event: PointerEvent$1<HTMLDivElement>, point: Point) => void;
|
|
333
406
|
/** The legal scale range; see `clampView`. */
|
|
334
407
|
clamp?: ClampOptions;
|
|
335
408
|
/** Keyboard zoom/pan shortcuts. On by default; the stage takes focus to receive them. */
|
|
@@ -344,10 +417,17 @@ interface ImageStageProps {
|
|
|
344
417
|
label?: string;
|
|
345
418
|
/**
|
|
346
419
|
* 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
|
|
420
|
+
* (inside the `fit` margin) and fit otherwise; `"fit"` always fit, for a viewer that should show the whole frame
|
|
348
421
|
* whatever its size.
|
|
349
422
|
*/
|
|
350
423
|
initialView?: "auto" | "fit" | undefined;
|
|
424
|
+
/**
|
|
425
|
+
* The margin and upscale cap of every fit: `initialView="fit"`, the handle's and the
|
|
426
|
+
* context's `fit()`, the `0` key, the double-click toggle, the toolbar's Fit button, and
|
|
427
|
+
* `isFit` / `data-fit`. Defaults to filling the viewport edge to edge, upscaling freely.
|
|
428
|
+
* Each field is read by value, so an inline object does not re-fit the view.
|
|
429
|
+
*/
|
|
430
|
+
fit?: FitOptions | undefined;
|
|
351
431
|
/** The stage's controls for code outside it; see `StageHandle`. */
|
|
352
432
|
ref?: Ref<StageHandle> | undefined;
|
|
353
433
|
}
|
|
@@ -356,11 +436,15 @@ interface ImageStageProps {
|
|
|
356
436
|
* size, so an overlay drawn in image coordinates stays registered with the photograph at
|
|
357
437
|
* any zoom and window size. Layers read the transform through `useStage`.
|
|
358
438
|
*
|
|
439
|
+
* The transformed box (`[data-stage]`) carries `will-change: transform` and `data-moving` while
|
|
440
|
+
* the view changes and for 150 ms after, so a pan stays on the compositor and the layer
|
|
441
|
+
* re-rasterises sharp once the view settles.
|
|
442
|
+
*
|
|
359
443
|
* State is exposed on the viewport as `data-fit` (the view is fit), `data-panning` (a drag
|
|
360
444
|
* is in progress) and `data-pan-mode` (the hand tool is on or space is held), each present
|
|
361
445
|
* or absent.
|
|
362
446
|
*/
|
|
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;
|
|
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;
|
|
364
448
|
//#endregion
|
|
365
449
|
//#region src/components/stage/hitTest.d.ts
|
|
366
450
|
/** What a layer is picked as, and so how it ranks against the layers around it. */
|
|
@@ -526,6 +610,13 @@ interface StageDrag {
|
|
|
526
610
|
onEnd?: ((point: Point, event: PointerEvent, moved: boolean) => void) | undefined;
|
|
527
611
|
/** The drag was interrupted (`pointercancel`) or the component unmounted mid-drag. */
|
|
528
612
|
onCancel?: (() => void) | undefined;
|
|
613
|
+
/**
|
|
614
|
+
* Claim a touch that starts this gesture, as a mouse press is claimed: the stage neither
|
|
615
|
+
* pans nor pinches from it. Without it a touch is only watched (see `StageSurface`), so
|
|
616
|
+
* return `true` for a gesture a finger must own, such as moving a selected shape. Ignored for
|
|
617
|
+
* a mouse or pen.
|
|
618
|
+
*/
|
|
619
|
+
claimsTouch?: boolean | undefined;
|
|
529
620
|
}
|
|
530
621
|
/**
|
|
531
622
|
* Start a drag from a press on any element inside an `ImageStage`.
|
|
@@ -541,6 +632,12 @@ export declare function useStageDrag(): (event: PointerEvent$1<Element>, drag: S
|
|
|
541
632
|
interface StagePress {
|
|
542
633
|
/** Where, in image coordinates. */
|
|
543
634
|
point: Point;
|
|
635
|
+
/** Where, in client coordinates, for anchoring a tooltip or a menu. */
|
|
636
|
+
client: Point;
|
|
637
|
+
/** The press is a touch: act on its release (see `StageSurface`), and expect a fingertip's tolerance. */
|
|
638
|
+
touch: boolean;
|
|
639
|
+
/** The hit-test tolerance for this pointer, in screen pixels: 12 for a touch, 6 otherwise. Pass it to `useStageHitTest`. */
|
|
640
|
+
radius: number;
|
|
544
641
|
/** Shift was held. */
|
|
545
642
|
shiftKey: boolean;
|
|
546
643
|
/** Alt / Option was held. */
|
|
@@ -553,22 +650,54 @@ interface StageSurfaceProps {
|
|
|
553
650
|
/**
|
|
554
651
|
* What a press means. Return a `StageDrag` to claim it (a click is a drag that never
|
|
555
652
|
* moved), or nothing to decline it: a declined press reaches the stage, which pans.
|
|
653
|
+
*
|
|
654
|
+
* **For a touch, act in `onEnd` when `moved` is `false` (a tap), not here.** The press may
|
|
655
|
+
* become a pan or the first finger of a pinch, so nothing should happen until the finger
|
|
656
|
+
* lifts. Return `claimsTouch: true` for a gesture the finger must own.
|
|
556
657
|
*/
|
|
557
658
|
onPress: (press: StagePress) => StageDrag | null | undefined | void;
|
|
558
659
|
/** The cursor over the image while no drag is in flight, e.g. `crosshair` for a draw tool. */
|
|
559
660
|
cursor?: string | undefined;
|
|
560
|
-
/** Where the
|
|
661
|
+
/** Where the mouse is over the image while no drag is in flight, for hover feedback. Not called for a touch. */
|
|
561
662
|
onHover?: ((point: Point) => void) | undefined;
|
|
663
|
+
/**
|
|
664
|
+
* A double click or double tap on the surface. When given, the surface handles it and the
|
|
665
|
+
* stage's double-click-to-fit does not run; leave it out to keep the fit.
|
|
666
|
+
*/
|
|
667
|
+
onDoubleClick?: ((point: Point) => void) | undefined;
|
|
668
|
+
/**
|
|
669
|
+
* How far the surface reaches. `"image"` (the default) is the image rectangle: a press in
|
|
670
|
+
* the margin around the image goes to the stage, which pans. `"viewport"` covers everything
|
|
671
|
+
* visible, margin included, so a drawing tool can place a point on the image's border by
|
|
672
|
+
* pressing just outside it; every point the surface then reports (the press, a drag's moves
|
|
673
|
+
* and release, hover, double-click) is clamped to the image's extent, `[-0.5, w - 0.5]` by
|
|
674
|
+
* `[-0.5, h - 0.5]`. `StagePress.client` stays the raw pointer position.
|
|
675
|
+
*/
|
|
676
|
+
extent?: "image" | "viewport" | undefined;
|
|
562
677
|
}
|
|
563
678
|
/**
|
|
564
679
|
* The stage's one full-frame press target. Put it inside an `ImageStage`, below the layers
|
|
565
680
|
* that have their own small targets (handles, strokes). Each press is offered to `onPress`
|
|
566
681
|
* unless the hand tool or a held space bar make it a pan; a declined press pans.
|
|
567
682
|
*
|
|
568
|
-
*
|
|
569
|
-
*
|
|
683
|
+
* **Mouse and pen.** Only the left button comes here. The press is claimed and followed on
|
|
684
|
+
* `window`, so the stage does not pan from it.
|
|
685
|
+
*
|
|
686
|
+
* **Touch.** A touch is only *watched* unless its `StageDrag` sets `claimsTouch`: the surface
|
|
687
|
+
* neither stops the press nor captures the pointer, so the stage still pans (one-finger mode)
|
|
688
|
+
* and a second finger still pinches. The drag then sees:
|
|
689
|
+
* - `onMove`, only once the finger has left the tap slop;
|
|
690
|
+
* - `onEnd(point, event, moved)` on release, with `moved` `false` for a tap;
|
|
691
|
+
* - `onCancel` on `pointercancel`, or when a second finger lands (a pinch).
|
|
692
|
+
*
|
|
693
|
+
* A touch gesture that sets `claimsTouch: true` is claimed like a mouse press.
|
|
694
|
+
*
|
|
695
|
+
* With `extent="viewport"` the surface also takes presses in the margin around the image, and
|
|
696
|
+
* clamps every reported point to the image.
|
|
697
|
+
*
|
|
698
|
+
* The surface draws nothing. It carries `data-dragging` while a gesture it started is in flight.
|
|
570
699
|
*/
|
|
571
|
-
export declare function StageSurface({ onPress, cursor, onHover }: StageSurfaceProps): import("react").JSX.Element;
|
|
700
|
+
export declare function StageSurface({ onPress, cursor, onHover, onDoubleClick, extent }: StageSurfaceProps): import("react").JSX.Element;
|
|
572
701
|
//#endregion
|
|
573
702
|
//#region src/components/stage/StageToolbar.d.ts
|
|
574
703
|
/** Props of `StageToolbar`. */
|
|
@@ -1104,11 +1233,18 @@ interface ContourEditorProps {
|
|
|
1104
1233
|
label?: string;
|
|
1105
1234
|
/** CSS stroke color. */
|
|
1106
1235
|
stroke?: string;
|
|
1236
|
+
/**
|
|
1237
|
+
* The area, in image coordinates, every vertex is kept inside: a drag, a keyboard nudge and
|
|
1238
|
+
* an inserted vertex are clamped to it. Defaults to the pixel centres,
|
|
1239
|
+
* `{ x: 0, y: 0, width: w - 1, height: h - 1 }`. Pass `{ x: -0.5, y: -0.5, width: w, height: h }`
|
|
1240
|
+
* for polygons in the area convention, which may lie exactly on the image border.
|
|
1241
|
+
*/
|
|
1242
|
+
bounds?: Rect | undefined;
|
|
1107
1243
|
}
|
|
1108
1244
|
/** Return the index of the closest segment, with the last vertex joined to the first. */
|
|
1109
1245
|
export declare function nearestContourSegment(points: Point[], point: Point): number;
|
|
1110
1246
|
/** Edit contour vertices over an ImageStage using its shared source-image transform. */
|
|
1111
|
-
export declare function ContourEditor({ points, onChange, onCommit, editable, label, stroke }: ContourEditorProps): import("react").JSX.Element;
|
|
1247
|
+
export declare function ContourEditor({ points, onChange, onCommit, editable, label, stroke, bounds }: ContourEditorProps): import("react").JSX.Element;
|
|
1112
1248
|
//#endregion
|
|
1113
1249
|
//#region src/components/RectRoiEditor.d.ts
|
|
1114
1250
|
/** Props of `RectRoiEditor`. */
|
|
@@ -1127,8 +1263,9 @@ interface RectRoiEditorProps {
|
|
|
1127
1263
|
*/
|
|
1128
1264
|
draw?: boolean | undefined;
|
|
1129
1265
|
/**
|
|
1130
|
-
* The area the region must stay in
|
|
1131
|
-
*
|
|
1266
|
+
* The area the region must stay in, in the stage's centre convention. Defaults to
|
|
1267
|
+
* `{ x: -0.5, y: -0.5, width, height }` of the image: its full extent, so a region that
|
|
1268
|
+
* fills it outlines the image edges.
|
|
1132
1269
|
*/
|
|
1133
1270
|
bounds?: Rect | undefined;
|
|
1134
1271
|
/** The smallest side, in image pixels; a smaller drawn box is a click, not a region. Defaults to 4. */
|
|
@@ -1290,6 +1427,17 @@ interface PolylineSetProps {
|
|
|
1290
1427
|
* and to the layers below.
|
|
1291
1428
|
*/
|
|
1292
1429
|
marquee?: boolean | undefined;
|
|
1430
|
+
/**
|
|
1431
|
+
* Whether the layer takes presses and hover. Defaults to `true` when any of `onItemPress`,
|
|
1432
|
+
* `onSelect`, `onHover`, `onHoverChange` or `marquee` is given. When `false` the layer
|
|
1433
|
+
* renders no press target at all: a press on a line falls through to whatever is below (a
|
|
1434
|
+
* draw tool's `StageSurface`, say), while `useStageHitTest` still finds the lines. Set it
|
|
1435
|
+
* `false` while a tool other than selection is active.
|
|
1436
|
+
*
|
|
1437
|
+
* A touch on an interactive layer is not claimed: the stage still pans and pinches, and the
|
|
1438
|
+
* line is selected when the finger lifts after a tap.
|
|
1439
|
+
*/
|
|
1440
|
+
interactive?: boolean | undefined;
|
|
1293
1441
|
/** CSS colour of the lines. Defaults to the overlay `feature` role: they are detected lines. */
|
|
1294
1442
|
stroke?: string | undefined;
|
|
1295
1443
|
/** CSS colour of a selected line. Defaults to the overlay `selection` role. */
|
|
@@ -1316,10 +1464,12 @@ interface PolylineSetProps {
|
|
|
1316
1464
|
* - **Halo.** Every line has a halo, so it holds on any image.
|
|
1317
1465
|
* - **Points.** Above `vertexScale`, the points of the hovered and selected lines are drawn.
|
|
1318
1466
|
* - **Panning.** The hand tool and a held space bar still pan.
|
|
1467
|
+
* - **Tools.** Without a handler (or with `interactive={false}`) the layer takes no presses
|
|
1468
|
+
* and only answers `useStageHitTest`, so a draw tool's surface below receives them.
|
|
1319
1469
|
*
|
|
1320
1470
|
* The SVG carries `data-hovered` (the hovered id) and `data-sweeping` while a band is drawn.
|
|
1321
1471
|
*/
|
|
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;
|
|
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;
|
|
1323
1473
|
//#endregion
|
|
1324
1474
|
//#region src/components/markerShapes.d.ts
|
|
1325
1475
|
/** One kind of marker. */
|
|
@@ -1342,9 +1492,11 @@ interface MarkerShape {
|
|
|
1342
1492
|
* @param y - Centre y, in image coordinates.
|
|
1343
1493
|
* @param unit - Image pixels per screen pixel.
|
|
1344
1494
|
* @param angle - The item's orientation in radians, `0` when it has none.
|
|
1495
|
+
* @param angle2 - The item's second angle in radians, `undefined` when it has none. Most
|
|
1496
|
+
* shapes ignore it; a glyph with two axes (a corner's two edge directions) reads it.
|
|
1345
1497
|
* @returns Path commands, absolute at the start (`M x y …`) and self-contained.
|
|
1346
1498
|
*/
|
|
1347
|
-
path: (x: number, y: number, unit: number, angle: number) => string;
|
|
1499
|
+
path: (x: number, y: number, unit: number, angle: number, angle2?: number) => string;
|
|
1348
1500
|
}
|
|
1349
1501
|
/**
|
|
1350
1502
|
* A circle as two arcs, centred at `(x, y)`.
|
|
@@ -1495,8 +1647,15 @@ interface PointSetItem extends PointItem {
|
|
|
1495
1647
|
kind?: string | undefined;
|
|
1496
1648
|
/** The overlay role it is painted in. Defaults to the marker kind's role, usually `feature`. */
|
|
1497
1649
|
role?: OverlayRole | undefined;
|
|
1650
|
+
/**
|
|
1651
|
+
* CSS colour of its mark (`#hex`, `var(--x)`, `color-mix(…)`; used as given). Overrides the
|
|
1652
|
+
* role; selection still paints in `selectionStroke`. Points sharing a colour share a batch.
|
|
1653
|
+
*/
|
|
1654
|
+
color?: string | undefined;
|
|
1498
1655
|
/** Its orientation in radians, clockwise from +x; read by `directed`. */
|
|
1499
1656
|
angle?: number | undefined;
|
|
1657
|
+
/** A second angle in radians, for a glyph with two axes. `MarkerShape.path` gets `undefined` without it. */
|
|
1658
|
+
angle2?: number | undefined;
|
|
1500
1659
|
/** Text drawn beside it, when the zoom leaves room (points at least 24 screen px apart). */
|
|
1501
1660
|
label?: string | undefined;
|
|
1502
1661
|
}
|
|
@@ -1676,6 +1835,13 @@ interface AreaSetItem extends Area {
|
|
|
1676
1835
|
role?: OverlayRole | undefined;
|
|
1677
1836
|
/** Text drawn at its centre (the mean of its vertices), when the zoom leaves room. */
|
|
1678
1837
|
label?: string | undefined;
|
|
1838
|
+
/**
|
|
1839
|
+
* CSS colour of its outline (`#hex`, `var(--x)`, `color-mix(…)`; used as given). Overrides
|
|
1840
|
+
* the role and the layer's `stroke`. Items sharing a colour share a batch.
|
|
1841
|
+
*/
|
|
1842
|
+
stroke?: string | undefined;
|
|
1843
|
+
/** CSS colour of its fill. Defaults to its outline colour. */
|
|
1844
|
+
fill?: string | undefined;
|
|
1679
1845
|
}
|
|
1680
1846
|
/** Props of `AreaSet`. */
|
|
1681
1847
|
interface AreaSetProps {
|
|
@@ -1710,6 +1876,30 @@ interface AreaSetProps {
|
|
|
1710
1876
|
* of a marker quad reads (the overlay grammar's "corner 0 ticked"). Off by default.
|
|
1711
1877
|
*/
|
|
1712
1878
|
firstVertexTick?: boolean | undefined;
|
|
1879
|
+
/** CSS colour of every outline that names none of its own, in place of its role's. */
|
|
1880
|
+
stroke?: string | undefined;
|
|
1881
|
+
/** The fill's alpha, 0 to 1. Defaults to 0.12. */
|
|
1882
|
+
fillOpacity?: number | undefined;
|
|
1883
|
+
/**
|
|
1884
|
+
* How a self-overlapping ring is filled. `"nonzero"` (the default) fills everything a ring
|
|
1885
|
+
* encloses; `"evenodd"` leaves the doubly-wound part of a self-intersecting ring open, as
|
|
1886
|
+
* a rasteriser would. With `"evenodd"` every region's fill is its own path (even-odd across
|
|
1887
|
+
* a batched path would cut a hole where two regions overlap); outlines stay batched.
|
|
1888
|
+
*/
|
|
1889
|
+
fillRule?: "nonzero" | "evenodd" | undefined;
|
|
1890
|
+
/**
|
|
1891
|
+
* The paint order. `"appearance"` (the default) draws one batch per appearance, in order of
|
|
1892
|
+
* first appearance. `"items"` draws consecutive runs in item order, so a later region
|
|
1893
|
+
* covers an earlier one of another appearance (a subtract region over an add region); more
|
|
1894
|
+
* runs mean more paths, so use it when the order matters.
|
|
1895
|
+
*/
|
|
1896
|
+
paintOrder?: "appearance" | "items" | undefined;
|
|
1897
|
+
/**
|
|
1898
|
+
* What a selected region looks like. `"selection"` (the default) paints it in the
|
|
1899
|
+
* selection colour, fill and outline. `"item"` keeps its own fill (and its place in the
|
|
1900
|
+
* paint order) and restyles only the outline.
|
|
1901
|
+
*/
|
|
1902
|
+
selectionFill?: "selection" | "item" | undefined;
|
|
1713
1903
|
/** Draw the dark band under every outline. On by default; off for a fast, flat layer. */
|
|
1714
1904
|
halo?: boolean | undefined;
|
|
1715
1905
|
/** CSS colour of selected regions. Defaults to the overlay `selection` role. */
|
|
@@ -1724,7 +1914,8 @@ interface AreaSetProps {
|
|
|
1724
1914
|
/**
|
|
1725
1915
|
* A selectable set of closed regions inside an `ImageStage`.
|
|
1726
1916
|
*
|
|
1727
|
-
* - **Rendering**: an outline and its 12 % fill, in the item's role (`feature` by default)
|
|
1917
|
+
* - **Rendering**: an outline and its 12 % fill, in the item's role (`feature` by default) or its own
|
|
1918
|
+
* `stroke` / `fill` colours (`fillOpacity`, `fillRule`, `paintOrder` and `selectionFill` tune the fill).
|
|
1728
1919
|
* Rings are wound alike before they are batched, so overlapping regions never cut a hole in
|
|
1729
1920
|
* each other.
|
|
1730
1921
|
* - **States**, from visual-language §5: default 1.5 screen px (1 for `model` and
|
|
@@ -1738,7 +1929,181 @@ interface AreaSetProps {
|
|
|
1738
1929
|
*
|
|
1739
1930
|
* The SVG carries `data-hovered` (the hovered id).
|
|
1740
1931
|
*/
|
|
1741
|
-
export declare function AreaSet({ items, role, hoveredId, onHoverChange, selectedIds, dimmed, onItemPress, labels, firstVertexTick, halo, selectionStroke, layerId, priority, label }: AreaSetProps): import("react").JSX.Element;
|
|
1932
|
+
export declare function AreaSet({ items, role, hoveredId, onHoverChange, selectedIds, dimmed, onItemPress, labels, firstVertexTick, stroke, fillOpacity, fillRule, paintOrder, selectionFill, halo, selectionStroke, layerId, priority, label }: AreaSetProps): import("react").JSX.Element;
|
|
1933
|
+
//#endregion
|
|
1934
|
+
//#region src/components/ellipseIndex.d.ts
|
|
1935
|
+
/** An ellipse's identity. */
|
|
1936
|
+
type EllipseId = string | number;
|
|
1937
|
+
/** One ellipse. */
|
|
1938
|
+
interface Ellipse {
|
|
1939
|
+
/** Its identity, unique in the set. */
|
|
1940
|
+
id: EllipseId;
|
|
1941
|
+
/** Centre x, image pixels. */
|
|
1942
|
+
x: number;
|
|
1943
|
+
/** Centre y, image pixels. */
|
|
1944
|
+
y: number;
|
|
1945
|
+
/** Semi-axis along the rotated x axis, image pixels. */
|
|
1946
|
+
rx: number;
|
|
1947
|
+
/** Semi-axis along the rotated y axis, image pixels. */
|
|
1948
|
+
ry: number;
|
|
1949
|
+
/** Rotation of the `rx` axis, radians clockwise on screen (y points down). Defaults to 0. */
|
|
1950
|
+
angle?: number | undefined;
|
|
1951
|
+
}
|
|
1952
|
+
/**
|
|
1953
|
+
* An index built by `buildEllipseIndex`. Treat it as opaque and query it with `nearestEllipse`
|
|
1954
|
+
* and `ellipsesInRect`; its layout may change.
|
|
1955
|
+
*/
|
|
1956
|
+
interface EllipseIndex {
|
|
1957
|
+
/** The ellipses, in the order given. */
|
|
1958
|
+
readonly items: readonly Ellipse[];
|
|
1959
|
+
/** The grid over their bounding boxes (an `AreaIndex` of boxes, one per ellipse). */
|
|
1960
|
+
readonly grid: AreaIndex;
|
|
1961
|
+
/** Per ellipse, its area `π·rx·ry`, used to prefer the smaller of nested ellipses; `NaN` for a degenerate one. */
|
|
1962
|
+
readonly size: Float64Array;
|
|
1963
|
+
}
|
|
1964
|
+
/** The ellipse `nearestEllipse` picked. */
|
|
1965
|
+
interface EllipseHit {
|
|
1966
|
+
/** Its id. */
|
|
1967
|
+
id: EllipseId;
|
|
1968
|
+
/** Its position in the array the index was built from. */
|
|
1969
|
+
index: number;
|
|
1970
|
+
/** Whether the query is inside the ellipse. */
|
|
1971
|
+
inside: boolean;
|
|
1972
|
+
/** The distance from the query to the ellipse's outline, in image pixels (also when inside). */
|
|
1973
|
+
distance: number;
|
|
1974
|
+
}
|
|
1975
|
+
/**
|
|
1976
|
+
* The axis-aligned bounding box of an ellipse.
|
|
1977
|
+
*
|
|
1978
|
+
* @param e - The ellipse.
|
|
1979
|
+
* @returns `[minX, minY, maxX, maxY]`, or `null` for a degenerate ellipse.
|
|
1980
|
+
*/
|
|
1981
|
+
export declare function ellipseBounds(e: Ellipse): [number, number, number, number] | null;
|
|
1982
|
+
/**
|
|
1983
|
+
* Whether `(x, y)` is inside the ellipse (its outline counts as inside).
|
|
1984
|
+
*
|
|
1985
|
+
* @param e - The ellipse.
|
|
1986
|
+
* @param x - The query's x.
|
|
1987
|
+
* @param y - The query's y.
|
|
1988
|
+
* @returns `false` for a degenerate ellipse.
|
|
1989
|
+
*/
|
|
1990
|
+
export declare function pointInEllipse(e: Ellipse, x: number, y: number): boolean;
|
|
1991
|
+
/**
|
|
1992
|
+
* An ellipse as an SVG path: two arcs, exactly, so it stays round at any zoom.
|
|
1993
|
+
*
|
|
1994
|
+
* @param cx - Centre x, image pixels.
|
|
1995
|
+
* @param cy - Centre y, image pixels.
|
|
1996
|
+
* @param rx - Semi-axis along the rotated x axis, image pixels.
|
|
1997
|
+
* @param ry - Semi-axis along the rotated y axis, image pixels.
|
|
1998
|
+
* @param angle - Rotation of the `rx` axis, radians clockwise on screen.
|
|
1999
|
+
* @returns Path data, or `""` for a degenerate ellipse (a non-finite value, or a radius not above zero).
|
|
2000
|
+
*/
|
|
2001
|
+
export declare function ellipsePath(cx: number, cy: number, rx: number, ry: number, angle?: number): string;
|
|
2002
|
+
/**
|
|
2003
|
+
* Index a set of ellipses.
|
|
2004
|
+
*
|
|
2005
|
+
* @param items - The ellipses.
|
|
2006
|
+
* @param cell - The grid cell side in image pixels; see `buildAreaIndex` for the default.
|
|
2007
|
+
* @returns The index.
|
|
2008
|
+
*/
|
|
2009
|
+
export declare function buildEllipseIndex(items: readonly Ellipse[], cell?: number): EllipseIndex;
|
|
2010
|
+
/**
|
|
2011
|
+
* The ellipse under a point: one whose outline passes within `radius`, or else one that
|
|
2012
|
+
* contains it.
|
|
2013
|
+
*
|
|
2014
|
+
* An outline is the more precise gesture, so it wins: among ellipses whose outline is within
|
|
2015
|
+
* `radius` the nearest is picked, and only without one the containing ellipse. Ties (equal
|
|
2016
|
+
* distance, or several containing ellipses) go to the smaller ellipse, so a ring drawn inside
|
|
2017
|
+
* another is picked rather than the outer one, then to the earlier one.
|
|
2018
|
+
*
|
|
2019
|
+
* @param index - The index.
|
|
2020
|
+
* @param p - The query, in image coordinates.
|
|
2021
|
+
* @param radius - How far from an outline the query still picks it, in image pixels.
|
|
2022
|
+
* @returns The ellipse, or `null`.
|
|
2023
|
+
*/
|
|
2024
|
+
export declare function nearestEllipse(index: EllipseIndex, p: Point, radius: number): EllipseHit | null;
|
|
2025
|
+
/**
|
|
2026
|
+
* The ellipses any part of which is inside `rect`: the rectangle meets the outline, or lies
|
|
2027
|
+
* inside the ellipse, or contains it.
|
|
2028
|
+
*
|
|
2029
|
+
* @param index - The index.
|
|
2030
|
+
* @param rect - The band, in image coordinates. A negative extent is read as the box between
|
|
2031
|
+
* its corners.
|
|
2032
|
+
* @returns Their ids, in the order the ellipses were given.
|
|
2033
|
+
*/
|
|
2034
|
+
export declare function ellipsesInRect(index: EllipseIndex, rect: Rect): EllipseId[];
|
|
2035
|
+
//#endregion
|
|
2036
|
+
//#region src/components/EllipseSet.d.ts
|
|
2037
|
+
/** One ellipse of an `EllipseSet`. */
|
|
2038
|
+
interface EllipseSetItem extends Ellipse {
|
|
2039
|
+
/** The overlay role it is painted in. Defaults to the layer's `role`. */
|
|
2040
|
+
role?: OverlayRole | undefined;
|
|
2041
|
+
/** Draw it dashed (4 3 screen px), so two kinds differ by more than colour. */
|
|
2042
|
+
dashed?: boolean | undefined;
|
|
2043
|
+
/** Opacity in [0, 1], rounded to a tenth so ellipses still share paths. Defaults to 1. */
|
|
2044
|
+
opacity?: number | undefined;
|
|
2045
|
+
}
|
|
2046
|
+
/** Props of `EllipseSet`. */
|
|
2047
|
+
interface EllipseSetProps {
|
|
2048
|
+
/** The ellipses, in image coordinates. */
|
|
2049
|
+
items: readonly EllipseSetItem[];
|
|
2050
|
+
/** The role of an item that names none. Defaults to `"feature"`. */
|
|
2051
|
+
role?: OverlayRole | undefined;
|
|
2052
|
+
/** The hovered id, when the app controls hover: its ellipses are drawn at 2 px. */
|
|
2053
|
+
hoveredId?: EllipseId | null | undefined;
|
|
2054
|
+
/** Called when the ellipse under the pointer changes. `null` when it leaves every ellipse. Not called when `pickable` is off. */
|
|
2055
|
+
onHoverChange?: ((id: EllipseId | null) => void) | undefined;
|
|
2056
|
+
/** The selected ids, drawn at 2.5 px in the selection colour. */
|
|
2057
|
+
selectedIds?: Iterable<EllipseId> | undefined;
|
|
2058
|
+
/** Ids drawn at 35 % opacity, as a set or a predicate. Pass a stable value: a new one re-batches the layer. */
|
|
2059
|
+
dimmed?: Iterable<EllipseId> | ((id: EllipseId) => boolean) | undefined;
|
|
2060
|
+
/**
|
|
2061
|
+
* A press landed on an ellipse. Setting it makes the layer claim presses on its ellipses,
|
|
2062
|
+
* so the stage does not pan from them. The event is the `pointerdown` (the `pointerup` for
|
|
2063
|
+
* a touch tap), so `useShapeDrag` can start a drag from it.
|
|
2064
|
+
*
|
|
2065
|
+
* A mounted `StageSurface` hears a press first; there, ask `useStageHitTest` what is
|
|
2066
|
+
* under it instead.
|
|
2067
|
+
*/
|
|
2068
|
+
onItemPress?: ((id: EllipseId, event: StagePointerEvent) => void) | undefined;
|
|
2069
|
+
/**
|
|
2070
|
+
* Whether the layer takes part in the stage's hit-test. On by default. Turn it off for a
|
|
2071
|
+
* decorative layer (the ring outlines under a `PointSet` of centres), so it neither
|
|
2072
|
+
* hovers, nor claims presses, nor answers `useStageHitTest`.
|
|
2073
|
+
*/
|
|
2074
|
+
pickable?: boolean | undefined;
|
|
2075
|
+
/** The id hit-tests report for this layer. Defaults to a generated one. */
|
|
2076
|
+
layerId?: string | undefined;
|
|
2077
|
+
/** Rank against other layers in hit-tests. Defaults to `STAGE_HIT_PRIORITY.area`. */
|
|
2078
|
+
priority?: number | undefined;
|
|
2079
|
+
/** Draw the dark band under every stroke. On by default. */
|
|
2080
|
+
halo?: boolean | undefined;
|
|
2081
|
+
/**
|
|
2082
|
+
* The smallest semi-axis, in screen pixels: a dot whose data size would vanish at the fitted
|
|
2083
|
+
* zoom is still drawn this large. Omit for none.
|
|
2084
|
+
*/
|
|
2085
|
+
minRadius?: number | undefined;
|
|
2086
|
+
/** CSS colour of selected ellipses. Defaults to the overlay `selection` role. */
|
|
2087
|
+
selectionStroke?: string | undefined;
|
|
2088
|
+
/** Name the layer as an image for assistive technology. Without it the layer is decorative (`aria-hidden`). */
|
|
2089
|
+
label?: string | undefined;
|
|
2090
|
+
}
|
|
2091
|
+
/**
|
|
2092
|
+
* A batched set of ellipses inside an `ImageStage`.
|
|
2093
|
+
*
|
|
2094
|
+
* - **Geometry** is data: `rx`, `ry` and the centre are image pixels and scale with the image;
|
|
2095
|
+
* the stroke is a screen constant.
|
|
2096
|
+
* - **States** follow visual-language §5: 1.5 screen px (1 for `model` and `structure`), hover
|
|
2097
|
+
* 2, selected 2.5 in the selection colour, dimmed at 35 % opacity. Every stroke has a halo.
|
|
2098
|
+
* - **Batching** is by (role, dash, opacity, dimming): a thousand rings are a dozen elements.
|
|
2099
|
+
* - **Picking** goes through the stage's hit registry: a press within the pointer's tolerance of
|
|
2100
|
+
* an outline picks that ellipse, else the smallest ellipse containing the point.
|
|
2101
|
+
* `onHoverChange` and `onItemPress` here, and `useStageHitTest` for an app that arbitrates
|
|
2102
|
+
* between layers. `pickable={false}` turns it off.
|
|
2103
|
+
*
|
|
2104
|
+
* The SVG carries `data-ellipses` (the count) and `data-hovered` (the hovered id).
|
|
2105
|
+
*/
|
|
2106
|
+
export declare function EllipseSet({ items, role, hoveredId, onHoverChange, selectedIds, dimmed, onItemPress, pickable, layerId, priority, halo, minRadius, selectionStroke, label }: EllipseSetProps): import("react").JSX.Element;
|
|
1742
2107
|
//#endregion
|
|
1743
2108
|
//#region src/components/GridLayer.d.ts
|
|
1744
2109
|
/** One node of a `GridLayer`: a point with its lattice index. */
|
|
@@ -2201,7 +2566,17 @@ interface ShapeEditorProps {
|
|
|
2201
2566
|
*
|
|
2202
2567
|
* - **Handles.** Eight handles resize the shape in its own frame: the dragged side follows the
|
|
2203
2568
|
* 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
|
|
2569
|
+
* `minSize` rather than flipping. The interior moves it, and so does the band along its
|
|
2570
|
+
* outline (the pointer's tolerance: 6 px for a mouse, 12 px for a finger), which is how a thin
|
|
2571
|
+
* or rotated shape is grabbed. The band is as wide as the device's primary pointer needs
|
|
2572
|
+
* (`(pointer: coarse)`), so on a touch laptop whose primary pointer is fine, a touch 6 to
|
|
2573
|
+
* 12 px outside the outline reaches the layers below instead of the editor.
|
|
2574
|
+
* - **Press order.** One decision serves every part of the editor: the nearest handle first,
|
|
2575
|
+
* then the interior or outline band (move), then nothing. A small shape's interior does not
|
|
2576
|
+
* steal a press meant for a handle, and a press that hits none of them is not claimed, so
|
|
2577
|
+
* it reaches whatever is below, or the stage.
|
|
2578
|
+
* - **Touch.** A press that grabs the shape is claimed; a second finger landing during an edit
|
|
2579
|
+
* cancels it (the shape reverts, nothing is committed) and is left to the stage.
|
|
2205
2580
|
* - **Rotation.** The handle past the top side turns the shape about its centre; hold Shift to
|
|
2206
2581
|
* round to 15°.
|
|
2207
2582
|
* - **Keyboard.** The shape is focusable: arrow keys move it by one image pixel (ten with Shift),
|
|
@@ -2224,7 +2599,12 @@ export declare function ShapeEditor({ kind, value, onValueChange, onCommit, edit
|
|
|
2224
2599
|
* - `point`: a position.
|
|
2225
2600
|
* - `line`: a segment from `from` to `to`.
|
|
2226
2601
|
* - `polyline` and `polygon`: the vertices placed so far, flat `[x0, y0, x1, y1, …]`, and
|
|
2227
|
-
* the pointer as `cursor`, which the next vertex would land on.
|
|
2602
|
+
* the pointer as `cursor`, which the next vertex would land on. A polygon with `closing`
|
|
2603
|
+
* set has the pointer on its first vertex: a click there closes it, so the first vertex is
|
|
2604
|
+
* highlighted and the closing edge drawn solid.
|
|
2605
|
+
* - `stroke`: a brush trail, the flat `points` swept by a round brush of `width` image pixels
|
|
2606
|
+
* (never thinner than 1 screen pixel), as a translucent filled band without dashes.
|
|
2607
|
+
* - `brush`: a brush footprint cursor, a circle of `diameter` image pixels centred on `x`, `y`.
|
|
2228
2608
|
* - `rect` and `ellipse`: two opposite corners of the axis-aligned box (the drag's start and
|
|
2229
2609
|
* the pointer).
|
|
2230
2610
|
*/
|
|
@@ -2244,6 +2624,16 @@ type DraftShapeSpec = {
|
|
|
2244
2624
|
kind: "polygon";
|
|
2245
2625
|
points: ArrayLike<number>;
|
|
2246
2626
|
cursor?: Point | undefined;
|
|
2627
|
+
closing?: boolean | undefined;
|
|
2628
|
+
} | {
|
|
2629
|
+
kind: "stroke";
|
|
2630
|
+
points: ArrayLike<number>;
|
|
2631
|
+
width: number;
|
|
2632
|
+
} | {
|
|
2633
|
+
kind: "brush";
|
|
2634
|
+
x: number;
|
|
2635
|
+
y: number;
|
|
2636
|
+
diameter: number;
|
|
2247
2637
|
} | {
|
|
2248
2638
|
kind: "rect";
|
|
2249
2639
|
from: Point;
|
|
@@ -2259,6 +2649,8 @@ interface DraftShapeProps {
|
|
|
2259
2649
|
shape: DraftShapeSpec | null;
|
|
2260
2650
|
/** The overlay role it is drawn in. Defaults to `"selection"`, the accent. */
|
|
2261
2651
|
role?: OverlayRole | undefined;
|
|
2652
|
+
/** A CSS colour that overrides `role`, for example `"var(--defect)"` for an eraser. */
|
|
2653
|
+
stroke?: string | undefined;
|
|
2262
2654
|
/** Draw the dark band under the outline. On by default. */
|
|
2263
2655
|
halo?: boolean | undefined;
|
|
2264
2656
|
}
|
|
@@ -2268,12 +2660,17 @@ interface DraftShapeProps {
|
|
|
2268
2660
|
* The outline is 1.5 screen px, dashed 6 4 screen px, in the accent (`selection`) role by
|
|
2269
2661
|
* default, with a halo; regions (`polygon`, `rect`, `ellipse`) carry the 12 % fill. A polyline
|
|
2270
2662
|
* or polygon shows its placed vertices as dots and a segment on to the pointer; a polygon also
|
|
2271
|
-
* shows, fainter, the segment that would close it
|
|
2663
|
+
* shows, fainter, the segment that would close it; with `closing` the first vertex gets a
|
|
2664
|
+
* ring and that segment turns solid and full strength: "click here to close". A `stroke`
|
|
2665
|
+
* (brush trail) is a translucent band of its own width with round caps and joins and no
|
|
2666
|
+
* dashes, and a `brush` is a footprint ring: a dark ring under a light one, so it reads on
|
|
2667
|
+
* any image. `points` may be a typed-array view that changes identity every move: the draft
|
|
2668
|
+
* is rebuilt in one O(n) pass per render, with no per-vertex elements. It takes no pointer events and is hidden
|
|
2272
2669
|
* from assistive technology: it is transient feedback for a gesture.
|
|
2273
2670
|
*
|
|
2274
2671
|
* The SVG carries `data-draft` (the shape's kind).
|
|
2275
2672
|
*/
|
|
2276
|
-
export declare function DraftShape({ shape, role, halo }: DraftShapeProps): import("react").JSX.Element;
|
|
2673
|
+
export declare function DraftShape({ shape, role, stroke, halo }: DraftShapeProps): import("react").JSX.Element;
|
|
2277
2674
|
/** Props of `MarqueeRect`. */
|
|
2278
2675
|
interface MarqueeRectProps {
|
|
2279
2676
|
/** The band in image coordinates, or `null` when no band is being dragged. */
|
|
@@ -2355,8 +2752,12 @@ interface MaskEditorProps {
|
|
|
2355
2752
|
/** RGBA overlay color. */
|
|
2356
2753
|
color?: readonly [number, number, number, number];
|
|
2357
2754
|
}
|
|
2358
|
-
/**
|
|
2755
|
+
/**
|
|
2756
|
+
* Render and edit a binary raster mask within the enclosing ImageStage. While editing, a
|
|
2757
|
+
* `DraftShape` brush footprint (a circle of the brush's diameter) follows the mouse or pen
|
|
2758
|
+
* pointer, and the keyboard brush while the layer has keyboard focus.
|
|
2759
|
+
*/
|
|
2359
2760
|
export declare function MaskEditor({ mask, onChange, onCommit, editable, brushRadius, mode, label, color }: MaskEditorProps): import("react").JSX.Element;
|
|
2360
2761
|
//#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 };
|
|
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 };
|
|
2362
2763
|
//# sourceMappingURL=index.d.ts.map
|