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
@@ -28,7 +28,6 @@ export function create(theme: ThemeMode = 'dark') {
28
28
  c={c}
29
29
  title="LayeredNetwork"
30
30
  subtitle="dense layers, active route, and annotations without coordinate code"
31
- tone="purple"
32
31
  width="100%"
33
32
  padding={14}
34
33
  align="center"
@@ -39,9 +38,9 @@ export function create(theme: ThemeMode = 'dark') {
39
38
  height={218}
40
39
  nodeSize={34}
41
40
  layers={[
42
- { title: 'Signal', nodes: ['x₁', 'x₂', 'x₃'], tone: 'blue' },
43
- { title: 'Encode', nodes: ['h₁', 'h₂', 'h₃'], tone: 'purple' },
44
- { title: 'Route', nodes: ['r₁', 'r₂'], tone: 'cyan' },
41
+ { title: 'Signal', nodes: ['x₁', 'x₂', 'x₃'] },
42
+ { title: 'Encode', nodes: ['h₁', 'h₂', 'h₃'] },
43
+ { title: 'Route', nodes: ['r₁', 'r₂'] },
45
44
  { title: 'Output', nodes: ['ŷ'], tone: 'green' },
46
45
  ]}
47
46
  activePath={[1, 1, 0, 0]}
@@ -56,7 +55,6 @@ export function create(theme: ThemeMode = 'dark') {
56
55
  c={c}
57
56
  title="GraphDiagram"
58
57
  subtitle="automatic layout, nested boundary, technical icons, and typed edges"
59
- tone="cyan"
60
58
  width={514}
61
59
  padding={14}
62
60
  align="center"
@@ -78,18 +76,18 @@ export function create(theme: ThemeMode = 'dark') {
78
76
  detailFontSize={11}
79
77
  iconSize={14}
80
78
  groups={[
81
- { id: 'runtime', label: 'Runtime', tone: 'cyan' },
79
+ { id: 'runtime', label: 'Runtime' },
82
80
  ]}
83
81
  nodes={[
84
- { id: 'brief', label: 'Brief', icon: 'file', group: 'runtime', tone: 'blue' },
85
- { id: 'plan', label: 'Plan', icon: 'layers', group: 'runtime', tone: 'purple' },
86
- { id: 'check', label: 'Check', icon: 'monitor', group: 'runtime', tone: 'cyan' },
82
+ { id: 'brief', label: 'Brief', icon: 'file', group: 'runtime' },
83
+ { id: 'plan', label: 'Plan', icon: 'layers', group: 'runtime' },
84
+ { id: 'check', label: 'Check', icon: 'monitor', group: 'runtime' },
87
85
  { id: 'asset', label: 'Asset', icon: 'storage', group: 'runtime', tone: 'green' },
88
86
  ]}
89
87
  edges={[
90
- { from: 'brief', to: 'plan', kind: 'sync', tone: 'blue' },
91
- { from: 'plan', to: 'check', kind: 'event', tone: 'purple' },
92
- { from: 'check', to: 'asset', kind: 'data', tone: 'green' },
88
+ { from: 'brief', to: 'plan', kind: 'sync' },
89
+ { from: 'plan', to: 'check', kind: 'event' },
90
+ { from: 'check', to: 'asset', kind: 'data' },
93
91
  ]}
94
92
  />
95
93
  </Panel>
@@ -119,10 +117,9 @@ export function create(theme: ThemeMode = 'dark') {
119
117
  {
120
118
  label: 'Visual',
121
119
  detail: 'composition',
122
- tone: 'blue',
123
120
  children: [
124
- { label: 'Diagram', detail: 'structure', tone: 'purple' },
125
- { label: 'Chart', detail: 'evidence', tone: 'cyan' },
121
+ { label: 'Diagram', detail: 'structure' },
122
+ { label: 'Chart', detail: 'evidence' },
126
123
  ],
127
124
  },
128
125
  {
@@ -130,7 +127,7 @@ export function create(theme: ThemeMode = 'dark') {
130
127
  detail: 'validation',
131
128
  tone: 'warm',
132
129
  children: [
133
- { label: 'Dark', detail: 'contrast', tone: 'purple' },
130
+ { label: 'Dark', detail: 'contrast' },
134
131
  { label: 'Light', detail: 'clarity', tone: 'green' },
135
132
  ],
136
133
  },
@@ -40,12 +40,12 @@ export function create(theme: ThemeMode = 'dark') {
40
40
  padding={28}
41
41
  gap={14}
42
42
  >
43
- <Panel c={c} title="Box · Arrow · Connector · FlowArrow" subtitle="HTML flow primitives for readable directional composition" tone="blue" width="100%" minHeight={174} align="center">
43
+ <Panel c={c} title="Box · Arrow · Connector · FlowArrow" subtitle="HTML flow primitives for readable directional composition" width="100%" align="center">
44
44
  <Row gap={8} align="center" justify="center">
45
45
  <Box c={c} label="Box" sublabel="source" color="primary" gradient width={86} height={54} fontSize={13} />
46
46
  <Arrow c={c} direction="right" label="Arrow" length={58} color={blue} />
47
47
  <Box c={c} label="Connector" sublabel="alias" color="secondary" width={96} height={54} fontSize={13} />
48
- <Connector c={c} direction="right" label="Connector" length={66} tone="purple" />
48
+ <Connector c={c} direction="right" label="Connector" length={66} />
49
49
  <Box c={c} label="FlowArrow" sublabel="semantic" color="info" width={98} height={54} fontSize={13} />
50
50
  <FlowArrow c={c} direction="right" label="FlowArrow" length={66} tone="green" />
51
51
  <Box c={c} label="Output" sublabel="frame" color="positive" width={86} height={54} fontSize={13} />
@@ -53,7 +53,7 @@ export function create(theme: ThemeMode = 'dark') {
53
53
  </Panel>
54
54
 
55
55
  <Row width="100%" gap={14} align="stretch">
56
- <Panel c={c} title="SVG primitives" subtitle="SvgFrame · SvgPoint · VectorSegment · VectorArrow · ArrowMarkerDef" tone="purple" width={500} minHeight={306}>
56
+ <Panel c={c} title="SVG primitives" subtitle="SvgFrame · SvgPoint · VectorSegment · VectorArrow · ArrowMarkerDef" width={500}>
57
57
  <Column gap={8} align="stretch">
58
58
  <svg width="468" height="184" viewBox="0 0 468 184">
59
59
  <defs>
@@ -70,7 +70,7 @@ export function create(theme: ThemeMode = 'dark') {
70
70
  </Column>
71
71
  </Panel>
72
72
 
73
- <Panel c={c} title="DotPoint + DashedLine" subtitle="absolute-position overlays" tone="warm" width={248} minHeight={306}>
73
+ <Panel c={c} title="DotPoint + DashedLine" subtitle="absolute-position overlays" tone="warm" width={248}>
74
74
  <div style={{ position: 'relative', display: 'flex', width: 214, height: 184, borderRadius: 10, backgroundColor: c.bgSubtle, border: `1px solid ${c.borderSubtle}` }}>
75
75
  {DashedLine({ x1: 38, y1: 142, x2: 172, y2: 58, color: warm, dotSpacing: 9, dotSize: 3 })}
76
76
  {DotPoint({ x: 38, y: 142, label: 'A', color: warm, c, size: 13, labelOffset: { x: 0, y: 12 } })}
@@ -80,7 +80,7 @@ export function create(theme: ThemeMode = 'dark') {
80
80
  <TextLabel c={c} text="DotPoint carries label and color." fontSize={11} mono />
81
81
  </Panel>
82
82
 
83
- <Panel c={c} title="AxisPlot" subtitle="points, paths, and vectors on axes" tone="cyan" width={282} minHeight={306} align="center">
83
+ <Panel c={c} title="AxisPlot" subtitle="points, paths, and vectors on axes" width={282} align="center">
84
84
  <AxisPlot
85
85
  c={c}
86
86
  width={254}
@@ -93,9 +93,9 @@ export function create(theme: ThemeMode = 'dark') {
93
93
  gridCount={4}
94
94
  xAxisLabel="x axis"
95
95
  yAxisLabel="y axis"
96
- paths={[{ points: [{ x: -2.4, y: -1.1 }, { x: -0.6, y: 0.2 }, { x: 0.7, y: 1.8 }, { x: 2.3, y: 2.4 }], tone: 'cyan', strokeWidth: 3 }]}
96
+ paths={[{ points: [{ x: -2.4, y: -1.1 }, { x: -0.6, y: 0.2 }, { x: 0.7, y: 1.8 }, { x: 2.3, y: 2.4 }], strokeWidth: 3 }]}
97
97
  vectors={[{ x1: 0, y1: 0, x2: 1.8, y2: 2.1, tone: 'green', arrow: true, strokeWidth: 3 }]}
98
- points={[{ x: -2.4, y: -1.1, tone: 'warm', r: 5 }, { x: 2.3, y: 2.4, tone: 'cyan', r: 5 }]}
98
+ points={[{ x: -2.4, y: -1.1, tone: 'warm', r: 5 }, { x: 2.3, y: 2.4, r: 5 }]}
99
99
  />
100
100
  </Panel>
101
101
  </Row>
@@ -31,7 +31,7 @@ export function create(theme: ThemeMode = 'dark') {
31
31
  gap={16}
32
32
  >
33
33
  <Row width="100%" gap={16} align="stretch">
34
- <Panel c={c} title="StatusRow + StatusList" subtitle="compact operational state" tone="green" width={330} minHeight={232}>
34
+ <Panel c={c} title="StatusRow + StatusList" subtitle="compact operational state" tone="green" width={330}>
35
35
  <Column gap={9} align="stretch">
36
36
  <StatusRow c={c} label="StatusRow" detail="single control" status="info" fontSize={12} />
37
37
  <StatusList
@@ -61,7 +61,7 @@ export function create(theme: ThemeMode = 'dark') {
61
61
  />
62
62
  </Row>
63
63
 
64
- <Panel c={c} title="Flow" subtitle="stage cards with semantic connectors" tone="purple" width="100%" minHeight={162} align="center">
64
+ <Panel c={c} title="Flow" subtitle="stage cards with semantic connectors" tone="purple" width="100%" align="center">
65
65
  <Flow
66
66
  c={c}
67
67
  gap={8}
@@ -77,7 +77,7 @@ export function create(theme: ThemeMode = 'dark') {
77
77
  </Panel>
78
78
 
79
79
  <Row width="100%" gap={16} align="stretch">
80
- <Panel c={c} title="Pipeline" subtitle="classic labeled stage chain" tone="blue" width={610} minHeight={206} align="center" justify="center">
80
+ <Panel c={c} title="Pipeline" subtitle="classic labeled stage chain" tone="blue" width={610} align="center" justify="center">
81
81
  <Pipeline
82
82
  c={c}
83
83
  title="Pipeline component"
@@ -88,7 +88,7 @@ export function create(theme: ThemeMode = 'dark') {
88
88
  ]}
89
89
  />
90
90
  </Panel>
91
- <Panel c={c} title="ProgressRow + ProgressList" subtitle="scores and completion bands" tone="cyan" width={434} minHeight={206}>
91
+ <Panel c={c} title="ProgressRow + ProgressList" subtitle="scores and completion bands" tone="cyan" width={434}>
92
92
  <Column gap={13} align="stretch">
93
93
  <ProgressRow c={c} label="ProgressRow" value={0.72} valueLabel="72%" tone="cyan" labelWidth={92} />
94
94
  <ProgressList
@@ -33,7 +33,7 @@ export function create(theme: ThemeMode = 'dark') {
33
33
  gap={14}
34
34
  >
35
35
  <Row width="100%" gap={14} align="stretch">
36
- <Panel c={c} title="Canvas + Scene" subtitle="root and composition layers" tone="purple" width={364} minHeight={116} justify="center">
36
+ <Panel c={c} title="Canvas + Scene" subtitle="root and composition layers" tone="purple" width={364} justify="center">
37
37
  <Column gap={8} align="stretch">
38
38
  <TextLabel c={c} text="Every poster starts with a theme-aware Canvas." fontSize={12} />
39
39
  <Row gap={8} justify="start">
@@ -42,10 +42,10 @@ export function create(theme: ThemeMode = 'dark') {
42
42
  </Row>
43
43
  </Column>
44
44
  </Panel>
45
- <Panel c={c} title="TitleBar" subtitle="standard poster header" tone="blue" width={330} minHeight={116} justify="center">
45
+ <Panel c={c} title="TitleBar" subtitle="standard poster header" tone="blue" width={330} justify="center">
46
46
  <TitleBar c={c} title="Named hierarchy" subtitle="title / subtitle / semantic tone" />
47
47
  </Panel>
48
- <Panel c={c} title="Layout contract" subtitle="explicit dimensions, readable spacing" tone="green" width={350} minHeight={116} justify="center">
48
+ <Panel c={c} title="Layout contract" subtitle="explicit dimensions, readable spacing" tone="green" width={350} justify="center">
49
49
  <Stack direction="horizontal" gap={10} align="center">
50
50
  <Icon c={c} name="code" tone="green" size={26} />
51
51
  <Column gap={3} align="start">
@@ -57,20 +57,20 @@ export function create(theme: ThemeMode = 'dark') {
57
57
  </Row>
58
58
 
59
59
  <Row width="100%" gap={14} align="stretch">
60
- <Panel c={c} title="Row" subtitle="horizontal distribution" tone="cyan" width={526} minHeight={210} justify="center">
60
+ <Panel c={c} title="Row" subtitle="horizontal distribution" tone="cyan" width={526} justify="center">
61
61
  <Row gap={10} align="stretch" justify="center">
62
- <Card c={c} title="start" tone="cyan" width={145} minHeight={116}>
62
+ <Card c={c} title="start" tone="cyan" width={145}>
63
63
  <TextLabel c={c} text="first child" fontSize={12} />
64
64
  </Card>
65
- <Card c={c} title="gap" tone="blue" width={145} minHeight={116}>
65
+ <Card c={c} title="gap" tone="blue" width={145}>
66
66
  <TextLabel c={c} text="shared rhythm" fontSize={12} />
67
67
  </Card>
68
- <Card c={c} title="end" tone="purple" width={145} minHeight={116}>
68
+ <Card c={c} title="end" tone="purple" width={145}>
69
69
  <TextLabel c={c} text="last child" fontSize={12} />
70
70
  </Card>
71
71
  </Row>
72
72
  </Panel>
73
- <Panel c={c} title="Column" subtitle="vertical hierarchy" tone="warm" width={518} minHeight={210}>
73
+ <Panel c={c} title="Column" subtitle="vertical hierarchy" tone="warm" width={518}>
74
74
  <Column gap={9} align="stretch">
75
75
  <Card c={c} title="headline" tone="warm" padding="10px 12px">
76
76
  <TextLabel c={c} text="Primary action or statement" fontSize={12} color={c.textPrimary} />
@@ -86,7 +86,7 @@ export function create(theme: ThemeMode = 'dark') {
86
86
  </Row>
87
87
 
88
88
  <Row width="100%" gap={14} align="stretch">
89
- <Panel c={c} title="Stack" subtitle="compact directional grouping" tone="green" width={300} minHeight={230} justify="center">
89
+ <Panel c={c} title="Stack" subtitle="compact directional grouping" tone="green" width={300} justify="center">
90
90
  <Stack gap={11} align="stretch">
91
91
  <Card c={c} tone="green" title="Stack item" padding="10px 12px">
92
92
  <TextLabel c={c} text="Vertical by default" fontSize={12} />
@@ -101,12 +101,12 @@ export function create(theme: ThemeMode = 'dark') {
101
101
  </Stack>
102
102
  </Stack>
103
103
  </Panel>
104
- <Card c={c} title="Card" subtitle="lightweight bordered surface" tone="blue" width={280} minHeight={230} gap={12}>
104
+ <Card c={c} title="Card" subtitle="lightweight bordered surface" tone="blue" width={280} gap={12}>
105
105
  <Icon c={c} name="spark" tone="blue" size={30} />
106
106
  <TextLabel c={c} text="Use Card for focused content with optional title, tone, and footer." fontSize={12} color={c.textPrimary} />
107
107
  <TextLabel c={c} text="Panel adds an accent header and structured body." fontSize={11} mono />
108
108
  </Card>
109
- <WindowFrame c={c} title="WindowFrame · terminal" variant="terminal" tone="green" width={464} minHeight={230}>
109
+ <WindowFrame c={c} title="WindowFrame · terminal" variant="terminal" tone="green" width={464}>
110
110
  <Column gap={10} align="stretch">
111
111
  <TextLabel c={c} text="$ vizmatic poster.tsx" fontSize={12} mono color={c.textPrimary} />
112
112
  <TextLabel c={c} text="✓ Canvas mounted" fontSize={12} mono color={positiveText} />
@@ -0,0 +1,146 @@
1
+ import {
2
+ crossCorrelate2d,
3
+ getThemeColors,
4
+ Matrix,
5
+ PixelGrid,
6
+ type ThemeMode,
7
+ } from 'vizmatic'
8
+
9
+ export const width = 1280
10
+ export const height = 720
11
+
12
+ const input = Array.from({ length: 7 }, (_, row) =>
13
+ Array.from({ length: 7 }, (_, column) => row === 3 && column === 3 ? 240 : 0))
14
+ const binomialAxis = [1, 2, 1]
15
+ const kernelNumerators = binomialAxis.map(row => binomialAxis.map(column => row * column))
16
+ const kernel = kernelNumerators.map(row => row.map(value => value / 16))
17
+ const output = crossCorrelate2d(input, kernel, { padding: 'same' })
18
+ const outputCrop = output.slice(2, 5).map(row => row.slice(2, 5))
19
+ export const gaussianOutputTargets = [
20
+ { row: 3, column: 3 },
21
+ { row: 2, column: 2 },
22
+ { row: 2, column: 3 },
23
+ { row: 2, column: 4 },
24
+ { row: 3, column: 2 },
25
+ { row: 3, column: 4 },
26
+ { row: 4, column: 2 },
27
+ { row: 4, column: 3 },
28
+ { row: 4, column: 4 },
29
+ ] as const
30
+ const integerLabels = (values: number[][]) => values.map(row => row.map(value => String(value)))
31
+ const pixelColors = (values: number[][], visible?: ReadonlySet<number>): readonly (readonly (readonly [number, number, number])[])[] =>
32
+ values.map((row, rowIndex) => row.map((value, columnIndex) => {
33
+ const visibleCell = visible === undefined || visible.has(rowIndex * row.length + columnIndex)
34
+ const byte = visibleCell ? Math.round(value) : 0
35
+ return [byte, byte, byte] as const
36
+ }))
37
+
38
+ export interface GaussianBlurState {
39
+ stage: number
40
+ target: number
41
+ tap: number
42
+ }
43
+
44
+ /** Shared by the catalog still and the MP4 lesson so every number agrees. */
45
+ export function blurFrame(theme: ThemeMode, state: Readonly<GaussianBlurState> = { stage: 1, target: gaussianOutputTargets.length, tap: 4 }) {
46
+ const c = getThemeColors(theme)
47
+ const stage = Math.max(0, Math.min(1, state.stage))
48
+ const targetIndex = state.target >= gaussianOutputTargets.length ? 0 : Math.max(0, Math.min(gaussianOutputTargets.length - 1, Math.floor(state.target)))
49
+ const tapIndex = Math.max(0, Math.min(8, Math.round(state.tap)))
50
+ const target = gaussianOutputTargets[targetIndex]
51
+ const selectedRow = target.row - 1
52
+ const selectedColumn = target.column - 1
53
+ const isCurrentReady = state.target >= gaussianOutputTargets.length || state.target > targetIndex || state.tap >= 7.99
54
+ const completed = Math.min(gaussianOutputTargets.length, Math.max(0, Math.floor(state.target) + (state.target >= gaussianOutputTargets.length ? 0 : isCurrentReady ? 1 : 0)))
55
+ const visibleOutputCells = new Set(state.target >= gaussianOutputTargets.length
56
+ ? Array.from({ length: 49 }, (_, index) => index)
57
+ : gaussianOutputTargets.slice(0, completed).map(cell => cell.row * 7 + cell.column))
58
+ const selectedPixel = input[selectedRow + Math.floor(tapIndex / 3)][selectedColumn + tapIndex % 3]
59
+ const selectedWeight = kernelNumerators[Math.floor(tapIndex / 3)][tapIndex % 3]
60
+ const partial = Array.from({ length: tapIndex + 1 }, (_, index) => {
61
+ const row = selectedRow + Math.floor(index / 3)
62
+ const column = selectedColumn + index % 3
63
+ return input[row]?.[column] ?? 0
64
+ }).reduce<number>((sum, value, index) => sum + value * kernelNumerators[Math.floor(index / 3)][index % 3], 0)
65
+ const operation = output[target.row][target.column]
66
+ const accent = theme === 'dark' ? c.warningLight : c.warningDark
67
+ const imageSize = 224 + (400 - 224) * (1 - stage)
68
+ const imageLeft = 76 + (440 - 76) * (1 - stage)
69
+ const imageTop = 220 + (180 - 220) * (1 - stage)
70
+ const gridOpacity = stage
71
+ const previewOnlyOpacity = 1 - stage
72
+ const selectedOutput = output[target.row][target.column]
73
+ const outputValues = outputCrop.map((row, rowIndex) => row.map((value, columnIndex) => {
74
+ const visible = state.target >= gaussianOutputTargets.length || visibleOutputCells.has((rowIndex + 2) * 7 + columnIndex + 2)
75
+ return visible ? value.toFixed(0) : '·'
76
+ }))
77
+ const formula = Array.from({ length: 9 }, (_, index) => {
78
+ const value = input[selectedRow + Math.floor(index / 3)][selectedColumn + index % 3]
79
+ const weight = kernelNumerators[Math.floor(index / 3)][index % 3]
80
+ return `${value}×${weight}`
81
+ }).join(' + ')
82
+
83
+ return (
84
+ <div style={{ position: 'relative', display: 'flex', width, height, overflow: 'hidden', backgroundColor: c.bg, color: c.textPrimary, fontFamily: c.fontSans }}>
85
+ <div style={{ position: 'absolute', left: 58, top: 37, display: 'flex', flexDirection: 'column', gap: 9 }}>
86
+ <span style={{ color: c.textSecondary, fontFamily: c.fontMono, fontSize: 14, fontWeight: 700, letterSpacing: 2 }}>COMPUTER VISION / GAUSSIAN-LIKE BLUR</span>
87
+ <span style={{ fontSize: 43, fontWeight: 760, letterSpacing: -1.2 }}>A bright point spreads into its neighbors.</span>
88
+ <span style={{ color: c.textSecondary, fontSize: 18 }}>A normalized kernel blends nearby pixels; padding sets the edge behavior.</span>
89
+ </div>
90
+
91
+ <div style={{ position: 'absolute', left: imageLeft, top: imageTop, display: 'flex', alignItems: 'center', justifyContent: 'center', width: imageSize, height: imageSize, opacity: previewOnlyOpacity, borderRadius: 18, backgroundColor: c.bgCard, border: `1px solid ${c.borderSubtle}` }}>
92
+ <PixelGrid c={c} pixels={pixelColors(input)} width={imageSize - 24} height={imageSize - 24} />
93
+ </div>
94
+
95
+ <div style={{ position: 'absolute', left: 44, top: 167, display: 'flex', width: 352, height: 398, flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 12, opacity: gridOpacity, backgroundColor: c.bgCard, border: `1px solid ${c.borderSubtle}`, borderRadius: 16 }}>
96
+ <span style={{ color: c.textPrimary, fontSize: 21, fontWeight: 730 }}>1 · Start with the image</span>
97
+ <span style={{ color: c.textSecondary, fontSize: 14 }}>One 240-value pixel on a dark field</span>
98
+ <div style={{ position: 'relative', display: 'flex' }}>
99
+ <PixelGrid c={c} pixels={pixelColors(input)} width={236} height={236}
100
+ region={{ row: selectedRow, column: selectedColumn, rows: 3, columns: 3 }}
101
+ activeCell={{ row: selectedRow + Math.floor(tapIndex / 3), column: selectedColumn + tapIndex % 3 }} highlightColor={accent} />
102
+ </div>
103
+ <span style={{ color: c.textSecondary, fontFamily: c.fontMono, fontSize: 14 }}>7 × 7 grayscale · values 0–255</span>
104
+ </div>
105
+
106
+ <div style={{ position: 'absolute', left: 424, top: 167, display: 'flex', width: 342, height: 398, flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 13, opacity: gridOpacity, backgroundColor: c.bgCard, border: `1px solid ${c.borderSubtle}`, borderRadius: 16 }}>
107
+ <span style={{ color: c.textPrimary, fontSize: 21, fontWeight: 730 }}>2 · Weight the neighborhood</span>
108
+ <span style={{ color: c.textSecondary, fontSize: 14 }}>A 3 × 3 binomial approximation · divide by 16</span>
109
+ <Matrix c={c} data={kernelNumerators} labels={integerLabels(kernelNumerators)} colorize={false} format="integer" fontSize={22} cellWidth={52} cellHeight={48}
110
+ highlightCell={{ row: Math.floor(tapIndex / 3), col: tapIndex % 3 }} highlightColor={accent} />
111
+ <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 6, marginTop: 7 }}>
112
+ <span style={{ color: c.textSecondary, fontFamily: c.fontMono, fontSize: 14, fontWeight: 650 }}>K = vᵀv / 16 · v = [1, 2, 1]</span>
113
+ <span style={{ color: theme === 'dark' ? c.infoLight : c.infoDark, fontFamily: c.fontMono, fontSize: 14, fontWeight: 700 }}>sum of all 9 weights = 1</span>
114
+ </div>
115
+ </div>
116
+
117
+ <div style={{ position: 'absolute', left: 794, top: 167, display: 'flex', width: 442, height: 398, flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 12, opacity: gridOpacity, backgroundColor: c.bgCard, border: `1px solid ${c.borderSubtle}`, borderRadius: 16 }}>
118
+ <span style={{ color: c.textPrimary, fontSize: 21, fontWeight: 730 }}>3 · Read the blurred image</span>
119
+ <span style={{ color: c.textSecondary, fontSize: 14 }}>The image reveals as the kernel scans</span>
120
+ <div style={{ display: 'flex', alignItems: 'center', gap: 15 }}>
121
+ <PixelGrid c={c} pixels={pixelColors(output, visibleOutputCells)} width={210} height={210}
122
+ activeCell={state.target < gaussianOutputTargets.length ? { row: target.row, column: target.column } : undefined} highlightColor={accent} />
123
+ <Matrix c={c} data={outputCrop} labels={outputValues} colorize={false} format="integer" fontSize={18} cellWidth={42} cellHeight={42}
124
+ highlightCell={state.target < gaussianOutputTargets.length ? { row: target.row - 2, col: target.column - 2 } : undefined} highlightColor={accent} />
125
+ </div>
126
+ <span style={{ color: c.textMuted, fontFamily: c.fontMono, fontSize: 12 }}>Expanded output · rows 2–4 · columns 2–4</span>
127
+ <span style={{ color: c.textSecondary, fontFamily: c.fontMono, fontSize: 14 }}>Center = {output[3][3].toFixed(0)} · adjacent = {output[3][2].toFixed(0)} · diagonal = {output[2][2].toFixed(0)}</span>
128
+ </div>
129
+
130
+ <div style={{ position: 'absolute', left: 44, top: 582, display: 'flex', width: 1192, height: 102, flexDirection: 'column', justifyContent: 'center', gap: 9, padding: '14px 22px', boxSizing: 'border-box', backgroundColor: c.bgCard, border: `1px solid ${c.borderSubtle}`, borderRadius: 14, opacity: gridOpacity }}>
131
+ <div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
132
+ <span style={{ color: accent, fontFamily: c.fontMono, fontSize: 13, fontWeight: 700, letterSpacing: 1 }}>OUTPUT [{target.row}, {target.column}]</span>
133
+ <span style={{ color: c.textSecondary, fontFamily: c.fontMono, fontSize: 14 }}>tap {Math.floor(tapIndex / 3) + 1},{tapIndex % 3 + 1} · {selectedPixel}×{selectedWeight} · first {tapIndex + 1}/9 terms: {partial}/16</span>
134
+ <span style={{ marginLeft: 'auto', color: c.textPrimary, fontFamily: c.fontMono, fontSize: 18, fontWeight: 750 }}>{isCurrentReady ? selectedOutput.toFixed(1) : '…'}</span>
135
+ </div>
136
+ <span style={{ color: c.textSecondary, fontFamily: c.fontMono, fontSize: 13 }}>({formula}) / 16 = {operation.toFixed(1)} · zero padding preserves the 7 × 7 image size</span>
137
+ </div>
138
+ </div>
139
+ )
140
+ }
141
+
142
+ export function create(theme: ThemeMode = 'dark') {
143
+ return blurFrame(theme)
144
+ }
145
+
146
+ export default create('dark')
@@ -0,0 +1,115 @@
1
+ /**
2
+ * One actual CIFAR-10 training image, reconstructed from its original RGB bytes.
3
+ * Source and binary format: https://www.cs.toronto.edu/~kriz/cifar.html
4
+ * Cite: Alex Krizhevsky, Learning Multiple Layers of Features from Tiny Images (2009).
5
+ * Regenerate the sample: node scripts/extract-cifar-sample.mjs
6
+ * The dataset page does not specify a license; these sample bytes are not MIT-licensed code.
7
+ */
8
+ import {
9
+ PixelGrid, Matrix, cropRgbImage, rgbChannel, getThemeColors,
10
+ type RgbPixel, type ThemeMode,
11
+ } from 'vizmatic'
12
+
13
+ export const width = 1280
14
+ export const height = 720
15
+
16
+ // CIFAR_SAMPLE_START
17
+ // Official training batch 1, record 0, label 6 (frog). Record SHA-256: 945dc5584f8efcf7dc58367c3b072c0a23dacc05ae824d7c77a33874a8ec83c7
18
+ export const cifar10Pixels: RgbPixel[][] = [
19
+ [[59,62,63],[43,46,45],[50,48,43],[68,54,42],[98,73,52],[119,91,63],[139,107,75],[145,110,80],[149,117,89],[149,120,93],[131,103,77],[125,99,76],[142,115,91],[144,112,86],[137,105,79],[129,97,71],[137,106,79],[134,106,76],[124,97,64],[139,113,78],[139,112,75],[133,105,69],[136,105,74],[139,108,77],[152,120,89],[163,131,100],[168,136,108],[159,129,102],[158,130,104],[158,132,108],[152,125,102],[148,124,103]],
20
+ [[16,20,20],[0,0,0],[18,8,0],[51,27,8],[88,51,21],[120,82,43],[128,89,45],[127,86,44],[126,87,50],[116,79,44],[106,70,37],[101,67,35],[105,70,36],[113,74,35],[109,70,33],[112,72,37],[119,79,44],[109,71,33],[105,69,27],[125,89,46],[127,92,46],[122,85,39],[131,89,47],[124,82,41],[121,79,37],[131,89,48],[132,91,53],[133,94,58],[133,96,60],[123,88,55],[119,83,50],[122,87,57]],
21
+ [[25,24,21],[16,7,0],[49,27,8],[83,50,23],[110,72,41],[129,92,54],[130,93,55],[121,82,47],[113,77,43],[112,78,44],[112,79,46],[106,75,45],[105,73,38],[128,92,48],[124,87,47],[130,92,56],[127,89,56],[122,85,51],[115,79,43],[120,85,47],[130,95,54],[131,96,55],[139,102,62],[127,90,51],[126,89,49],[127,89,50],[130,92,53],[142,105,68],[130,94,58],[118,84,50],[120,84,50],[109,73,42]],
22
+ [[33,25,17],[38,20,4],[87,54,25],[106,63,28],[115,70,33],[117,74,35],[114,72,37],[105,62,33],[107,68,33],[121,84,45],[125,90,53],[109,75,40],[113,77,38],[146,105,58],[133,91,47],[127,84,45],[118,76,40],[117,76,41],[127,87,52],[122,81,43],[132,92,51],[137,99,58],[136,99,57],[131,93,52],[124,86,44],[130,91,50],[132,90,49],[135,93,51],[130,90,50],[125,87,50],[121,85,48],[94,62,35]],
23
+ [[50,32,21],[59,32,11],[102,65,34],[127,79,39],[124,77,36],[121,77,36],[120,78,40],[114,74,39],[107,72,34],[125,88,49],[129,89,51],[106,68,31],[108,71,33],[124,83,42],[121,78,39],[108,68,29],[98,65,23],[110,74,37],[117,80,49],[120,80,41],[134,93,50],[140,106,66],[131,95,58],[141,98,66],[135,92,51],[127,84,45],[121,79,41],[119,79,40],[103,67,32],[87,57,27],[75,47,23],[67,42,25]],
24
+ [[71,48,29],[84,53,24],[110,73,37],[129,82,38],[136,88,45],[131,84,42],[129,84,43],[119,77,37],[108,70,33],[122,82,44],[123,81,39],[105,65,25],[107,72,31],[111,77,31],[108,74,34],[98,65,27],[94,62,21],[97,63,32],[83,56,38],[88,58,36],[102,68,42],[97,69,46],[88,54,36],[118,74,72],[140,96,79],[136,97,64],[120,80,45],[107,68,34],[88,54,24],[67,39,15],[35,10,0],[32,13,4]],
25
+ [[97,69,40],[111,75,36],[123,85,43],[130,84,38],[136,88,44],[132,83,40],[122,74,30],[121,74,31],[127,83,46],[138,94,54],[124,79,34],[120,79,39],[107,71,34],[80,50,14],[68,43,17],[74,41,17],[101,51,21],[105,56,23],[65,37,16],[58,36,19],[63,37,18],[78,51,31],[136,93,83],[122,68,80],[139,86,79],[151,106,69],[129,87,49],[108,68,36],[95,59,29],[96,63,37],[89,61,38],[66,47,30]],
26
+ [[115,82,49],[119,76,33],[130,90,47],[140,97,53],[133,88,48],[127,81,40],[138,90,47],[137,89,46],[131,86,48],[133,89,46],[134,91,46],[108,70,39],[72,39,19],[51,26,10],[41,22,14],[72,31,17],[181,102,69],[209,127,81],[125,76,47],[68,40,23],[64,38,17],[82,53,30],[123,77,62],[112,56,55],[135,81,60],[151,103,61],[137,95,54],[114,76,39],[105,69,34],[101,66,33],[126,92,59],[102,74,46]],
27
+ [[137,100,68],[128,82,41],[132,91,51],[128,87,48],[119,81,44],[123,82,43],[128,85,44],[130,85,44],[121,80,40],[137,97,54],[131,94,53],[74,42,20],[54,25,16],[50,29,16],[44,29,18],[86,39,15],[203,106,56],[217,109,62],[162,90,71],[100,58,49],[77,42,27],[75,43,24],[74,39,24],[76,35,22],[107,67,36],[135,96,59],[135,97,58],[129,91,49],[127,89,48],[119,83,43],[125,86,45],[134,95,56]],
28
+ [[154,120,89],[154,112,77],[156,114,82],[140,100,65],[123,89,53],[125,86,50],[126,86,48],[127,91,52],[133,97,60],[132,97,68],[90,60,30],[63,35,9],[62,33,16],[70,39,20],[79,50,30],[103,53,26],[152,70,33],[148,64,37],[141,79,61],[121,75,57],[101,58,41],[96,54,33],[86,48,24],[75,38,21],[101,63,32],[136,91,53],[136,92,53],[134,93,50],[133,93,52],[132,93,52],[128,86,45],[133,92,55]],
29
+ [[154,122,94],[155,117,82],[156,117,82],[147,108,70],[133,100,64],[137,100,66],[139,102,68],[134,102,66],[141,111,81],[121,87,68],[80,40,13],[97,53,17],[90,45,17],[98,56,30],[137,91,57],[139,84,49],[148,87,54],[134,73,37],[138,82,46],[134,85,57],[140,92,76],[175,129,106],[142,99,53],[102,61,26],[108,67,25],[135,90,41],[131,87,45],[133,91,51],[138,97,57],[136,95,55],[130,86,46],[134,93,57]],
30
+ [[145,114,89],[146,109,73],[146,109,69],[135,97,55],[127,92,57],[129,94,65],[117,84,55],[103,74,42],[130,103,70],[120,83,55],[111,60,14],[146,86,22],[136,78,23],[163,116,77],[169,115,69],[152,100,52],[161,116,73],[148,97,57],[177,121,82],[161,110,71],[195,150,113],[209,167,123],[189,146,94],[125,78,40],[108,63,25],[140,96,52],[137,95,59],[132,93,56],[136,95,57],[133,90,51],[132,87,46],[133,92,56]],
31
+ [[142,115,86],[141,106,69],[140,105,68],[144,105,64],[147,110,74],[121,89,65],[84,56,34],[88,61,33],[109,80,44],[101,57,23],[138,79,19],[213,150,59],[178,123,41],[191,150,98],[211,169,122],[189,148,99],[205,164,110],[207,162,115],[213,164,118],[191,143,91],[199,158,97],[188,151,88],[161,121,76],[130,83,50],[124,77,38],[131,87,51],[130,91,61],[131,93,60],[134,93,57],[135,91,52],[136,89,48],[133,91,56]],
32
+ [[158,131,98],[154,119,82],[142,107,74],[143,102,65],[132,92,59],[90,59,36],[72,44,22],[81,52,24],[84,47,19],[107,55,25],[165,106,50],[229,176,92],[183,137,57],[191,158,103],[239,216,176],[219,192,149],[228,188,128],[225,188,120],[214,177,112],[216,174,112],[210,171,110],[200,169,109],[189,162,114],[174,137,100],[161,118,76],[139,95,57],[134,96,66],[126,90,59],[131,92,56],[142,98,60],[136,89,48],[138,97,61]],
33
+ [[145,115,79],[149,109,66],[147,108,68],[147,105,65],[136,95,62],[80,47,21],[89,57,32],[105,68,40],[96,51,26],[129,81,45],[192,152,113],[185,148,107],[145,101,51],[203,162,121],[223,200,170],[242,227,196],[244,227,186],[238,220,165],[241,219,163],[227,197,144],[225,191,139],[235,209,157],[219,206,164],[224,208,181],[215,192,156],[156,118,78],[128,89,57],[129,95,62],[131,95,60],[133,97,60],[128,89,50],[130,92,56]],
34
+ [[148,116,79],[146,100,54],[145,100,55],[147,100,51],[133,96,54],[63,42,21],[66,43,31],[88,50,34],[113,65,37],[182,146,110],[220,191,169],[138,94,71],[162,105,63],[206,156,112],[196,166,135],[247,234,212],[255,253,232],[255,252,219],[245,234,197],[236,217,180],[230,208,170],[215,196,160],[231,217,197],[250,241,229],[241,229,195],[158,132,78],[125,95,49],[126,97,58],[124,92,52],[125,91,49],[126,88,46],[124,88,54]],
35
+ [[149,115,79],[143,95,49],[144,97,51],[151,99,51],[132,87,49],[64,40,21],[84,59,41],[112,69,37],[163,121,75],[223,204,166],[206,182,157],[145,90,56],[196,133,84],[204,157,110],[220,188,156],[243,226,208],[245,237,226],[239,233,215],[234,224,201],[231,217,192],[195,181,152],[150,137,100],[208,193,154],[250,241,216],[227,216,173],[163,142,78],[145,127,60],[143,129,62],[140,123,55],[136,116,46],[121,95,30],[114,82,40]],
36
+ [[147,111,76],[134,88,47],[140,99,61],[148,103,66],[135,89,60],[100,64,38],[108,73,43],[144,104,66],[210,181,140],[248,243,212],[175,147,115],[175,119,73],[220,176,129],[226,197,164],[230,207,179],[233,218,196],[224,212,195],[201,186,166],[184,163,138],[181,158,128],[190,171,136],[170,157,105],[179,167,105],[231,218,181],[223,206,161],[162,133,71],[146,116,43],[140,115,34],[139,116,33],[145,123,38],[142,119,35],[128,102,41]],
37
+ [[152,114,80],[117,75,37],[114,80,48],[123,90,57],[126,91,56],[122,83,48],[93,58,32],[179,154,138],[238,226,212],[248,243,229],[170,134,104],[185,132,88],[241,214,177],[230,218,195],[187,169,142],[180,160,131],[166,146,115],[146,119,85],[149,116,79],[157,124,83],[184,157,110],[216,195,141],[212,198,152],[236,221,197],[236,212,176],[166,125,63],[136,85,16],[134,81,13],[130,83,13],[127,86,16],[137,105,27],[151,128,54]],
38
+ [[145,105,72],[127,82,41],[128,90,51],[133,92,53],[132,89,49],[135,95,51],[171,145,110],[237,227,205],[252,247,235],[229,213,194],[173,136,100],[169,121,73],[220,182,138],[194,169,135],[123,89,55],[135,98,60],[127,91,48],[151,114,63],[165,127,74],[132,99,50],[151,126,79],[202,183,142],[240,228,203],[240,225,210],[222,196,169],[156,117,64],[119,76,12],[120,75,16],[112,66,14],[100,65,15],[99,74,19],[140,121,54]],
39
+ [[143,104,66],[127,80,38],[129,86,49],[129,85,46],[130,86,45],[140,102,59],[219,196,161],[244,232,210],[210,199,186],[193,173,151],[166,129,92],[153,104,55],[191,146,96],[179,145,105],[128,86,47],[147,102,58],[149,106,59],[172,131,78],[147,108,54],[128,94,45],[141,113,67],[173,150,112],[202,183,160],[190,171,147],[198,175,146],[152,124,86],[100,72,26],[109,81,34],[119,88,43],[121,92,50],[108,82,36],[136,119,50]],
40
+ [[143,104,64],[125,76,32],[131,85,48],[128,81,43],[123,81,39],[153,117,76],[148,118,85],[166,141,118],[188,166,147],[182,156,132],[171,134,99],[165,115,69],[195,148,99],[190,153,110],[152,108,66],[143,95,49],[152,105,56],[153,110,58],[142,102,51],[141,102,54],[135,101,55],[136,101,60],[148,110,74],[141,106,65],[141,111,68],[138,113,71],[111,100,37],[111,111,31],[121,118,35],[129,116,39],[138,116,45],[179,162,83]],
41
+ [[141,102,65],[131,80,35],[139,89,46],[139,87,44],[138,90,50],[151,111,71],[128,91,52],[136,97,61],[175,136,104],[173,136,107],[189,151,118],[205,160,120],[201,157,113],[168,131,89],[151,108,65],[145,97,53],[146,101,52],[149,106,57],[153,110,61],[149,108,61],[144,104,59],[144,105,59],[145,104,59],[143,102,60],[129,96,48],[123,103,39],[124,126,30],[113,135,14],[108,133,8],[113,122,10],[148,136,44],[199,184,102]],
42
+ [[143,103,72],[139,87,44],[138,89,42],[149,96,52],[160,109,72],[150,106,64],[147,104,58],[151,104,57],[169,121,81],[167,123,87],[179,141,105],[212,174,138],[203,168,132],[207,177,141],[149,112,74],[139,96,55],[144,102,56],[137,94,47],[151,107,61],[155,111,65],[152,109,63],[140,101,55],[107,76,38],[91,60,34],[84,61,23],[105,99,25],[132,142,34],[118,141,20],[96,121,4],[102,113,9],[159,149,63],[190,174,99]],
43
+ [[149,107,74],[133,80,37],[136,88,48],[147,99,59],[150,104,63],[153,109,62],[157,112,67],[162,117,78],[175,131,96],[190,145,107],[166,124,84],[202,168,133],[224,197,168],[197,175,148],[192,165,133],[180,144,107],[146,106,64],[126,82,40],[141,97,52],[156,112,66],[153,109,61],[115,74,29],[77,43,14],[79,50,25],[93,73,33],[126,117,47],[133,134,39],[119,116,31],[113,99,24],[140,121,42],[187,165,91],[154,132,75]],
44
+ [[172,128,76],[144,88,18],[135,85,35],[136,88,48],[135,90,45],[139,94,49],[153,108,68],[163,117,83],[166,120,82],[184,136,100],[166,118,88],[150,110,75],[184,149,110],[156,121,86],[158,123,87],[168,130,92],[149,109,71],[135,91,51],[130,85,43],[132,88,43],[128,84,37],[127,83,36],[135,92,52],[143,105,66],[139,108,62],[136,112,52],[127,105,39],[121,92,39],[135,102,44],[189,159,87],[211,181,114],[136,107,58]],
45
+ [[202,157,82],[187,129,26],[151,100,25],[128,79,34],[122,76,41],[134,88,49],[142,98,53],[150,106,56],[153,106,58],[148,99,63],[135,87,59],[127,82,44],[153,109,60],[166,121,77],[143,99,59],[130,88,51],[128,87,52],[151,108,70],[152,106,65],[135,90,48],[139,95,50],[155,110,63],[161,113,65],[154,107,63],[154,112,67],[143,105,54],[130,93,44],[132,90,46],[171,131,70],[215,183,106],[186,155,91],[117,86,48]],
46
+ [[216,174,87],[193,136,16],[168,122,19],[151,111,35],[131,88,34],[126,82,35],[138,94,49],[144,100,53],[142,95,53],[137,92,51],[120,78,34],[131,87,41],[145,99,52],[144,101,57],[137,94,54],[127,83,48],[126,82,51],[139,94,60],[153,108,69],[149,104,63],[140,95,53],[135,91,46],[147,103,57],[148,105,59],[149,108,62],[149,109,63],[137,101,54],[143,107,57],[203,167,102],[206,173,105],[124,93,49],[71,48,26]],
47
+ [[220,182,91],[201,150,22],[186,148,24],[172,139,28],[156,120,26],[142,103,30],[142,100,51],[153,108,75],[150,105,73],[139,98,57],[126,88,38],[136,92,47],[148,102,62],[141,101,60],[131,89,51],[126,82,49],[127,81,51],[138,88,52],[150,100,60],[154,104,65],[149,101,60],[124,78,36],[126,85,41],[141,101,55],[145,107,61],[147,112,68],[127,101,59],[114,87,46],[186,155,98],[173,144,87],[56,29,9],[33,19,9]],
48
+ [[208,170,96],[201,153,34],[198,161,26],[191,157,27],[183,146,34],[171,135,32],[159,121,42],[147,107,52],[135,95,49],[130,87,46],[139,93,57],[147,98,62],[144,95,55],[145,99,57],[137,91,51],[136,89,52],[137,90,54],[148,102,58],[152,106,60],[150,103,61],[155,110,64],[138,94,46],[120,76,33],[128,84,39],[142,102,58],[135,103,62],[90,69,40],[50,24,11],[137,105,60],[160,133,70],[56,31,7],[53,34,20]],
49
+ [[180,139,96],[173,123,42],[186,144,30],[194,153,25],[198,158,34],[201,164,36],[189,153,32],[173,137,32],[156,118,38],[139,99,38],[142,97,49],[145,97,56],[141,92,52],[141,93,52],[139,91,51],[140,91,53],[143,95,58],[139,99,60],[138,98,60],[143,96,56],[146,93,43],[135,84,33],[117,80,38],[112,72,29],[122,81,39],[104,67,30],[58,31,11],[34,5,0],[131,94,57],[184,148,94],[97,62,34],[83,53,34]],
50
+ [[177,144,116],[168,129,94],[179,142,87],[188,149,67],[202,168,68],[218,189,76],[218,191,72],[207,181,70],[191,163,79],[175,143,82],[166,132,86],[163,128,92],[163,127,94],[161,123,92],[153,114,84],[159,120,90],[162,124,93],[149,116,91],[140,104,83],[148,103,77],[161,105,69],[144,95,55],[112,90,59],[119,91,58],[130,96,65],[120,87,59],[92,67,46],[103,78,57],[170,140,104],[216,184,140],[151,118,84],[123,92,72]],
51
+ ]
52
+ // CIFAR_SAMPLE_END
53
+
54
+ export const cropRegion = { row: 12, column: 14, rows: 4, columns: 4 }
55
+ const channels = ['red', 'green', 'blue'] as const
56
+ const channelLabels = ['R · red', 'G · green', 'B · blue']
57
+
58
+ /** All labels, image colors and moving values share this same original sample. */
59
+ export function imageTensorFrame(theme: ThemeMode, cursor = 15.999, reveal = 1, animate = false) {
60
+ const c = getThemeColors(theme)
61
+ const step = Math.min(15, Math.max(0, Math.floor(cursor)))
62
+ const row = Math.floor(step / 4), col = step % 4
63
+ const activeCell = { row: cropRegion.row + row, column: cropRegion.column + col }
64
+ const pixel = cifar10Pixels[activeCell.row][activeCell.column]
65
+ const crop = cropRgbImage(cifar10Pixels, cropRegion)
66
+ const travel = Math.min(1, Math.max(0, (cursor - Math.floor(cursor)) / .85))
67
+ const arrival = !animate || travel >= .98
68
+ const channelColor = theme === 'dark'
69
+ ? [c.criticalLight, c.positiveLight, c.infoLight]
70
+ : [c.criticalDark, c.positiveDark, c.infoDark]
71
+ const originX = 64 + (activeCell.column + .5) * 10
72
+ const originY = 217 + (activeCell.row + .5) * 10
73
+ return (
74
+ <div style={{ display: 'flex', position: 'relative', width, height, backgroundColor: c.bg, color: c.textPrimary, fontFamily: c.fontSans, overflow: 'hidden' }}>
75
+ <div style={{ display: 'flex', position: 'absolute', left: 64, top: 34, color: c.textSecondary, fontFamily: c.fontMono, fontSize: 13, letterSpacing: 2 }}>COMPUTER VISION / IMAGE → TENSOR</div>
76
+ <div style={{ display: 'flex', position: 'absolute', left: 64, top: 65, fontSize: 44, fontWeight: 750, letterSpacing: -1.4 }}>One picture. Three matrices.</div>
77
+ <div style={{ display: 'flex', position: 'absolute', left: 64, top: 127, fontSize: 19, color: c.textSecondary }}>Read one pixel, then copy its red, green and blue bytes into three channel matrices.</div>
78
+ <div style={{ display: 'flex', position: 'absolute', left: 64, top: 180, fontSize: 20, fontWeight: 700 }}>Actual CIFAR-10 image · frog</div>
79
+ <div style={{ display: 'flex', position: 'absolute', left: 64, top: 217 }}>
80
+ <PixelGrid c={c} pixels={cifar10Pixels} width={320} height={320} region={cropRegion} activeCell={activeCell} highlightColor={c.warning} />
81
+ </div>
82
+ <div style={{ display: 'flex', position: 'absolute', left: 64, top: 555, width: 330, flexDirection: 'column', gap: 8 }}>
83
+ <span style={{ color: c.textPrimary, fontSize: 21, fontFamily: c.fontMono }}>pixel[{activeCell.row}, {activeCell.column}]</span>
84
+ <span style={{ fontSize: 25, fontFamily: c.fontMono, fontWeight: 700 }}>[{pixel.join(', ')}]</span>
85
+ <span style={{ color: c.textSecondary, fontSize: 16 }}>32 × 32 × 3 = 3,072 byte values</span>
86
+ <span style={{ color: c.textSecondary, fontSize: 15 }}>Crop: rows 12–15 · cols 14–17</span>
87
+ </div>
88
+ {channels.map((channel, index) => {
89
+ const x = 430 + index * 274
90
+ const values = rgbChannel(crop, channel)
91
+ const labels = values.map((r, ri) => r.map((v, ci) => !animate || ri * 4 + ci < step || ri * 4 + ci === step && arrival ? String(v) : '·'))
92
+ const alpha = Math.min(1, Math.max(0, (reveal - index * .14) / .6))
93
+ return <div key={channel} style={{ display: 'flex', position: 'absolute', left: x, top: 177, width: 250, height: 470, opacity: alpha }}>
94
+ <span style={{ display: 'flex', position: 'absolute', left: 0, top: 0, width: 250, justifyContent: 'center', color: channelColor[index], fontSize: 21, fontWeight: 700 }}>{channelLabels[index]} · 32 × 32</span>
95
+ <div style={{ display: 'flex', position: 'absolute', left: 45, top: 40 }}><PixelGrid c={c} pixels={cifar10Pixels} width={160} height={160} channel={channel} region={cropRegion} activeCell={activeCell} highlightColor={c.warning} /></div>
96
+ <span style={{ display: 'flex', position: 'absolute', left: 0, top: 435, width: 250, justifyContent: 'center', color: c.textSecondary, fontSize: 14 }}>The same 4 × 4 crop · values 0–255</span>
97
+ {Array.from({ length: 4 }, (_, i) => <span key={'col' + i} style={{ display: 'flex', position: 'absolute', left: 36 + i * 45, top: 233, width: 43, height: 20, alignItems: 'center', justifyContent: 'center', color: c.textSecondary, fontFamily: c.fontMono, fontSize: 14 }}>{14 + i}</span>)}
98
+ {Array.from({ length: 4 }, (_, i) => <span key={'row' + i} style={{ display: 'flex', position: 'absolute', left: 4, top: 253 + i * 44, width: 28, height: 42, alignItems: 'center', justifyContent: 'center', color: c.textSecondary, fontFamily: c.fontMono, fontSize: 14 }}>{12 + i}</span>)}
99
+ <div style={{ display: 'flex', position: 'absolute', left: 36, top: 253 }}><Matrix c={c} data={values} labels={labels} colorize={false} format="integer" fontSize={20} cellWidth={43} cellHeight={42} highlightCell={{ row, col }} highlightColor={channelColor[index]} /></div>
100
+ </div>
101
+ })}
102
+ {animate && reveal >= .99 && travel > .02 && travel < .98 && channels.map((channel, index) => {
103
+ const targetX = 430 + index * 274 + 36 + 21.5 + col * 45
104
+ const targetY = 430 + 21 + row * 44
105
+ const x = originX + (targetX - originX) * travel
106
+ const y = originY + (targetY - originY) * travel - Math.sin(Math.PI * travel) * 45
107
+ return <div key={channel} style={{ display: 'flex', position: 'absolute', left: x - 22, top: y - 17, width: 44, height: 34, alignItems: 'center', justifyContent: 'center', borderRadius: 6, backgroundColor: c.bgCard, border: '2px solid ' + channelColor[index], color: c.textPrimary, fontFamily: c.fontMono, fontSize: 17, fontWeight: 700 }}>{pixel[index]}</div>
108
+ })}
109
+ <div style={{ display: 'flex', position: 'absolute', left: 64, top: 684, color: c.textSecondary, fontSize: 13 }}>Source: CIFAR-10 · Krizhevsky (2009) · training batch 1, record 0 · original channel-first bytes [3, 32, 32]</div>
110
+ </div>
111
+ )
112
+ }
113
+
114
+ export function create(theme: ThemeMode = 'dark') { return imageTensorFrame(theme) }
115
+ export default create('dark')