cseen 0.0.0-stage → 0.2.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.
Files changed (139) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +169 -2
  3. package/dist/all.d.ts +9 -0
  4. package/dist/all.js +11 -0
  5. package/dist/all.js.map +1 -0
  6. package/dist/anim/mount.d.ts +69 -0
  7. package/dist/anim/mount.js +234 -0
  8. package/dist/anim/mount.js.map +1 -0
  9. package/dist/anim/orbit.d.ts +85 -0
  10. package/dist/anim/orbit.js +198 -0
  11. package/dist/anim/orbit.js.map +1 -0
  12. package/dist/anim/timeline.d.ts +287 -0
  13. package/dist/anim/timeline.js +379 -0
  14. package/dist/anim/timeline.js.map +1 -0
  15. package/dist/charts/charts.d.ts +216 -0
  16. package/dist/charts/charts.js +570 -0
  17. package/dist/charts/charts.js.map +1 -0
  18. package/dist/charts/index.d.ts +2 -0
  19. package/dist/charts/index.js +2 -0
  20. package/dist/charts/index.js.map +1 -0
  21. package/dist/construct/construct.d.ts +73 -0
  22. package/dist/construct/construct.js +96 -0
  23. package/dist/construct/construct.js.map +1 -0
  24. package/dist/construct/geom.d.ts +91 -0
  25. package/dist/construct/geom.js +118 -0
  26. package/dist/construct/geom.js.map +1 -0
  27. package/dist/core/animatable.d.ts +19 -0
  28. package/dist/core/animatable.js +41 -0
  29. package/dist/core/animatable.js.map +1 -0
  30. package/dist/core/camera.d.ts +48 -0
  31. package/dist/core/camera.js +95 -0
  32. package/dist/core/camera.js.map +1 -0
  33. package/dist/core/math.d.ts +39 -0
  34. package/dist/core/math.js +104 -0
  35. package/dist/core/math.js.map +1 -0
  36. package/dist/core/nodes.d.ts +387 -0
  37. package/dist/core/nodes.js +418 -0
  38. package/dist/core/nodes.js.map +1 -0
  39. package/dist/core/render.d.ts +98 -0
  40. package/dist/core/render.js +386 -0
  41. package/dist/core/render.js.map +1 -0
  42. package/dist/core/scene.d.ts +96 -0
  43. package/dist/core/scene.js +104 -0
  44. package/dist/core/scene.js.map +1 -0
  45. package/dist/core/sort.d.ts +40 -0
  46. package/dist/core/sort.js +181 -0
  47. package/dist/core/sort.js.map +1 -0
  48. package/dist/core/split.d.ts +47 -0
  49. package/dist/core/split.js +169 -0
  50. package/dist/core/split.js.map +1 -0
  51. package/dist/core/svg-import.d.ts +16 -0
  52. package/dist/core/svg-import.js +53 -0
  53. package/dist/core/svg-import.js.map +1 -0
  54. package/dist/cseen.css +106 -0
  55. package/dist/devices/devices.d.ts +307 -0
  56. package/dist/devices/devices.js +327 -0
  57. package/dist/devices/devices.js.map +1 -0
  58. package/dist/devices/index.d.ts +6 -0
  59. package/dist/devices/index.js +4 -0
  60. package/dist/devices/index.js.map +1 -0
  61. package/dist/devices/keyboard.d.ts +86 -0
  62. package/dist/devices/keyboard.js +186 -0
  63. package/dist/devices/keyboard.js.map +1 -0
  64. package/dist/devices/peripherals.d.ts +103 -0
  65. package/dist/devices/peripherals.js +171 -0
  66. package/dist/devices/peripherals.js.map +1 -0
  67. package/dist/draw/heads.d.ts +11 -0
  68. package/dist/draw/heads.js +26 -0
  69. package/dist/draw/heads.js.map +1 -0
  70. package/dist/draw/link.d.ts +76 -0
  71. package/dist/draw/link.js +102 -0
  72. package/dist/draw/link.js.map +1 -0
  73. package/dist/draw/overlap.d.ts +50 -0
  74. package/dist/draw/overlap.js +80 -0
  75. package/dist/draw/overlap.js.map +1 -0
  76. package/dist/draw/pen.d.ts +41 -0
  77. package/dist/draw/pen.js +57 -0
  78. package/dist/draw/pen.js.map +1 -0
  79. package/dist/draw/shapes.d.ts +206 -0
  80. package/dist/draw/shapes.js +225 -0
  81. package/dist/draw/shapes.js.map +1 -0
  82. package/dist/draw/svgplane.d.ts +74 -0
  83. package/dist/draw/svgplane.js +97 -0
  84. package/dist/draw/svgplane.js.map +1 -0
  85. package/dist/draw/text.d.ts +111 -0
  86. package/dist/draw/text.js +204 -0
  87. package/dist/draw/text.js.map +1 -0
  88. package/dist/draw/words.d.ts +29 -0
  89. package/dist/draw/words.js +30 -0
  90. package/dist/draw/words.js.map +1 -0
  91. package/dist/flow/flow.d.ts +206 -0
  92. package/dist/flow/flow.js +408 -0
  93. package/dist/flow/flow.js.map +1 -0
  94. package/dist/flow/index.d.ts +4 -0
  95. package/dist/flow/index.js +3 -0
  96. package/dist/flow/index.js.map +1 -0
  97. package/dist/flow/layout.d.ts +66 -0
  98. package/dist/flow/layout.js +353 -0
  99. package/dist/flow/layout.js.map +1 -0
  100. package/dist/flow/sequence.d.ts +114 -0
  101. package/dist/flow/sequence.js +309 -0
  102. package/dist/flow/sequence.js.map +1 -0
  103. package/dist/index.d.ts +30 -0
  104. package/dist/index.js +17 -0
  105. package/dist/index.js.map +1 -0
  106. package/dist/math/index.d.ts +2 -0
  107. package/dist/math/index.js +2 -0
  108. package/dist/math/index.js.map +1 -0
  109. package/dist/math/math.d.ts +238 -0
  110. package/dist/math/math.js +421 -0
  111. package/dist/math/math.js.map +1 -0
  112. package/dist/optics/index.d.ts +2 -0
  113. package/dist/optics/index.js +2 -0
  114. package/dist/optics/index.js.map +1 -0
  115. package/dist/optics/optics.d.ts +94 -0
  116. package/dist/optics/optics.js +173 -0
  117. package/dist/optics/optics.js.map +1 -0
  118. package/dist/ui/index.d.ts +2 -0
  119. package/dist/ui/index.js +2 -0
  120. package/dist/ui/index.js.map +1 -0
  121. package/dist/ui/ui.d.ts +166 -0
  122. package/dist/ui/ui.js +255 -0
  123. package/dist/ui/ui.js.map +1 -0
  124. package/dist/uml/factory.d.ts +15 -0
  125. package/dist/uml/factory.js +16 -0
  126. package/dist/uml/factory.js.map +1 -0
  127. package/dist/uml/index.d.ts +3 -0
  128. package/dist/uml/index.js +3 -0
  129. package/dist/uml/index.js.map +1 -0
  130. package/dist/uml/uml.d.ts +187 -0
  131. package/dist/uml/uml.js +599 -0
  132. package/dist/uml/uml.js.map +1 -0
  133. package/dist/waves/index.d.ts +2 -0
  134. package/dist/waves/index.js +2 -0
  135. package/dist/waves/index.js.map +1 -0
  136. package/dist/waves/waves.d.ts +93 -0
  137. package/dist/waves/waves.js +206 -0
  138. package/dist/waves/waves.js.map +1 -0
  139. package/package.json +85 -4
@@ -0,0 +1,379 @@
1
+ import { lerpValue } from "../core/animatable.js";
2
+ import { clamp } from "../core/math.js";
3
+ import { unionBounds } from "../core/render.js";
4
+ /** The named easing curves: `linear`, `in`, `out`, `inOut`, `smooth` and `back`. Each maps time 0 to 1 onto progress 0 to 1. */
5
+ export const ease = {
6
+ linear: (t) => t,
7
+ in: (t) => t * t * t,
8
+ out: (t) => 1 - (1 - t) ** 3,
9
+ inOut: (t) => (t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2),
10
+ smooth: (t) => t * t * (3 - 2 * t),
11
+ back: (t) => { const c = 1.70158, c3 = c + 1; return 1 + c3 * (t - 1) ** 3 + c * (t - 1) ** 2; },
12
+ };
13
+ /**
14
+ * Animate any properties of a node or camera: `tween(cube, { opacity: 0.2, pos: [1, 0, 0] })`.
15
+ *
16
+ * @example
17
+ * const s = new Scene({ fit: 'sphere' });
18
+ * s.add(ground());
19
+ * const b = s.add(box({ at: [-2, 0, 0], size: 1.2, role: 'accent' }));
20
+ *
21
+ * const tl = new Timeline();
22
+ * tl.play(tween(b, { pos: [2, 0, 0], rot: [0, 0, 90] }, { duration: 1.6, ease: 'inOut' }));
23
+ * tl.lockFit(s);
24
+ */
25
+ export function tween(target, to, o = {}) {
26
+ const e = typeof o.ease === 'function' ? o.ease : ease[o.ease ?? 'inOut'];
27
+ const delay = o.delay ?? 0, duration = o.duration ?? 1;
28
+ return { duration: delay + duration, tweens: [{ target, to, from: o.from, start: delay, duration, ease: e }] };
29
+ }
30
+ /**
31
+ * Fades a node in from invisible to its own opacity.
32
+ *
33
+ * @example
34
+ * const s = new Scene({ fit: 'sphere' });
35
+ * s.add(ground());
36
+ * const b = s.add(box({ at: [0, 0, 0], size: 1.5, role: 'accent' }));
37
+ *
38
+ * const tl = new Timeline();
39
+ * tl.play(fadeIn(b, 1));
40
+ * tl.lockFit(s);
41
+ */
42
+ export const fadeIn = (n, duration = 0.6) => tween(n, { opacity: n.props.opacity }, { duration, from: { opacity: 0 }, ease: 'out' });
43
+ /**
44
+ * Fades a node out to invisible.
45
+ *
46
+ * @example
47
+ * const s = new Scene({ fit: 'sphere' });
48
+ * s.add(ground());
49
+ * const b = s.add(box({ at: [0, 0, 0], size: 1.5, role: 'accent' }));
50
+ *
51
+ * const tl = new Timeline();
52
+ * tl.play(wait(0.5));
53
+ * tl.play(fadeOut(b, 1));
54
+ * tl.lockFit(s);
55
+ */
56
+ export const fadeOut = (n, duration = 0.6) => tween(n, { opacity: 0 }, { duration });
57
+ /**
58
+ * Draws a line, curve or outline on from its start to its end.
59
+ *
60
+ * @example
61
+ * const s = new Scene({ fit: 'sphere' });
62
+ * s.add(ground());
63
+ * const a = s.add(arrow([-3, 0, 0], [3, 0, 2], { role: 'accent' }));
64
+ *
65
+ * const tl = new Timeline();
66
+ * tl.play(draw(a, 1.2));
67
+ * tl.lockFit(s);
68
+ */
69
+ export const draw = (n, duration = 1) => tween(n, { draw: 1 }, { duration, from: { draw: 0 }, ease: 'inOut' });
70
+ /**
71
+ * Moves a node to a point.
72
+ *
73
+ * @example
74
+ * const s = new Scene({ fit: 'sphere' });
75
+ * s.add(ground());
76
+ * const b = s.add(box({ at: [-3, 0, 0], size: 1.2, role: 'accent' }));
77
+ *
78
+ * const tl = new Timeline();
79
+ * tl.play(moveTo(b, [3, 0, 0], 1.5));
80
+ * tl.lockFit(s);
81
+ */
82
+ export const moveTo = (n, pos, duration = 1, ease) => tween(n, { pos }, { duration, ease });
83
+ /**
84
+ * Moves a node by an offset from where it is when the animation starts.
85
+ *
86
+ * @example
87
+ * const s = new Scene({ fit: 'sphere' });
88
+ * s.add(ground());
89
+ * const b = s.add(box({ at: [-2, 0, 0], size: 1.2, role: 'accent' }));
90
+ *
91
+ * const tl = new Timeline();
92
+ * tl.play(moveBy(b, [4, 0, 0], 1.5));
93
+ * tl.lockFit(s);
94
+ */
95
+ export const moveBy = (n, by, duration = 1, ease) => tween(n, { pos: (c) => c.map((x, i) => x + by[i]) }, { duration, ease });
96
+ /**
97
+ * Rotates a node to Euler angles in degrees about x, y and z.
98
+ *
99
+ * @example
100
+ * const s = new Scene({ fit: 'sphere' });
101
+ * s.add(ground());
102
+ * const b = s.add(box({ at: [0, 0, 0], size: [2, 1, 1], role: 'accent' }));
103
+ *
104
+ * const tl = new Timeline();
105
+ * tl.play(rotateTo(b, [0, 0, 90], 1.5));
106
+ * tl.lockFit(s);
107
+ */
108
+ export const rotateTo = (n, rot, duration = 1) => tween(n, { rot }, { duration });
109
+ /**
110
+ * Scales a node to a factor.
111
+ *
112
+ * @example
113
+ * const s = new Scene({ fit: 'sphere' });
114
+ * s.add(ground());
115
+ * const b = s.add(box({ at: [0, 0, 0], size: 1, role: 'accent' }));
116
+ *
117
+ * const tl = new Timeline();
118
+ * tl.play(scaleTo(b, 2, 1.2));
119
+ * tl.lockFit(s);
120
+ */
121
+ export const scaleTo = (n, scale, duration = 1) => tween(n, { scale }, { duration });
122
+ /**
123
+ * Types text or code onto a plane letter by letter.
124
+ *
125
+ * @example
126
+ * const s = new Scene({ view: 'front' });
127
+ * const t = s.add(write('Typed, letter by letter.', { at: [-3, 0, 0], size: [6, 1], fontSize: 0.5 }));
128
+ *
129
+ * const tl = new Timeline();
130
+ * tl.play(typeOn(t, 2));
131
+ * tl.lockFit(s);
132
+ */
133
+ export const typeOn = (n, duration = 2) => tween(n, { type: 1 }, { duration, from: { type: 0 }, ease: 'linear' });
134
+ /**
135
+ * Does nothing for a while. Use it to leave a gap between two animations.
136
+ *
137
+ * @example
138
+ * const s = new Scene({ fit: 'sphere' });
139
+ * s.add(ground());
140
+ * const b = s.add(box({ at: [0, 0, 0], size: 1.2, role: 'accent' }));
141
+ *
142
+ * const tl = new Timeline();
143
+ * tl.play(wait(1)); // nothing happens for a second
144
+ * tl.play(moveBy(b, [2, 0, 0], 1));
145
+ * tl.lockFit(s);
146
+ */
147
+ export const wait = (duration) => ({ duration, tweens: [] });
148
+ /**
149
+ * Plays the animations one after another.
150
+ *
151
+ * @example
152
+ * const s = new Scene({ fit: 'sphere' });
153
+ * s.add(ground());
154
+ * const b = s.add(box({ at: [-2, 0, 0], size: 1.2, role: 'accent' }));
155
+ *
156
+ * const tl = new Timeline();
157
+ * tl.play(seq(moveBy(b, [4, 0, 0], 1), moveBy(b, [0, 3, 0], 1))); // one, then the other
158
+ * tl.lockFit(s);
159
+ */
160
+ export function seq(...anims) {
161
+ let t = 0;
162
+ const tweens = [];
163
+ for (const a of anims) {
164
+ for (const tw of a.tweens)
165
+ tweens.push({ ...tw, start: tw.start + t });
166
+ t += a.duration;
167
+ }
168
+ return { duration: t, tweens };
169
+ }
170
+ /**
171
+ * Plays the animations at the same time.
172
+ *
173
+ * @example
174
+ * const s = new Scene({ fit: 'sphere' });
175
+ * s.add(ground());
176
+ * const b = s.add(box({ at: [-2, 0, 0], size: 1.2, role: 'accent' }));
177
+ *
178
+ * const tl = new Timeline();
179
+ * tl.play(par(moveBy(b, [4, 0, 0], 1.5), rotateTo(b, [0, 0, 90], 1.5))); // both at once
180
+ * tl.lockFit(s);
181
+ */
182
+ export function par(...anims) {
183
+ return { duration: Math.max(0, ...anims.map((a) => a.duration)), tweens: anims.flatMap((a) => a.tweens) };
184
+ }
185
+ /**
186
+ * Starts each animation a little after the previous one.
187
+ *
188
+ * @example
189
+ * const s = new Scene({ fit: 'sphere' });
190
+ * s.add(ground());
191
+ * const boxes = [-3, -1, 1, 3].map((x) => s.add(box({ at: [x, 0, 0], size: 1 })));
192
+ *
193
+ * const tl = new Timeline();
194
+ * tl.play(stagger(0.25, ...boxes.map((b) => fadeIn(b, 0.6)))); // each starts a little after the last
195
+ * tl.lockFit(s);
196
+ */
197
+ export function stagger(gap, ...anims) {
198
+ return par(...anims.map((a, i) => seq(wait(gap * i), a)));
199
+ }
200
+ /**
201
+ * Plays an animation backwards: every tween runs from its end value to its start value, last one first.
202
+ * Each tween needs a literal `to` and a `from`, so there is something to return to. Put it after the
203
+ * animation to take a construction apart again, or to make a loop that ends where it began.
204
+ *
205
+ * @example
206
+ * const s = new Scene({ fit: 'sphere' });
207
+ * s.add(ground());
208
+ * const b = s.add(box({ at: [-3, 0, 0], size: 1.2, role: 'accent' }));
209
+ *
210
+ * const tl = new Timeline();
211
+ * const there = tween(b, { pos: [3, 0, 0] }, { duration: 1.5, from: { pos: [-3, 0, 0] } });
212
+ * tl.play(there);
213
+ * tl.play(reverse(there));
214
+ * tl.lockFit(s);
215
+ */
216
+ export function reverse(a) {
217
+ return {
218
+ duration: a.duration,
219
+ tweens: a.tweens.map((tw) => {
220
+ if (!tw.from)
221
+ throw new Error('cseen: reverse needs a "from" on every tween');
222
+ const to = {};
223
+ for (const k in tw.to) {
224
+ const v = tw.to[k];
225
+ if (typeof v === 'function')
226
+ throw new Error('cseen: reverse needs literal "to" values');
227
+ const f = tw.from[k];
228
+ if (f === undefined)
229
+ throw new Error(`cseen: reverse needs a "from" for "${k}"`);
230
+ to[k] = f;
231
+ }
232
+ const from = {};
233
+ for (const k in tw.to)
234
+ from[k] = tw.to[k];
235
+ const e = tw.ease;
236
+ return { ...tw, to, from, start: a.duration - tw.start - tw.duration, ease: (t) => 1 - e(1 - t) };
237
+ }),
238
+ };
239
+ }
240
+ /**
241
+ * A timeline is a list of tweens. `seek(t)` rewinds everything to its starting state and replays up
242
+ * to t, so the result depends only on t. Playing, scrubbing and rendering a still frame all work the same way.
243
+ *
244
+ * @example
245
+ * const s = new Scene({ fit: 'sphere' });
246
+ * s.add(ground());
247
+ * const b = s.add(box({ at: [0, 0, 0], size: 1.5, role: 'accent' }));
248
+ *
249
+ * const tl = new Timeline();
250
+ * tl.play(fadeIn(b, 1));
251
+ * tl.chapter('move').play(moveBy(b, [2, 0, 0], 1.2));
252
+ * tl.lockFit(s);
253
+ */
254
+ export class Timeline {
255
+ /** every tween, with start times on the timeline's clock */
256
+ tweens = [];
257
+ /** named marks, in the order made, for step buttons and captions */
258
+ chapters = [];
259
+ /** where the next `play` starts: the end of everything so far */
260
+ cursor = 0;
261
+ /** each animated object with its state before any tween ran, taken lazily and dropped whenever tweens are added */
262
+ bases = null;
263
+ /** appends an animation after everything so far */
264
+ play(a) {
265
+ for (const tw of a.tweens)
266
+ this.tweens.push({ ...tw, start: tw.start + this.cursor });
267
+ this.cursor += a.duration;
268
+ this.bases = null;
269
+ return this;
270
+ }
271
+ /** places an animation at an absolute time without moving the cursor */
272
+ at(time, a) {
273
+ for (const tw of a.tweens)
274
+ this.tweens.push({ ...tw, start: tw.start + time });
275
+ this.cursor = Math.max(this.cursor, time + a.duration);
276
+ this.bases = null;
277
+ return this;
278
+ }
279
+ /** leaves a gap: the next `play` starts `d` seconds later */
280
+ wait(d) { this.cursor += d; return this; }
281
+ /** marks the current time as a named step, for "next step" buttons and captions */
282
+ chapter(name) { this.chapters.push({ name, time: this.cursor }); return this; }
283
+ /** the length in seconds: where the cursor is, so a trailing `wait` counts */
284
+ get duration() { return this.cursor; }
285
+ /** remembers the starting state of every animated object, once */
286
+ init() {
287
+ if (this.bases)
288
+ return;
289
+ this.bases = [];
290
+ for (const tw of this.tweens)
291
+ if (!this.bases.some((b) => b.target === tw.target))
292
+ this.bases.push({ target: tw.target, snap: tw.target.snapshot() });
293
+ }
294
+ /** puts every animated object in the state it has at time `t` (seconds) */
295
+ seek(t) {
296
+ this.init();
297
+ for (const b of this.bases)
298
+ b.target.restore(b.snap);
299
+ const ordered = [...this.tweens].sort((a, b) => a.start - b.start);
300
+ // Things that fade in start hidden, from the very beginning: use the first `from` of each property.
301
+ const seen = new Set();
302
+ const key = (tw, k) => `${this.bases.findIndex((b) => b.target === tw.target)}:${k}`;
303
+ const first = new Set();
304
+ for (const tw of ordered)
305
+ if (tw.from)
306
+ for (const k in tw.from) {
307
+ const id = key(tw, k);
308
+ if (!seen.has(id)) {
309
+ seen.add(id);
310
+ tw.target.set(k, tw.from[k]);
311
+ first.add(tw);
312
+ }
313
+ }
314
+ for (const tw of ordered) {
315
+ if (t < tw.start)
316
+ continue;
317
+ if (tw.from && !first.has(tw))
318
+ for (const k in tw.from)
319
+ tw.target.set(k, tw.from[k]);
320
+ const p = tw.duration <= 0 ? 1 : clamp((t - tw.start) / tw.duration);
321
+ const e = p >= 1 ? 1 : tw.ease(p);
322
+ for (const k in tw.to) {
323
+ const cur = tw.target.get(k);
324
+ const raw = tw.to[k];
325
+ const to = typeof raw === 'function' ? raw(cur) : raw;
326
+ // Earlier tweens were replayed first, so `cur` is the value this tween starts from.
327
+ tw.target.set(k, e >= 1 ? to : lerpValue(cur, to, e));
328
+ }
329
+ }
330
+ }
331
+ /**
332
+ * Fixes the scene's framing to fit every moment of this timeline, so the picture does not
333
+ * shift as things move. Call it once after building the timeline.
334
+ */
335
+ lockFit(scene, samples = 24) {
336
+ samples = Math.max(1, Math.floor(samples)); // 0 would divide by zero
337
+ if (scene.fit === 'sphere')
338
+ return this.lockSphere(scene, samples);
339
+ let b = null;
340
+ for (let i = 0; i <= samples; i++) {
341
+ this.seek((this.duration * i) / samples);
342
+ b = unionBounds(b, scene.bounds());
343
+ }
344
+ this.seek(0);
345
+ if (b)
346
+ scene.lockTo(b);
347
+ return this;
348
+ }
349
+ /** For `fit: 'sphere'`: one sphere around the scene at every moment, so orbiting a moving scene does not make it breathe. */
350
+ lockSphere(scene, samples) {
351
+ scene.sphere = undefined;
352
+ const lo = [Infinity, Infinity, Infinity], hi = [-Infinity, -Infinity, -Infinity];
353
+ const boxes = [];
354
+ for (let i = 0; i <= samples; i++) {
355
+ this.seek((this.duration * i) / samples);
356
+ const b = scene.box();
357
+ if (!b)
358
+ continue;
359
+ boxes.push(b);
360
+ for (let k = 0; k < 3; k++) {
361
+ lo[k] = Math.min(lo[k], b.lo[k]);
362
+ hi[k] = Math.max(hi[k], b.hi[k]);
363
+ }
364
+ }
365
+ this.seek(0);
366
+ if (!boxes.length)
367
+ return this;
368
+ const c = [(lo[0] + hi[0]) / 2, (lo[1] + hi[1]) / 2, (lo[2] + hi[2]) / 2];
369
+ let r = 0;
370
+ for (const b of boxes)
371
+ for (const x of [b.lo[0], b.hi[0]])
372
+ for (const y of [b.lo[1], b.hi[1]])
373
+ for (const z of [b.lo[2], b.hi[2]])
374
+ r = Math.max(r, Math.hypot(x - c[0], y - c[1], z - c[2]));
375
+ scene.sphere = { c, r };
376
+ return this;
377
+ }
378
+ }
379
+ //# sourceMappingURL=timeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeline.js","sourceRoot":"","sources":["../../src/anim/timeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA+B,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,KAAK,EAAW,MAAM,iBAAiB,CAAC;AAGjD,OAAO,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAC;AAI7D,gIAAgI;AAChI,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChB,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IACpB,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;IAC5B,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,EAAE,CAAC,CAAC,EAAE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I,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7L,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,216 @@
1
+ import { SvgPlane, niceTicks, type SvgPlaneOpts } from '../draw/svgplane.ts';
2
+ export { niceTicks };
3
+ /** A named list of values, with an optional colour. */
4
+ export interface Series {
5
+ /** the name shown in the legend */
6
+ name: string;
7
+ /** one number per label */
8
+ values: number[];
9
+ /** a role (`accent`, `s3`) or any CSS colour */
10
+ color?: string;
11
+ }
12
+ /** Chart data after normalising: the labels along the axis and one series per colour. */
13
+ export interface Table {
14
+ /** the labels along the axis */
15
+ labels: string[];
16
+ /** one entry per colour */
17
+ series: Series[];
18
+ }
19
+ /** What `data` can be. Every form ends up as labels and series. */
20
+ export type ChartData = number[] | number[][] | Record<string, number[]> | {
21
+ labels?: string[];
22
+ series: Series[];
23
+ } | Array<{
24
+ label: string;
25
+ value: number;
26
+ }> | Array<[string, number]>;
27
+ /** A point of a scatter plot. */
28
+ export interface Point2 {
29
+ /** horizontal value */
30
+ x: number;
31
+ /** vertical value */
32
+ y: number;
33
+ /** size, for bubbles */
34
+ r?: number;
35
+ /** value that sets the colour */
36
+ v?: number;
37
+ /** series index or name */
38
+ s?: number | string;
39
+ }
40
+ /** The kinds of chart `chart` can draw. */
41
+ export type ChartType = 'bar' | 'line' | 'area' | 'scatter' | 'pie' | 'donut' | 'histogram' | 'heatmap' | 'radar' | 'sparkline';
42
+ /** Options of `chart` and of the named chart factories (`bars`, `lines`, `pie`, and so on). Which ones apply depends on the chart type. */
43
+ export interface ChartOpts extends SvgPlaneOpts {
44
+ /** which chart to draw, for `chart`; the named factories set it */
45
+ type?: ChartType;
46
+ /** bar, line, area, pie, donut, radar, sparkline */
47
+ data?: ChartData;
48
+ /** labels along the category axis */
49
+ labels?: string[];
50
+ /** scatter */
51
+ points?: Point2[];
52
+ /** histogram: the raw values, binned for you */
53
+ values?: number[];
54
+ /** histogram: number of bins */
55
+ bins?: number;
56
+ /** heatmap */
57
+ matrix?: number[][];
58
+ /** heatmap: label of each row */
59
+ rowLabels?: string[];
60
+ /** heatmap: label of each column */
61
+ colLabels?: string[];
62
+ /** text above the chart */
63
+ title?: string;
64
+ /** axes and grid: true, false, or pick parts */
65
+ axes?: boolean | {
66
+ x?: boolean;
67
+ y?: boolean;
68
+ grid?: boolean;
69
+ xLabel?: string;
70
+ yLabel?: string;
71
+ };
72
+ /** lowest value on the value axis */
73
+ yMin?: number;
74
+ /** highest value on the value axis */
75
+ yMax?: number;
76
+ /** bars: side by side (default) or stacked. Areas and lines: overlapping (default) or stacked. */
77
+ stack?: boolean;
78
+ /** stacked values as shares of 100% */
79
+ normalize?: boolean;
80
+ /** bars: run left to right instead of bottom to top */
81
+ horizontal?: boolean;
82
+ /** lines: how the points are joined */
83
+ curve?: 'linear' | 'smooth' | 'step';
84
+ /** lines: draw a dot at each point (default true) */
85
+ dots?: boolean;
86
+ /** lines: shade the area under each line */
87
+ fill?: boolean;
88
+ /** show the values on bars, slices, points and cells (true), or format them yourself */
89
+ labelValues?: boolean | ((v: number) => string);
90
+ /** where to put the legend, or `false` */
91
+ legend?: boolean | 'top' | 'bottom' | 'right';
92
+ /** how colours are chosen. See `palette` below. */
93
+ palette?: Palette;
94
+ /** series (or categories, for a single series) to show in the accent colour while the others fade to grey */
95
+ highlight?: number | string | Array<number | string>;
96
+ /** donut hole, as a fraction of the radius */
97
+ hole?: number;
98
+ /** scatter: biggest dot radius in svg units. Heatmap: draw the numbers. */
99
+ maxR?: number;
100
+ /** extra margin inside the chart, in world units */
101
+ pad?: number;
102
+ /** how to print a number on the axes and as a value label (`labelValues` as a function takes precedence) */
103
+ format?: (v: number) => string;
104
+ }
105
+ /**
106
+ * Where series colours come from. The default, 'categorical', walks through the theme's series colours
107
+ * (--c-s1 to --c-s8), which are derived from your accent. The others are built from the theme too, so no
108
+ * palette is tied to a particular look:
109
+ * 'categorical' distinct hues 'sequential' light to strong, one hue
110
+ * 'diverging' two hues around a quiet middle 'mono' the accent in steps
111
+ * or a list of roles and CSS colours, or a function (index, count) => colour.
112
+ */
113
+ export type Palette = 'categorical' | 'sequential' | 'diverging' | 'mono' | string[] | ((i: number, n: number) => string);
114
+ /** The name of the i-th series when you gave none, as a spreadsheet names columns: A to Z, then AA, AB and so on. */
115
+ export declare function seriesName(i: number): string;
116
+ /** The table behind any form of data: the labels along the axis and one series per colour. */
117
+ export declare function toTable(data: ChartData | undefined, labels?: string[]): Table;
118
+ /**
119
+ * A chart drawn on a plane in the scene: flat on the page, standing up, or on a screen (`device.put`). It takes the
120
+ * theme's colours and updates with them. `grow` (0 to 1) reveals it, and `data` (the numbers flattened) can be
121
+ * tweened to morph from one dataset to another: `tween(c, { data: c.flatten(next) })`.
122
+ */
123
+ export declare class Chart extends SvgPlane {
124
+ o: ChartOpts;
125
+ private table0;
126
+ private uid;
127
+ constructor(o?: ChartOpts);
128
+ /** all the numbers of a table in one list: what the `data` property holds, and what you tween to */
129
+ flatten(t: ChartData | Table): number[];
130
+ /** the current table: the original shape with the numbers from the `data` property, which may be mid-tween. A value that is not a finite number counts as 0, so one bad entry cannot spoil the whole drawing. */
131
+ table(): Table;
132
+ draw(W: number, H: number): string;
133
+ /** the id the line charts give their reveal clip path, unique to this chart. @internal */ get clipId(): string;
134
+ }
135
+ /** A chart. `chart({ type: 'bar', data: [3, 5, 2] })`, or use the shortcuts `bars`, `lines`, `pie`... */
136
+ export declare const chart: (o?: ChartOpts) => Chart;
137
+ /**
138
+ * A bar chart. `data` can be numbers, several series, label and value pairs, or a map of series.
139
+ *
140
+ * @example
141
+ * const s = new Scene({ view: 'front' });
142
+ * s.add(bars({ data: [12, 19, 7, 15, 22, 9], labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'], title: 'Signups', labelValues: true }));
143
+ */
144
+ export declare const bars: (o?: Omit<ChartOpts, "type">) => Chart;
145
+ /**
146
+ * A line chart. Several series are drawn together, joined linearly, smoothly or in steps.
147
+ *
148
+ * @example
149
+ * const s = new Scene({ view: 'front' });
150
+ * s.add(lines({ data: { Latency: [220, 180, 240, 190, 150, 170], Errors: [90, 110, 80, 60, 70, 40] }, curve: 'smooth' }));
151
+ */
152
+ export declare const lines: (o?: Omit<ChartOpts, "type">) => Chart;
153
+ /**
154
+ * An area chart: overlapping filled areas, or stacked with `stack: true`.
155
+ *
156
+ * @example
157
+ * const s = new Scene({ view: 'front' });
158
+ * s.add(areas({ data: { A: [3, 5, 4, 7, 6, 8], B: [2, 3, 5, 4, 6, 5] }, stack: true }));
159
+ */
160
+ export declare const areas: (o?: Omit<ChartOpts, "type">) => Chart;
161
+ /**
162
+ * A scatter plot. Points can carry a size `r` (bubbles), a value `v` for colour, and a series `s`.
163
+ *
164
+ * @example
165
+ * const s = new Scene({ view: 'front' });
166
+ * s.add(scatter({ points: [{ x: 1, y: 2 }, { x: 2, y: 3.5 }, { x: 3, y: 3 }, { x: 4, y: 5.2 }, { x: 5, y: 4.8 }], title: 'Scatter' }));
167
+ */
168
+ export declare const scatter: (o?: Omit<ChartOpts, "type">) => Chart;
169
+ /**
170
+ * A pie chart of the shares in `data`.
171
+ *
172
+ * @example
173
+ * const s = new Scene({ view: 'front' });
174
+ * s.add(pie({ data: [['Chrome', 62], ['Safari', 20], ['Firefox', 8], ['Other', 10]], labelValues: true, legend: 'right' }));
175
+ */
176
+ export declare const pie: (o?: Omit<ChartOpts, "type">) => Chart;
177
+ /**
178
+ * A pie with a hole. Takes the same options as `pie`.
179
+ *
180
+ * @example
181
+ * const s = new Scene({ view: 'front' });
182
+ * s.add(donut({ data: [['Done', 70], ['Open', 20], ['Blocked', 10]], labelValues: true }));
183
+ */
184
+ export declare const donut: (o?: Omit<ChartOpts, "type">) => Chart;
185
+ /**
186
+ * A histogram of raw `values`, binned into `bins` bars.
187
+ *
188
+ * @example
189
+ * const s = new Scene({ view: 'front' });
190
+ * s.add(histogram({ values: [1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5, 6, 7, 7, 8], bins: 6, title: 'Histogram' }));
191
+ */
192
+ export declare const histogram: (o?: Omit<ChartOpts, "type">) => Chart;
193
+ /**
194
+ * A matrix coloured through the theme's sequential ramp, or a diverging ramp for values around zero.
195
+ *
196
+ * @example
197
+ * const s = new Scene({ view: 'front' });
198
+ * s.add(heatmap({ matrix: [[1, 3, 5, 2], [4, 6, 9, 3], [7, 2, 4, 8]], rowLabels: ['Mon', 'Tue', 'Wed'], colLabels: ['9', '10', '11', '12'], labelValues: true }));
199
+ */
200
+ export declare const heatmap: (o?: Omit<ChartOpts, "type">) => Chart;
201
+ /**
202
+ * A radar chart: one spoke per label, one polygon per series.
203
+ *
204
+ * @example
205
+ * const s = new Scene({ view: 'front' });
206
+ * s.add(radar({ data: { Alpha: [8, 6, 7, 5, 9], Beta: [5, 8, 4, 9, 6] }, labels: ['A', 'B', 'C', 'D', 'E'] }));
207
+ */
208
+ export declare const radar: (o?: Omit<ChartOpts, "type">) => Chart;
209
+ /**
210
+ * A small line chart with no axes, the size of a word.
211
+ *
212
+ * @example
213
+ * const s = new Scene({ view: 'front' });
214
+ * s.add(sparkline({ data: [3, 5, 4, 8, 6, 9, 7, 11], size: [4, 1.4] }));
215
+ */
216
+ export declare const sparkline: (o?: Omit<ChartOpts, "type">) => Chart;