@vitavision/stage2d 0.15.0 → 0.16.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 +16 -0
- package/dist/index.d.ts +382 -1
- package/dist/index.js +944 -10
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/ContourLayer.tsx +211 -0
- package/src/components/PointMarquee.tsx +229 -0
- package/src/components/VectorField.tsx +302 -0
- package/src/components/VectorFieldKey.tsx +91 -0
- package/src/components/contour.ts +270 -0
- package/src/components/vectorGeometry.ts +159 -0
- package/src/index.ts +23 -0
package/README.md
CHANGED
|
@@ -76,6 +76,22 @@ and the edges between lattice neighbours as two batched paths, each axis restyle
|
|
|
76
76
|
`@vitavision/charts` maps fit) or an `rgba` buffer as one image, rasterised in an effect, placed over the
|
|
77
77
|
image (or `rect`), pixelated from 4 CSS px per cell. `rasterizePlane` and `planeRange` are pure.
|
|
78
78
|
|
|
79
|
+
**Contours**: `ContourLayer` draws the iso-lines of a `ValuePlane` channel (marching squares, in image coordinates, placed like a
|
|
80
|
+
`HeatmapLayer` of the same plane). `levels` is a list or `{ step, origin? }`; `dashedLevels` draws a level dashed (a threshold, zero) even when
|
|
81
|
+
`levels` lacks it; `labels` writes the level along long lines. A cell touching `NaN` holds no line, so a line ends at a hole. Solid and dashed
|
|
82
|
+
levels are one path each. `contourPaths` and `resolveLevels` are pure.
|
|
83
|
+
|
|
84
|
+
**Vector fields**: `VectorField` draws many arrows (a displacement, a flow, the direction and size of an error) from
|
|
85
|
+
flat `anchors` `[x, y, …]` and `vectors` `[dx, dy, …]` as a halo path and one path per colour step, never one element per vector.
|
|
86
|
+
- **Scale:** a number is image pixels per data unit; `{ length, percentile }` makes the percentile vector span `length`
|
|
87
|
+
screen pixels at every zoom. The default is the 95th percentile at 28 screen px.
|
|
88
|
+
- **Colour:** one tone (`color` or a `role`), or by magnitude through `colormap` over `range` (the `@vitavision/charts` maps fit).
|
|
89
|
+
- **Absent data:** a non-finite number, or an arrow under one screen pixel, is not drawn.
|
|
90
|
+
- **Pointer:** `onHoverChange` and `onItemPress` pick the vector whose anchor is nearest.
|
|
91
|
+
- **Key:** `VectorFieldKey` shows an arrow of a round length with its value ("0.1 px") at the field's scale, for the
|
|
92
|
+
stage's readout (`bare` inside a `StageReadout`'s `extra`).
|
|
93
|
+
- **Pure functions:** `arrowPath`, `vectorMagnitudes`, `magnitudePercentile`, `imagePerUnit`, `niceLength`, `colorBin`.
|
|
94
|
+
|
|
79
95
|
**Rotated shapes**: `ShapeEditor` edits `{ cx, cy, width, height, rotation }` as a rectangle or an ellipse:
|
|
80
96
|
eight handles resize in the shape's own frame (the opposite side stays put), a rotation handle turns it, the
|
|
81
97
|
interior moves it, arrow keys nudge it. **Rotation is radians, clockwise on screen** (Konva's degrees are
|
package/dist/index.d.ts
CHANGED
|
@@ -2229,6 +2229,75 @@ interface PointSetProps {
|
|
|
2229
2229
|
*/
|
|
2230
2230
|
export declare function PointSet({ items, kind, markers, hoveredId, onHoverChange, selectedIds, dimmed, onItemPress, pickable, labels, halo, selectionStroke, layerId, priority, label }: PointSetProps): import("react").JSX.Element;
|
|
2231
2231
|
//#endregion
|
|
2232
|
+
//#region src/components/PointMarquee.d.ts
|
|
2233
|
+
/** The key that arms a `PointMarquee`. `"meta"` is ⌘ on macOS and Ctrl elsewhere. */
|
|
2234
|
+
type PointMarqueeModifier = "shift" | "alt" | "meta";
|
|
2235
|
+
/** How a marquee combines with the current selection: replaces it, or adds to it. */
|
|
2236
|
+
type PointMarqueeMode = "replace" | "add";
|
|
2237
|
+
/**
|
|
2238
|
+
* What `PointMarquee`'s `ref` exposes, for an app that already has a `StageSurface` (a stage
|
|
2239
|
+
* has one full-frame press target) and starts the marquee from its `onPress`.
|
|
2240
|
+
*/
|
|
2241
|
+
interface PointMarqueeHandle {
|
|
2242
|
+
/**
|
|
2243
|
+
* The marquee as a `StageDrag`, to return from `StageSurface`'s `onPress`.
|
|
2244
|
+
*
|
|
2245
|
+
* @param press - The press the surface was given.
|
|
2246
|
+
* @returns The drag when the press holds the marquee's modifier, `undefined` otherwise: a
|
|
2247
|
+
* declined press is for the surface's other tools or the stage's pan. A touch has no
|
|
2248
|
+
* modifier, so it is never started here.
|
|
2249
|
+
*/
|
|
2250
|
+
sweepDrag(press: StagePress): StageDrag | undefined;
|
|
2251
|
+
}
|
|
2252
|
+
/** Props of `PointMarquee`. */
|
|
2253
|
+
interface PointMarqueeProps {
|
|
2254
|
+
/** The points the marquee selects among, in image coordinates. Pass a stable array: a new one rebuilds the index. */
|
|
2255
|
+
items: readonly PointItem[];
|
|
2256
|
+
/**
|
|
2257
|
+
* Called on release with the ids of the points inside the rectangle (edges included), in
|
|
2258
|
+
* item order; an empty list for a rectangle that holds none. Not called for a modifier-press
|
|
2259
|
+
* that did not move (a click is not a rectangle), nor after `Escape`.
|
|
2260
|
+
*
|
|
2261
|
+
* `mode` is `"add"` when ⌘/Ctrl is held as well as the modifier, `"replace"` otherwise. When
|
|
2262
|
+
* the modifier is `"meta"` itself, the mode is always `"replace"`.
|
|
2263
|
+
*/
|
|
2264
|
+
onSelect: (ids: PointId[], mode: PointMarqueeMode) => void;
|
|
2265
|
+
/** Called with the rectangle (image coordinates) while it is dragged, and with `null` when it ends. */
|
|
2266
|
+
onBandChange?: ((band: Rect | null) => void) | undefined;
|
|
2267
|
+
/** Called when a marquee is abandoned: `Escape`, or the pointer was cancelled. `onSelect` is not called. */
|
|
2268
|
+
onCancel?: (() => void) | undefined;
|
|
2269
|
+
/** The key that arms the marquee. Defaults to `"shift"`. */
|
|
2270
|
+
modifier?: PointMarqueeModifier | undefined;
|
|
2271
|
+
/**
|
|
2272
|
+
* Whether the layer has a full-frame press target of its own. Defaults to `true`. The target
|
|
2273
|
+
* exists only while the modifier is held, so it never covers the layers below otherwise. Turn
|
|
2274
|
+
* it off to start the marquee from your own `StageSurface` through `ref`.
|
|
2275
|
+
*/
|
|
2276
|
+
surface?: boolean | undefined;
|
|
2277
|
+
/** Turn the marquee off without unmounting it. Defaults to `true`. */
|
|
2278
|
+
enabled?: boolean | undefined;
|
|
2279
|
+
/** CSS colour of the rectangle. Defaults to the overlay `selection` role. */
|
|
2280
|
+
stroke?: string | undefined;
|
|
2281
|
+
/** Start a marquee from a press elsewhere; see `PointMarqueeHandle`. */
|
|
2282
|
+
ref?: Ref<PointMarqueeHandle> | undefined;
|
|
2283
|
+
}
|
|
2284
|
+
/**
|
|
2285
|
+
* A modifier-drag rectangle that selects points, inside an `ImageStage`.
|
|
2286
|
+
*
|
|
2287
|
+
* - **Opt-in**: a press without the modifier is left alone, so pan, wheel zoom and the layers
|
|
2288
|
+
* below behave as without it. While the modifier is held the layer takes presses over the
|
|
2289
|
+
* whole image and the cursor is a crosshair.
|
|
2290
|
+
* - **Reports ids**, by the points' centres, through a spatial index: thousands of points cost
|
|
2291
|
+
* microseconds.
|
|
2292
|
+
* - **Escape** abandons a marquee in flight; releasing the pointer without moving does nothing.
|
|
2293
|
+
* - **Touch** has no modifier: a finger pans as usual.
|
|
2294
|
+
*
|
|
2295
|
+
* It draws only the rectangle (`data-marquee`); selection feedback is the point layer's, fed by
|
|
2296
|
+
* the ids the app keeps. The layer carries `data-armed` while the modifier is held and
|
|
2297
|
+
* `data-sweeping` while a rectangle is being dragged.
|
|
2298
|
+
*/
|
|
2299
|
+
export declare function PointMarquee({ items, onSelect, onBandChange, onCancel, modifier, surface, enabled, stroke, ref }: PointMarqueeProps): import("react").JSX.Element;
|
|
2300
|
+
//#endregion
|
|
2232
2301
|
//#region src/components/areaIndex.d.ts
|
|
2233
2302
|
/** An area's identity. */
|
|
2234
2303
|
type AreaId = string | number;
|
|
@@ -2861,6 +2930,318 @@ type HeatmapLayerProps = HeatmapRgbaProps | HeatmapPlaneProps;
|
|
|
2861
2930
|
*/
|
|
2862
2931
|
export declare function HeatmapLayer(props: HeatmapLayerProps): import("react").JSX.Element | null;
|
|
2863
2932
|
//#endregion
|
|
2933
|
+
//#region src/components/ContourLayer.d.ts
|
|
2934
|
+
/** Props of `ContourLayer`. */
|
|
2935
|
+
interface ContourLayerProps {
|
|
2936
|
+
/** The field, as decoded by `decodePlane`. `NaN` is "no data": a line never crosses it. */
|
|
2937
|
+
plane: ValuePlane;
|
|
2938
|
+
/** Which channel of the plane. Defaults to the first. */
|
|
2939
|
+
channel?: number | undefined;
|
|
2940
|
+
/**
|
|
2941
|
+
* The levels to draw: a list of values, or `{ step, origin? }` for every multiple of `step`
|
|
2942
|
+
* (from `origin`, default 0) inside the channel's finite range. A step that would give more than
|
|
2943
|
+
* 64 levels is widened by whole multiples. Pass a stable value: a new one recomputes the lines.
|
|
2944
|
+
*/
|
|
2945
|
+
levels: readonly number[] | {
|
|
2946
|
+
step: number;
|
|
2947
|
+
origin?: number | undefined;
|
|
2948
|
+
};
|
|
2949
|
+
/**
|
|
2950
|
+
* Levels drawn dashed: a significance threshold, zero. They are drawn even when `levels` does
|
|
2951
|
+
* not contain them, and a level in both is dashed. Compared with a relative tolerance of 1e-9.
|
|
2952
|
+
*/
|
|
2953
|
+
dashedLevels?: readonly number[] | undefined;
|
|
2954
|
+
/**
|
|
2955
|
+
* Write each line's level on it: `true` for the level to three significant figures, or a
|
|
2956
|
+
* function. Labels are horizontal, sit along lines at least 90 screen pixels long (again every
|
|
2957
|
+
* 280), only inside the viewport, and at most 200 at a time.
|
|
2958
|
+
*/
|
|
2959
|
+
labels?: boolean | ((level: number) => string) | undefined;
|
|
2960
|
+
/**
|
|
2961
|
+
* Where the plane is placed, in image coordinates, as for `HeatmapLayer`: the top-left edge of
|
|
2962
|
+
* its first pixel's footprint and the extent it is stretched over. Defaults to the whole image,
|
|
2963
|
+
* so a plane of any resolution lines up with a `HeatmapLayer` of the same plane.
|
|
2964
|
+
*/
|
|
2965
|
+
rect?: Rect | undefined;
|
|
2966
|
+
/** The overlay role of the lines. Defaults to `"structure"`. */
|
|
2967
|
+
role?: OverlayRole | undefined;
|
|
2968
|
+
/** One CSS colour for the lines instead of the role's (`#hex` or `var(--x)`, used as given). */
|
|
2969
|
+
color?: string | undefined;
|
|
2970
|
+
/** Draw the dark band under lines and labels. On by default. */
|
|
2971
|
+
halo?: boolean | undefined;
|
|
2972
|
+
/** Draw it. Defaults to `true`; while `false` nothing is computed. */
|
|
2973
|
+
visible?: boolean | undefined;
|
|
2974
|
+
/** The layer's accessible name. Defaults to "Contours". */
|
|
2975
|
+
label?: string | undefined;
|
|
2976
|
+
}
|
|
2977
|
+
/**
|
|
2978
|
+
* Contour lines inside an `ImageStage`.
|
|
2979
|
+
*
|
|
2980
|
+
* - **Lines**: marching squares per level over the plane's nodes (pixel centres), linear along
|
|
2981
|
+
* edges; a saddle is resolved by the mean of its four corners. They are computed once per
|
|
2982
|
+
* change of `plane`, `channel` and `levels`, not on pan or zoom.
|
|
2983
|
+
* - **No data**: a cell touching a `NaN` node has no line, so a line stops at a hole.
|
|
2984
|
+
* - **Styles**: solid levels in one path, dashed ones in another, each over a halo.
|
|
2985
|
+
* - **Labels**: optional, by zoom (see `labels`).
|
|
2986
|
+
* - **Input**: none. The layer is decorative; the numbers are read from the plane (`valueAt`),
|
|
2987
|
+
* and a legend or `labels` carry the levels as text.
|
|
2988
|
+
*
|
|
2989
|
+
* The SVG carries `data-count` (lines) and `data-levels` (the levels drawn).
|
|
2990
|
+
*/
|
|
2991
|
+
export declare function ContourLayer({ plane, channel, levels, dashedLevels, labels, rect, role, color, halo, visible, label }: ContourLayerProps): import("react").JSX.Element | null;
|
|
2992
|
+
//#endregion
|
|
2993
|
+
//#region src/components/contour.d.ts
|
|
2994
|
+
/** One iso-line: a polyline at a level. */
|
|
2995
|
+
interface ContourLine {
|
|
2996
|
+
/** The level it lies on. */
|
|
2997
|
+
level: number;
|
|
2998
|
+
/** Flat `[x0, y0, x1, y1, …]` in nodes. For a closed line the first point is not repeated. */
|
|
2999
|
+
points: number[];
|
|
3000
|
+
/** Whether it returns to its start. */
|
|
3001
|
+
closed: boolean;
|
|
3002
|
+
}
|
|
3003
|
+
/**
|
|
3004
|
+
* The levels to draw.
|
|
3005
|
+
*
|
|
3006
|
+
* @param spec - Explicit levels (non-finite ones are dropped, duplicates merged), or `{ step }`:
|
|
3007
|
+
* every multiple of `step` (offset by `origin`) inside `[min, max]`. If that gives more than
|
|
3008
|
+
* `MAX_LEVELS` levels the step is multiplied by a whole number until it does not.
|
|
3009
|
+
* @param min - The field's smallest finite value, for a step.
|
|
3010
|
+
* @param max - The field's largest finite value.
|
|
3011
|
+
* @returns Ascending, distinct levels.
|
|
3012
|
+
*/
|
|
3013
|
+
export declare function resolveLevels(spec: readonly number[] | {
|
|
3014
|
+
step: number;
|
|
3015
|
+
origin?: number | undefined;
|
|
3016
|
+
}, min: number, max: number): number[];
|
|
3017
|
+
/**
|
|
3018
|
+
* The iso-lines of a plane's channel at every level, lowest level first.
|
|
3019
|
+
*
|
|
3020
|
+
* @param plane - The field; `NaN` is "no data".
|
|
3021
|
+
* @param channel - Which channel. Default 0; out of range gives no lines.
|
|
3022
|
+
* @param levels - See `resolveLevels`; the lines of each level, in turn.
|
|
3023
|
+
*/
|
|
3024
|
+
export declare function contourPaths(plane: ValuePlane, channel: number, levels: readonly number[]): ContourLine[];
|
|
3025
|
+
//#endregion
|
|
3026
|
+
//#region src/components/vectorGeometry.d.ts
|
|
3027
|
+
/**
|
|
3028
|
+
* The arithmetic of a vector field overlay: magnitudes, the scale that turns data units into
|
|
3029
|
+
* image pixels, the path of an arrow, and the bins a colour map is quantised into.
|
|
3030
|
+
*
|
|
3031
|
+
* Everything here is pure. Vectors are a flat `[dx0, dy0, dx1, dy1, …]` array in data units
|
|
3032
|
+
* (a displacement in pixels, a velocity, a gradient); a vector with a non-finite component is
|
|
3033
|
+
* absent.
|
|
3034
|
+
*/
|
|
3035
|
+
/**
|
|
3036
|
+
* How data units become image pixels.
|
|
3037
|
+
* - A number is image pixels per data unit: the arrows are geometry, so they grow with the zoom
|
|
3038
|
+
* like the image does.
|
|
3039
|
+
* - `{ length }` sizes the arrows so the `percentile` vector spans `length` screen pixels at
|
|
3040
|
+
* every zoom: the field stays readable whatever the magnification.
|
|
3041
|
+
*/
|
|
3042
|
+
type VectorScale = number | {
|
|
3043
|
+
/** The screen length, in CSS pixels, the reference vector spans. */
|
|
3044
|
+
length: number;
|
|
3045
|
+
/** Which magnitude is the reference, in `[0, 1]`. Defaults to `1`, the longest vector. */
|
|
3046
|
+
percentile?: number | undefined;
|
|
3047
|
+
};
|
|
3048
|
+
/**
|
|
3049
|
+
* The length of vector `i`, or `NaN` when it is absent.
|
|
3050
|
+
*
|
|
3051
|
+
* @param vectors - Flat `[dx0, dy0, …]`.
|
|
3052
|
+
* @param i - The vector's index.
|
|
3053
|
+
* @returns `hypot(dx, dy)`, or `NaN` for a non-finite component.
|
|
3054
|
+
*/
|
|
3055
|
+
export declare function vectorMagnitude(vectors: ArrayLike<number>, i: number): number;
|
|
3056
|
+
/**
|
|
3057
|
+
* The magnitudes of every vector, `NaN` for an absent one.
|
|
3058
|
+
*
|
|
3059
|
+
* @param vectors - Flat `[dx0, dy0, …]`.
|
|
3060
|
+
* @returns One magnitude per vector.
|
|
3061
|
+
*/
|
|
3062
|
+
export declare function vectorMagnitudes(vectors: ArrayLike<number>): Float64Array;
|
|
3063
|
+
/**
|
|
3064
|
+
* A magnitude's rank statistic over the present vectors.
|
|
3065
|
+
*
|
|
3066
|
+
* @param magnitudes - As `vectorMagnitudes` returns them; `NaN` entries are ignored.
|
|
3067
|
+
* @param p - The fraction in `[0, 1]` (clamped): `1` is the longest, `0.5` the median.
|
|
3068
|
+
* @returns The nearest-rank value, or `0` when no vector is present.
|
|
3069
|
+
*/
|
|
3070
|
+
export declare function magnitudePercentile(magnitudes: ArrayLike<number>, p: number): number;
|
|
3071
|
+
/**
|
|
3072
|
+
* The scale in image pixels per data unit.
|
|
3073
|
+
*
|
|
3074
|
+
* @param scale - See `VectorScale`.
|
|
3075
|
+
* @param referenceMagnitude - The reference vector's length in data units, for an automatic scale.
|
|
3076
|
+
* @param imagePerScreenPx - Image pixels covered by one screen pixel at the current zoom.
|
|
3077
|
+
* @returns Image pixels per data unit; `0` when an automatic scale has no vector to measure.
|
|
3078
|
+
*/
|
|
3079
|
+
export declare function imagePerUnit(scale: VectorScale, referenceMagnitude: number, imagePerScreenPx: number): number;
|
|
3080
|
+
/**
|
|
3081
|
+
* A round length for a key: the largest of 1, 2 and 5 times a power of ten that is at most `max`.
|
|
3082
|
+
*
|
|
3083
|
+
* @param max - The upper bound, in data units.
|
|
3084
|
+
* @returns The round length, or `0` for a non-positive `max`.
|
|
3085
|
+
*/
|
|
3086
|
+
export declare function niceLength(max: number): number;
|
|
3087
|
+
/** The shape of an arrow, in screen pixels. */
|
|
3088
|
+
interface ArrowStyle {
|
|
3089
|
+
/** The arrowhead's length. */
|
|
3090
|
+
head: number;
|
|
3091
|
+
/** The arrowhead's full width, as a fraction of its length. */
|
|
3092
|
+
headWidth: number;
|
|
3093
|
+
/** A vector shorter than this is not drawn. */
|
|
3094
|
+
minLength: number;
|
|
3095
|
+
}
|
|
3096
|
+
/**
|
|
3097
|
+
* The path data of one arrow: a shaft and a filled head.
|
|
3098
|
+
*
|
|
3099
|
+
* The head is capped at 45 % of the arrow's length, so a short arrow is a small wedge rather
|
|
3100
|
+
* than a head on no shaft. Lengths are in the units of `(x, y)` (image pixels); `unit` converts
|
|
3101
|
+
* the style's screen pixels to them.
|
|
3102
|
+
*
|
|
3103
|
+
* @param x - The anchor's x.
|
|
3104
|
+
* @param y - The anchor's y.
|
|
3105
|
+
* @param dx - The displacement's x, already scaled to image pixels.
|
|
3106
|
+
* @param dy - The displacement's y, already scaled to image pixels.
|
|
3107
|
+
* @param unit - Image pixels per screen pixel.
|
|
3108
|
+
* @param style - The arrow's shape.
|
|
3109
|
+
* @returns Path data, or `""` when the arrow is absent or shorter than `style.minLength`.
|
|
3110
|
+
*/
|
|
3111
|
+
export declare function arrowPath(x: number, y: number, dx: number, dy: number, unit: number, style: ArrowStyle): string;
|
|
3112
|
+
/** The number of colour steps a magnitude-coloured field is quantised into: one path each. */
|
|
3113
|
+
export declare const VECTOR_COLOR_BINS = 24;
|
|
3114
|
+
/**
|
|
3115
|
+
* The colour bin of a magnitude.
|
|
3116
|
+
*
|
|
3117
|
+
* @param magnitude - The vector's length.
|
|
3118
|
+
* @param low - The magnitude drawn in the map's first colour.
|
|
3119
|
+
* @param high - The magnitude drawn in the map's last colour.
|
|
3120
|
+
* @param bins - The number of bins. Defaults to `VECTOR_COLOR_BINS`.
|
|
3121
|
+
* @returns An integer in `[0, bins - 1]`; a degenerate range puts everything in bin `0`.
|
|
3122
|
+
*/
|
|
3123
|
+
export declare function colorBin(magnitude: number, low: number, high: number, bins?: number): number;
|
|
3124
|
+
//#endregion
|
|
3125
|
+
//#region src/components/VectorField.d.ts
|
|
3126
|
+
/** Props of `VectorField`. */
|
|
3127
|
+
interface VectorFieldProps {
|
|
3128
|
+
/** The anchors, flat `[x0, y0, x1, y1, …]` in image coordinates. A non-finite anchor is skipped. */
|
|
3129
|
+
anchors: ArrayLike<number>;
|
|
3130
|
+
/**
|
|
3131
|
+
* The vectors, flat `[dx0, dy0, dx1, dy1, …]` in data units, one per anchor. A non-finite
|
|
3132
|
+
* component, or a missing entry, skips the vector.
|
|
3133
|
+
*/
|
|
3134
|
+
vectors: ArrayLike<number>;
|
|
3135
|
+
/**
|
|
3136
|
+
* How data units become image pixels: a number is image pixels per data unit and zooms with
|
|
3137
|
+
* the image; `{ length, percentile }` makes the `percentile` vector (default `1`, the longest)
|
|
3138
|
+
* span `length` screen pixels at every zoom. Defaults to the 95th-percentile vector at 28 screen
|
|
3139
|
+
* pixels, so a few outliers do not shrink the rest to nothing.
|
|
3140
|
+
*/
|
|
3141
|
+
scale?: VectorScale | undefined;
|
|
3142
|
+
/**
|
|
3143
|
+
* One CSS colour for every arrow (`#hex`, `var(--x)`; used as given). Ignored with `colormap`.
|
|
3144
|
+
* Defaults to the `role`'s colour.
|
|
3145
|
+
*/
|
|
3146
|
+
color?: string | undefined;
|
|
3147
|
+
/** The overlay role the arrows are painted in without a `color`. Defaults to `"feature"`. */
|
|
3148
|
+
role?: OverlayRole | undefined;
|
|
3149
|
+
/**
|
|
3150
|
+
* Colour each arrow by its magnitude through this map: a position in `[0, 1]` to `[r, g, b]`
|
|
3151
|
+
* (the maps of `@vitavision/charts` fit, as for `HeatmapLayer`). Pass a stable function.
|
|
3152
|
+
* Magnitudes are quantised into 24 steps, one path each.
|
|
3153
|
+
*/
|
|
3154
|
+
colormap?: Colormap | undefined;
|
|
3155
|
+
/** The magnitudes mapped onto `colormap`. Defaults to `0` to the longest vector. */
|
|
3156
|
+
range?: ValueRange | undefined;
|
|
3157
|
+
/** Ids by vector index. Defaults to the index. */
|
|
3158
|
+
ids?: ArrayLike<PointId> | undefined;
|
|
3159
|
+
/** The hovered id, when the app controls hover. */
|
|
3160
|
+
hoveredId?: PointId | null | undefined;
|
|
3161
|
+
/**
|
|
3162
|
+
* Called when the vector under the pointer changes; `null` when it leaves every vector. A
|
|
3163
|
+
* vector is picked at its anchor. Not called while `pickable` is off.
|
|
3164
|
+
*/
|
|
3165
|
+
onHoverChange?: ((id: PointId | null) => void) | undefined;
|
|
3166
|
+
/**
|
|
3167
|
+
* A press landed on a vector's anchor. Setting it makes the layer claim presses there, so the
|
|
3168
|
+
* stage does not pan from them.
|
|
3169
|
+
*/
|
|
3170
|
+
onItemPress?: ((id: PointId, event: StagePointerEvent) => void) | undefined;
|
|
3171
|
+
/** Draw the dark band under every arrow. On by default; off for a fast, flat layer. */
|
|
3172
|
+
halo?: boolean | undefined;
|
|
3173
|
+
/** Whether the layer takes part in the stage's hit-test. On by default. */
|
|
3174
|
+
pickable?: boolean | undefined;
|
|
3175
|
+
/** The id hit-tests report for this layer. Defaults to a generated one. */
|
|
3176
|
+
layerId?: string | undefined;
|
|
3177
|
+
/** Rank against other layers in hit-tests. Defaults to `STAGE_HIT_PRIORITY.point`. */
|
|
3178
|
+
priority?: number | undefined;
|
|
3179
|
+
/** The layer's accessible name. Defaults to "Vectors". */
|
|
3180
|
+
label?: string | undefined;
|
|
3181
|
+
}
|
|
3182
|
+
/**
|
|
3183
|
+
* The reference vector of a scale and the scale it gives, shared by the layer and its key.
|
|
3184
|
+
*
|
|
3185
|
+
* @param vectors - Flat `[dx0, dy0, …]`.
|
|
3186
|
+
* @param scale - See `VectorScale`.
|
|
3187
|
+
* @returns The reference magnitude in data units, and image pixels per data unit.
|
|
3188
|
+
*/
|
|
3189
|
+
export declare function useVectorScale(vectors: ArrayLike<number>, scale?: VectorScale): {
|
|
3190
|
+
reference: number;
|
|
3191
|
+
perUnit: number;
|
|
3192
|
+
};
|
|
3193
|
+
/**
|
|
3194
|
+
* A field of arrows inside an `ImageStage`.
|
|
3195
|
+
*
|
|
3196
|
+
* - **Scale**: see `VectorScale`. The same `vectors` and `scale` given to `VectorFieldKey` draw a
|
|
3197
|
+
* reference length at exactly this scale.
|
|
3198
|
+
* - **Colour**: one tone (`color` or `role`), or by magnitude through `colormap` over `range`.
|
|
3199
|
+
* - **Absent data**: an anchor or vector with a non-finite number, or shorter than one screen
|
|
3200
|
+
* pixel, is not drawn.
|
|
3201
|
+
* - **Picking** goes through the stage's hit registry: `onHoverChange` and `onItemPress` here, and
|
|
3202
|
+
* `useStageHitTest` for an app that arbitrates between layers. The hovered arrow is redrawn
|
|
3203
|
+
* at 2.5 screen px in the selection colour.
|
|
3204
|
+
*
|
|
3205
|
+
* Arrowheads and strokes are screen-constant; their paths are regenerated when the zoom changes,
|
|
3206
|
+
* and past 3,000 vectors only those near the viewport are generated. The SVG carries
|
|
3207
|
+
* `data-hovered` (the hovered id) and `data-count` (the vectors drawn).
|
|
3208
|
+
*/
|
|
3209
|
+
export declare function VectorField({ anchors, vectors, scale, color, role, colormap, range, ids, hoveredId, onHoverChange, onItemPress, halo, pickable, layerId, priority, label }: VectorFieldProps): import("react").JSX.Element;
|
|
3210
|
+
//#endregion
|
|
3211
|
+
//#region src/components/VectorFieldKey.d.ts
|
|
3212
|
+
/** Props of `VectorFieldKey`. */
|
|
3213
|
+
interface VectorFieldKeyProps {
|
|
3214
|
+
/** The field's `vectors`: the scale of an automatic `scale` depends on them. */
|
|
3215
|
+
vectors: ArrayLike<number>;
|
|
3216
|
+
/** The field's `scale`, so the key is drawn at exactly the field's scale. Defaults as `VectorField` does. */
|
|
3217
|
+
scale?: VectorScale | undefined;
|
|
3218
|
+
/**
|
|
3219
|
+
* The length the key shows, in data units. Defaults to the largest 1, 2 or 5 times a power of
|
|
3220
|
+
* ten that is at most the field's reference vector.
|
|
3221
|
+
*/
|
|
3222
|
+
length?: number | undefined;
|
|
3223
|
+
/** The data unit, written after the value (`px`, `m/s`). */
|
|
3224
|
+
unit?: string | undefined;
|
|
3225
|
+
/** Formats the value. Defaults to at most 3 significant figures, without trailing zeros. */
|
|
3226
|
+
format?: ((value: number) => string) | undefined;
|
|
3227
|
+
/**
|
|
3228
|
+
* Draw without its own dark chip, for a place that has one already: the `extra` of a
|
|
3229
|
+
* `StageReadout`. Off by default.
|
|
3230
|
+
*/
|
|
3231
|
+
bare?: boolean | undefined;
|
|
3232
|
+
/** Merged onto the key with `cn`. */
|
|
3233
|
+
className?: string | undefined;
|
|
3234
|
+
}
|
|
3235
|
+
/**
|
|
3236
|
+
* An arrow of a known length and its value ("0.1 px"). Pass it as `ImageStage`'s `readout`, or
|
|
3237
|
+
* as the `extra` of a `StageReadout` with `bare`; it reads the stage's zoom through `useStage`, so it stays
|
|
3238
|
+
* true as the view changes, and draws nothing while the field has no scale or the arrow would
|
|
3239
|
+
* be wider than 160 screen pixels.
|
|
3240
|
+
*
|
|
3241
|
+
* On its own it is drawn in the readout's light-on-dark chip, so it sits on the image like the readout does.
|
|
3242
|
+
*/
|
|
3243
|
+
export declare function VectorFieldKey({ vectors, scale, length, unit, format, bare, className }: VectorFieldKeyProps): import("react").JSX.Element | null;
|
|
3244
|
+
//#endregion
|
|
2864
3245
|
//#region src/components/roiEdit.d.ts
|
|
2865
3246
|
/** A region's handle, by compass direction. */
|
|
2866
3247
|
type RoiHandle = "nw" | "n" | "ne" | "e" | "se" | "s" | "sw" | "w";
|
|
@@ -3415,5 +3796,5 @@ interface MaskEditorProps {
|
|
|
3415
3796
|
*/
|
|
3416
3797
|
export declare function MaskEditor({ mask, onChange, onCommit, editable, brushRadius, mode, label, color }: MaskEditorProps): import("react").JSX.Element;
|
|
3417
3798
|
//#endregion
|
|
3418
|
-
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 };
|
|
3799
|
+
export type { ArcPrimitive, Area, AreaHit, AreaId, AreaIndex, AreaSetItem, AreaSetProps, ArrowStyle, Box, BuiltinMarkerKind, CaliperPrimitive, CirclePrimitive, ClampOptions, Colormap, CompareLayerProps, CompareMode, CompareOrientation, ContourEditorProps, ContourLayerProps, ContourLine, 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, PointMarqueeHandle, PointMarqueeMode, PointMarqueeModifier, PointMarqueeProps, 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, VectorFieldKeyProps, VectorFieldProps, VectorScale, View, ZoomPanCanvasProps };
|
|
3419
3800
|
//# sourceMappingURL=index.d.ts.map
|