vizmatic 0.4.0 → 0.6.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 (149) hide show
  1. package/PROMPT.md +75 -531
  2. package/README.md +85 -1052
  3. package/ROADMAP.md +49 -67
  4. package/SCIENCE.md +250 -0
  5. package/assets/THIRD_PARTY_LICENSES.md +44 -1
  6. package/assets/fonts/InstrumentSerif-Italic.ttf +0 -0
  7. package/assets/fonts/InstrumentSerif-Regular.ttf +0 -0
  8. package/assets/fonts/SourceSerif4-24pt-Italic.ttf +0 -0
  9. package/assets/fonts/SourceSerif4-24pt-Regular.ttf +0 -0
  10. package/assets/licenses/raster-codecs-MIT.txt +74 -0
  11. package/dist/chunk-3F2VQ7NW.js +1 -0
  12. package/dist/{chunk-FEIPTPBZ.js → chunk-4XE64I2U.js} +53 -463
  13. package/dist/chunk-5ZAFH2JC.js +4231 -0
  14. package/dist/chunk-JHHPLALU.js +79 -0
  15. package/dist/chunk-LTX44BAE.js +112 -0
  16. package/dist/chunk-MLKGABMK.js +9 -0
  17. package/dist/chunk-PSBF4TEK.js +1 -0
  18. package/dist/chunk-RPAHMKAR.js +605 -0
  19. package/dist/chunk-RWF4VBUL.js +3617 -0
  20. package/dist/cli.js +369 -12
  21. package/dist/index.cjs +7413 -1810
  22. package/dist/index.d.cts +900 -599
  23. package/dist/index.d.ts +900 -599
  24. package/dist/index.js +5019 -3278
  25. package/dist/math-LXB4FH4E.js +7 -0
  26. package/dist/math-QVCETQDQ.js +1 -0
  27. package/dist/scene-browser-assets.d.ts +38 -0
  28. package/dist/scene-browser-assets.js +53 -0
  29. package/dist/scene-browser-chunks/chunk-5MVLYGXM.js +70 -0
  30. package/dist/scene-browser-chunks/chunk-ASXKN3NU.js +1 -0
  31. package/dist/scene-browser-chunks/chunk-CM5Y5LZP.js +1 -0
  32. package/dist/scene-browser-chunks/chunk-DP7NB4EW.js +6 -0
  33. package/dist/scene-browser-chunks/emscripten-module.browser-M5AEKJGE.js +1 -0
  34. package/dist/scene-browser-chunks/ffi-FL6ORJU3.js +1 -0
  35. package/dist/scene-browser-chunks/module-ES6BEMUI-JD5S5VKR.js +1 -0
  36. package/dist/scene-browser-chunks/module-asyncify-2EFITU5U-HWPFJFJC.js +1 -0
  37. package/dist/scene-browser-chunks/scene-browser-layout-M3XSXMV4.js +27 -0
  38. package/dist/scene-browser.d.ts +117 -0
  39. package/dist/scene-browser.js +220 -0
  40. package/dist/scene-cli.js +1 -1
  41. package/dist/scene-runtime.cjs +168 -103
  42. package/dist/scene-runtime.d.cts +3 -2
  43. package/dist/scene-runtime.d.ts +3 -2
  44. package/dist/scene-runtime.js +3 -1
  45. package/dist/server-2FYHZ4UO.js +331 -0
  46. package/dist/stage-browser/browser.d.ts +2483 -0
  47. package/dist/stage-browser/chunk-SQE76S5B.js +1 -0
  48. package/dist/stage-browser/chunk-VZNL6JY2.js +59 -0
  49. package/dist/stage-browser/dagre.esm-N2NIVIAZ.js +6 -0
  50. package/dist/stage-browser/math-4WFNHVV2.js +18 -0
  51. package/dist/stage-browser/stage.js +19 -0
  52. package/dist/stage-export.cjs +4980 -0
  53. package/dist/stage-export.d.cts +112 -0
  54. package/dist/stage-export.d.ts +112 -0
  55. package/dist/stage-export.js +544 -0
  56. package/dist/stage.cjs +9789 -0
  57. package/dist/stage.d.cts +1679 -0
  58. package/dist/stage.d.ts +1679 -0
  59. package/dist/stage.js +5418 -0
  60. package/dist/svg-import-Djj2q7Pc.d.cts +742 -0
  61. package/dist/svg-import-Djj2q7Pc.d.ts +742 -0
  62. package/dist/video-CcHW1qhV.d.cts +532 -0
  63. package/dist/video-CcHW1qhV.d.ts +532 -0
  64. package/examples/README.md +18 -0
  65. package/examples/agent-pipeline.tsx +4 -4
  66. package/examples/animated-pipeline.tsx +1 -5
  67. package/examples/attention-head.tsx +12 -12
  68. package/examples/aurora-incident.tsx +4 -3
  69. package/examples/building-blocks.tsx +8 -9
  70. package/examples/catalog-charts.tsx +4 -4
  71. package/examples/catalog-content.tsx +7 -9
  72. package/examples/catalog-convolution-kernel.tsx +116 -0
  73. package/examples/catalog-data.tsx +2 -8
  74. package/examples/catalog-dataflow.tsx +5 -9
  75. package/examples/catalog-dense.tsx +80 -0
  76. package/examples/catalog-deployment.tsx +5 -11
  77. package/examples/catalog-diagrams.tsx +13 -16
  78. package/examples/catalog-drawing.tsx +7 -7
  79. package/examples/catalog-flows.tsx +4 -4
  80. package/examples/catalog-foundations.tsx +11 -11
  81. package/examples/catalog-gaussian-blur.tsx +146 -0
  82. package/examples/catalog-image-tensors.tsx +115 -0
  83. package/examples/catalog-ml.tsx +36 -31
  84. package/examples/catalog-numeric-matrices.tsx +93 -0
  85. package/examples/catalog-photo-blur.tsx +209 -0
  86. package/examples/catalog-science-ai.tsx +130 -0
  87. package/examples/catalog-science-chemistry.tsx +103 -0
  88. package/examples/catalog-science-math.tsx +93 -0
  89. package/examples/catalog-science-physics.tsx +84 -0
  90. package/examples/catalog-sequence.tsx +59 -38
  91. package/examples/data-pipeline-lineage-presentation.tsx +5 -0
  92. package/examples/data-pipeline-lineage.tsx +85 -0
  93. package/examples/daybreak-launch.tsx +1 -0
  94. package/examples/desired-quadrant.tsx +7 -8
  95. package/examples/engineering-dashboard-presentation.tsx +13 -0
  96. package/examples/engineering-dashboard.tsx +160 -0
  97. package/examples/engineering-flow.tsx +2 -4
  98. package/examples/eval-dashboard.tsx +6 -6
  99. package/examples/films/attention.ts +278 -0
  100. package/examples/films/cache-miss.ts +431 -0
  101. package/examples/films/catalog.json +132 -0
  102. package/examples/films/central-limit.ts +269 -0
  103. package/examples/films/complex-maps.ts +273 -0
  104. package/examples/films/deck-example.ts +224 -0
  105. package/examples/films/euler-circle.ts +179 -0
  106. package/examples/films/fourier-epicycles.ts +265 -0
  107. package/examples/films/gradient-descent.ts +345 -0
  108. package/examples/films/linear-maps.ts +175 -0
  109. package/examples/films/lorenz.ts +207 -0
  110. package/examples/films/pythagoras.ts +185 -0
  111. package/examples/films/taylor-series.ts +159 -0
  112. package/examples/films/vizmatic-title.ts +117 -0
  113. package/examples/llm-serving-stack-presentation.tsx +5 -0
  114. package/examples/llm-serving-stack.tsx +94 -0
  115. package/examples/model-garden.tsx +1 -0
  116. package/examples/model-router.tsx +6 -6
  117. package/examples/nccl-all-gather.tsx +3 -3
  118. package/examples/nccl-all-reduce.tsx +3 -3
  119. package/examples/nccl-all-to-all.tsx +1 -1
  120. package/examples/nccl-broadcast.tsx +1 -1
  121. package/examples/nccl-reduce-scatter.tsx +5 -5
  122. package/examples/orthogonal-routing.tsx +4 -4
  123. package/examples/pareto-frontier.tsx +9 -10
  124. package/examples/presentation-frame.tsx +6 -6
  125. package/examples/production-system-map-presentation.tsx +5 -0
  126. package/examples/production-system-map.tsx +130 -0
  127. package/examples/rag-graph.tsx +7 -7
  128. package/examples/release-card.tsx +5 -5
  129. package/examples/spec-anatomy.tsx +5 -5
  130. package/examples/system-architecture.tsx +19 -32
  131. package/examples/theme-system.tsx +1 -1
  132. package/examples/token-matrix.tsx +4 -2
  133. package/examples/transparent-badge.tsx +1 -2
  134. package/examples/videos/README.md +36 -2
  135. package/examples/videos/calculus-tangent.tsx +101 -0
  136. package/examples/videos/catalyst-pathway.tsx +56 -0
  137. package/examples/videos/causal-attention.tsx +91 -0
  138. package/examples/videos/convolution-kernel.tsx +34 -0
  139. package/examples/videos/gaussian-blur.tsx +32 -0
  140. package/examples/videos/image-to-matrix.tsx +22 -0
  141. package/examples/videos/matrix-multiplication.tsx +128 -0
  142. package/examples/videos/photo-gaussian-blur.tsx +39 -0
  143. package/examples/videos/wave-interference.tsx +80 -0
  144. package/examples/vizmatic-bare.d.ts +1 -0
  145. package/examples/vizmatic-hero.tsx +9 -18
  146. package/examples/website-workflow.tsx +7 -7
  147. package/examples/weekend-field-notes.tsx +3 -2
  148. package/package.json +65 -11
  149. package/dist/chunk-TH3F4SDB.js +0 -79
@@ -0,0 +1,1679 @@
1
+ import { P as Path, N as Node, c as ColorInput, V as Vec, C as CompileOverrides, B as Bounds, b as FilmDefinition, a as CompiledFilm, d as Side, A as AnimOptions, e as Anim, f as Value, R as Rgba, E as Edge, T as Target, g as PathOp, M as Mat } from './svg-import-Djj2q7Pc.js';
2
+ export { h as AnimContext, i as Aspect, j as BlendMode, k as Canvas2D, l as Caption, m as Chapter, n as Clip, D as DrawOp, o as EMPTY_BOUNDS, p as Ease, q as FadeOptions, r as FilmOptions, s as Frame, F as FromSvgOptions, G as Gradient, I as IDENTITY, t as ImageOp, L as LOOKS, u as Look, v as LookName, w as LookToken, x as NodeProps, y as Paint, z as PlayOptions, H as PropName, J as Ring, K as Stage, O as StageImage, Q as Suspend, S as SvgNode, U as along, W as appear, X as apply, Y as applyMatrix, Z as arcPath, _ as blueprint, $ as bounce, a0 as buildOps, a1 as call, a2 as chalk, a3 as circlePath, a4 as circumscribe, a5 as colorAlong, a6 as compileFilm, a7 as compose, a8 as concat, a9 as css, aa as cubicBezier, ab as curveThrough, ac as delay, ad as draw, ae as during, af as dynamic, ag as easeInCubic, ah as easeInExpo, ai as easeInOutCubic, aj as easeInOutQuint, ak as easeInQuad, al as easeOutCubic, am as easeOutExpo, an as easeOutQuad, ao as easeOutQuint, ap as erase, aq as fade, ar as fadeIn, as as fadeOut, at as film, au as flash, av as frameInkBounds, aw as frameToSvg, ax as fromSvg, ay as group, az as grow, aA as indicate, aB as invert, aC as isFilm, aD as isSuspend, aE as lagged, aF as linePath, aG as linear, aH as linearGradient, aI as lingering, aJ as matScale, aK as midnight, aL as mixColor, aM as morph, aN as morphMatching, aO as moveTo, aP as mul, aQ as neon, aR as notQuiteThere, aS as overshoot, aT as paintFrame, aU as paper, aV as par, aW as parametricPath, aX as parseColor, aY as parseSvgPath, aZ as pathBounds, a_ as pathLength, a$ as pathToD, b0 as pointAt, b1 as polyPath, b2 as pulse, b3 as radialGradient, b4 as ramp, b5 as recolor, b6 as rectPath, b7 as resolveLook, b8 as retime, b9 as reverseRing, ba as ring, bb as ringCenter, bc as ringLength, bd as ripple, be as rotate, bf as runningStart, bg as rushFrom, bh as rushInto, bi as scaleBy, bj as segmentCount, bk as seq, bl as shake, bm as shift, bn as signedArea, bo as slowInto, bp as smooth, bq as smoothBy, br as smoothPath, bs as smoother, bt as spring, bu as subdivideEach, bv as tangentAt, bw as thereAndBack, bx as thereAndBackWithPause, by as to, bz as toPaint, bA as transformPath, bB as trimPath, bC as trimRing, bD as unionBounds, bE as vanish, bF as warp, bG as warpPath, bH as wiggle, bI as write } from './svg-import-Djj2q7Pc.js';
3
+
4
+ interface GlyphOutline {
5
+ /** Each contour is a closed cubic ring in font units, with y pointing up. */
6
+ readonly contours: readonly number[][];
7
+ }
8
+ interface LoadedFont {
9
+ readonly unitsPerEm: number;
10
+ readonly ascent: number;
11
+ readonly descent: number;
12
+ readonly lineGap: number;
13
+ glyphFor(code: number): number;
14
+ advance(glyph: number): number;
15
+ kern(left: number, right: number): number;
16
+ outline(glyph: number): GlyphOutline | null;
17
+ }
18
+
19
+ declare function parseFont(bytes: ArrayBuffer): LoadedFont;
20
+ type FontFamily = 'sans' | 'serif' | 'text-serif' | 'mono' | 'noto';
21
+ type FontWeight = 400 | 600 | 700;
22
+ type BundledFamily = FontFamily | 'math';
23
+ /** Get a font now, or suspend the current compile until it arrives. */
24
+ declare function fontFor(family: BundledFamily, weight?: FontWeight, italic?: boolean): LoadedFont;
25
+ /** Glyph outline scaled to a pixel size, with y pointing down and the origin on the baseline. */
26
+ declare function glyphPath(font: LoadedFont, glyph: number, size: number): Path;
27
+
28
+ interface TextOptions {
29
+ size?: number;
30
+ font?: FontFamily;
31
+ weight?: FontWeight;
32
+ italic?: boolean;
33
+ color?: ColorInput;
34
+ /** Line alignment inside the block. */
35
+ align?: 'left' | 'center' | 'right';
36
+ /** Wrap to this width, in stage pixels. */
37
+ maxWidth?: number;
38
+ /** Line height as a multiple of size. */
39
+ leading?: number;
40
+ /** Extra space between letters, as a fraction of size. */
41
+ tracking?: number;
42
+ uppercase?: boolean;
43
+ }
44
+ /**
45
+ * A line or block of text as real vector glyphs. Each glyph is its own child, so
46
+ * text can be handwritten, staggered, or morphed. `.chars` lists them in order.
47
+ */
48
+ declare class TextNode extends Node {
49
+ readonly chars: Node[];
50
+ source: string;
51
+ /** Glyph nodes whose characters match, such as every "x". */
52
+ find(fragment: string): Node[];
53
+ }
54
+ declare function text(content: string, options?: TextOptions): TextNode;
55
+
56
+ interface TexOptions {
57
+ size?: number;
58
+ color?: ColorInput;
59
+ display?: boolean;
60
+ }
61
+ /** Typeset equation as glyph nodes. Ordinary characters keep their identity for morphs. */
62
+ declare class TexNode extends Node {
63
+ readonly glyphs: Node[];
64
+ source: string;
65
+ /** Glyphs matching a TeX fragment, such as eq.part('b^2'). Use it to color or morph a term. */
66
+ part(fragment: string): Node[];
67
+ /** Every occurrence of a fragment, in order. */
68
+ parts(fragment: string): Node[][];
69
+ }
70
+ /** Typeset TeX with real math glyphs. `tex.part('x^2')` selects a term for color or morphing. */
71
+ declare function tex(source: string, options?: TexOptions): TexNode;
72
+
73
+ /** Tell the browser build where fonts live. The URL must end with a slash. */
74
+ declare function setAssetBase(url: string): void;
75
+
76
+ interface ShapeStyle {
77
+ fill?: ColorInput | null;
78
+ stroke?: ColorInput | null;
79
+ width?: number;
80
+ opacity?: number;
81
+ glow?: number;
82
+ dash?: readonly number[];
83
+ z?: number;
84
+ }
85
+ /** Wrap any path as a stroked shape in the default ink. */
86
+ declare function shape(path: Path, style?: ShapeStyle): Node;
87
+ declare function svgPath(d: string, style?: ShapeStyle): Node;
88
+ declare function line(a: Vec, b: Vec, style?: ShapeStyle): Node;
89
+ declare function polyline(points: readonly Vec[], style?: ShapeStyle & {
90
+ closed?: boolean;
91
+ }): Node;
92
+ /** A smooth curve through points. Non-finite points leave gaps. */
93
+ declare function curve(points: readonly Vec[], style?: ShapeStyle & {
94
+ closed?: boolean;
95
+ }): Node;
96
+ declare function parametric(f: (t: number) => Vec, from: number, to: number, style?: ShapeStyle & {
97
+ samples?: number;
98
+ }): Node;
99
+ declare function circle(radius: number, style?: ShapeStyle): Node;
100
+ declare function ellipse(rx: number, ry: number, style?: ShapeStyle): Node;
101
+ declare function arc(radius: number, from: number, to: number, style?: ShapeStyle): Node;
102
+ declare function rect(width: number, height: number, style?: ShapeStyle & {
103
+ radius?: number;
104
+ }): Node;
105
+ declare function polygon(points: readonly Vec[], style?: ShapeStyle): Node;
106
+ declare function regularPolygon(sides: number, radius: number, style?: ShapeStyle): Node;
107
+ /** A filled point. */
108
+ declare function dot(radius?: number, color?: ColorInput, style?: ShapeStyle): Node;
109
+ interface ArrowStyle extends ShapeStyle {
110
+ /** Tip length in pixels. */
111
+ tip?: number;
112
+ /** Tip width relative to its length. */
113
+ tipRatio?: number;
114
+ /** Curve the shaft: positive bends left of the direction of travel. */
115
+ bend?: number;
116
+ /** Space left at each end, so arrows stop short of what they point at. */
117
+ pad?: number;
118
+ both?: boolean;
119
+ }
120
+ /**
121
+ * A shaft and a clean tip as one group. The shaft ends at the tip's base, so a
122
+ * thick line never pokes through the point.
123
+ */
124
+ declare function arrow(from: Vec, to: Vec, style?: ArrowStyle): Node;
125
+ /** Curly brace beside a span of two points, pointing out to one side. */
126
+ declare function brace(from: Vec, to: Vec, style?: ShapeStyle & {
127
+ depth?: number;
128
+ }): Node;
129
+
130
+ interface AxesOptions {
131
+ /** Math range on the x axis. */
132
+ x?: readonly [number, number];
133
+ y?: readonly [number, number];
134
+ /** On-screen size in stage pixels. */
135
+ width?: number;
136
+ height?: number;
137
+ xStep?: number;
138
+ yStep?: number;
139
+ color?: ColorInput;
140
+ /** Number labels on ticks. */
141
+ labels?: boolean;
142
+ labelSize?: number;
143
+ /** Faint background grid. */
144
+ grid?: boolean;
145
+ xLabel?: string;
146
+ yLabel?: string;
147
+ tips?: boolean;
148
+ }
149
+ /**
150
+ * Coordinate axes. `.p(x, y)` converts math coordinates to stage points in this
151
+ * group's local space, and `.plot(f)` draws a function on them.
152
+ */
153
+ declare class Axes extends Node {
154
+ readonly xRange: readonly [number, number];
155
+ readonly yRange: readonly [number, number];
156
+ readonly plotWidth: number;
157
+ readonly plotHeight: number;
158
+ /** Lines and ticks, for drawing in on their own. */
159
+ readonly lines: Node;
160
+ readonly grid: Node;
161
+ readonly numbers: Node;
162
+ constructor(options?: AxesOptions);
163
+ /** Math coordinates to this group's local stage coordinates. */
164
+ p(x: number, y: number): [number, number];
165
+ /** Math coordinates to stage coordinates, following this group's transform. */
166
+ world(x: number, y: number): [number, number];
167
+ /** Geometry of a function over a range, clipped to the visible y range. */
168
+ plotPath(f: (x: number) => number, options?: {
169
+ from?: number;
170
+ to?: number;
171
+ samples?: number;
172
+ }): Path;
173
+ /** Draw a function on the axes. The curve becomes a child, so it moves with them. */
174
+ plot(f: (x: number) => number, style?: ShapeStyle & {
175
+ from?: number;
176
+ to?: number;
177
+ samples?: number;
178
+ }): Node;
179
+ /** A point on the axes. */
180
+ dotAt(x: number, y: number, color?: ColorInput, radius?: number): Node;
181
+ /** Dashed guides from a point down to both axes. */
182
+ guides(x: number, y: number, style?: ShapeStyle): Node;
183
+ }
184
+ declare function axes(options?: AxesOptions): Axes;
185
+ interface PlaneOptions {
186
+ /** Stage pixels per math unit. */
187
+ unit?: number;
188
+ /** Extent in math units. Defaults to overscan past the frame edges, for warps that pull in. */
189
+ x?: readonly [number, number];
190
+ y?: readonly [number, number];
191
+ color?: ColorInput;
192
+ /** Minor grid lines per unit. */
193
+ minor?: number;
194
+ axisColor?: ColorInput;
195
+ width?: number;
196
+ }
197
+ /**
198
+ * The classic infinite grid. Each line is a dense path, so it bends smoothly
199
+ * under `applyMatrix` and under `warp` with a nonlinear function.
200
+ */
201
+ declare class NumberPlane extends Node {
202
+ readonly unit: number;
203
+ readonly major: Node;
204
+ readonly minor: Node;
205
+ readonly axes: Node;
206
+ constructor(options?: PlaneOptions);
207
+ /** Math coordinates to stage coordinates. y points up on the plane. */
208
+ p(x: number, y: number): [number, number];
209
+ /** A vector drawn from the origin, as an arrow. */
210
+ vector(x: number, y: number, style?: ShapeStyle): Node;
211
+ }
212
+ declare function plane(options?: PlaneOptions): NumberPlane;
213
+ interface DecimalOptions {
214
+ digits?: number;
215
+ size?: number;
216
+ color?: ColorInput;
217
+ font?: 'sans' | 'mono' | 'serif';
218
+ prefix?: string;
219
+ suffix?: string;
220
+ }
221
+ /** A number readout that follows a function of the timeline, drawn fresh each frame. */
222
+ declare function decimal(read: () => number, options?: DecimalOptions): Node;
223
+
224
+ type FilmDiagnosticCode = 'film.off_canvas' | 'film.text_overlap' | 'film.text_crossed' | 'film.missing_glyph';
225
+ interface FilmDiagnostic {
226
+ code: FilmDiagnosticCode;
227
+ severity: 'error' | 'warning';
228
+ message: string;
229
+ /** First sampled time with this problem, in seconds. */
230
+ time: number;
231
+ /** Last sampled time with this problem, in seconds. */
232
+ until: number;
233
+ /** Where to look, in canvas pixels with the origin at the top left. */
234
+ box: Bounds;
235
+ /** The center of the box in authoring coordinates, with (0, 0) at mid-frame. */
236
+ stage: {
237
+ x: number;
238
+ y: number;
239
+ };
240
+ /** The text involved, when there is any. */
241
+ text?: string;
242
+ /** The second text involved in an overlap. */
243
+ other?: string;
244
+ }
245
+ interface FilmCheckReport {
246
+ ok: boolean;
247
+ width: number;
248
+ height: number;
249
+ duration: number;
250
+ /** The times that were inspected, in seconds. */
251
+ sampled: number[];
252
+ diagnostics: FilmDiagnostic[];
253
+ summary: {
254
+ errors: number;
255
+ warnings: number;
256
+ };
257
+ }
258
+ interface FilmCheckOptions extends CompileOverrides {
259
+ /** Inspect exactly these times, in seconds, in place of the automatic sampling. */
260
+ times?: readonly number[];
261
+ /** Add this many evenly spaced samples to the moments at rest. */
262
+ samples?: number;
263
+ }
264
+ /**
265
+ * Inspect a film for layout defects: marks off the canvas, text on text, strokes
266
+ * through text, and characters that no font can draw. It looks where the film comes to rest, because objects may
267
+ * cross each other while moving. Runs anywhere, with no rendering.
268
+ */
269
+ declare function checkFilm(film: FilmDefinition | CompiledFilm, options?: FilmCheckOptions): Promise<FilmCheckReport>;
270
+
271
+ type Reactive = number | (() => number);
272
+ interface NumberLineOptions {
273
+ range?: readonly [number, number];
274
+ /** On-screen length in stage pixels. */
275
+ length?: number;
276
+ step?: number;
277
+ labels?: boolean;
278
+ labelSize?: number;
279
+ color?: ColorInput;
280
+ tips?: boolean;
281
+ width?: number;
282
+ }
283
+ declare class NumberLine extends Node {
284
+ readonly range: readonly [number, number];
285
+ readonly length: number;
286
+ readonly line: Node;
287
+ readonly ticks: Node;
288
+ readonly numbers: Node;
289
+ constructor(options?: NumberLineOptions);
290
+ /** Value to local stage coordinates. */
291
+ p(value: number): [number, number];
292
+ world(value: number): [number, number];
293
+ /** A point on the line. Pass a function to follow a Value over time. */
294
+ marker(value: Reactive, options?: {
295
+ color?: ColorInput;
296
+ label?: string;
297
+ radius?: number;
298
+ labelSize?: number;
299
+ }): Node;
300
+ /** A highlighted span, with open or closed endpoints. */
301
+ interval(from: number, to: number, options?: {
302
+ color?: ColorInput;
303
+ width?: number;
304
+ offset?: number;
305
+ openLeft?: boolean;
306
+ openRight?: boolean;
307
+ }): Node;
308
+ }
309
+ declare function numberLine(options?: NumberLineOptions): NumberLine;
310
+ interface ComplexPlaneOptions extends PlaneOptions {
311
+ /** Label real and imaginary integers out to this distance from the origin. */
312
+ labelRange?: number;
313
+ labelSize?: number;
314
+ }
315
+ declare class ComplexPlane extends NumberPlane {
316
+ readonly numbers: Node;
317
+ constructor(options?: ComplexPlaneOptions);
318
+ /** Complex number to local stage coordinates. */
319
+ z(re: number, im: number): [number, number];
320
+ }
321
+ declare function complexPlane(options?: ComplexPlaneOptions): ComplexPlane;
322
+ /**
323
+ * Deform a complex plane through f(re, im). Labels stay readable by fading
324
+ * separately, so this moves only the grid.
325
+ */
326
+ declare function applyComplex(plane: NumberPlane, f: (re: number, im: number) => Vec, options?: AnimOptions & {
327
+ subdivisions?: number;
328
+ }): Anim;
329
+ /** Small complex arithmetic on [re, im] pairs. */
330
+ declare const complex: {
331
+ mul: (a: Vec, b: Vec) => Vec;
332
+ div: (a: Vec, b: Vec) => Vec;
333
+ exp: (a: Vec) => Vec;
334
+ log: (a: Vec) => Vec;
335
+ pow: (a: Vec, n: number) => Vec;
336
+ sin: (a: Vec) => Vec;
337
+ cos: (a: Vec) => Vec;
338
+ inv: (a: Vec) => Vec;
339
+ };
340
+ type FieldFn = (x: number, y: number, t: number) => Vec;
341
+ interface VectorFieldOptions {
342
+ x?: readonly [number, number];
343
+ y?: readonly [number, number];
344
+ /** Math units between arrows. */
345
+ step?: number;
346
+ /** Stage pixels per math unit. */
347
+ unit?: number;
348
+ /** Longest arrow, in stage pixels. */
349
+ maxLength?: number;
350
+ /** Magnitude that reaches the last color. */
351
+ max?: number;
352
+ colors?: readonly ColorInput[];
353
+ /** Thickness of the shaft. */
354
+ width?: number;
355
+ /** Recompute from f(x, y, t) on every frame. */
356
+ animate?: boolean;
357
+ }
358
+ /** A grid of arrows that shows a field's direction and strength. y points up in field space. */
359
+ declare class VectorField extends Node {
360
+ readonly f: FieldFn;
361
+ readonly unit: number;
362
+ readonly arrows: Node[];
363
+ constructor(f: FieldFn, options?: VectorFieldOptions);
364
+ }
365
+ declare function vectorField(f: FieldFn, options?: VectorFieldOptions): VectorField;
366
+ interface StreamLinesOptions {
367
+ x?: readonly [number, number];
368
+ y?: readonly [number, number];
369
+ unit?: number;
370
+ /** Math units between seed points. Smaller is denser. */
371
+ spacing?: number;
372
+ /** Integration step and number of steps for each line. */
373
+ dt?: number;
374
+ steps?: number;
375
+ colors?: readonly ColorInput[];
376
+ max?: number;
377
+ width?: number;
378
+ /** Passes per second along a full line. */
379
+ speed?: number;
380
+ /** Lit fraction of each line. */
381
+ tail?: number;
382
+ seed?: number;
383
+ /** Show the whole lines faintly underneath the moving light. */
384
+ trace?: number;
385
+ }
386
+ /**
387
+ * Flow made visible: lines are integrated once, then light runs along them.
388
+ * Drawing is batched by color and brightness, so hundreds of lines stay live.
389
+ */
390
+ declare class StreamLines extends Node {
391
+ readonly lineCount: number;
392
+ constructor(f: FieldFn, options?: StreamLinesOptions);
393
+ }
394
+ declare function streamLines(f: FieldFn, options?: StreamLinesOptions): StreamLines;
395
+ interface RiemannOptions {
396
+ from?: number;
397
+ to?: number;
398
+ n?: number;
399
+ /** Where each rectangle samples the function. */
400
+ rule?: 'left' | 'mid' | 'right';
401
+ colors?: readonly ColorInput[];
402
+ opacity?: number;
403
+ stroke?: ColorInput;
404
+ strokeWidth?: number;
405
+ }
406
+ /** Rectangles under a curve. Morph one set into a finer one to show the integral appear. */
407
+ declare function riemann(axes: Axes, f: (x: number) => number, options?: RiemannOptions): Node;
408
+ interface AreaOptions {
409
+ from?: Reactive;
410
+ to?: Reactive;
411
+ fill?: ColorInput;
412
+ opacity?: number;
413
+ samples?: number;
414
+ }
415
+ /** Shaded region between a curve and the x axis. Pass functions for bounds that move. */
416
+ declare function areaUnder(axes: Axes, f: (x: number) => number, options?: AreaOptions): Node;
417
+ interface TangentOptions extends ShapeStyle {
418
+ /** Length of the drawn segment, in stage pixels. */
419
+ length?: number;
420
+ /** Mark the point of tangency. */
421
+ point?: boolean;
422
+ }
423
+ /** The tangent at x, as a line on the axes. Pass a function of time to make it slide. */
424
+ declare function tangentLine(axes: Axes, f: (x: number) => number, x: Reactive, style?: TangentOptions): Node;
425
+ interface SecantOptions extends ShapeStyle {
426
+ /** Extra length past each point, in stage pixels. */
427
+ extend?: number;
428
+ points?: boolean;
429
+ /** Draw the run and rise legs of the slope triangle. */
430
+ legs?: boolean;
431
+ legColor?: ColorInput;
432
+ }
433
+ /** The line through two points on a curve. Pass functions to shrink h on screen. */
434
+ declare function secantLine(axes: Axes, f: (x: number) => number, a: Reactive, b: Reactive, style?: SecantOptions): Node;
435
+ /** Dashed drop lines from a point on the axes. Pass functions to follow a moving point. */
436
+ declare function dashedGuides(axes: Axes, x: Reactive, y: Reactive, style?: ShapeStyle): Node;
437
+ interface AngleOptions {
438
+ radius?: number;
439
+ color?: ColorInput;
440
+ width?: number;
441
+ label?: string;
442
+ labelSize?: number;
443
+ /** Soft wedge under the arc. */
444
+ fillOpacity?: number;
445
+ /** Take the long way around. */
446
+ reflex?: boolean;
447
+ }
448
+ /** An angle at a vertex, between the rays toward two points. */
449
+ declare function angleMark(vertex: Vec, from: Vec, to: Vec, options?: AngleOptions): Node;
450
+ /** The small square that marks a right angle. */
451
+ declare function rightAngle(vertex: Vec, a: Vec, b: Vec, options?: {
452
+ size?: number;
453
+ color?: ColorInput;
454
+ width?: number;
455
+ }): Node;
456
+ interface MatrixOptions {
457
+ size?: number;
458
+ color?: ColorInput;
459
+ /** Space between columns and rows, as multiples of size. */
460
+ gapX?: number;
461
+ gapY?: number;
462
+ bracket?: '[' | '(' | '|';
463
+ bracketColor?: ColorInput;
464
+ }
465
+ /** A typeset matrix with real TeX brackets. Each entry is its own node. */
466
+ declare class MatrixNode extends Node {
467
+ readonly cells: TexNode[][];
468
+ readonly entries: Node;
469
+ readonly brackets: Node;
470
+ readonly rowCount: number;
471
+ readonly colCount: number;
472
+ private readonly positions;
473
+ private readonly options;
474
+ constructor(rows: readonly (readonly (string | number)[])[], options?: MatrixOptions);
475
+ cell(row: number, column: number): TexNode;
476
+ row(index: number): TexNode[];
477
+ col(index: number): TexNode[];
478
+ /** Replace one entry, morphing matching glyphs. Later calls to `.cell` return the new one. */
479
+ setCell(row: number, column: number, value: string | number, options?: AnimOptions): Anim;
480
+ }
481
+ declare function matrix(rows: readonly (readonly (string | number)[])[], options?: MatrixOptions): MatrixNode;
482
+ interface BraceLabelOptions {
483
+ side?: 'bottom' | 'top' | 'left' | 'right';
484
+ gap?: number;
485
+ size?: number;
486
+ color?: ColorInput;
487
+ /** Set for plain text labels. Labels are math by default. */
488
+ plain?: boolean;
489
+ depth?: number;
490
+ }
491
+ /** A brace along one side of a node or nodes, with a label at its point. */
492
+ declare function braceLabel(target: Node | readonly Node[], label: string, options?: BraceLabelOptions): Node;
493
+ interface SurroundOptions {
494
+ pad?: number;
495
+ radius?: number;
496
+ color?: ColorInput;
497
+ width?: number;
498
+ fill?: ColorInput;
499
+ fillOpacity?: number;
500
+ glow?: number;
501
+ }
502
+ /** A rounded box around a node or nodes, measured now. */
503
+ declare function surroundingBox(target: Node | readonly Node[], options?: SurroundOptions): Node;
504
+ interface LabeledDotOptions {
505
+ color?: ColorInput;
506
+ radius?: number;
507
+ side?: Side;
508
+ gap?: number;
509
+ size?: number;
510
+ plain?: boolean;
511
+ labelColor?: ColorInput;
512
+ }
513
+ /** A point with a label. The node's origin stays on the point. */
514
+ declare class LabeledDot extends Node {
515
+ readonly mark: Node;
516
+ readonly caption: Node;
517
+ constructor(label: string, options?: LabeledDotOptions);
518
+ }
519
+ declare function labeledDot(label: string, options?: LabeledDotOptions): LabeledDot;
520
+ interface TracedOptions {
521
+ color?: ColorInput;
522
+ width?: number;
523
+ /** Seconds of history to keep. Older parts of the trail are gone. */
524
+ tail?: number;
525
+ /** Brightness at the old end, from 0 to 1. Use 1 for a solid trail. */
526
+ fade?: number;
527
+ /** Samples per second along the trail. */
528
+ rate?: number;
529
+ glow?: number;
530
+ }
531
+ /**
532
+ * The path a moving point has taken. It is computed by re-reading the point at
533
+ * earlier times, so it scrubs correctly in both directions. The point function
534
+ * should read Values or tracked node properties, not `update` overlays.
535
+ */
536
+ declare function traced(point: () => Vec, from: number, to: number, options?: TracedOptions): Node;
537
+ interface FourierTerm {
538
+ /** Whole turns per trip around the shape. */
539
+ readonly freq: number;
540
+ readonly amp: number;
541
+ readonly phase: number;
542
+ }
543
+ /**
544
+ * Discrete Fourier transform of a closed outline, largest terms first. Sample
545
+ * the points evenly along the outline, for example with `samplePath`.
546
+ */
547
+ declare function fourier(points: readonly Vec[], options?: {
548
+ terms?: number;
549
+ }): FourierTerm[];
550
+ /** Value of a Fourier series at u, where u from 0 to 1 is one trip around the shape. */
551
+ declare function fourierPoint(terms: readonly FourierTerm[], u: number): [number, number];
552
+ /** Evenly spaced points along a path, by arc length. */
553
+ declare function samplePath(path: Path, count: number): Vec[];
554
+ interface EpicyclesOptions {
555
+ /** Progress as a function of the timeline. 1 means one full trip. */
556
+ u: () => number;
557
+ /** Most circles to draw. The sum still uses every term. */
558
+ circles?: number;
559
+ circleColor?: ColorInput;
560
+ armColor?: ColorInput;
561
+ traceColor?: ColorInput;
562
+ traceWidth?: number;
563
+ glow?: number;
564
+ /** Share of a trip to keep lit. Use 1 for the whole drawing. */
565
+ tail?: number;
566
+ samples?: number;
567
+ }
568
+ /** Circles on circles: the tip of the chain draws the original shape. */
569
+ declare class Epicycles extends Node {
570
+ readonly terms: readonly FourierTerm[];
571
+ private readonly outlinePoints;
572
+ constructor(terms: readonly FourierTerm[], options: EpicyclesOptions);
573
+ /** The reconstructed outline as a path, for morphing the drawing into something else. */
574
+ outline(): Path;
575
+ point(u: number): [number, number];
576
+ }
577
+ declare function epicycles(terms: readonly FourierTerm[], options: EpicyclesOptions): Epicycles;
578
+ /** A closed outline shrunk to a parametric function. */
579
+ declare function ringThrough(f: (t: number) => Vec, samples?: number): Path;
580
+
581
+ interface ChartOptions {
582
+ width?: number;
583
+ height?: number;
584
+ /** Text size for direct labels and ticks. */
585
+ labelSize?: number;
586
+ color?: ColorInput;
587
+ }
588
+ interface BarDatum {
589
+ label: string;
590
+ value: number;
591
+ color?: ColorInput;
592
+ }
593
+ interface BarChartOptions extends ChartOptions {
594
+ /** Fraction of each band left empty between bars. */
595
+ gap?: number;
596
+ /** Fixes the top of the scale. Defaults to the largest value. */
597
+ max?: number;
598
+ min?: number;
599
+ showValues?: boolean;
600
+ format?: (value: number) => string;
601
+ horizontal?: boolean;
602
+ radius?: number;
603
+ }
604
+ /**
605
+ * Bars with direct labels and a single hairline baseline. `enter()` grows them
606
+ * from zero and `update(values)` animates to new data, with readouts that count.
607
+ */
608
+ declare class BarChart extends Node {
609
+ readonly bars: Node[];
610
+ readonly labels: Node[];
611
+ readonly readouts: Node[];
612
+ readonly baseline: Node;
613
+ readonly values: Value[];
614
+ private readonly maxValue;
615
+ private readonly minValue;
616
+ private readonly w;
617
+ private readonly h;
618
+ private readonly horizontal;
619
+ private readonly band;
620
+ private readonly gap;
621
+ private readonly fixedMax?;
622
+ private readonly fixedMin?;
623
+ constructor(data: readonly BarDatum[], options?: BarChartOptions);
624
+ private lengthOf;
625
+ /** Baseline position for bar i. */
626
+ private place;
627
+ private tip;
628
+ private barPath;
629
+ bar(i: number): Node;
630
+ /** Baseline and labels appear, then bars rise one after another while readouts count up. */
631
+ enter(options?: AnimOptions): Anim;
632
+ /** Animate to new values. The scale follows unless it was fixed at creation. */
633
+ update(values: readonly number[], options?: AnimOptions): Anim;
634
+ private barPathAt;
635
+ }
636
+ declare function barChart(data: readonly BarDatum[], options?: BarChartOptions): BarChart;
637
+ interface HistogramOptions extends ChartOptions {
638
+ bins?: number;
639
+ range?: readonly [number, number];
640
+ /** Fixes the top of the scale, for a stable axis while samples arrive. */
641
+ max?: number;
642
+ gap?: number;
643
+ /** Number of x tick labels. */
644
+ ticks?: number;
645
+ colors?: readonly ColorInput[];
646
+ }
647
+ /**
648
+ * A distribution that can fill up over time. `fillUp()` drops the samples in, in
649
+ * order, so bars rise exactly as the data accumulates.
650
+ */
651
+ declare class Histogram extends Node {
652
+ readonly shown: Value;
653
+ readonly bins: number;
654
+ readonly range: readonly [number, number];
655
+ readonly chartWidth: number;
656
+ readonly chartHeight: number;
657
+ readonly axis: Node;
658
+ readonly total: number;
659
+ private readonly assigned;
660
+ readonly peak: number;
661
+ constructor(samples: readonly number[], options?: HistogramOptions);
662
+ private xAt;
663
+ /** Local stage point for a value and a count. */
664
+ p(value: number, count: number): [number, number];
665
+ /** Samples arrive in order, from none to `count` (all of them by default). */
666
+ fillUp(options?: AnimOptions & {
667
+ count?: number;
668
+ }): Anim;
669
+ /** Overlay a curve, such as the fitted density, on the same axes. f returns a count. */
670
+ curve(f: (x: number) => number, options?: {
671
+ color?: ColorInput;
672
+ width?: number;
673
+ samples?: number;
674
+ }): Node;
675
+ }
676
+ declare function histogram(samples: readonly number[], options?: HistogramOptions): Histogram;
677
+ interface ScatterPoint {
678
+ x: number;
679
+ y: number;
680
+ color?: ColorInput;
681
+ radius?: number;
682
+ /** Points with the same group share a color and one direct label. */
683
+ group?: string;
684
+ }
685
+ interface ScatterOptions extends ChartOptions {
686
+ x?: readonly [number, number];
687
+ y?: readonly [number, number];
688
+ radius?: number;
689
+ xLabel?: string;
690
+ yLabel?: string;
691
+ /** Label each group near its center, instead of using a legend. */
692
+ groupLabels?: boolean;
693
+ }
694
+ declare class Scatter extends Node {
695
+ readonly dots: Node[];
696
+ readonly axis: Node;
697
+ readonly groupLabels: Node[];
698
+ private readonly frame;
699
+ constructor(points: readonly ScatterPoint[], options?: ScatterOptions);
700
+ p(x: number, y: number): [number, number];
701
+ /** Axes draw, then points land from left to right. */
702
+ enter(options?: AnimOptions): Anim;
703
+ /** A straight or curved fit through the data, drawn on the same axes. */
704
+ fit(f: (x: number) => number, options?: {
705
+ color?: ColorInput;
706
+ width?: number;
707
+ samples?: number;
708
+ }): Node;
709
+ }
710
+ declare function scatter(points: readonly ScatterPoint[], options?: ScatterOptions): Scatter;
711
+ interface LineSeries {
712
+ name?: string;
713
+ /** Y values at x = 0, 1, 2, ... */
714
+ values?: readonly number[];
715
+ points?: readonly Vec[];
716
+ color?: ColorInput;
717
+ width?: number;
718
+ dash?: readonly number[];
719
+ /** Soft fill under the line. */
720
+ area?: number;
721
+ smooth?: boolean;
722
+ }
723
+ interface LineChartOptions extends ChartOptions {
724
+ x?: readonly [number, number];
725
+ y?: readonly [number, number];
726
+ xLabel?: string;
727
+ yLabel?: string;
728
+ xFormat?: (x: number) => string;
729
+ yFormat?: (y: number) => string;
730
+ xTicks?: number;
731
+ yTicks?: number;
732
+ }
733
+ declare class LineChart extends Node {
734
+ readonly lines: Node[];
735
+ readonly areas: Node[];
736
+ readonly names: Node[];
737
+ readonly axis: Node;
738
+ private readonly byName;
739
+ private readonly frame;
740
+ constructor(series: readonly LineSeries[], options?: LineChartOptions);
741
+ p(x: number, y: number): [number, number];
742
+ series(name: string): Node;
743
+ /** Axes fade in, lines draw left to right, and their labels arrive as each line lands. */
744
+ enter(options?: AnimOptions): Anim;
745
+ }
746
+ declare function lineChart(series: readonly LineSeries[], options?: LineChartOptions): LineChart;
747
+ interface PieDatum {
748
+ label: string;
749
+ value: number;
750
+ color?: ColorInput;
751
+ }
752
+ interface PieOptions {
753
+ radius?: number;
754
+ /** Inner radius as a fraction of the outer radius. 0 makes a pie. */
755
+ hole?: number;
756
+ /** Angular gap between wedges, in radians. */
757
+ gap?: number;
758
+ labelSize?: number;
759
+ /** Show each share as a percentage beside its label. */
760
+ percent?: boolean;
761
+ labels?: boolean;
762
+ centerLabel?: string;
763
+ centerSize?: number;
764
+ }
765
+ /** Share of a whole, labeled directly. `enter()` sweeps around, and `update()` re-divides it. */
766
+ declare class PieChart extends Node {
767
+ readonly wedges: Node[];
768
+ readonly labels: Node[];
769
+ readonly leaders: Node[];
770
+ readonly centerText: Node | null;
771
+ private readonly shares;
772
+ private readonly inner;
773
+ private readonly outer;
774
+ private readonly gap;
775
+ constructor(data: readonly PieDatum[], options?: PieOptions);
776
+ private angles;
777
+ /** Wedges sweep open around the circle, then the labels arrive. */
778
+ enter(options?: AnimOptions): Anim;
779
+ /** Re-divide the circle. Geometry animates, and labels follow their wedges. */
780
+ update(values: readonly number[], options?: AnimOptions): Anim;
781
+ }
782
+ declare function pie(data: readonly PieDatum[], options?: PieOptions): PieChart;
783
+ declare function donut(data: readonly PieDatum[], options?: PieOptions): PieChart;
784
+ interface HeatmapOptions {
785
+ /** Cell edge in stage pixels. */
786
+ cell?: number;
787
+ cellWidth?: number;
788
+ cellHeight?: number;
789
+ gap?: number;
790
+ colors?: readonly ColorInput[];
791
+ /** Value range for the color ramp. */
792
+ domain?: readonly [number, number];
793
+ /** Print values in cells. */
794
+ values?: boolean;
795
+ format?: (value: number) => string;
796
+ valueSize?: number;
797
+ rowLabels?: readonly string[];
798
+ columnLabels?: readonly string[];
799
+ labelSize?: number;
800
+ /** Tilt column labels so long names fit, in radians. */
801
+ columnLabelAngle?: number;
802
+ radius?: number;
803
+ }
804
+ declare class Heatmap extends Node {
805
+ readonly cells: Node[][];
806
+ readonly rowLabels: Node[];
807
+ readonly columnLabels: Node[];
808
+ readonly numbers: Node[][];
809
+ readonly rowCount: number;
810
+ readonly colCount: number;
811
+ private readonly stops;
812
+ private readonly domain;
813
+ constructor(values: readonly (readonly number[])[], options?: HeatmapOptions);
814
+ colorFor(value: number): Rgba;
815
+ cell(row: number, column: number): Node;
816
+ row(index: number): Node[];
817
+ col(index: number): Node[];
818
+ /** Cells fade in along the diagonal. */
819
+ enter(options?: AnimOptions): Anim;
820
+ /** Recolor every cell to new values. */
821
+ update(values: readonly (readonly number[])[], options?: AnimOptions): Anim;
822
+ }
823
+ declare function heatmap(values: readonly (readonly number[])[], options?: HeatmapOptions): Heatmap;
824
+
825
+ interface GraphNodeSpec {
826
+ id: string;
827
+ label?: string;
828
+ color?: ColorInput;
829
+ /** Circle radius. */
830
+ radius?: number;
831
+ /** Box size. A node with a width draws as a rounded box. */
832
+ width?: number;
833
+ height?: number;
834
+ /** Manual position, used by layout: 'manual'. */
835
+ at?: Vec;
836
+ /** Typeset the label as math. */
837
+ math?: boolean;
838
+ }
839
+ interface GraphEdgeSpec {
840
+ from: string;
841
+ to: string;
842
+ label?: string;
843
+ color?: ColorInput;
844
+ width?: number;
845
+ dash?: readonly number[];
846
+ directed?: boolean;
847
+ }
848
+ interface GraphOptions {
849
+ layout?: 'dagre' | 'force' | 'circle' | 'manual';
850
+ direction?: 'LR' | 'RL' | 'TB' | 'BT';
851
+ /** Bounding size for force and circle layouts. */
852
+ width?: number;
853
+ height?: number;
854
+ nodeGap?: number;
855
+ rankGap?: number;
856
+ radius?: number;
857
+ labelSize?: number;
858
+ edgeLabelSize?: number;
859
+ directed?: boolean;
860
+ nodeColor?: ColorInput;
861
+ edgeColor?: ColorInput;
862
+ seed?: number;
863
+ /** Fill nodes softly with their color instead of leaving them hollow. */
864
+ fillOpacity?: number;
865
+ }
866
+ declare class GraphNode extends Node {
867
+ shape: Node;
868
+ caption: Node | null;
869
+ halfWidth: number;
870
+ halfHeight: number;
871
+ round: boolean;
872
+ /** Point on this node's outline facing a stage point, in graph space. */
873
+ edgePoint(fx: number, fy: number, tx: number, ty: number, pad?: number): Vec;
874
+ }
875
+ declare class GraphEdge extends Node {
876
+ shaft: Node;
877
+ tip: Node | null;
878
+ caption: Node | null;
879
+ from: string;
880
+ to: string;
881
+ tipSize: number;
882
+ }
883
+ /**
884
+ * Nodes and edges with a stable layout. `node(id)` and `edge(from, to)` return
885
+ * ordinary nodes, so every verb works on them, and `visit` and `pulseEdge` tell
886
+ * an algorithm's story.
887
+ */
888
+ declare class Graph extends Node {
889
+ readonly nodes: Map<string, GraphNode>;
890
+ readonly edges: GraphEdge[];
891
+ readonly edgeLayer: Node;
892
+ readonly nodeLayer: Node;
893
+ private readonly specs;
894
+ constructor(nodes: readonly GraphNodeSpec[], edges: readonly GraphEdgeSpec[], options?: GraphOptions);
895
+ node(id: string): GraphNode;
896
+ edge(from: string, to: string): GraphEdge;
897
+ /** Nodes pop in by order, and each edge draws as its source is shown. */
898
+ enter(options?: AnimOptions): Anim;
899
+ /** A lit signal travels along an edge. */
900
+ pulseEdge(from: string, to: string, options?: AnimOptions & {
901
+ color?: ColorInput;
902
+ length?: number;
903
+ }): Anim;
904
+ /** Mark a node as reached: its color changes and it swells for a moment. */
905
+ visit(id: string, options?: AnimOptions & {
906
+ color?: ColorInput;
907
+ }): Anim;
908
+ /** Move a node. Its edges follow, re-routed as straight lines. */
909
+ moveNode(id: string, to: Vec, options?: AnimOptions): Anim;
910
+ }
911
+ declare function graph(nodes: readonly GraphNodeSpec[], edges: readonly GraphEdgeSpec[], options?: GraphOptions): Graph;
912
+ interface TreeSpec {
913
+ id?: string;
914
+ label?: string;
915
+ color?: ColorInput;
916
+ children?: readonly TreeSpec[];
917
+ math?: boolean;
918
+ }
919
+ interface TreeOptions extends Pick<GraphOptions, 'radius' | 'labelSize' | 'nodeColor' | 'edgeColor' | 'fillOpacity'> {
920
+ levelGap?: number;
921
+ siblingGap?: number;
922
+ direction?: 'down' | 'right';
923
+ }
924
+ /** A tidy tree: parents center over children, and subtrees never overlap. */
925
+ declare class TreeGraph extends Graph {
926
+ readonly depths: Map<string, number>;
927
+ constructor(root: TreeSpec, options?: TreeOptions);
928
+ /** Grow from the root, one level at a time. */
929
+ enter(options?: AnimOptions): Anim;
930
+ }
931
+ declare function tree(root: TreeSpec, options?: TreeOptions): TreeGraph;
932
+ interface ArrayCellsOptions {
933
+ cell?: number;
934
+ gap?: number;
935
+ size?: number;
936
+ color?: ColorInput;
937
+ indices?: boolean;
938
+ indexSize?: number;
939
+ font?: 'mono' | 'sans';
940
+ }
941
+ /** A row of boxes. `swap(i, j)` lifts two items over each other, and `.cell(i)` follows them. */
942
+ declare class ArrayCells extends Node {
943
+ readonly slots: Node[];
944
+ readonly indexLabels: Node[];
945
+ /** The item at each index, updated as swaps are authored. */
946
+ readonly items: Node[];
947
+ private readonly cellSize;
948
+ private readonly step;
949
+ constructor(values: readonly (string | number)[], options?: ArrayCellsOptions);
950
+ /** The item currently at an index. */
951
+ cell(index: number): Node;
952
+ /** Local stage position of a slot. */
953
+ slotAt(index: number): Vec;
954
+ /** Exchange two items along opposite arcs. */
955
+ swap(i: number, j: number, options?: AnimOptions & {
956
+ lift?: number;
957
+ }): Anim;
958
+ /** Recolor an item. */
959
+ mark(index: number, color: ColorInput, options?: AnimOptions): Anim;
960
+ /** Cells appear from left to right. */
961
+ enter(options?: AnimOptions): Anim;
962
+ }
963
+ declare function arrayCells(values: readonly (string | number)[], options?: ArrayCellsOptions): ArrayCells;
964
+ type TokenKind = 'keyword' | 'string' | 'number' | 'comment' | 'function' | 'type' | 'punctuation' | 'plain' | 'space';
965
+ interface CodeToken {
966
+ text: string;
967
+ kind: TokenKind;
968
+ line: number;
969
+ glyphs: Node[];
970
+ }
971
+ /** A small tokenizer for film code. It colors the common cases and never blocks on odd input. */
972
+ declare function tokenize(source: string, language?: string): Omit<CodeToken, 'glyphs'>[];
973
+ interface CodeBlockOptions {
974
+ language?: string;
975
+ size?: number;
976
+ /** Line height as a multiple of size. */
977
+ leading?: number;
978
+ lineNumbers?: boolean;
979
+ /** Draw a quiet panel behind the code. */
980
+ panel?: boolean;
981
+ padding?: number;
982
+ /** Minimum panel width, so versions of a snippet can share one frame. */
983
+ minWidth?: number;
984
+ colors?: Partial<Record<Exclude<TokenKind, 'space'>, ColorInput>>;
985
+ }
986
+ /**
987
+ * Syntax-colored code as real glyphs. It can be written on, focused line by
988
+ * line, and morphed token by token into a new version with `morphCode`.
989
+ */
990
+ declare class CodeBlock extends Node {
991
+ readonly lines: Node[];
992
+ readonly tokens: CodeToken[];
993
+ readonly chars: Node[];
994
+ readonly panelNode: Node | null;
995
+ readonly body: Node;
996
+ readonly source: string;
997
+ private readonly bar;
998
+ private readonly rowHeight;
999
+ private readonly originY;
1000
+ private readonly contentWidth;
1001
+ constructor(source: string, options?: CodeBlockOptions);
1002
+ /** One line of code, as a node. Lines count from 0. */
1003
+ line(index: number): Node;
1004
+ /** Glyphs of every token whose text matches. */
1005
+ find(fragment: string): Node[];
1006
+ /** Dim everything except these lines, and lay a soft bar behind them. */
1007
+ focus(lines: number | readonly number[], options?: AnimOptions & {
1008
+ dim?: number;
1009
+ color?: ColorInput;
1010
+ }): Anim;
1011
+ /** Restore all lines and remove the focus bar. */
1012
+ unfocus(options?: AnimOptions): Anim;
1013
+ }
1014
+ declare function codeBlock(source: string, options?: CodeBlockOptions): CodeBlock;
1015
+ /**
1016
+ * Morph one version of code into another. Tokens are matched in order, so
1017
+ * unchanged code slides to its new place and only real edits fade.
1018
+ */
1019
+ declare function morphCode(from: CodeBlock, to: CodeBlock, options?: AnimOptions): Anim;
1020
+ interface NeuralNetOptions {
1021
+ width?: number;
1022
+ height?: number;
1023
+ radius?: number;
1024
+ /** Show at most this many neurons per layer, with an ellipsis for the rest. */
1025
+ collapse?: number;
1026
+ colors?: readonly ColorInput[];
1027
+ edgeColor?: ColorInput;
1028
+ edgeOpacity?: number;
1029
+ layerLabels?: readonly string[];
1030
+ labelSize?: number;
1031
+ /** Seed for the default activations. */
1032
+ seed?: number;
1033
+ }
1034
+ /** Layers of neurons joined by hairline weights. `forward()` runs a signal through it. */
1035
+ declare class NeuralNet extends Node {
1036
+ readonly neurons: Node[][];
1037
+ /** Edges between layer i and layer i + 1, by [from][to]. */
1038
+ readonly links: Node[][][];
1039
+ readonly edgeLayer: Node;
1040
+ readonly neuronLayer: Node;
1041
+ readonly captions: Node[];
1042
+ private readonly seed;
1043
+ private readonly layerColors;
1044
+ constructor(layers: readonly number[], options?: NeuralNetOptions);
1045
+ layer(index: number): Node[];
1046
+ /** Neurons appear layer by layer, then the weights draw between them. */
1047
+ enter(options?: AnimOptions): Anim;
1048
+ /** Set how strongly each neuron in a layer fires, from 0 to 1. */
1049
+ activate(layer: number, values: readonly number[], options?: AnimOptions & {
1050
+ color?: ColorInput;
1051
+ }): Anim;
1052
+ /**
1053
+ * Run a signal from the first layer to the last. Pass activations per layer,
1054
+ * or let a seeded generator pick plausible ones. The strongest paths light up.
1055
+ */
1056
+ forward(options?: AnimOptions & {
1057
+ activations?: readonly (readonly number[])[];
1058
+ color?: ColorInput;
1059
+ pulses?: number;
1060
+ }): Anim;
1061
+ }
1062
+ declare function neuralNet(layers: readonly number[], options?: NeuralNetOptions): NeuralNet;
1063
+ interface TokenSpec {
1064
+ text: string;
1065
+ /** Small line under the chip, such as an id or a probability. */
1066
+ sub?: string;
1067
+ color?: ColorInput;
1068
+ }
1069
+ interface TokensOptions {
1070
+ size?: number;
1071
+ /** Wrap to this width. */
1072
+ maxWidth?: number;
1073
+ gap?: number;
1074
+ color?: ColorInput;
1075
+ /** Ramp of colors across the row. */
1076
+ colors?: readonly ColorInput[];
1077
+ font?: 'mono' | 'sans';
1078
+ subSize?: number;
1079
+ radius?: number;
1080
+ }
1081
+ /** A sequence of token chips, as in a tokenizer's output. Small type by default. */
1082
+ declare class TokenRow extends Node {
1083
+ readonly chips: Node[];
1084
+ constructor(items: readonly (string | TokenSpec)[], options?: TokensOptions);
1085
+ token(index: number): Node;
1086
+ /** Chips arrive from left to right. */
1087
+ enter(options?: AnimOptions): Anim;
1088
+ /**
1089
+ * Curved links from one token to others, brighter for stronger weights.
1090
+ * Add the result to the stage after this row is in place.
1091
+ */
1092
+ arcs(from: number, weights: readonly number[], options?: {
1093
+ color?: ColorInput;
1094
+ maxWidth?: number;
1095
+ lift?: number;
1096
+ }): Node;
1097
+ }
1098
+ declare function tokens(items: readonly (string | TokenSpec)[], options?: TokensOptions): TokenRow;
1099
+ interface AttentionMatrixOptions {
1100
+ cell?: number;
1101
+ colors?: readonly ColorInput[];
1102
+ values?: boolean;
1103
+ labelSize?: number;
1104
+ gap?: number;
1105
+ }
1106
+ /**
1107
+ * Attention weights as a heatmap, with source tokens across the top and targets
1108
+ * down the side. It is a Heatmap, so `.cell(i, j)` and `.row(i)` work.
1109
+ */
1110
+ declare function attentionMatrix(rows: readonly string[], columns: readonly string[], weights: readonly (readonly number[])[], options?: AttentionMatrixOptions): Heatmap;
1111
+
1112
+ interface InfoRow {
1113
+ label: string;
1114
+ value?: string;
1115
+ /** Color for the value. */
1116
+ tone?: ColorInput;
1117
+ /** Thin meter under the row, from 0 to 1. */
1118
+ meter?: number;
1119
+ /** Small trend drawn at the end of the row. */
1120
+ spark?: readonly number[];
1121
+ }
1122
+ interface InfoBoxOptions {
1123
+ title: string;
1124
+ subtitle?: string;
1125
+ /** Short status tag at the top right, such as "p99" or "degraded". */
1126
+ badge?: string;
1127
+ badgeTone?: ColorInput;
1128
+ rows?: readonly InfoRow[];
1129
+ /** Small chips along the bottom. */
1130
+ tags?: readonly string[];
1131
+ /** Width in stage pixels. Grows to fit the content when omitted. */
1132
+ width?: number;
1133
+ /** Base text size. Everything scales from it. Raise it for a presentation. */
1134
+ size?: number;
1135
+ /** Color of the left edge. */
1136
+ accent?: ColorInput;
1137
+ fill?: ColorInput;
1138
+ border?: ColorInput;
1139
+ radius?: number;
1140
+ }
1141
+ /**
1142
+ * A compact node for system stories: a title, a status, and rows of labeled
1143
+ * metrics at reading size. It packs information like an engineering figure,
1144
+ * not a slide. For a talk, raise `size` and the whole box scales with it.
1145
+ */
1146
+ declare class InfoBox extends Node {
1147
+ readonly frame: Node;
1148
+ readonly accentBar: Node | null;
1149
+ readonly titleNode: Node;
1150
+ readonly subtitleNode: Node | null;
1151
+ readonly badgeNode: Node | null;
1152
+ readonly rowLabels: Node[];
1153
+ readonly rowValues: (Node | null)[];
1154
+ readonly meters: Node[];
1155
+ readonly tagNodes: Node[];
1156
+ readonly boxWidth: number;
1157
+ readonly boxHeight: number;
1158
+ private readonly valueSize;
1159
+ constructor(options: InfoBoxOptions);
1160
+ /** Stage point on one side of the box. `at` moves along the side, from -1 to 1. */
1161
+ port(side: Edge, at?: number): [number, number];
1162
+ /** The frame draws, then the contents settle in, top to bottom. */
1163
+ enter(options?: AnimOptions): Anim;
1164
+ /** Change a row's value in place. Matching digits slide, and the others cross-fade. */
1165
+ setValue(row: number, value: string, options?: AnimOptions & {
1166
+ tone?: ColorInput;
1167
+ }): Anim;
1168
+ }
1169
+ declare function infoBox(options: InfoBoxOptions): InfoBox;
1170
+ interface SparklineOptions {
1171
+ width?: number;
1172
+ height?: number;
1173
+ color?: ColorInput;
1174
+ weight?: number;
1175
+ /** Mark the latest value. */
1176
+ dotted?: boolean;
1177
+ area?: number;
1178
+ }
1179
+ /** A word-sized line chart, with no axes. */
1180
+ declare function sparkline(values: readonly number[], options?: SparklineOptions): Node;
1181
+ type ConnectorEnd = Node | Vec;
1182
+ interface ConnectorOptions {
1183
+ /** Side to leave from and arrive at. Chosen automatically when omitted. */
1184
+ from?: Edge;
1185
+ to?: Edge;
1186
+ route?: 'curve' | 'ortho' | 'straight';
1187
+ color?: ColorInput;
1188
+ width?: number;
1189
+ dash?: readonly number[];
1190
+ /** Draw an arrowhead at the end. */
1191
+ tip?: boolean;
1192
+ tipSize?: number;
1193
+ /** Label on the line, on a plate so the line never crosses its text. */
1194
+ label?: string;
1195
+ labelSize?: number;
1196
+ labelColor?: ColorInput;
1197
+ labelBackground?: ColorInput;
1198
+ /** Where the label sits along the line. */
1199
+ labelAt?: number;
1200
+ /** Space between the line and the box it touches. */
1201
+ gap?: number;
1202
+ /** Slide each end along its side, from -1 to 1. Use it to separate parallel lines. */
1203
+ fromOffset?: number;
1204
+ toOffset?: number;
1205
+ curvature?: number;
1206
+ radius?: number;
1207
+ /** Dashes travel along the line at this many pixels per second. */
1208
+ flow?: number;
1209
+ }
1210
+ /**
1211
+ * A line between two nodes that is routed fresh on every frame. Move a node and
1212
+ * the line follows. `draw(connector)` traces it, and `.pulse()` sends a signal.
1213
+ */
1214
+ declare class Connector extends Node {
1215
+ private readonly fromEnd;
1216
+ private readonly toEnd;
1217
+ private readonly options;
1218
+ private readonly pulses;
1219
+ private plate;
1220
+ private caption;
1221
+ constructor(from: ConnectorEnd, to: ConnectorEnd, options?: ConnectorOptions);
1222
+ private anchors;
1223
+ /** Geometry from end to end at this moment, in stage coordinates. */
1224
+ routeNow(): Path;
1225
+ private build;
1226
+ /** Send a signal along the line. Pulses can overlap, and they follow a moving route. */
1227
+ pulse(options?: AnimOptions & {
1228
+ color?: ColorInput;
1229
+ length?: number;
1230
+ width?: number;
1231
+ glow?: number;
1232
+ }): Anim;
1233
+ /** Point at a fraction along the current route, for placing notes beside the line. */
1234
+ pointNow(fraction?: number): [number, number];
1235
+ }
1236
+ declare function connector(from: ConnectorEnd, to: ConnectorEnd, options?: ConnectorOptions): Connector;
1237
+ interface LegendItem {
1238
+ label: string;
1239
+ color?: ColorInput;
1240
+ kind?: 'swatch' | 'line' | 'dash' | 'dot' | 'ring';
1241
+ }
1242
+ interface LegendOptions {
1243
+ direction?: 'row' | 'column';
1244
+ size?: number;
1245
+ gap?: number;
1246
+ }
1247
+ /** A small key. Prefer direct labels. Use this when a figure holds too many marks to label. */
1248
+ declare function legend(items: readonly LegendItem[], options?: LegendOptions): Node;
1249
+ interface CalloutOptions {
1250
+ title?: string;
1251
+ /** Which way the text sits from its target. */
1252
+ side?: Edge;
1253
+ /** Distance from the target to the text, in stage pixels. */
1254
+ distance?: number;
1255
+ /** Slide the text along the other axis. */
1256
+ offset?: number;
1257
+ /** Wrap width for the body. */
1258
+ width?: number;
1259
+ size?: number;
1260
+ color?: ColorInput;
1261
+ bodyColor?: ColorInput;
1262
+ /** Plate behind the text, for placing a note over busy marks. */
1263
+ plate?: boolean;
1264
+ }
1265
+ /**
1266
+ * A note with a leader line back to what it describes. The leader stops at the
1267
+ * text block's edge, so it never runs through the words.
1268
+ */
1269
+ declare class Callout extends Node {
1270
+ readonly leader: Node;
1271
+ readonly marker: Node;
1272
+ readonly body: Node;
1273
+ readonly titleNode: Node | null;
1274
+ constructor(target: Node | Vec, body: string, options?: CalloutOptions);
1275
+ /** The marker lands, the leader runs out, and the text settles at the end of it. */
1276
+ enter(options?: AnimOptions): Anim;
1277
+ }
1278
+ declare function callout(target: Node | Vec, body: string, options?: CalloutOptions): Callout;
1279
+
1280
+ interface TypewriterOptions extends AnimOptions {
1281
+ /** Show a block cursor at the writing position. */
1282
+ cursor?: boolean;
1283
+ cursorColor?: ColorInput;
1284
+ }
1285
+ /** Characters appear one at a time, at a steady rate, with an optional cursor. */
1286
+ declare function typewriter(target: Target, options?: TypewriterOptions): Anim;
1287
+ interface WipeOptions extends AnimOptions {
1288
+ /** Edge the reveal starts from. */
1289
+ from?: 'left' | 'right' | 'top' | 'bottom';
1290
+ /** Share of the time each mark takes to fade up as the edge passes. */
1291
+ soft?: number;
1292
+ /** Slide each mark this far as it arrives. */
1293
+ travel?: number;
1294
+ }
1295
+ /**
1296
+ * Reveal marks in the order a moving edge reaches them. Each mark fades up as
1297
+ * the edge passes, so a dense diagram opens like a sweep across the page.
1298
+ */
1299
+ declare function wipe(target: Target, options?: WipeOptions): Anim;
1300
+ interface CounterOptions {
1301
+ digits?: number;
1302
+ size?: number;
1303
+ color?: ColorInput;
1304
+ font?: 'mono' | 'sans' | 'serif';
1305
+ weight?: 400 | 600 | 700;
1306
+ prefix?: string;
1307
+ suffix?: string;
1308
+ /** Thousands separators. */
1309
+ grouped?: boolean;
1310
+ }
1311
+ /** A number readout. Animate it with `countUp`. */
1312
+ declare class Counter extends Node {
1313
+ readonly value: Value;
1314
+ constructor(initial?: number, options?: CounterOptions);
1315
+ }
1316
+ declare function counter(initial?: number, options?: CounterOptions): Counter;
1317
+ /** Count a Counter or Value to a target. */
1318
+ declare function countUp(target: Counter | Value, to: number, options?: AnimOptions): Anim;
1319
+ /** Steady rotation for as long as it plays: radians per second, around the center or a point. */
1320
+ declare function spin(node: Node, rate: number, options?: AnimOptions & {
1321
+ about?: Vec;
1322
+ }): Anim;
1323
+ /** Two nodes trade places along opposite arcs. */
1324
+ declare function swap(a: Node, b: Node, options?: AnimOptions & {
1325
+ lift?: number;
1326
+ }): Anim;
1327
+ interface HighlightOptions extends AnimOptions {
1328
+ color?: ColorInput;
1329
+ opacity?: number;
1330
+ /** Extra room around the target. */
1331
+ pad?: number;
1332
+ radius?: number;
1333
+ /** Keep the mark afterwards. By default it stays until you fade it. */
1334
+ from?: 'left' | 'right';
1335
+ }
1336
+ /**
1337
+ * A marker stroke sweeps across a target and stays behind it. `.mark` is the
1338
+ * node, so it can be faded out later.
1339
+ */
1340
+ declare function highlightSweep(target: Node | readonly Node[], options?: HighlightOptions): Anim & {
1341
+ mark: Node;
1342
+ };
1343
+
1344
+ /**
1345
+ * 3D on the stage: a camera, meshes, curves, and points, all projected to paths
1346
+ * on every frame and drawn back to front. There is no GPU dependency, so the
1347
+ * browser and the video exporter produce the same picture. Camera angles and
1348
+ * every object's opacity and reveal live on the timeline like anything else.
1349
+ */
1350
+
1351
+ type Vec3 = readonly [number, number, number];
1352
+ type Reactive3 = Vec3 | (() => Vec3);
1353
+ interface Scene3DOptions {
1354
+ /** Angle down from straight overhead, in radians. 0 looks straight down. */
1355
+ phi?: number;
1356
+ /** Rotation around the vertical axis, in radians. */
1357
+ theta?: number;
1358
+ /** Camera distance in math units. Smaller exaggerates perspective. */
1359
+ distance?: number;
1360
+ /** Stage pixels per math unit. */
1361
+ unit?: number;
1362
+ focus?: Vec3;
1363
+ /** Set to false for an orthographic view. */
1364
+ perspective?: boolean;
1365
+ /** Direction toward the light, in world space. */
1366
+ light?: Vec3;
1367
+ /** Share of light that reaches every face, from 0 to 1. */
1368
+ ambient?: number;
1369
+ /** Size of the bright highlight. 0 turns it off. */
1370
+ shine?: number;
1371
+ /** How much distant marks sink toward the background, from 0 to 1. */
1372
+ fog?: number;
1373
+ fogColor?: ColorInput;
1374
+ /** Multiplies lit surface color. Defaults to 0.8 on dark looks, where large areas also bloom. */
1375
+ brightness?: number;
1376
+ }
1377
+ /** Everything an object needs to project itself for one frame. */
1378
+ declare class View3D {
1379
+ readonly ops: PathOp[];
1380
+ readonly depths: number[];
1381
+ rx: number;
1382
+ ry: number;
1383
+ ux: number;
1384
+ uy: number;
1385
+ uz: number;
1386
+ dx: number;
1387
+ dy: number;
1388
+ dz: number;
1389
+ fx: number;
1390
+ fy: number;
1391
+ fz: number;
1392
+ distance: number;
1393
+ unit: number;
1394
+ perspective: boolean;
1395
+ matrix: Mat;
1396
+ alpha: number;
1397
+ scale: number;
1398
+ light: Vec3;
1399
+ half: Vec3;
1400
+ ambient: number;
1401
+ shine: number;
1402
+ fog: number;
1403
+ fogColor: Rgba;
1404
+ depthRange: number;
1405
+ brightness: number;
1406
+ px: number;
1407
+ py: number;
1408
+ pz: number;
1409
+ ps: number;
1410
+ /** Project a world point. Returns false when it falls behind the camera. */
1411
+ project(x: number, y: number, z: number): boolean;
1412
+ /** Local stage point before the scene's own transform, for placing labels. */
1413
+ screen(x: number, y: number, z: number): [number, number] | null;
1414
+ /** Mix a color toward the background for marks further from the camera. */
1415
+ fogged(r: number, g: number, b: number, depth: number): Rgba;
1416
+ push(op: PathOp, depth: number): void;
1417
+ }
1418
+ /**
1419
+ * A thing in a 3D scene. It is a regular node with an empty 2D path, so verbs
1420
+ * work on it: fadeIn sets opacity, and draw animates its reveal through trimTo.
1421
+ */
1422
+ declare abstract class Object3D extends Node {
1423
+ constructor();
1424
+ abstract emit(view: View3D, time: number): void;
1425
+ /** Screen-facing labels, drawn on top. */
1426
+ labelsNow(_view: View3D): Node[];
1427
+ protected objectAlpha(view: View3D): number;
1428
+ }
1429
+ declare class Scene3D extends Node {
1430
+ readonly phi: Value;
1431
+ readonly theta: Value;
1432
+ readonly distance: Value;
1433
+ readonly unit: Value;
1434
+ readonly focusX: Value;
1435
+ readonly focusY: Value;
1436
+ readonly focusZ: Value;
1437
+ private readonly orthographic;
1438
+ private readonly settings;
1439
+ private readonly spins;
1440
+ private openSpin;
1441
+ constructor(options?: Scene3DOptions);
1442
+ private readonly worldless;
1443
+ private view;
1444
+ private render;
1445
+ /** Move the camera over time. Any subset of phi, theta, distance, unit, and focus. */
1446
+ orbit(target: {
1447
+ phi?: number;
1448
+ theta?: number;
1449
+ distance?: number;
1450
+ unit?: number;
1451
+ focus?: Vec3;
1452
+ }, options?: AnimOptions): Anim;
1453
+ /** Start a slow ambient rotation here on the timeline, in radians per second. */
1454
+ spin(rate?: number): this;
1455
+ stopSpin(): this;
1456
+ /** Stage point of a world position at this moment, for placing 2D notes. */
1457
+ stagePoint(point: Vec3): [number, number];
1458
+ }
1459
+ declare function scene3d(options?: Scene3DOptions): Scene3D;
1460
+ interface SurfaceOptions {
1461
+ /** Grid cells in each direction. A number applies to both. */
1462
+ resolution?: number | readonly [number, number];
1463
+ /** One color for the whole surface. */
1464
+ color?: ColorInput;
1465
+ /** Color ramp by height. */
1466
+ colors?: readonly ColorInput[];
1467
+ /** Two colors in a checker pattern. */
1468
+ checker?: readonly [ColorInput, ColorInput];
1469
+ /** Any color per face. */
1470
+ colorAt?: (x: number, y: number, z: number, u: number, v: number) => Rgba;
1471
+ opacity?: number;
1472
+ /** Thin lines along the cells. */
1473
+ mesh?: ColorInput | false;
1474
+ meshOpacity?: number;
1475
+ meshWidth?: number;
1476
+ /** Set to false for flat, unlit color. */
1477
+ shaded?: boolean;
1478
+ /** Skip faces pointing away. Good for closed shapes such as spheres. */
1479
+ cull?: boolean;
1480
+ /** Recompute the shape on every frame from time. */
1481
+ animate?: boolean;
1482
+ /** Point normals away from this point. Closed shapes need it so `cull` keeps the near side. */
1483
+ outwardFrom?: Vec3;
1484
+ }
1485
+ type ParametricFn = (u: number, v: number, t: number) => Vec3;
1486
+ /** A shaded mesh. Faces sort with everything else in the scene, so objects can intersect. */
1487
+ declare class Surface3D extends Object3D {
1488
+ private readonly fn;
1489
+ private readonly uRange;
1490
+ private readonly vRange;
1491
+ private readonly options;
1492
+ private readonly nu;
1493
+ private readonly nv;
1494
+ private readonly positions;
1495
+ private readonly normals;
1496
+ private readonly vertexNormals;
1497
+ private readonly shadingNormals;
1498
+ private readonly faceColors;
1499
+ private computedFor;
1500
+ private readonly screenX;
1501
+ private readonly screenY;
1502
+ private readonly screenZ;
1503
+ private readonly valid;
1504
+ private readonly meshColor;
1505
+ private ramp;
1506
+ private checkerColors;
1507
+ constructor(fn: ParametricFn, uRange: readonly [number, number], vRange: readonly [number, number], options?: SurfaceOptions);
1508
+ private compute;
1509
+ emit(view: View3D, time: number): void;
1510
+ }
1511
+ /** A surface over any two parameters. */
1512
+ declare function parametricSurface(fn: ParametricFn, u: readonly [number, number], v: readonly [number, number], options?: SurfaceOptions): Surface3D;
1513
+ /** A height field z = f(x, y). `f` also receives time when `animate` is on. */
1514
+ declare function surface(f: (x: number, y: number, t: number) => number, options?: SurfaceOptions & {
1515
+ x?: readonly [number, number];
1516
+ y?: readonly [number, number];
1517
+ }): Surface3D;
1518
+ declare function sphere(radius?: number, options?: SurfaceOptions & {
1519
+ center?: Vec3;
1520
+ }): Surface3D;
1521
+ interface Line3DStyle {
1522
+ color?: ColorInput;
1523
+ /** Color ramp along the line. */
1524
+ colors?: readonly ColorInput[];
1525
+ width?: number;
1526
+ opacity?: number;
1527
+ glow?: number;
1528
+ /** Draw over everything else in the scene. */
1529
+ onTop?: boolean;
1530
+ /** Nudge toward the camera so a line lying on a surface stays visible. */
1531
+ bias?: number;
1532
+ }
1533
+ /** A curve in space, cut into pieces so it passes correctly in front of and behind other marks. */
1534
+ declare class Curve3D extends Object3D {
1535
+ private readonly style;
1536
+ private readonly points;
1537
+ private readonly stops;
1538
+ constructor(f: (t: number) => Vec3, from: number, to: number, style?: Line3DStyle & {
1539
+ samples?: number;
1540
+ });
1541
+ emit(view: View3D): void;
1542
+ }
1543
+ declare function curve3d(f: (t: number) => Vec3, from: number, to: number, style?: Line3DStyle & {
1544
+ samples?: number;
1545
+ }): Curve3D;
1546
+ /** A straight line in space. Ends can be functions, so it can follow moving points. */
1547
+ declare class Line3D extends Object3D {
1548
+ private readonly a;
1549
+ private readonly b;
1550
+ private readonly style;
1551
+ constructor(a: Reactive3, b: Reactive3, style?: Line3DStyle & {
1552
+ pieces?: number;
1553
+ });
1554
+ emit(view: View3D): void;
1555
+ }
1556
+ declare function line3d(a: Reactive3, b: Reactive3, style?: Line3DStyle & {
1557
+ pieces?: number;
1558
+ }): Line3D;
1559
+ /** An arrow in space. The head always faces the camera, so it reads from any angle. */
1560
+ declare class Vector3D extends Line3D {
1561
+ private readonly from3;
1562
+ private readonly to3;
1563
+ private readonly tipSize;
1564
+ constructor(from: Reactive3, to: Reactive3, style?: Line3DStyle & {
1565
+ tip?: number;
1566
+ });
1567
+ emit(view: View3D): void;
1568
+ }
1569
+ declare function vector3d(from: Reactive3, to: Reactive3, style?: Line3DStyle & {
1570
+ tip?: number;
1571
+ }): Vector3D;
1572
+ interface Points3DStyle {
1573
+ color?: ColorInput;
1574
+ /** Per-point color. */
1575
+ colorAt?: (index: number, point: Vec3) => ColorInput;
1576
+ /** Radius in stage pixels at the focus. */
1577
+ radius?: number;
1578
+ opacity?: number;
1579
+ onTop?: boolean;
1580
+ /** Soft ring around each point. */
1581
+ halo?: number;
1582
+ }
1583
+ /** Points in space. Pass a function to move them. They shrink with distance and sort with everything else. */
1584
+ declare class Points3D extends Object3D {
1585
+ private readonly source;
1586
+ private readonly style;
1587
+ constructor(source: readonly Vec3[] | (() => readonly Vec3[]), style?: Points3DStyle);
1588
+ emit(view: View3D): void;
1589
+ }
1590
+ declare function points3d(points: readonly Vec3[] | (() => readonly Vec3[]), style?: Points3DStyle): Points3D;
1591
+ /** One point in space, as a convenience over points3d. */
1592
+ declare function point3d(point: Reactive3, style?: Points3DStyle): Points3D;
1593
+ /** The path a moving point has taken, with a fading tail. Scrubs correctly in both directions. */
1594
+ declare class Trail3D extends Object3D {
1595
+ private readonly point;
1596
+ private readonly from;
1597
+ private readonly to;
1598
+ private readonly style;
1599
+ private readonly cache;
1600
+ constructor(point: () => Vec3, from: number, to: number, style?: Line3DStyle & {
1601
+ tail?: number;
1602
+ rate?: number;
1603
+ fade?: number;
1604
+ });
1605
+ private sample;
1606
+ emit(view: View3D, time: number): void;
1607
+ }
1608
+ declare function trail3d(point: () => Vec3, from: number, to: number, style?: Line3DStyle & {
1609
+ tail?: number;
1610
+ rate?: number;
1611
+ fade?: number;
1612
+ }): Trail3D;
1613
+ interface Axes3DOptions {
1614
+ x?: readonly [number, number];
1615
+ y?: readonly [number, number];
1616
+ z?: readonly [number, number];
1617
+ step?: number;
1618
+ color?: ColorInput;
1619
+ width?: number;
1620
+ /** Labels at the axis tips. Pass false to leave them off. */
1621
+ labels?: boolean | readonly [string, string, string];
1622
+ labelSize?: number;
1623
+ numbers?: boolean;
1624
+ ticks?: boolean;
1625
+ /** Pull toward the camera, so axes lying in a surface do not break into dashes. */
1626
+ bias?: number;
1627
+ onTop?: boolean;
1628
+ }
1629
+ /** Three axes with ticks and tips. */
1630
+ declare class Axes3D extends Object3D {
1631
+ private readonly options;
1632
+ private readonly ranges;
1633
+ private readonly step;
1634
+ private readonly tags;
1635
+ private readonly numberNodes;
1636
+ constructor(options?: Axes3DOptions);
1637
+ emit(view: View3D): void;
1638
+ labelsNow(view: View3D): Node[];
1639
+ }
1640
+ declare function axes3d(options?: Axes3DOptions): Axes3D;
1641
+ interface GridPlaneOptions {
1642
+ x?: readonly [number, number];
1643
+ y?: readonly [number, number];
1644
+ z?: number;
1645
+ step?: number;
1646
+ color?: ColorInput;
1647
+ width?: number;
1648
+ opacity?: number;
1649
+ }
1650
+ /** A hairline grid on a horizontal plane, to ground a scene. */
1651
+ declare class GridPlane3D extends Object3D {
1652
+ private readonly options;
1653
+ constructor(options?: GridPlaneOptions);
1654
+ emit(view: View3D): void;
1655
+ }
1656
+ declare function gridPlane3d(options?: GridPlaneOptions): GridPlane3D;
1657
+ /** A label pinned to a point in space. It always faces the camera. */
1658
+ declare class Label3D extends Object3D {
1659
+ private readonly position;
1660
+ private readonly content;
1661
+ constructor(content: string | Node, position: Reactive3, options?: {
1662
+ size?: number;
1663
+ color?: ColorInput;
1664
+ math?: boolean;
1665
+ offset?: Vec;
1666
+ });
1667
+ private readonly offset;
1668
+ emit(): void;
1669
+ labelsNow(view: View3D): Node[];
1670
+ }
1671
+ declare function label3d(content: string | Node, position: Reactive3, options?: {
1672
+ size?: number;
1673
+ color?: ColorInput;
1674
+ math?: boolean;
1675
+ offset?: Vec;
1676
+ }): Label3D;
1677
+
1678
+ export { Anim, AnimOptions, ArrayCells, Axes, Axes3D, BarChart, Bounds, Callout, CodeBlock, ColorInput, CompileOverrides, CompiledFilm, ComplexPlane, Connector, Counter, Curve3D, Edge, Epicycles, FilmDefinition, Graph, GraphEdge, GraphNode, GridPlane3D, Heatmap, Histogram, InfoBox, Label3D, LabeledDot, Line3D, LineChart, Mat, MatrixNode, NeuralNet, Node, NumberLine, NumberPlane, Object3D, Path, PathOp, PieChart, Points3D, Rgba, Scatter, Scene3D, Side, StreamLines, Surface3D, Target, TexNode, TextNode, TokenRow, Trail3D, TreeGraph, Value, Vec, Vector3D, VectorField, View3D, angleMark, applyComplex, arc, areaUnder, arrayCells, arrow, attentionMatrix, axes, axes3d, barChart, brace, braceLabel, callout, checkFilm, circle, codeBlock, complex, complexPlane, connector, countUp, counter, curve, curve3d, dashedGuides, decimal, donut, dot, ellipse, epicycles, fontFor, fourier, fourierPoint, glyphPath, graph, gridPlane3d, heatmap, highlightSweep, histogram, infoBox, label3d, labeledDot, legend, line, line3d, lineChart, matrix, morphCode, neuralNet, numberLine, parametric, parametricSurface, parseFont, pie, plane, point3d, points3d, polygon, polyline, rect, regularPolygon, riemann, rightAngle, ringThrough, samplePath, scatter, scene3d, secantLine, setAssetBase, shape, sparkline, sphere, spin, streamLines, surface, surroundingBox, svgPath, swap, tangentLine, tex, text, tokenize, tokens, traced, trail3d, tree, typewriter, vector3d, vectorField, wipe };
1679
+ export type { AngleOptions, AreaOptions, ArrayCellsOptions, ArrowStyle, AttentionMatrixOptions, Axes3DOptions, AxesOptions, BarChartOptions, BarDatum, BraceLabelOptions, CalloutOptions, ChartOptions, CodeBlockOptions, CodeToken, ComplexPlaneOptions, ConnectorEnd, ConnectorOptions, CounterOptions, DecimalOptions, EpicyclesOptions, FieldFn, FilmCheckOptions, FilmCheckReport, FilmDiagnostic, FilmDiagnosticCode, FontFamily, FontWeight, FourierTerm, GraphEdgeSpec, GraphNodeSpec, GraphOptions, GridPlaneOptions, HeatmapOptions, HighlightOptions, HistogramOptions, InfoBoxOptions, InfoRow, LabeledDotOptions, LegendItem, LegendOptions, Line3DStyle, LineChartOptions, LineSeries, LoadedFont, MatrixOptions, NeuralNetOptions, NumberLineOptions, ParametricFn, PieDatum, PieOptions, PlaneOptions, Points3DStyle, RiemannOptions, ScatterOptions, ScatterPoint, Scene3DOptions, SecantOptions, ShapeStyle, SparklineOptions, StreamLinesOptions, SurfaceOptions, SurroundOptions, TangentOptions, TexOptions, TextOptions, TokenKind, TokenSpec, TokensOptions, TracedOptions, TreeOptions, TreeSpec, TypewriterOptions, Vec3, VectorFieldOptions, WipeOptions };