@niivue/uikit 1.0.0-rc.13 → 1.0.0-rc.15
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/dist/index.d.ts +4 -0
- package/dist/pointLabel.d.ts +68 -0
- package/dist/pointLabelOverlay.d.ts +39 -0
- package/dist/uikit.js +689 -577
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -35,6 +35,10 @@ export type { NumberInputLayout, NumberInputSpec, NumberInputStyle, NumberInputV
|
|
|
35
35
|
export { DEFAULT_NUMBER_INPUT_STYLE } from './numberInput';
|
|
36
36
|
export type { UIKitNumberInputOverlayOptions } from './numberInputOverlay';
|
|
37
37
|
export { UIKitNumberInputOverlay } from './numberInputOverlay';
|
|
38
|
+
export type { PointLabelBounds, PointLabelGeometry, PointLabelSpec, } from './pointLabel';
|
|
39
|
+
export { buildPointLabel } from './pointLabel';
|
|
40
|
+
export type { MMPoint, MMProjector, PointLabelPlacement, } from './pointLabelOverlay';
|
|
41
|
+
export { UIKitPointLabelOverlay } from './pointLabelOverlay';
|
|
38
42
|
export type { RectData, RectSpec } from './rect';
|
|
39
43
|
export { buildRect } from './rect';
|
|
40
44
|
export { UIKitRectOverlay } from './rectOverlay';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { LineData } from './line';
|
|
2
|
+
import { RGBA, Vec2 } from './ruler';
|
|
3
|
+
import { UIKitFontMetrics } from './text/font';
|
|
4
|
+
import { UIKitTextItem } from './textOverlay';
|
|
5
|
+
export interface PointLabelBounds {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}
|
|
11
|
+
export interface PointLabelSpec {
|
|
12
|
+
/** The labelled point in screen pixels. */
|
|
13
|
+
target: Vec2;
|
|
14
|
+
text: string;
|
|
15
|
+
/**
|
|
16
|
+
* Where the leader ends and the text starts, in screen pixels. Omit to place
|
|
17
|
+
* it `leaderLength` from the target, pointing away from the centre of
|
|
18
|
+
* `bounds` (or up and to the right without bounds).
|
|
19
|
+
*/
|
|
20
|
+
anchor?: Vec2;
|
|
21
|
+
/**
|
|
22
|
+
* The drawable area. Used to choose the automatic anchor direction and to
|
|
23
|
+
* keep the text inside the frame: the text flips to the other side of the
|
|
24
|
+
* anchor when it would run off an edge.
|
|
25
|
+
*/
|
|
26
|
+
bounds?: PointLabelBounds;
|
|
27
|
+
/**
|
|
28
|
+
* The eight projected corners of a box to outline around the target (a
|
|
29
|
+
* volume brick, say), in screen pixels. Corner `c` sits at the box's
|
|
30
|
+
* minimum on each axis whose bit of `c` is clear and at its maximum where
|
|
31
|
+
* it is set, so the twelve edges join corners whose indices differ in one
|
|
32
|
+
* bit. Omit for no box.
|
|
33
|
+
*/
|
|
34
|
+
box?: readonly Vec2[];
|
|
35
|
+
/** Colour of the box edges. Defaults to `lineColor`. */
|
|
36
|
+
boxColor?: RGBA;
|
|
37
|
+
/** Thickness of the box edges in pixels. Defaults to `thickness`. */
|
|
38
|
+
boxThickness?: number;
|
|
39
|
+
/** Leader length for the automatic anchor, in pixels. Default 110. */
|
|
40
|
+
leaderLength?: number;
|
|
41
|
+
/** Text height in pixels. Default 28. */
|
|
42
|
+
sizePx?: number;
|
|
43
|
+
lineColor?: RGBA;
|
|
44
|
+
textColor?: RGBA;
|
|
45
|
+
/** Line thickness in pixels. Default 3. */
|
|
46
|
+
thickness?: number;
|
|
47
|
+
/** Half-size of the diamond marking the target, in pixels. Default 6. */
|
|
48
|
+
markerSize?: number;
|
|
49
|
+
/** Text outline width in pixels, 0 for none. Default 2. */
|
|
50
|
+
textOutlineWidthPx?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Multiplies every pixel size above (given or default), so one spec reads
|
|
53
|
+
* the same on a 1x and a 2x display. The overlay passes the frame's device
|
|
54
|
+
* pixel ratio. Default 1.
|
|
55
|
+
*/
|
|
56
|
+
scale?: number;
|
|
57
|
+
}
|
|
58
|
+
export interface PointLabelGeometry {
|
|
59
|
+
lines: LineData[];
|
|
60
|
+
text: UIKitTextItem[];
|
|
61
|
+
/** The resolved anchor (useful for tests and for chaining labels). */
|
|
62
|
+
anchor: Vec2;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Build the line + text draw data for a point label. Pure geometry; the font
|
|
66
|
+
* metrics are only used to measure the text so it can be kept in frame.
|
|
67
|
+
*/
|
|
68
|
+
export declare function buildPointLabel(metrics: UIKitFontMetrics, spec: PointLabelSpec): PointLabelGeometry;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { UIKitOverlayFrame, UIKitOverlayRenderer } from '@niivue/niivue';
|
|
2
|
+
import { PointLabelSpec } from './pointLabel';
|
|
3
|
+
import { UIKitFont } from './text/font';
|
|
4
|
+
export type MMPoint = readonly [number, number, number];
|
|
5
|
+
/** Maps a world-mm point to canvas backing-store pixels, or null if off screen. */
|
|
6
|
+
export type MMProjector = (mm: MMPoint) => [number, number] | null;
|
|
7
|
+
/**
|
|
8
|
+
* A label pinned to a world-mm point; the rest styles the callout. Pixel
|
|
9
|
+
* sizes are in CSS pixels: the overlay scales them by the frame's device
|
|
10
|
+
* pixel ratio (times any `scale` given here).
|
|
11
|
+
*/
|
|
12
|
+
export type PointLabelPlacement = Omit<PointLabelSpec, 'target' | 'bounds' | 'box'> & {
|
|
13
|
+
mm: MMPoint;
|
|
14
|
+
/**
|
|
15
|
+
* The eight world-mm corners of a box to outline around the point (the
|
|
16
|
+
* volume brick holding it, say), in the corner order `PointLabelSpec.box`
|
|
17
|
+
* describes. The overlay projects them each frame.
|
|
18
|
+
*/
|
|
19
|
+
boxMM?: readonly MMPoint[];
|
|
20
|
+
};
|
|
21
|
+
export declare class UIKitPointLabelOverlay implements UIKitOverlayRenderer {
|
|
22
|
+
private project;
|
|
23
|
+
private readonly lines;
|
|
24
|
+
private readonly labels;
|
|
25
|
+
private readonly font;
|
|
26
|
+
private placements;
|
|
27
|
+
constructor(font: UIKitFont, project: MMProjector, labels?: PointLabelPlacement[]);
|
|
28
|
+
/** Replace the labels. Trigger a redraw via the host. */
|
|
29
|
+
setLabels(labels: PointLabelPlacement[]): void;
|
|
30
|
+
/** Swap the projection (after a view change, say). */
|
|
31
|
+
setProjector(project: MMProjector): void;
|
|
32
|
+
/** Remove every label so nothing draws. */
|
|
33
|
+
clear(): void;
|
|
34
|
+
drawOverlay(frame: UIKitOverlayFrame): void;
|
|
35
|
+
/** The box's corners on the canvas, or undefined when any is off screen. */
|
|
36
|
+
private projectBox;
|
|
37
|
+
/** Release GPU resources on both backends. */
|
|
38
|
+
destroy(): void;
|
|
39
|
+
}
|