@beeson-group/tycho 0.2.0 → 0.3.1
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/AUTHORS +1 -0
- package/NOTICE +1 -1
- package/THIRD_PARTY_NOTICES.md +4 -4
- package/dist/tycho.esm.js +1231 -728
- package/dist/tycho.js +1231 -728
- package/dist/types/container.d.ts +16 -16
- package/dist/types/errors.d.ts +2 -3
- package/dist/types/evaluate/clock.d.ts +21 -15
- package/dist/types/evaluate/frames.d.ts +11 -11
- package/dist/types/evaluate/index.d.ts +9 -2
- package/dist/types/evaluate/layers.d.ts +87 -26
- package/dist/types/evaluate/resolve.d.ts +34 -23
- package/dist/types/evaluate/sets.d.ts +16 -15
- package/dist/types/evaluate/timeline.d.ts +60 -0
- package/dist/types/evaluate/types.d.ts +57 -6
- package/dist/types/index.d.ts +2 -2
- package/dist/types/runtime/colormaps.d.ts +1 -1
- package/dist/types/runtime/colors.d.ts +40 -13
- package/dist/types/runtime/contexts.d.ts +40 -0
- package/dist/types/runtime/element.d.ts +100 -22
- package/dist/types/runtime/export.d.ts +44 -34
- package/dist/types/runtime/geometry.d.ts +106 -103
- package/dist/types/runtime/icons.d.ts +12 -2
- package/dist/types/runtime/outline.d.ts +29 -0
- package/dist/types/runtime/overlay.d.ts +3 -1
- package/dist/types/runtime/paint.d.ts +116 -0
- package/dist/types/runtime/raster.d.ts +33 -0
- package/dist/types/runtime/readouts.d.ts +35 -28
- package/dist/types/runtime/renderer.d.ts +344 -61
- package/dist/types/runtime/state.d.ts +27 -29
- package/dist/types/runtime/tiles.d.ts +2 -2
- package/dist/types/scene.d.ts +27 -13
- package/dist/types/scene.gen.d.ts +1826 -194
- package/dist/types/validate.d.ts +1 -1
- package/package.json +4 -4
|
@@ -1,84 +1,84 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Static geometry of a
|
|
3
|
-
* reading. A set's samples are transformed once per display frame and
|
|
4
|
-
* (rules
|
|
5
|
-
* drawing a frame only compares readings and blends two transformed samples (rule
|
|
6
|
-
* panel showing the same frame shares the same buffers, and a
|
|
2
|
+
* Static geometry of a trajectory set in a display frame, and the revealed part of one trajectory at a
|
|
3
|
+
* reading. A set's samples are transformed once per display frame and revolution, each in its context
|
|
4
|
+
* (rules `sample-context` and `revolutions`). Their readings u_i are computed once per clock channel (rule `sample-fraction`), so that
|
|
5
|
+
* drawing a frame only compares readings and blends two transformed samples (rule `segment`). Every
|
|
6
|
+
* panel showing the same frame shares the same buffers, and a revolution is transformed the first time
|
|
7
7
|
* something draws it.
|
|
8
8
|
*
|
|
9
|
-
* The GPU draws the stored segments of one
|
|
10
|
-
* closing sample of a
|
|
11
|
-
* of rule
|
|
9
|
+
* The GPU draws the stored segments of one revolution per pass. Within a revolution below the top one, the
|
|
10
|
+
* closing sample of a trajectory is replaced by the first sample of the next revolution, which is the joint
|
|
11
|
+
* of rule `revolutions`, so that the passes of consecutive revolutions draw one polyline. A segment is drawn when
|
|
12
12
|
* both its ends lie strictly inside the revealed range of loop readings U = n u, where n is the
|
|
13
|
-
* number of
|
|
14
|
-
* each end, and compared
|
|
15
|
-
* does not add a
|
|
16
|
-
* the GPU and the CPU together draw the polyline of rules
|
|
13
|
+
* number of revolutions and u the reading. The range is stored as the revolution and the within-revolution reading of
|
|
14
|
+
* each end, and compared revolution by revolution, so that the GPU compares the float32 readings as stored and
|
|
15
|
+
* does not add a revolution to any of them. The CPU draws the pieces at the two ends of the range, thus
|
|
16
|
+
* the GPU and the CPU together draw the polyline of rules `polyline`, `trail-wrap` and `revolutions`.
|
|
17
17
|
*/
|
|
18
18
|
import type { DataStore } from '../container.js';
|
|
19
|
-
import {
|
|
19
|
+
import { TrajectoryClock } from '../evaluate/clock.js';
|
|
20
20
|
import { Frames } from '../evaluate/frames.js';
|
|
21
21
|
import { type Vertex } from '../evaluate/layers.js';
|
|
22
22
|
import { SetCache, type SetData } from '../evaluate/sets.js';
|
|
23
|
-
import type { Clock, Scene,
|
|
23
|
+
import type { Clock, Scene, TrajectoriesLayer } from '../scene.js';
|
|
24
24
|
type Box6 = [number, number, number, number, number, number];
|
|
25
|
-
/** The
|
|
26
|
-
export declare function
|
|
25
|
+
/** The revolution a vertex is evaluated in, which is its revolution of rule `revolutions`, or one lower when it is shifted (rule `trail-wrap`). */
|
|
26
|
+
export declare function vertexRevolution(v: Vertex): number;
|
|
27
27
|
/**
|
|
28
|
-
* Every sample of a set in one display frame, per
|
|
29
|
-
* A
|
|
30
|
-
* large set costs one
|
|
28
|
+
* Every sample of a set in one display frame, per revolution, as x, y, z per sample in storage order.
|
|
29
|
+
* A trajectory is transformed in a revolution the first time it is needed, so that drawing one member of a
|
|
30
|
+
* large set costs one trajectory, and the revolutions of rule `revolutions` do not cost anything until something draws them.
|
|
31
31
|
*/
|
|
32
|
-
export declare class
|
|
32
|
+
export declare class TrajectoryGeometry {
|
|
33
33
|
readonly set: SetData;
|
|
34
34
|
readonly frame: string;
|
|
35
|
-
/** The number of
|
|
36
|
-
readonly
|
|
37
|
-
/** The highest
|
|
35
|
+
/** The number of revolutions of rule `revolutions` on the set. It is taken from the clock for a periodic set, and is one otherwise. */
|
|
36
|
+
readonly revolutions: number;
|
|
37
|
+
/** The highest revolution, the only one that keeps its closing sample when the revolutions are joined. */
|
|
38
38
|
readonly top: number;
|
|
39
|
-
/** True when the edges into the display frame do not read any channel, meaning that every
|
|
39
|
+
/** True when the edges into the display frame do not read any channel, meaning that every revolution has the positions of revolution 0. */
|
|
40
40
|
readonly invariant: boolean;
|
|
41
41
|
private readonly frames;
|
|
42
42
|
private readonly stores;
|
|
43
43
|
private box;
|
|
44
|
-
constructor(set: SetData, frame: string, frames: Frames,
|
|
45
|
-
/** The
|
|
46
|
-
private
|
|
47
|
-
/** A name for the GPU's segments of
|
|
48
|
-
|
|
44
|
+
constructor(set: SetData, frame: string, frames: Frames, revolutions?: number);
|
|
45
|
+
/** The revolution whose positions revolution `j` has. */
|
|
46
|
+
private storeRevolution;
|
|
47
|
+
/** A name for the GPU's segments of revolution `j`, the same for every revolution whose segments are the same. */
|
|
48
|
+
revolutionKey(j: number): string;
|
|
49
49
|
private store;
|
|
50
|
-
/** Transforms
|
|
51
|
-
ensure(t: number,
|
|
52
|
-
/** Every sample of
|
|
53
|
-
|
|
54
|
-
/** Every sample of
|
|
50
|
+
/** Transforms trajectory `t` in revolution `revolution` (true stands for revolution -1 and false for revolution 0), unless it is already transformed. */
|
|
51
|
+
ensure(t: number, revolution: number | boolean): Float64Array;
|
|
52
|
+
/** Every sample of revolution `j`, each in its context. */
|
|
53
|
+
revolutionPositions(j: number): Float64Array;
|
|
54
|
+
/** Every sample of revolution 0, each in its context (rule `sample-context`). */
|
|
55
55
|
get positions(): Float64Array;
|
|
56
|
-
/** Every sample of
|
|
56
|
+
/** Every sample of revolution -1, the shifted contexts of rule `trail-wrap`, for a periodic set only. */
|
|
57
57
|
get shifted(): Float64Array | null;
|
|
58
|
-
/** The samples of
|
|
59
|
-
|
|
58
|
+
/** The samples of trajectory `t` alone in a revolution, as x, y, z per sample. */
|
|
59
|
+
trajectory(t: number, revolution: number | boolean): Float64Array;
|
|
60
60
|
/**
|
|
61
|
-
* Sample `i` of
|
|
62
|
-
* of
|
|
63
|
-
* sample of the next
|
|
61
|
+
* Sample `i` of trajectory `t` as the GPU draws revolution `revolution`, written at `out[o..o+2]`. It is the sample
|
|
62
|
+
* of revolution `revolution` itself, except for the closing sample of a revolution below the top, which is the first
|
|
63
|
+
* sample of the next revolution (rule `revolutions`).
|
|
64
64
|
*/
|
|
65
|
-
gpuSample(t: number,
|
|
65
|
+
gpuSample(t: number, revolution: number, i: number, out: {
|
|
66
66
|
[i: number]: number;
|
|
67
67
|
}, o?: number): void;
|
|
68
68
|
/**
|
|
69
|
-
* The bounding box of
|
|
69
|
+
* The bounding box of trajectory `t`, or of the whole set, over every revolution from 0 to the top, as
|
|
70
70
|
* minimum then maximum x, y, z.
|
|
71
71
|
*/
|
|
72
72
|
bounds(t?: number): Box6;
|
|
73
|
-
/** The position of a vertex of
|
|
73
|
+
/** The position of a vertex of trajectory `t` (rule `segment`) in its revolution, written at `out[o..o+2]`. */
|
|
74
74
|
vertex(t: number, v: Vertex, out: {
|
|
75
75
|
[i: number]: number;
|
|
76
76
|
}, o?: number): void;
|
|
77
77
|
}
|
|
78
|
-
/** The clock along every
|
|
79
|
-
export declare class
|
|
78
|
+
/** The clock along every trajectory of a set for one channel, with the reading u_i of every sample and one TrajectoryClock per trajectory. */
|
|
79
|
+
export declare class TrajectoryReadings {
|
|
80
80
|
readonly channel: string;
|
|
81
|
-
readonly clocks:
|
|
81
|
+
readonly clocks: TrajectoryClock[];
|
|
82
82
|
readonly u: Float64Array;
|
|
83
83
|
constructor(set: SetData, channel: string);
|
|
84
84
|
}
|
|
@@ -90,56 +90,59 @@ export declare class GeometryCache {
|
|
|
90
90
|
private readonly geometries;
|
|
91
91
|
private readonly readingsBy;
|
|
92
92
|
private readonly bodyTrails;
|
|
93
|
+
private readonly data;
|
|
93
94
|
constructor(scene: Scene, data: DataStore);
|
|
94
|
-
/**
|
|
95
|
-
|
|
95
|
+
/** The bytes of an array of `uint8` elements, e.g. the image file of a body. */
|
|
96
|
+
bytes(name: string): Uint8Array;
|
|
97
|
+
/** Throws an error of rule `revolutions` when the clock is in epoch mode but has revolutions. */
|
|
98
|
+
geometry(setId: string, frame: string): TrajectoryGeometry;
|
|
96
99
|
hasChannel(setId: string, channel: string): boolean;
|
|
97
|
-
/** Throws an error of rule
|
|
98
|
-
readings(setId: string, channel: string):
|
|
99
|
-
/** The positions of a body along one
|
|
100
|
-
bodyTrail(bodyId: string, display: string, setId: string,
|
|
100
|
+
/** Throws an error of rule `clock-channel-carried` when the set lacks the channel. */
|
|
101
|
+
readings(setId: string, channel: string): TrajectoryReadings;
|
|
102
|
+
/** The positions of a body along one reference trajectory in one display frame, kept per revolution. */
|
|
103
|
+
bodyTrail(bodyId: string, display: string, setId: string, trajectory: number): BodyTrailTable;
|
|
101
104
|
}
|
|
102
105
|
/**
|
|
103
|
-
* A channel of the
|
|
104
|
-
* reading is clamped to [0, 1], and the channel is blended between the samples of rule
|
|
105
|
-
* context of the
|
|
106
|
+
* A channel of the reference trajectory's trajectory at progress `q`, as a readout shows it (section 2.9). The
|
|
107
|
+
* reading is clamped to [0, 1], and the channel is blended between the samples of rule `segment` in the
|
|
108
|
+
* context of the reference trajectory's revolution of rule `revolutions`.
|
|
106
109
|
*/
|
|
107
|
-
export declare function channelAtReading(set: SetData, tc:
|
|
108
|
-
/** A range that does not contain any vertex, as [
|
|
110
|
+
export declare function channelAtReading(set: SetData, tc: TrajectoryClock, trajectory: number, channel: string, clock: Clock, q: number, hold?: boolean): number;
|
|
111
|
+
/** A range that does not contain any vertex, as [revolution, reading, revolution, reading] of its two ends. */
|
|
109
112
|
export declare const EMPTY_RANGE: readonly [number, number, number, number];
|
|
110
|
-
/** The range every sample of every
|
|
113
|
+
/** The range every sample of every revolution from 0 to `top` lies inside, closing samples included. */
|
|
111
114
|
export declare const fullRange: (top: number) => [number, number, number, number];
|
|
112
115
|
/** The part of a polyline the GPU draws and the pieces the CPU draws at its two ends. */
|
|
113
116
|
export interface LoopSpan {
|
|
114
|
-
/** The
|
|
117
|
+
/** The revolution and the within-revolution reading of each end for the GPU, [jA, uA, jB, uB], rounded as the GPU stores readings. */
|
|
115
118
|
range: [number, number, number, number];
|
|
116
|
-
/** The lowest and the highest
|
|
117
|
-
|
|
119
|
+
/** The lowest and the highest revolution whose pass draws a segment, or null when the GPU does not draw any segment. */
|
|
120
|
+
revolutions: [number, number] | null;
|
|
118
121
|
/** Segments the CPU draws, at the ends of the range. */
|
|
119
122
|
pieces: [Vertex, Vertex][];
|
|
120
123
|
}
|
|
121
124
|
/**
|
|
122
|
-
* Whether the GPU draws, in
|
|
125
|
+
* Whether the GPU draws, in revolution `revolution`, a segment whose samples read `ui` and `uj` (as stored),
|
|
123
126
|
* against a range of `LoopSpan.range`. Both ends must lie strictly inside the range in loop
|
|
124
|
-
* readings, compared
|
|
127
|
+
* readings, compared revolution first and reading second.
|
|
125
128
|
*/
|
|
126
|
-
export declare function segmentShown(range: readonly [number, number, number, number],
|
|
129
|
+
export declare function segmentShown(range: readonly [number, number, number, number], revolution: number, ui: number, uj: number): boolean;
|
|
127
130
|
/**
|
|
128
|
-
* The polyline of rules
|
|
129
|
-
* vertex is inside when its rounded reading in its
|
|
131
|
+
* The polyline of rules `polyline` and `revolutions` between loop readings `ua <= ub`, on a set of `revolutions` revolutions. A
|
|
132
|
+
* vertex is inside when its rounded reading in its revolution lies strictly inside the rounded range, as
|
|
130
133
|
* segmentShown tests it. With `round` the identity, the test selects the vertices of the
|
|
131
134
|
* evaluator's polyline. With Math.fround, it is the comparison a float32 GPU makes, so that the
|
|
132
135
|
* CPU's end pieces meet the GPU's segments at the same samples.
|
|
133
136
|
*/
|
|
134
|
-
export declare function loopSpan(tc:
|
|
137
|
+
export declare function loopSpan(tc: TrajectoryClock, ua: number, ub: number, revolutions: number, round?: (x: number) => number): LoopSpan;
|
|
135
138
|
export interface Reveal extends LoopSpan {
|
|
136
|
-
/** The
|
|
139
|
+
/** The trajectory is not drawn at this reading (rule `before-after`). */
|
|
137
140
|
hidden: boolean;
|
|
138
|
-
/** The
|
|
141
|
+
/** The trajectory's reading u, bounded by rule `before-after`, or null when the layer does not take a reading or the trajectory is hidden. */
|
|
139
142
|
reading: number | null;
|
|
140
|
-
/** The loop reading U = n u of rule
|
|
143
|
+
/** The loop reading U = n u of rule `revolutions`, null when `reading` is null. */
|
|
141
144
|
loop: number | null;
|
|
142
|
-
/** The point at the reading, i.e. the head of rule
|
|
145
|
+
/** The point at the reading, i.e. the head of rule `head`, when the layer draws a head and the trajectory is shown. */
|
|
143
146
|
head: Vertex | null;
|
|
144
147
|
}
|
|
145
148
|
export interface RevealSpec {
|
|
@@ -149,66 +152,66 @@ export interface RevealSpec {
|
|
|
149
152
|
after?: 'clamp' | 'hidden';
|
|
150
153
|
head: boolean;
|
|
151
154
|
periodic: boolean;
|
|
152
|
-
/** The number of
|
|
153
|
-
|
|
155
|
+
/** The number of revolutions n of rule `revolutions` on this set, taken from the clock for a periodic set and one otherwise. */
|
|
156
|
+
revolutions: number;
|
|
154
157
|
}
|
|
155
|
-
/** Whether a layer takes a reading on its
|
|
156
|
-
export declare function needsReading(layer:
|
|
157
|
-
export declare function revealSpec(layer:
|
|
158
|
+
/** Whether a layer takes a reading on its trajectories (rule `clock-channel-carried`), by the same test as the evaluator. */
|
|
159
|
+
export declare function needsReading(layer: TrajectoriesLayer, clock: Clock): boolean;
|
|
160
|
+
export declare function revealSpec(layer: TrajectoriesLayer, periodic: boolean, revolutions?: number): RevealSpec;
|
|
158
161
|
/**
|
|
159
|
-
* The revealed part of one
|
|
160
|
-
* `tc` is null only for a layer that does not take a reading, which shows every sample of every
|
|
162
|
+
* The revealed part of one trajectory at progress `q` (rules `clock-mode`, `before-after`, `revolutions`, `polyline`, `trail-wrap` and `head`). The trajectory clock
|
|
163
|
+
* `tc` is null only for a layer that does not take a reading, which shows every sample of every revolution.
|
|
161
164
|
*/
|
|
162
|
-
export declare function
|
|
163
|
-
/** The number of stored segments of a set, i.e. its number of samples minus its number of
|
|
165
|
+
export declare function revealTrajectory(tc: TrajectoryClock | null, clock: Clock, q: number, spec: RevealSpec, round?: (x: number) => number): Reveal;
|
|
166
|
+
/** The number of stored segments of a set, i.e. its number of samples minus its number of trajectories. */
|
|
164
167
|
export declare function segmentCount(set: SetData): number;
|
|
165
|
-
/** The index of the first segment of
|
|
168
|
+
/** The index of the first segment of trajectory `t`. */
|
|
166
169
|
export declare function firstSegment(set: SetData, t: number): number;
|
|
167
170
|
/** Per-sample values of width `k`, as two vertices per segment. */
|
|
168
171
|
export declare function pairs(set: SetData, values: ArrayLike<number>, k: number): Float32Array;
|
|
169
172
|
/** Per-sample values of width `k` of the `m` samples from `s` on, as two vertices per segment. */
|
|
170
173
|
export declare function slicePairs(values: ArrayLike<number>, k: number, s: number, m: number): Float32Array;
|
|
171
|
-
/** The positions of every segment of a set in
|
|
172
|
-
export declare function
|
|
173
|
-
/** The positions of the segments of
|
|
174
|
-
export declare function
|
|
175
|
-
/** The loop reading of a vertex, which is the reading u_i at a sample or the blended reading at a point, plus its
|
|
176
|
-
export declare function vertexReading(tc:
|
|
174
|
+
/** The positions of every segment of a set in revolution `revolution`, as two vertices per segment, joined to the next revolution below the top. */
|
|
175
|
+
export declare function revolutionPairs(g: TrajectoryGeometry, revolution: number): Float32Array;
|
|
176
|
+
/** The positions of the segments of trajectory `t` in revolution `revolution`, as revolutionPairs lays them out. */
|
|
177
|
+
export declare function trajectoryRevolutionPairs(g: TrajectoryGeometry, t: number, revolution: number): Float32Array;
|
|
178
|
+
/** The loop reading of a vertex, which is the reading u_i at a sample or the blended reading at a point, plus its revolution. */
|
|
179
|
+
export declare function vertexReading(tc: TrajectoryClock, v: Vertex): number;
|
|
177
180
|
/** The readings of a segment's two samples, (u_i, u_(i+1)), on both its vertices. */
|
|
178
181
|
export declare function pairReadings(set: SetData, u: Float64Array): Float32Array;
|
|
179
182
|
/** The readings of the `m` samples from `s` on, as pairReadings lays them out. */
|
|
180
183
|
export declare function readingPairs(u: ArrayLike<number>, s: number, m: number): Float32Array;
|
|
181
|
-
/** The
|
|
182
|
-
export declare function
|
|
184
|
+
/** The trajectory index of every vertex. */
|
|
185
|
+
export declare function pairTrajectories(set: SetData): Float32Array;
|
|
183
186
|
/**
|
|
184
|
-
* A body's position in one display frame in the context of each sample of one
|
|
185
|
-
* per
|
|
187
|
+
* A body's position in one display frame in the context of each sample of one reference trajectory,
|
|
188
|
+
* per revolution of rule `revolutions`, as x, y, z per sample. A revolution is filled the first time it is drawn and kept,
|
|
186
189
|
* so that a frame copies a trail instead of evaluating it. When neither the body's position nor an
|
|
187
|
-
* edge into the display frame reads a channel, every
|
|
190
|
+
* edge into the display frame reads a channel, every revolution has the positions of revolution 0.
|
|
188
191
|
*/
|
|
189
192
|
export declare class BodyTrailTable {
|
|
190
193
|
private readonly frames;
|
|
191
194
|
private readonly body;
|
|
192
195
|
private readonly display;
|
|
193
196
|
private readonly set;
|
|
194
|
-
private readonly
|
|
197
|
+
private readonly trajectory;
|
|
195
198
|
readonly m: number;
|
|
196
199
|
readonly invariant: boolean;
|
|
197
|
-
private readonly
|
|
198
|
-
constructor(frames: Frames, body: string, display: string, set: SetData,
|
|
199
|
-
/** The body's positions at every sample of
|
|
200
|
-
|
|
201
|
-
/** The position of a vertex (rule
|
|
200
|
+
private readonly revolutions;
|
|
201
|
+
constructor(frames: Frames, body: string, display: string, set: SetData, trajectory: number);
|
|
202
|
+
/** The body's positions at every sample of revolution `j`, each in the context of its sample. */
|
|
203
|
+
revolution(j: number): Float64Array;
|
|
204
|
+
/** The position of a vertex (rule `segment`) in its revolution, written at `out[o..o+2]`. */
|
|
202
205
|
vertex(v: Vertex, out: {
|
|
203
206
|
[i: number]: number;
|
|
204
207
|
}, o?: number): void;
|
|
205
208
|
/**
|
|
206
|
-
* The polyline of rules
|
|
209
|
+
* The polyline of rules `polyline` and `revolutions` between loop readings `ua <= ub`, with the same vertices as the
|
|
207
210
|
* evaluator's `loopPolyline`, written as x, y, z per vertex from `out[0]`. Returns the vertex
|
|
208
|
-
* count. The samples of a
|
|
211
|
+
* count. The samples of a revolution are copied as runs, and only the two ends are blended.
|
|
209
212
|
*/
|
|
210
|
-
polyline(tc:
|
|
213
|
+
polyline(tc: TrajectoryClock, ua: number, ub: number, revolutions: number, out: Float32Array): number;
|
|
211
214
|
}
|
|
212
|
-
/** The most vertices a trail of `fraction` of a loop of `
|
|
213
|
-
export declare function trailCapacity(m: number,
|
|
215
|
+
/** The most vertices a trail of `fraction` of a loop of `revolutions` revolutions over `m` samples can have. */
|
|
216
|
+
export declare function trailCapacity(m: number, revolutions: number, fraction: number): number;
|
|
214
217
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The icons of the viewer's controls, as inline SVG built with createElementNS from path strings, so that
|
|
3
3
|
* the browser neither parses markup nor fetches a file. The icons house, chevron-down, grip-vertical, x,
|
|
4
|
-
* rotate-ccw, plus, and download are taken from Lucide, on its 24 px grid with a 2 px
|
|
5
|
-
* are written as paths). The icons play and pause are drawn here on a 16 px grid and filled.
|
|
4
|
+
* rotate-ccw, undo and redo (here turnLeft and turnRight), plus, and download are taken from Lucide, on its 24 px grid with a 2 px
|
|
5
|
+
* stroke (the dots of grip-vertical are written as paths). The icons play and pause are drawn here on a 16 px grid and filled.
|
|
6
6
|
*/
|
|
7
7
|
export declare const GLYPHS: {
|
|
8
8
|
readonly house: {
|
|
@@ -30,6 +30,16 @@ export declare const GLYPHS: {
|
|
|
30
30
|
readonly fill: false;
|
|
31
31
|
readonly d: readonly ["M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", "M3 3v5h5"];
|
|
32
32
|
};
|
|
33
|
+
readonly turnLeft: {
|
|
34
|
+
readonly grid: 24;
|
|
35
|
+
readonly fill: false;
|
|
36
|
+
readonly d: readonly ["M3 7v6h6", "M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"];
|
|
37
|
+
};
|
|
38
|
+
readonly turnRight: {
|
|
39
|
+
readonly grid: 24;
|
|
40
|
+
readonly fill: false;
|
|
41
|
+
readonly d: readonly ["M21 7v6h-6", "M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"];
|
|
42
|
+
};
|
|
33
43
|
readonly plus: {
|
|
34
44
|
readonly grid: 24;
|
|
35
45
|
readonly fill: false;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The screen geometry of an inset box layer (rule `inset-box`), i.e. the corners of the target panel's visible rectangle on the host panel, widened to a
|
|
3
|
+
* minimum size, cut into dashes across the visible part of the panel, and laid out as triangles with mitered corners.
|
|
4
|
+
*/
|
|
5
|
+
type Vec2 = [number, number];
|
|
6
|
+
/**
|
|
7
|
+
* Corners in the order of a ring, stretched about their center along each screen axis on which they span less than `min` CSS pixels. The corners
|
|
8
|
+
* are those of a parallelogram, which is the image of a rectangle under the affine map from the target frame.
|
|
9
|
+
*/
|
|
10
|
+
export declare function widen(corners: [Vec2, Vec2, Vec2, Vec2], min: number): [Vec2, Vec2, Vec2, Vec2];
|
|
11
|
+
/**
|
|
12
|
+
* The polylines of a ring with the given corners in CSS pixels that are drawn on a panel of `w` by `h` pixels. They are one closed polyline when
|
|
13
|
+
* the whole ring is solid and within reach of the panel, and open polylines otherwise. A dash pattern of `dash` [on, off] pixels starts at the
|
|
14
|
+
* first corner and runs along the ring. Only the parts of the ring within a margin of the panel are laid out, hence a ring far larger than the
|
|
15
|
+
* panel is not cut into more dashes than the panel can show.
|
|
16
|
+
*/
|
|
17
|
+
export declare function outlinePaths(corners: Vec2[], w: number, h: number, dash?: [number, number]): {
|
|
18
|
+
closed: boolean;
|
|
19
|
+
paths: Vec2[][];
|
|
20
|
+
};
|
|
21
|
+
/** Appends to `out` the triangles, as x, y pairs in CSS pixels, of a line `width` pixels wide along `path`, with mitered joins and butt ends. */
|
|
22
|
+
export declare function strokeTriangles(path: Vec2[], closed: boolean, width: number, out?: number[]): number[];
|
|
23
|
+
/** The triangles, as x, y pairs in CSS pixels, of an outline with the given corners in pixels on a panel of `w` by `h` pixels. */
|
|
24
|
+
export declare function outlineTriangles(corners: [Vec2, Vec2, Vec2, Vec2], w: number, h: number, look: {
|
|
25
|
+
width: number;
|
|
26
|
+
minSize: number;
|
|
27
|
+
dash?: [number, number];
|
|
28
|
+
}): number[];
|
|
29
|
+
export {};
|
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
* What a panel shows over its drawing, as data: its text labels and its colorbars. The renderer
|
|
3
3
|
* computes them, the element writes them as DOM, and the video export draws them on a canvas.
|
|
4
4
|
*/
|
|
5
|
+
import type { TextRun } from './paint.js';
|
|
5
6
|
/**
|
|
6
7
|
* A text label over a panel, centered vertically on (x, y) in CSS pixels from the panel's corner.
|
|
7
8
|
* Its start sits at (x, y) by default, and its center or its end with `align` set to 'center' or
|
|
8
9
|
* 'end'. A rotated label reads upward, turned a quarter turn about (x, y).
|
|
9
10
|
*/
|
|
10
11
|
export interface PanelLabel {
|
|
11
|
-
text
|
|
12
|
+
/** The text, as a string or as runs with subscripts and superscripts. */
|
|
13
|
+
text: string | TextRun[];
|
|
12
14
|
x: number;
|
|
13
15
|
y: number;
|
|
14
16
|
align?: 'start' | 'center' | 'end';
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The 2D painting of markers, labels, the box of an axes layer, and the overlays. The page
|
|
3
|
+
* paints them onto a canvas over the panel area, and a video export onto each of its frames, with the same functions, so that a frame of a
|
|
4
|
+
* video shows what the page shows. Every text is canvas text, never markup (rule `plain-text`).
|
|
5
|
+
*/
|
|
6
|
+
import type { Box, LabelLayer, Marker, Overlay, Readout, Scene, State, StaticText } from '../scene.js';
|
|
7
|
+
import type { PanelAreaRenderer } from './renderer.js';
|
|
8
|
+
import { type Theme } from './colors.js';
|
|
9
|
+
import type { Rect } from './tiles.js';
|
|
10
|
+
export declare const FONT = "\"Helvetica Neue\", Arial, sans-serif";
|
|
11
|
+
export declare const LABEL_SIZE = 13;
|
|
12
|
+
export declare const TICK_SIZE = 12;
|
|
13
|
+
type G = CanvasRenderingContext2D;
|
|
14
|
+
/** Draws a marker of `shape`, `d` CSS pixels across, centered at (x, y). A ring, a cross, and a plus are stroked in `fill`. */
|
|
15
|
+
export declare function drawMarker(g: G, shape: string, x: number, y: number, d: number, fill: string | null, edge: string | null, edgeWidth: number): void;
|
|
16
|
+
/** The width of the stroke of a marker: its outline, or the line of a ring, a cross, or a plus. */
|
|
17
|
+
export declare function markerStroke(marker: Marker, size: number): number;
|
|
18
|
+
/**
|
|
19
|
+
* A square canvas holding a marker for the texture of a sprite of `size` plus its stroke CSS pixels across, drawn at `scale` texture
|
|
20
|
+
* pixels per CSS pixel. The shape is `size` across, and its stroke is centered on its outline, as matplotlib draws a marker's edge.
|
|
21
|
+
* Without a fill color, the shape is white, so that a sprite's vertex color tints it.
|
|
22
|
+
*/
|
|
23
|
+
export declare function markerCanvas(marker: Marker, size: number, scale?: number): HTMLCanvasElement;
|
|
24
|
+
/**
|
|
25
|
+
* The text metrics of matplotlib's layout, in units of the font size, which the labels, the overlays, the legends, and the boxes
|
|
26
|
+
* follow: a line's box is 0.984 tall with its baseline 0.227 above its bottom, and the lines of a text are 1.15 apart.
|
|
27
|
+
*/
|
|
28
|
+
export declare const TEXT_HEIGHT = 0.984;
|
|
29
|
+
export declare const TEXT_DESCENT = 0.227;
|
|
30
|
+
export declare const TEXT_ASCENT: number;
|
|
31
|
+
export declare const LINE_PITCH = 1.15;
|
|
32
|
+
export interface TextStyle {
|
|
33
|
+
size: number;
|
|
34
|
+
color: string;
|
|
35
|
+
weight: 'normal' | 'bold';
|
|
36
|
+
font: string;
|
|
37
|
+
align: 'start' | 'center' | 'end';
|
|
38
|
+
/** `alphabetic` puts the baseline of the last line at the anchor, as matplotlib's `va="baseline"` does. */
|
|
39
|
+
baseline: 'top' | 'middle' | 'bottom' | 'alphabetic';
|
|
40
|
+
opacity: number;
|
|
41
|
+
box?: Box;
|
|
42
|
+
/** The spacing of the lines, as matplotlib's `linespacing`, 1.2 by default. */
|
|
43
|
+
linespacing?: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The distance between the baselines of two lines of a text, in units of its size. Matplotlib puts each line's baseline its
|
|
47
|
+
* ascent times `linespacing` below the descent of the line before, hence the default pitch grows by the ascent per unit.
|
|
48
|
+
*/
|
|
49
|
+
export declare function linePitch(linespacing?: number): number;
|
|
50
|
+
/** A run of a text, set lowered and smaller as a subscript, raised and smaller as a superscript, or on the baseline (rule `timeline-parts`). */
|
|
51
|
+
export interface TextRun {
|
|
52
|
+
text: string;
|
|
53
|
+
shift?: 'sub' | 'sup';
|
|
54
|
+
}
|
|
55
|
+
/** A subscript or a superscript is set at this fraction of the size, lowered or raised by the fractions below, as mathtext sets them. */
|
|
56
|
+
export declare const SCRIPT_SIZE = 0.7;
|
|
57
|
+
export declare const SUB_DROP = 0.18;
|
|
58
|
+
export declare const SUP_RISE = 0.42;
|
|
59
|
+
/** The plain text of a text of runs. */
|
|
60
|
+
export declare const plainText: (text: string | TextRun[]) => string;
|
|
61
|
+
/** The rectangle a text of possibly several lines covers when drawn at (x, y) in `style`, as [left, top, width, height]. */
|
|
62
|
+
export declare function textRect(g: G, text: string | TextRun[], x: number, y: number, style: TextStyle): [number, number, number, number];
|
|
63
|
+
/** Draws a text of possibly several lines at (x, y), aligned by `style`, on its box when it has one. */
|
|
64
|
+
export declare function drawText(g: G, text: string | TextRun[], x: number, y: number, style: TextStyle): void;
|
|
65
|
+
/** The style of a label or a text overlay at time `s` of the timeline. */
|
|
66
|
+
export declare function styleOf(spec: Pick<LabelLayer, 'size' | 'color' | 'weight' | 'align' | 'baseline' | 'opacity' | 'box' | 'linespacing'>, theme: Theme, s: number): TextStyle;
|
|
67
|
+
/**
|
|
68
|
+
* Draws a label (rule `label`) whose anchor lies at (ax, ay), with its text `offset` pixels away and the leader between them. The leader
|
|
69
|
+
* runs from the anchor to the nearest point of the text's rectangle, and stops 3 pixels short of it.
|
|
70
|
+
*/
|
|
71
|
+
export declare function drawLabel(g: G, layer: LabelLayer, text: string | TextRun[], ax: number, ay: number, theme: Theme, s: number): void;
|
|
72
|
+
/** Ticks across [lo, hi] at the smallest round step of at least (hi - lo) / bins, as matplotlib's MaxNLocator picks them. */
|
|
73
|
+
export declare function boxTicks(lo: number, hi: number, bins: number): {
|
|
74
|
+
values: number[];
|
|
75
|
+
step: number;
|
|
76
|
+
};
|
|
77
|
+
/** A tick number with the decimals its step needs, and a true minus. */
|
|
78
|
+
export declare function tickLabel(v: number, step: number): string;
|
|
79
|
+
export interface BoxPaint {
|
|
80
|
+
/** The part of the panel the camera draws, in pixels of the panel area. */
|
|
81
|
+
rect: Rect;
|
|
82
|
+
/** The visible window along the camera's right and up axes. */
|
|
83
|
+
x0: number;
|
|
84
|
+
x1: number;
|
|
85
|
+
y0: number;
|
|
86
|
+
y1: number;
|
|
87
|
+
/** The axes that carry tick numbers. */
|
|
88
|
+
ticks: {
|
|
89
|
+
x: boolean;
|
|
90
|
+
y: boolean;
|
|
91
|
+
};
|
|
92
|
+
size: number;
|
|
93
|
+
/** The axis titles, the frame's or the axes layer's own, as text or as runs with subscripts. */
|
|
94
|
+
titles: [string | TextRun[], string | TextRun[]];
|
|
95
|
+
opacity: number;
|
|
96
|
+
}
|
|
97
|
+
/** Draws the box of an axes layer with `"span": "box"` around its rectangle, with ticks pointing out, tick numbers, and the axis titles. */
|
|
98
|
+
export declare function drawBox(g: G, b: BoxPaint, theme: Theme): void;
|
|
99
|
+
/** Draws a legend overlay on a panel area of `w` by `h` pixels. */
|
|
100
|
+
export declare function drawLegend(g: G, legend: Extract<Overlay, {
|
|
101
|
+
kind: 'legend';
|
|
102
|
+
}>, w: number, h: number, theme: Theme, s: number): void;
|
|
103
|
+
/** Covers a panel with the background at `1 - opacity`, which fades it as a whole. */
|
|
104
|
+
export declare function coverPanel(g: G, r: Rect, opacity: number, theme: Theme): void;
|
|
105
|
+
/** The gutter color of a video, the theme's or a blend of its foreground and background. */
|
|
106
|
+
export declare const gutterColor: (theme: Theme) => string;
|
|
107
|
+
/**
|
|
108
|
+
* Paints, for every panel of `state`, the cover of its opacity, the box of its axes layer, and its labels, and then the
|
|
109
|
+
* overlays of the scene, onto `g`, a 2D context in pixels of the panel area. `text` gives the text of a list of parts in a panel.
|
|
110
|
+
*/
|
|
111
|
+
export declare function paintPanelArea(g: CanvasRenderingContext2D, renderer: PanelAreaRenderer, scene: Scene, state: State, theme: Theme, q: number, w: number, h: number, text: (pid: string, parts: Readout['parts']) => string[]): void;
|
|
112
|
+
/** The runs of a text from its parts and the text of each part, a `sub` or a `sup` part set as a script (rule `timeline-parts`). */
|
|
113
|
+
export declare function runsOf(parts: Readout['parts'], pieces: string[]): TextRun[];
|
|
114
|
+
/** The runs of a static text, e.g. the label of a legend entry or an axis title of a frame (rule `timeline-parts`). */
|
|
115
|
+
export declare function staticRuns(label: StaticText): TextRun[];
|
|
116
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paints a laid-out element tree onto a 2D canvas, for a video frame that shows what the page shows. The browser lays the tree out,
|
|
3
|
+
* and `rasterize` draws every box, text run, and canvas where the layout put it, in the colors, fonts, and shadows of its computed
|
|
4
|
+
* style. The painter covers the CSS that the viewer uses over its panel area: background colors and linear gradients, solid borders (also
|
|
5
|
+
* a triangle made of borders), box and text shadows, opacity, overflow clipping, 2D transforms, absolutely positioned `::before` and
|
|
6
|
+
* `::after` boxes without text, and canvases. Boxes are painted in tree order, which is the order of their z-index in the viewer.
|
|
7
|
+
* Visibility is not read, since the tree is hidden while it is painted.
|
|
8
|
+
*/
|
|
9
|
+
type G = CanvasRenderingContext2D;
|
|
10
|
+
interface Shadow {
|
|
11
|
+
color: string;
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
blur: number;
|
|
15
|
+
spread: number;
|
|
16
|
+
inset: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** The shadows of a computed `text-shadow` or `box-shadow`, whose color Chrome writes first. Exported for the tests. */
|
|
19
|
+
export declare function parseShadows(s: string): Shadow[];
|
|
20
|
+
/**
|
|
21
|
+
* The direction and the stops of a computed `linear-gradient(...)`, or null for any other image. The direction is a unit vector in
|
|
22
|
+
* CSS pixels with y down, and each stop is a position in [0, 1] and a color. Exported for the tests.
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseGradient(s: string): {
|
|
25
|
+
dir: [number, number];
|
|
26
|
+
stops: [number, string][];
|
|
27
|
+
} | null;
|
|
28
|
+
/**
|
|
29
|
+
* Paints `root` and its descendants, inside its open shadow root too, onto `g`. The transform of `g` maps the CSS pixels of the
|
|
30
|
+
* root, from its top left corner, to the canvas.
|
|
31
|
+
*/
|
|
32
|
+
export declare function rasterize(g: G, root: HTMLElement): void;
|
|
33
|
+
export {};
|