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
@@ -17,48 +17,35 @@ export function create(theme: ThemeMode = 'dark') {
17
17
  title="Checkout system architecture"
18
18
  subtitle="Nested boundaries, technical icons, protocols, and synchronous or asynchronous relationships"
19
19
  background={c.bg}
20
- padding={28}
21
- gap={16}
22
20
  >
23
21
  <GraphDiagram
24
22
  c={c}
25
- width={1544}
26
- height={574}
27
- sizing="fixed"
28
23
  direction="LR"
29
24
  ariaLabel="Checkout system architecture"
30
- nodeWidth={132}
31
- nodeHeight={62}
32
- nodeGap={34}
33
- rankGap={46}
34
- edgeGap={18}
35
- labelFontSize={12}
36
- detailFontSize={11}
37
- iconSize={20}
38
25
  groups={[
39
- { id: 'edge', label: 'Edge', detail: 'public', tone: 'cyan' },
40
- { id: 'production', label: 'Production', detail: 'private network', tone: 'blue' },
41
- { id: 'services', label: 'Services', parent: 'production', tone: 'purple' },
42
- { id: 'data', label: 'Data', parent: 'production', tone: 'green' },
26
+ { id: 'edge', label: 'Edge', detail: 'public' },
27
+ { id: 'production', label: 'Production', detail: 'private network' },
28
+ { id: 'services', label: 'Services', parent: 'production' },
29
+ { id: 'data', label: 'Data', parent: 'production' },
43
30
  ]}
44
31
  nodes={[
45
- { id: 'customer', label: 'Customer', detail: 'web + mobile', icon: 'user', tone: 'blue' },
46
- { id: 'cdn', label: 'CDN', detail: 'static assets', icon: 'cloud', group: 'edge', tone: 'cyan' },
47
- { id: 'gateway', label: 'API gateway', detail: 'auth + routing', icon: 'gateway', group: 'services', tone: 'warm' },
48
- { id: 'checkout', label: 'Checkout', detail: 'TypeScript', icon: 'server', group: 'services', tone: 'purple' },
49
- { id: 'events', label: 'Order events', detail: 'durable queue', icon: 'queue', group: 'services', tone: 'warm' },
50
- { id: 'inventory', label: 'Inventory', detail: 'worker', icon: 'container', group: 'services', tone: 'purple' },
51
- { id: 'cache', label: 'Redis', detail: 'session cache', icon: 'cache', group: 'data', tone: 'cyan' },
52
- { id: 'orders', label: 'Postgres', detail: 'orders', icon: 'database', group: 'data', tone: 'green' },
32
+ { id: 'customer', label: 'Customer', detail: 'web + mobile', icon: 'user' },
33
+ { id: 'cdn', label: 'CDN', detail: 'static assets', icon: 'cloud', group: 'edge' },
34
+ { id: 'gateway', label: 'API gateway', detail: 'auth + routing', icon: 'gateway', group: 'services' },
35
+ { id: 'checkout', label: 'Checkout', detail: 'TypeScript', icon: 'server', group: 'services' },
36
+ { id: 'events', label: 'Order events', detail: 'durable queue', icon: 'queue', group: 'services' },
37
+ { id: 'inventory', label: 'Inventory', detail: 'worker', icon: 'container', group: 'services' },
38
+ { id: 'cache', label: 'Redis', detail: 'session cache', icon: 'cache', group: 'data' },
39
+ { id: 'orders', label: 'Postgres', detail: 'orders', icon: 'database', group: 'data' },
53
40
  ]}
54
41
  edges={[
55
- { from: 'customer', to: 'cdn', label: 'HTTPS', kind: 'sync', tone: 'blue' },
56
- { from: 'cdn', to: 'gateway', label: 'HTTPS', kind: 'sync', tone: 'cyan' },
57
- { from: 'gateway', to: 'checkout', label: 'REST', kind: 'sync', arrow: 'both', tone: 'purple' },
58
- { from: 'checkout', to: 'cache', label: 'GET / SET', kind: 'data', tone: 'cyan' },
59
- { from: 'checkout', to: 'orders', label: 'SQL', kind: 'data', tone: 'green' },
60
- { from: 'checkout', to: 'events', label: 'publish', kind: 'event', tone: 'warm' },
61
- { from: 'events', to: 'inventory', label: 'consume', kind: 'async', tone: 'purple' },
42
+ { from: 'customer', to: 'cdn', label: 'HTTPS', kind: 'sync' },
43
+ { from: 'cdn', to: 'gateway', label: 'HTTPS', kind: 'sync' },
44
+ { from: 'gateway', to: 'checkout', label: 'REST', kind: 'sync', arrow: 'both' },
45
+ { from: 'checkout', to: 'cache', label: 'GET / SET', kind: 'data' },
46
+ { from: 'checkout', to: 'orders', label: 'SQL', kind: 'data' },
47
+ { from: 'checkout', to: 'events', label: 'publish', kind: 'event' },
48
+ { from: 'events', to: 'inventory', label: 'consume', kind: 'async' },
62
49
  ]}
63
50
  />
64
51
  </Scene>
@@ -6,7 +6,7 @@ const tones = ['blue', 'purple', 'green', 'warm', 'cyan', 'pink', 'critical', 'o
6
6
  <Scene title="Theme-aware primitives" subtitle="semantic tones, not hard-coded colors" gap={18}>
7
7
  <Row gap={14} wrap width="100%">
8
8
  {tones.map((tone) => (
9
- <Panel key={tone} title={tone} tone={tone} width={225} minHeight={106}>
9
+ <Panel key={tone} title={tone} tone={tone} width={225}>
10
10
  <Column gap={9} align="stretch">
11
11
  <ToneStrip tone={tone} width={62} />
12
12
  <TextLabel text="inherits border, fill, label, and chart color" fontSize={11} />
@@ -15,7 +15,7 @@ function heatText(background: string) {
15
15
 
16
16
  <Scene title="Token matrix view" subtitle="tables and grids use wrapping-safe cells" background={c.bg} gap={18}>
17
17
  <Row gap={18} align="stretch">
18
- <Panel title="Attention weights" tone="purple" width={480} align="center">
18
+ <Panel title="Attention weights" width={480} align="center">
19
19
  <Grid
20
20
  cellWidth={48}
21
21
  cellHeight={34}
@@ -30,7 +30,7 @@ function heatText(background: string) {
30
30
  ]}
31
31
  />
32
32
  </Panel>
33
- <Panel title="Feature table" tone="cyan" width={420} align="center">
33
+ <Panel title="Feature table" width={420} align="center">
34
34
  <Column gap={12}>
35
35
  <DataTable
36
36
  firstColWidth={98}
@@ -40,6 +40,8 @@ function heatText(background: string) {
40
40
  ['BLEU', '31.2', '34.8', '+3.6'],
41
41
  ['faith', '.72', '.81', '+.09'],
42
42
  ['latency', '1.3s', '1.1s', '-.2s'],
43
+ ['cost', '$4.10', '$2.75', '-$1.35'],
44
+ ['recall', '.64', '.71', '+.07'],
43
45
  ]}
44
46
  />
45
47
  <TextLabel text="Same component renders dark and light themes without rewriting cells." align="center" width={330} />
@@ -3,13 +3,12 @@ height = 420;
3
3
 
4
4
  <Scene align="center" contentWidth={620}>
5
5
  <Row gap={16} width="100%" justify="center">
6
- <MetricCard label="Alpha" value="default" detail="no canvas fill" tone="cyan" width={210} />
6
+ <MetricCard label="Alpha" value="default" detail="no canvas fill" width={210} />
7
7
  <StepCard title="Titleless" subtitle="visual-only scene" tone="green" width={210} />
8
8
  </Row>
9
9
  <CalloutCard
10
10
  title="No title bar required"
11
11
  detail="Use a titleless scene when surrounding copy already names the visual."
12
- tone="purple"
13
12
  width={560}
14
13
  />
15
14
  </Scene>
@@ -7,12 +7,46 @@ generic example that depends on the published Vizmatic package.
7
7
  one request through receive, process, and return stages.
8
8
  - [`signal-to-story.tsx`](signal-to-story.tsx) is a longer example. It adds
9
9
  observations to a chart, traces a fitted line, and holds the result on screen.
10
+ - [`calculus-tangent.tsx`](calculus-tangent.tsx) couples a moving secant,
11
+ shrinking increment, and slope approaching the derivative.
12
+ - [`wave-interference.tsx`](wave-interference.tsx) changes relative phase while
13
+ showing both waves and their signed sum on fixed axes.
14
+ - [`catalyst-pathway.tsx`](catalyst-pathway.tsx) compares illustrative reaction
15
+ pathways with different barriers and unchanged endpoint energies.
16
+ - [`causal-attention.tsx`](causal-attention.tsx) computes masked softmax weights
17
+ and the corresponding weighted value output from explicit small tensors.
18
+ - [`matrix-multiplication.tsx`](matrix-multiplication.tsx) follows each selected
19
+ row/column pair through its dot product, including negative values.
20
+ - [`image-to-matrix.tsx`](image-to-matrix.tsx) reconstructs a real CIFAR-10 frog,
21
+ splits its RGB channels, and carries the same pixel bytes into numerical crops.
22
+ - [`convolution-kernel.tsx`](convolution-kernel.tsx) follows each pixel and
23
+ hand-set filter weight into one signed response, then shows ReLU across the
24
+ feature map.
25
+ - [`gaussian-blur.tsx`](gaussian-blur.tsx) tracks weighted pixel taps as a
26
+ bright point spreads through a normalized binomial blur kernel.
27
+ - [`photo-gaussian-blur.tsx`](photo-gaussian-blur.tsx) opens on a sharp CC0
28
+ coffee photo, then reveals its matching crop and the numerical center 5 × 5
29
+ of the 25 × 25 Gaussian filter matrix. It steps through the computed RGB
30
+ outputs from σ = 0 to 4, keeping the source and result the same size and
31
+ showing the 360 × 232 valid crop.
32
+
33
+ The scientific examples require the scientific components in this checkout.
34
+ Build it with `pnpm build`, then use `node dist/cli.js video` in place of
35
+ `npx vizmatic video` below. See the [science guide](../../SCIENCE.md) for the
36
+ data contracts and references. `crossCorrelate2d` handles one 2D channel;
37
+ `gaussianBlurRgb` processes row-major RGB rasters and retains floating-point
38
+ results until PNG encoding. These helpers are available in this checkout;
39
+ consumers need a Vizmatic release that includes them. They are part of full
40
+ SDK imports and the full Playground, not the isolated QuickJS author-code
41
+ environment. These are short lesson segments; narration and publication review
42
+ remain separate production steps.
10
43
 
11
44
  Use Node.js 20 or newer. In a project that contains the downloaded or copied
12
- TSX file, install Vizmatic and React:
45
+ TSX file, add the [consumer security overrides](../../README.md#consumer-security-overrides)
46
+ before installing Vizmatic and React:
13
47
 
14
48
  ```bash
15
- npm install --save-dev vizmatic@0.4.0 react
49
+ npm install --save-dev vizmatic@0.6.0 react
16
50
  npx vizmatic video ./request-lifecycle.tsx --out ./dist/videos --theme dark --fps 30
17
51
  ```
18
52
 
@@ -0,0 +1,101 @@
1
+ /**
2
+ * The secant of f(x)=x² at x=1 has slope 2+h; its limit as h→0 is 2.
3
+ * The moving point, secant, number line and readout share the same positive h.
4
+ * Source: https://openstax.org/books/calculus-volume-1/pages/3-1-defining-the-derivative
5
+ */
6
+ import {
7
+ AxisPlot,
8
+ NumberLine,
9
+ defineAnimation,
10
+ getThemeColors,
11
+ hold,
12
+ tween,
13
+ type ThemeMode,
14
+ } from 'vizmatic'
15
+
16
+ export const width = 1280
17
+ export const height = 720
18
+
19
+ export function secantState(h: number) {
20
+ if (!Number.isFinite(h) || h <= 0) throw new Error('The secant increment must be positive and finite')
21
+ return { h, x: 1 + h, y: (1 + h) ** 2, slope: 2 + h, tangentSlope: 2 }
22
+ }
23
+
24
+ const parabola = Array.from({ length: 121 }, (_, index) => {
25
+ const x = index / 40
26
+ return { x, y: x * x }
27
+ })
28
+
29
+ function buildFrame(theme: ThemeMode, h: number) {
30
+ const c = getThemeColors(theme)
31
+ const state = secantState(h)
32
+ const secantColor = theme === 'dark' ? c.warningLight : c.warningDark
33
+ const tangentColor = theme === 'dark' ? c.positiveLight : c.positiveDark
34
+ const curveColor = theme === 'dark' ? c.secondaryLight : c.secondaryDark
35
+
36
+ return (
37
+ <div style={{ display: 'flex', position: 'relative', width, height, overflow: 'hidden', backgroundColor: c.bg, color: c.textPrimary, fontFamily: c.fontSans }}>
38
+ <div style={{ display: 'flex', position: 'absolute', left: 64, top: 42, flexDirection: 'column', gap: 12 }}>
39
+ <span style={{ fontFamily: c.fontMono, color: c.textSecondary, fontSize: 14, letterSpacing: 2 }}>CALCULUS / A LIMIT YOU CAN SEE</span>
40
+ <span style={{ fontSize: 48, fontWeight: 750, letterSpacing: -1.5 }}>Two points become one tangent.</span>
41
+ <span style={{ color: c.textSecondary, fontSize: 22 }}>The increment shrinks. The secant slope approaches 2.</span>
42
+ </div>
43
+
44
+ <div style={{ display: 'flex', position: 'absolute', left: 64, top: 184 }}>
45
+ <AxisPlot c={c} width={770} height={350} xMin={0} xMax={3} yMin={-3} yMax={9} padding={30}
46
+ showFrame={false} showGrid gridCount={5} xAxisLabel="x" yAxisLabel="f(x)"
47
+ paths={[
48
+ { points: parabola, color: curveColor, strokeWidth: 4 },
49
+ { points: [{ x: 0, y: -1 }, { x: 3, y: 5 }], color: tangentColor, strokeWidth: 3, dashed: true },
50
+ { points: [{ x: 0, y: -1 - h }, { x: 3, y: 5 + 2 * h }], color: secantColor, strokeWidth: 4 },
51
+ ]}
52
+ vectors={[
53
+ { x1: 1, y1: 1, x2: state.x, y2: 1, color: secantColor, strokeWidth: 2 },
54
+ { x1: state.x, y1: 1, x2: state.x, y2: state.y, color: secantColor, strokeWidth: 2 },
55
+ ]}
56
+ points={[
57
+ { x: 1, y: 1, fill: tangentColor, r: 8, stroke: c.bg, strokeWidth: 3 },
58
+ { x: state.x, y: state.y, fill: secantColor, r: 8, stroke: c.bg, strokeWidth: 3 },
59
+ ]}
60
+ />
61
+ </div>
62
+
63
+ <div style={{ display: 'flex', position: 'absolute', left: 888, top: 204, width: 324, flexDirection: 'column', gap: 14 }}>
64
+ <span style={{ fontSize: 22, color: curveColor, fontWeight: 700 }}>f(x) = x²</span>
65
+ <span style={{ fontSize: 17, color: c.textSecondary, fontFamily: c.fontMono }}>FIXED POINT (1, 1)</span>
66
+ <span style={{ marginTop: 12, fontSize: 18, color: secantColor, fontFamily: c.fontMono }}>h = {h.toFixed(2)}</span>
67
+ <span style={{ fontSize: 18, color: c.textSecondary }}>Secant slope</span>
68
+ <span style={{ fontSize: 54, fontWeight: 750, color: secantColor, fontFamily: c.fontMono }}>{state.slope.toFixed(2)}</span>
69
+ <span style={{ fontSize: 20, fontFamily: c.fontMono }}>m = 2 + h</span>
70
+ <span style={{ marginTop: 18, fontSize: 21, color: tangentColor, fontWeight: 700 }}>Tangent slope = 2</span>
71
+ <span style={{ color: c.textSecondary, fontSize: 17, lineHeight: 1.5 }}>The tangent is the limit, not a second approximation.</span>
72
+ </div>
73
+
74
+ <div style={{ display: 'flex', position: 'absolute', left: 78, top: 544 }}>
75
+ <NumberLine c={c} width={740} height={132} min={0} max={1.8} title="The increment h"
76
+ ticks={[{ value: 0 }, { value: 0.6 }, { value: 1.2 }, { value: 1.8 }]}
77
+ markers={[{ id: 'increment', label: `h = ${h.toFixed(2)}`, value: h, color: secantColor }]}
78
+ ariaLabel={`Positive increment h is ${h.toFixed(2)} and approaches zero`} />
79
+ </div>
80
+ <span style={{ position: 'absolute', left: 888, top: 632, width: 324, fontSize: 15, color: c.textMuted }}>Each secant uses h ≠ 0. Take the limit as h → 0.</span>
81
+ </div>
82
+ )
83
+ }
84
+
85
+ export function create(theme: ThemeMode = 'dark') {
86
+ return buildFrame(theme, 0.04)
87
+ }
88
+
89
+ export function createAnimation(theme: ThemeMode = 'dark') {
90
+ return defineAnimation({
91
+ initial: { h: 1.6 },
92
+ timeline: [
93
+ tween({ h: 0.04 }, { duration: 6000, easing: 'ease-out', label: 'Shrink the secant increment' }),
94
+ hold(1800, 'Read the limiting slope'),
95
+ ],
96
+ fps: 30,
97
+ render: ({ h }) => buildFrame(theme, h),
98
+ })
99
+ }
100
+
101
+ export default create('dark')
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Illustrative generic A→B energy profile, not measured energies of a named reaction.
3
+ * Both routes keep endpoint energies of 20 and -40 kJ/mol, so ΔE=-60.
4
+ * Their activation energies are 100 and 45 kJ/mol.
5
+ * Source: https://openstax.org/books/chemistry-2e/pages/12-7-catalysis
6
+ */
7
+ import { ReactionEnergyDiagram, defineAnimation, getThemeColors, hold, tween, type ThemeMode } from 'vizmatic'
8
+
9
+ export const width = 1280
10
+ export const height = 720
11
+
12
+ export const energyProfile = Object.freeze({ reactants: 20, products: -40, barrier: 120, catalyzedBarrier: 65 })
13
+
14
+ function buildFrame(theme: ThemeMode, pathProgress: number) {
15
+ const c = getThemeColors(theme)
16
+ const accent = theme === 'dark' ? c.positiveLight : c.positiveDark
17
+
18
+ return (
19
+ <div style={{ display: 'flex', position: 'relative', width, height, overflow: 'hidden', backgroundColor: c.bg, color: c.textPrimary, fontFamily: c.fontSans }}>
20
+ <div style={{ display: 'flex', position: 'absolute', left: 64, top: 42, flexDirection: 'column', gap: 12 }}>
21
+ <span style={{ fontFamily: c.fontMono, color: c.textSecondary, fontSize: 14, letterSpacing: 2 }}>CHEMISTRY / TWO REACTION PATHWAYS</span>
22
+ <span style={{ fontSize: 46, fontWeight: 750, letterSpacing: -1.5 }}>A lower barrier. The same energy change.</span>
23
+ <span style={{ color: c.textSecondary, fontSize: 22 }}>A catalyst provides an alternative route between the same endpoints.</span>
24
+ </div>
25
+
26
+ <div style={{ display: 'flex', position: 'absolute', left: 64, top: 174 }}>
27
+ <ReactionEnergyDiagram c={c} width={1152} height={430} {...energyProfile}
28
+ progress={pathProgress} unit="kJ/mol" reactantLabel="A · Reactants" productLabel="B · Products" />
29
+ </div>
30
+
31
+ <div style={{ display: 'flex', position: 'absolute', left: 92, right: 92, top: 620, justifyContent: 'space-between', alignItems: 'center' }}>
32
+ <span style={{ fontSize: 27, color: accent, fontWeight: 700 }}>Activation energy: 100 → 45 kJ/mol</span>
33
+ <span style={{ fontSize: 27, fontWeight: 700 }}>ΔE = −60 kJ/mol</span>
34
+ </div>
35
+ <span style={{ position: 'absolute', left: 92, top: 674, fontSize: 15, color: c.textMuted }}>Illustrative values. Reaction coordinate describes a pathway, not elapsed time or a predicted reaction rate.</span>
36
+ </div>
37
+ )
38
+ }
39
+
40
+ export function create(theme: ThemeMode = 'dark') {
41
+ return buildFrame(theme, 1)
42
+ }
43
+
44
+ export function createAnimation(theme: ThemeMode = 'dark') {
45
+ return defineAnimation({
46
+ initial: { pathProgress: 0.18 },
47
+ timeline: [
48
+ tween({ pathProgress: 1 }, { duration: 5500, easing: 'linear', label: 'Compare the two fixed energy pathways' }),
49
+ hold(2000, 'Same endpoints, lower activation energy'),
50
+ ],
51
+ fps: 30,
52
+ render: ({ pathProgress }) => buildFrame(theme, pathProgress),
53
+ })
54
+ }
55
+
56
+ export default create('dark')
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Four explicit illustrative Q/K/V vectors; no learned model or generated output.
3
+ * Each query uses only keys at its own index or earlier, before row-wise softmax.
4
+ * Source: https://arxiv.org/abs/1706.03762 (scaled dot-product attention, section3.2.1).
5
+ */
6
+ import {
7
+ AttentionMatrix,
8
+ defineAnimation,
9
+ getThemeColors,
10
+ hold,
11
+ scaledDotProductAttention,
12
+ tween,
13
+ type ThemeMode,
14
+ } from 'vizmatic'
15
+
16
+ export const width = 1280
17
+ export const height = 720
18
+
19
+ export const queries = [[1, 0], [0, 1], [1, 1], [1, -1]]
20
+ export const keys = [[1, 0], [0, 1], [1, 1], [-1, 1]]
21
+ export const values = [[1, 0], [0, 2], [2, 1], [-1, 3]]
22
+ export const attention = scaledDotProductAttention(queries, keys, values, { causal: true })
23
+ export const causalMask = queries.map((_, row) => keys.map((__, column) => column <= row))
24
+ const labels = ['Token 1', 'Token 2', 'Token 3', 'Token 4']
25
+
26
+ export function attentionFocus(cursor: number) {
27
+ if (!Number.isFinite(cursor)) throw new Error('The attention cursor must be finite')
28
+ const bounded = Math.max(0, Math.min(3.999, cursor))
29
+ const query = Math.floor(bounded)
30
+ const key = Math.min(query, Math.floor((bounded - query) * (query + 1)))
31
+ return { query, key, weights: attention.weights[query], output: attention.output[query], scores: attention.scores[query] }
32
+ }
33
+
34
+ const vectorText = (row: readonly number[]) => `[${row.map(value => value.toFixed(2)).join(', ')}]`
35
+
36
+ function buildFrame(theme: ThemeMode, cursor: number) {
37
+ const c = getThemeColors(theme)
38
+ const focus = attentionFocus(cursor)
39
+ const accent = theme === 'dark' ? c.infoLight : c.infoDark
40
+ const resultColor = theme === 'dark' ? c.positiveLight : c.positiveDark
41
+
42
+ return (
43
+ <div style={{ display: 'flex', position: 'relative', width, height, overflow: 'hidden', backgroundColor: c.bg, color: c.textPrimary, fontFamily: c.fontSans }}>
44
+ <div style={{ display: 'flex', position: 'absolute', left: 64, top: 42, flexDirection: 'column', gap: 12 }}>
45
+ <span style={{ fontFamily: c.fontMono, color: c.textSecondary, fontSize: 14, letterSpacing: 2 }}>ARTIFICIAL INTELLIGENCE / CAUSAL ATTENTION</span>
46
+ <span style={{ fontSize: 48, fontWeight: 750, letterSpacing: -1.5 }}>The future gets zero weight.</span>
47
+ <span style={{ color: c.textSecondary, fontSize: 22 }}>Mask scores before softmax, then use the normalized weights to mix values.</span>
48
+ </div>
49
+
50
+ <div style={{ display: 'flex', position: 'absolute', left: 48, top: 178 }}>
51
+ <AttentionMatrix c={c} width={788} height={420} weights={attention.weights} mask={causalMask}
52
+ queryLabels={labels} keyLabels={labels} activeQuery={focus.query} activeKey={focus.key}
53
+ title="Causal attention probabilities" />
54
+ </div>
55
+
56
+ <div style={{ display: 'flex', position: 'absolute', left: 884, top: 216, width: 330, flexDirection: 'column', gap: 16 }}>
57
+ <span style={{ color: accent, fontSize: 27, fontWeight: 750 }}>Query: Token {focus.query + 1}</span>
58
+ <span style={{ color: c.textSecondary, fontSize: 13, fontFamily: c.fontMono }}>MASKED QKᵀ / √2</span>
59
+ <span style={{ fontFamily: c.fontMono, fontSize: 18 }}>[{focus.scores.map(score => score === null ? '−∞' : score.toFixed(2)).join(', ')}]</span>
60
+ <span style={{ marginTop: 10, color: c.textSecondary, fontSize: 13, fontFamily: c.fontMono }}>ROW-WISE SOFTMAX</span>
61
+ <span style={{ fontFamily: c.fontMono, fontSize: 18 }}>{vectorText(focus.weights)}</span>
62
+ <span style={{ marginTop: 18, color: c.textSecondary, fontSize: 13, fontFamily: c.fontMono }}>WEIGHTED VALUE OUTPUT</span>
63
+ <span style={{ color: resultColor, fontFamily: c.fontMono, fontSize: 36, fontWeight: 700 }}>{vectorText(focus.output)}</span>
64
+ <span style={{ color: c.textSecondary, fontSize: 18, lineHeight: 1.5 }}>Every displayed value is computed from the same Q, K and V.</span>
65
+ </div>
66
+
67
+ <div style={{ display: 'flex', position: 'absolute', left: 90, top: 618, flexDirection: 'column', gap: 16 }}>
68
+ <span style={{ color: c.textPrimary, fontFamily: c.fontMono, fontSize: 22 }}>V = [[1, 0], [0, 2], [2, 1], [−1, 3]]</span>
69
+ <span style={{ color: c.textMuted, fontSize: 16 }}>Four explicit illustrative vectors. Each highlighted row is a separate query, not a blended query.</span>
70
+ </div>
71
+ </div>
72
+ )
73
+ }
74
+
75
+ export function create(theme: ThemeMode = 'dark') {
76
+ return buildFrame(theme, 3.999)
77
+ }
78
+
79
+ export function createAnimation(theme: ThemeMode = 'dark') {
80
+ return defineAnimation({
81
+ initial: { cursor: 0 },
82
+ timeline: [
83
+ tween({ cursor: 3.999 }, { duration: 6500, easing: 'linear', label: 'Inspect four causal attention rows' }),
84
+ hold(1500, 'Read the last weighted output'),
85
+ ],
86
+ fps: 30,
87
+ render: ({ cursor }) => buildFrame(theme, cursor),
88
+ })
89
+ }
90
+
91
+ export default create('dark')
@@ -0,0 +1,34 @@
1
+ import { defineAnimation, hold, keyframe, tween, type AnimationTimelineStep, type ThemeMode } from 'vizmatic'
2
+ import { convolutionFrame, type KernelLessonState } from '../catalog-convolution-kernel'
3
+ export { width, height } from '../catalog-convolution-kernel'
4
+
5
+ export function create(theme: ThemeMode = 'dark') {
6
+ return convolutionFrame(theme, { cell: 0, term: 0, filled: 0, windowRow: 0, windowCol: 0, moving: 0, reveal: 0 })
7
+ }
8
+
9
+ export function createAnimation(theme: ThemeMode = 'dark') {
10
+ const timeline: AnimationTimelineStep<KernelLessonState>[] = [
11
+ hold(1100, 'Start with the actual synthetic pixel image'),
12
+ tween<Partial<KernelLessonState>>({ reveal: 1 }, { duration: 650, easing: 'ease-in-out', label: 'Reveal pixel values and the kernel' }),
13
+ hold(600, 'Select the first 3 by 3 patch'),
14
+ ]
15
+ for (let term = 1; term < 9; term++) {
16
+ timeline.push(keyframe<Partial<KernelLessonState>>({ term }, `Multiply pixel ${term + 1} by its kernel weight`), hold(500))
17
+ }
18
+ timeline.push(keyframe<Partial<KernelLessonState>>({ filled: 1 }), hold(650, 'Write the first sum and its ReLU'))
19
+ for (let cell = 1; cell < 16; cell++) {
20
+ timeline.push(
21
+ keyframe<Partial<KernelLessonState>>({ moving: 1 }),
22
+ tween<Partial<KernelLessonState>>({ windowRow: Math.floor(cell / 4), windowCol: cell % 4 }, { duration: 230, easing: 'ease-in-out', label: 'Slide the same weights to the next patch' }),
23
+ keyframe<Partial<KernelLessonState>>({ cell, term: cell % 4 < 2 ? 2 : 0, moving: 0, filled: cell + 1 }),
24
+ hold(cell === 2 ? 1150 : 360, cell === 2 ? 'The opposite edge gives a negative sum, which ReLU sets to zero' : 'Write the response and activation'),
25
+ )
26
+ }
27
+ timeline.push(hold(2200, 'Read the completed signed response and activation maps'))
28
+ return defineAnimation<KernelLessonState>({
29
+ initial: { cell: 0, term: 0, filled: 0, windowRow: 0, windowCol: 0, moving: 0, reveal: 0 },
30
+ timeline, fps: 24,
31
+ render: state => convolutionFrame(theme, state),
32
+ })
33
+ }
34
+ export default create('dark')
@@ -0,0 +1,32 @@
1
+ import { defineAnimation, hold } from 'vizmatic'
2
+ import { gaussianOutputTargets, blurFrame, type GaussianBlurState } from '../catalog-gaussian-blur'
3
+
4
+ export const width = 1280
5
+ export const height = 720
6
+
7
+ export function create(theme: 'dark' | 'light' = 'dark') {
8
+ return blurFrame(theme)
9
+ }
10
+
11
+ export function createAnimation(theme: 'dark' | 'light' = 'dark') {
12
+ const timeline = [
13
+ hold(1000, 'Look at the single bright pixel'),
14
+ { type: 'tween' as const, to: { stage: 1 }, duration: 1300, easing: 'ease-out' as const, label: 'Reveal the image, kernel, and output' },
15
+ { type: 'hold' as const, duration: 650, label: 'The center point is brighter than its neighbors' },
16
+ ...Array.from({ length: gaussianOutputTargets.length }, (_, index) => [
17
+ ...(index > 0 ? [{ type: 'keyframe' as const, value: { target: index, tap: 0 }, label: `Move the window to output row ${gaussianOutputTargets[index].row}, column ${gaussianOutputTargets[index].column}` }] : []),
18
+ { type: 'tween' as const, to: { tap: 8 }, duration: 800, easing: 'linear' as const, label: 'Accumulate nine weighted pixel taps' },
19
+ { type: 'hold' as const, duration: 250, label: 'Read the weighted output value' },
20
+ ]).flat(),
21
+ { type: 'keyframe' as const, value: { target: gaussianOutputTargets.length, tap: 8 }, label: 'Reveal the completed blur' },
22
+ { type: 'tween' as const, to: { tap: 4 }, duration: 350, easing: 'ease-in-out' as const, label: 'Return focus to the bright center pixel and its weight' },
23
+ { type: 'hold' as const, duration: 2600, label: 'The point has spread across the neighborhood' },
24
+ ]
25
+
26
+ return defineAnimation<GaussianBlurState>({
27
+ initial: { stage: 0, target: 0, tap: 0 },
28
+ timeline,
29
+ fps: 30,
30
+ render: state => blurFrame(theme, state),
31
+ })
32
+ }
@@ -0,0 +1,22 @@
1
+ /** Exact bytes from an actual CIFAR-10 image, not generated image data. */
2
+ import { defineAnimation, hold, tween, type ThemeMode } from 'vizmatic'
3
+ import { imageTensorFrame } from '../catalog-image-tensors'
4
+
5
+ export const width = 1280
6
+ export const height = 720
7
+
8
+ export function create(theme: ThemeMode = 'dark') { return imageTensorFrame(theme) }
9
+ export function createAnimation(theme: ThemeMode = 'dark') {
10
+ return defineAnimation({
11
+ initial: { reveal: 0, cursor: 0 },
12
+ timeline: [
13
+ hold(800, 'Start with the actual CIFAR image'),
14
+ tween({ reveal: 1 }, { duration: 1200, easing: 'ease-in-out', label: 'Separate the three RGB channels' }),
15
+ tween({ cursor: 15.999 }, { duration: 11000, easing: 'linear', label: 'Read a pixel and copy the same three bytes into its channel matrices' }),
16
+ hold(1200, 'Inspect the completed numerical crop'),
17
+ ],
18
+ fps: 24,
19
+ render: ({ reveal, cursor }) => imageTensorFrame(theme, cursor, reveal, true),
20
+ })
21
+ }
22
+ export default create('dark')