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.
- package/PROMPT.md +75 -531
- package/README.md +85 -1052
- package/ROADMAP.md +49 -67
- package/SCIENCE.md +250 -0
- package/assets/THIRD_PARTY_LICENSES.md +44 -1
- package/assets/fonts/InstrumentSerif-Italic.ttf +0 -0
- package/assets/fonts/InstrumentSerif-Regular.ttf +0 -0
- package/assets/fonts/SourceSerif4-24pt-Italic.ttf +0 -0
- package/assets/fonts/SourceSerif4-24pt-Regular.ttf +0 -0
- package/assets/licenses/raster-codecs-MIT.txt +74 -0
- package/dist/chunk-3F2VQ7NW.js +1 -0
- package/dist/{chunk-FEIPTPBZ.js → chunk-4XE64I2U.js} +53 -463
- package/dist/chunk-5ZAFH2JC.js +4231 -0
- package/dist/chunk-JHHPLALU.js +79 -0
- package/dist/chunk-LTX44BAE.js +112 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/chunk-PSBF4TEK.js +1 -0
- package/dist/chunk-RPAHMKAR.js +605 -0
- package/dist/chunk-RWF4VBUL.js +3617 -0
- package/dist/cli.js +369 -12
- package/dist/index.cjs +7413 -1810
- package/dist/index.d.cts +900 -599
- package/dist/index.d.ts +900 -599
- package/dist/index.js +5019 -3278
- package/dist/math-LXB4FH4E.js +7 -0
- package/dist/math-QVCETQDQ.js +1 -0
- package/dist/scene-browser-assets.d.ts +38 -0
- package/dist/scene-browser-assets.js +53 -0
- package/dist/scene-browser-chunks/chunk-5MVLYGXM.js +70 -0
- package/dist/scene-browser-chunks/chunk-ASXKN3NU.js +1 -0
- package/dist/scene-browser-chunks/chunk-CM5Y5LZP.js +1 -0
- package/dist/scene-browser-chunks/chunk-DP7NB4EW.js +6 -0
- package/dist/scene-browser-chunks/emscripten-module.browser-M5AEKJGE.js +1 -0
- package/dist/scene-browser-chunks/ffi-FL6ORJU3.js +1 -0
- package/dist/scene-browser-chunks/module-ES6BEMUI-JD5S5VKR.js +1 -0
- package/dist/scene-browser-chunks/module-asyncify-2EFITU5U-HWPFJFJC.js +1 -0
- package/dist/scene-browser-chunks/scene-browser-layout-M3XSXMV4.js +27 -0
- package/dist/scene-browser.d.ts +117 -0
- package/dist/scene-browser.js +220 -0
- package/dist/scene-cli.js +1 -1
- package/dist/scene-runtime.cjs +168 -103
- package/dist/scene-runtime.d.cts +3 -2
- package/dist/scene-runtime.d.ts +3 -2
- package/dist/scene-runtime.js +3 -1
- package/dist/server-2FYHZ4UO.js +331 -0
- package/dist/stage-browser/browser.d.ts +2483 -0
- package/dist/stage-browser/chunk-SQE76S5B.js +1 -0
- package/dist/stage-browser/chunk-VZNL6JY2.js +59 -0
- package/dist/stage-browser/dagre.esm-N2NIVIAZ.js +6 -0
- package/dist/stage-browser/math-4WFNHVV2.js +18 -0
- package/dist/stage-browser/stage.js +19 -0
- package/dist/stage-export.cjs +4980 -0
- package/dist/stage-export.d.cts +112 -0
- package/dist/stage-export.d.ts +112 -0
- package/dist/stage-export.js +544 -0
- package/dist/stage.cjs +9789 -0
- package/dist/stage.d.cts +1679 -0
- package/dist/stage.d.ts +1679 -0
- package/dist/stage.js +5418 -0
- package/dist/svg-import-Djj2q7Pc.d.cts +742 -0
- package/dist/svg-import-Djj2q7Pc.d.ts +742 -0
- package/dist/video-CcHW1qhV.d.cts +532 -0
- package/dist/video-CcHW1qhV.d.ts +532 -0
- package/examples/README.md +18 -0
- package/examples/agent-pipeline.tsx +4 -4
- package/examples/animated-pipeline.tsx +1 -5
- package/examples/attention-head.tsx +12 -12
- package/examples/aurora-incident.tsx +4 -3
- package/examples/building-blocks.tsx +8 -9
- package/examples/catalog-charts.tsx +4 -4
- package/examples/catalog-content.tsx +7 -9
- package/examples/catalog-convolution-kernel.tsx +116 -0
- package/examples/catalog-data.tsx +2 -8
- package/examples/catalog-dataflow.tsx +5 -9
- package/examples/catalog-dense.tsx +80 -0
- package/examples/catalog-deployment.tsx +5 -11
- package/examples/catalog-diagrams.tsx +13 -16
- package/examples/catalog-drawing.tsx +7 -7
- package/examples/catalog-flows.tsx +4 -4
- package/examples/catalog-foundations.tsx +11 -11
- package/examples/catalog-gaussian-blur.tsx +146 -0
- package/examples/catalog-image-tensors.tsx +115 -0
- package/examples/catalog-ml.tsx +36 -31
- package/examples/catalog-numeric-matrices.tsx +93 -0
- package/examples/catalog-photo-blur.tsx +209 -0
- package/examples/catalog-science-ai.tsx +130 -0
- package/examples/catalog-science-chemistry.tsx +103 -0
- package/examples/catalog-science-math.tsx +93 -0
- package/examples/catalog-science-physics.tsx +84 -0
- package/examples/catalog-sequence.tsx +59 -38
- package/examples/data-pipeline-lineage-presentation.tsx +5 -0
- package/examples/data-pipeline-lineage.tsx +85 -0
- package/examples/daybreak-launch.tsx +1 -0
- package/examples/desired-quadrant.tsx +7 -8
- package/examples/engineering-dashboard-presentation.tsx +13 -0
- package/examples/engineering-dashboard.tsx +160 -0
- package/examples/engineering-flow.tsx +2 -4
- package/examples/eval-dashboard.tsx +6 -6
- package/examples/films/attention.ts +278 -0
- package/examples/films/cache-miss.ts +431 -0
- package/examples/films/catalog.json +132 -0
- package/examples/films/central-limit.ts +269 -0
- package/examples/films/complex-maps.ts +273 -0
- package/examples/films/deck-example.ts +224 -0
- package/examples/films/euler-circle.ts +179 -0
- package/examples/films/fourier-epicycles.ts +265 -0
- package/examples/films/gradient-descent.ts +345 -0
- package/examples/films/linear-maps.ts +175 -0
- package/examples/films/lorenz.ts +207 -0
- package/examples/films/pythagoras.ts +185 -0
- package/examples/films/taylor-series.ts +159 -0
- package/examples/films/vizmatic-title.ts +117 -0
- package/examples/llm-serving-stack-presentation.tsx +5 -0
- package/examples/llm-serving-stack.tsx +94 -0
- package/examples/model-garden.tsx +1 -0
- package/examples/model-router.tsx +6 -6
- package/examples/nccl-all-gather.tsx +3 -3
- package/examples/nccl-all-reduce.tsx +3 -3
- package/examples/nccl-all-to-all.tsx +1 -1
- package/examples/nccl-broadcast.tsx +1 -1
- package/examples/nccl-reduce-scatter.tsx +5 -5
- package/examples/orthogonal-routing.tsx +4 -4
- package/examples/pareto-frontier.tsx +9 -10
- package/examples/presentation-frame.tsx +6 -6
- package/examples/production-system-map-presentation.tsx +5 -0
- package/examples/production-system-map.tsx +130 -0
- package/examples/rag-graph.tsx +7 -7
- package/examples/release-card.tsx +5 -5
- package/examples/spec-anatomy.tsx +5 -5
- package/examples/system-architecture.tsx +19 -32
- package/examples/theme-system.tsx +1 -1
- package/examples/token-matrix.tsx +4 -2
- package/examples/transparent-badge.tsx +1 -2
- package/examples/videos/README.md +36 -2
- package/examples/videos/calculus-tangent.tsx +101 -0
- package/examples/videos/catalyst-pathway.tsx +56 -0
- package/examples/videos/causal-attention.tsx +91 -0
- package/examples/videos/convolution-kernel.tsx +34 -0
- package/examples/videos/gaussian-blur.tsx +32 -0
- package/examples/videos/image-to-matrix.tsx +22 -0
- package/examples/videos/matrix-multiplication.tsx +128 -0
- package/examples/videos/photo-gaussian-blur.tsx +39 -0
- package/examples/videos/wave-interference.tsx +80 -0
- package/examples/vizmatic-bare.d.ts +1 -0
- package/examples/vizmatic-hero.tsx +9 -18
- package/examples/website-workflow.tsx +7 -7
- package/examples/weekend-field-notes.tsx +3 -2
- package/package.json +65 -11
- package/dist/chunk-TH3F4SDB.js +0 -79
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineAnimation,
|
|
3
|
+
getThemeColors,
|
|
4
|
+
hold,
|
|
5
|
+
keyframe,
|
|
6
|
+
Matrix,
|
|
7
|
+
multiplyMatrices,
|
|
8
|
+
tween,
|
|
9
|
+
type ThemeMode,
|
|
10
|
+
} from 'vizmatic'
|
|
11
|
+
|
|
12
|
+
export const width = 1280
|
|
13
|
+
export const height = 720
|
|
14
|
+
|
|
15
|
+
const matrixA = [
|
|
16
|
+
[1, 2, 0],
|
|
17
|
+
[-1, 3, 2],
|
|
18
|
+
]
|
|
19
|
+
const matrixB = [
|
|
20
|
+
[2, 1],
|
|
21
|
+
[0, 4],
|
|
22
|
+
[3, -2],
|
|
23
|
+
]
|
|
24
|
+
const product = multiplyMatrices(matrixA, matrixB)
|
|
25
|
+
const integerLabels = (values: number[][]) => values.map(row => row.map(String))
|
|
26
|
+
type MultiplicationState = { cell: number; term: number }
|
|
27
|
+
|
|
28
|
+
function buildFrame(theme: ThemeMode, state: Readonly<MultiplicationState>) {
|
|
29
|
+
const c = getThemeColors(theme)
|
|
30
|
+
const outputRow = Math.floor(state.cell / product[0].length)
|
|
31
|
+
const outputCol = state.cell % product[0].length
|
|
32
|
+
const termIndex = Math.max(0, Math.min(matrixA[0].length - 1, Math.round(state.term)))
|
|
33
|
+
const currentLeft = matrixA[outputRow][termIndex]
|
|
34
|
+
const currentRight = matrixB[termIndex][outputCol]
|
|
35
|
+
const activeColor = theme === 'dark' ? c.warningLight : c.warningDark
|
|
36
|
+
const formulaTerms = matrixA[outputRow].map((left, index) => ({
|
|
37
|
+
left,
|
|
38
|
+
right: matrixB[index][outputCol],
|
|
39
|
+
product: left * matrixB[index][outputCol],
|
|
40
|
+
}))
|
|
41
|
+
const colorDomain: readonly [number, number] = [-2, 9]
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div style={{ position: 'relative', display: 'flex', width, height, overflow: 'hidden', backgroundColor: c.bg, color: c.textPrimary, fontFamily: c.fontSans }}>
|
|
45
|
+
<div style={{ position: 'absolute', left: 54, top: 36, display: 'flex', flexDirection: 'column', gap: 7 }}>
|
|
46
|
+
<span style={{ color: c.textSecondary, fontFamily: c.fontMono, fontSize: 14, fontWeight: 700, letterSpacing: 2 }}>LINEAR ALGEBRA / A PRODUCT YOU CAN FOLLOW</span>
|
|
47
|
+
<span style={{ fontSize: 40, fontWeight: 760, letterSpacing: -1.2 }}>One row. One column. One output.</span>
|
|
48
|
+
<span style={{ color: c.textSecondary, fontSize: 18 }}>The highlighted pair of entries contributes to the selected cell in C.</span>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<div style={{ position: 'absolute', left: 42, top: 150, display: 'flex', width: 330, height: 294, flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 13, backgroundColor: c.bgCard, border: `1px solid ${c.borderSubtle}`, borderRadius: 16 }}>
|
|
52
|
+
<div style={{ display: 'flex', width: 282, flexDirection: 'column', gap: 4 }}>
|
|
53
|
+
<span style={{ color: c.textPrimary, fontSize: 24, fontWeight: 750 }}>A <span style={{ color: c.textMuted, fontSize: 15, fontWeight: 500 }}>2 × 3</span></span>
|
|
54
|
+
<span style={{ color: c.textSecondary, fontSize: 14 }}>Row {outputRow + 1} is selected</span>
|
|
55
|
+
</div>
|
|
56
|
+
<Matrix data={matrixA} c={c} rowLabels={['A₁', 'A₂']} colLabels={['k₁', 'k₂', 'k₃']} labels={integerLabels(matrixA)} format="integer" cellWidth={62} cellHeight={50} rowLabelWidth={42} fontSize={19} highlightRow={outputRow} highlightCell={{ row: outputRow, col: termIndex }} highlightColor={activeColor} colorDomain={colorDomain} />
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<span style={{ position: 'absolute', left: 386, top: 259, color: c.textMuted, fontSize: 43, fontWeight: 500 }}>×</span>
|
|
60
|
+
|
|
61
|
+
<div style={{ position: 'absolute', left: 426, top: 150, display: 'flex', width: 330, height: 294, flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 13, backgroundColor: c.bgCard, border: `1px solid ${c.borderSubtle}`, borderRadius: 16 }}>
|
|
62
|
+
<div style={{ display: 'flex', width: 282, flexDirection: 'column', gap: 4 }}>
|
|
63
|
+
<span style={{ color: c.textPrimary, fontSize: 24, fontWeight: 750 }}>B <span style={{ color: c.textMuted, fontSize: 15, fontWeight: 500 }}>3 × 2</span></span>
|
|
64
|
+
<span style={{ color: c.textSecondary, fontSize: 14 }}>Column {outputCol + 1} is selected</span>
|
|
65
|
+
</div>
|
|
66
|
+
<Matrix data={matrixB} c={c} rowLabels={['k₁', 'k₂', 'k₃']} colLabels={['B₁', 'B₂']} labels={integerLabels(matrixB)} format="integer" cellWidth={70} cellHeight={43} rowLabelWidth={42} fontSize={19} highlightCol={outputCol} highlightCell={{ row: termIndex, col: outputCol }} highlightColor={activeColor} colorDomain={colorDomain} />
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<span style={{ position: 'absolute', left: 773, top: 259, color: c.textMuted, fontSize: 41, fontWeight: 500 }}>=</span>
|
|
70
|
+
|
|
71
|
+
<div style={{ position: 'absolute', left: 814, top: 150, display: 'flex', width: 424, height: 294, flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 13, backgroundColor: c.bgCard, border: `1px solid ${c.borderSubtle}`, borderRadius: 16 }}>
|
|
72
|
+
<div style={{ display: 'flex', width: 340, flexDirection: 'column', gap: 4 }}>
|
|
73
|
+
<span style={{ color: c.textPrimary, fontSize: 24, fontWeight: 750 }}>C = AB <span style={{ color: c.textMuted, fontSize: 15, fontWeight: 500 }}>2 × 2</span></span>
|
|
74
|
+
<span style={{ color: c.textSecondary, fontSize: 14 }}>Output C{outputRow + 1}{outputCol + 1} = {product[outputRow][outputCol]}</span>
|
|
75
|
+
</div>
|
|
76
|
+
<Matrix data={product} c={c} rowLabels={['A₁', 'A₂']} colLabels={['B₁', 'B₂']} labels={integerLabels(product)} format="integer" cellWidth={78} cellHeight={60} rowLabelWidth={44} fontSize={22} highlightCell={{ row: outputRow, col: outputCol }} highlightColor={activeColor} colorDomain={colorDomain} />
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<div style={{ position: 'absolute', left: 42, top: 466, display: 'flex', width: 1196, height: 206, flexDirection: 'column', justifyContent: 'center', gap: 16, padding: '22px 28px', boxSizing: 'border-box', backgroundColor: c.bgCard, border: `1px solid ${c.borderSubtle}`, borderRadius: 16 }}>
|
|
80
|
+
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
|
81
|
+
<span style={{ color: activeColor, fontFamily: c.fontMono, fontSize: 14, fontWeight: 700, letterSpacing: 1.5 }}>DOT PRODUCT · ROW {outputRow + 1} × COLUMN {outputCol + 1}</span>
|
|
82
|
+
<span style={{ color: c.textSecondary, fontFamily: c.fontMono, fontSize: 15 }}>TERM {termIndex + 1} OF 3 · {currentLeft} × {currentRight} = {currentLeft * currentRight}</span>
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 14, fontFamily: c.fontMono, fontSize: 23, fontWeight: 650 }}>
|
|
86
|
+
{formulaTerms.map((term, index) => (
|
|
87
|
+
<div key={`term-${index}`} style={{ display: 'flex', alignItems: 'center', gap: 14 }}>
|
|
88
|
+
{index > 0 && <span style={{ color: c.textMuted }}>+</span>}
|
|
89
|
+
<span style={{ display: 'flex', alignItems: 'center', gap: 8, padding: '10px 13px', borderRadius: 10, backgroundColor: index === termIndex ? `${activeColor}26` : c.bgCardAlt, color: c.textPrimary, ...(index === termIndex ? { boxShadow: `inset 0 0 0 2px ${activeColor}` } : {}) }}>
|
|
90
|
+
<span>{term.left} × {term.right}</span>
|
|
91
|
+
<span style={{ color: c.textPrimary, fontSize: 17 }}>= {term.product}</span>
|
|
92
|
+
</span>
|
|
93
|
+
</div>
|
|
94
|
+
))}
|
|
95
|
+
<span style={{ color: c.textMuted }}>=</span>
|
|
96
|
+
<span style={{ color: c.textPrimary, fontSize: 29 }}>{product[outputRow][outputCol]}</span>
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
<span style={{ color: c.textSecondary, fontSize: 16 }}>The three products add to the selected result. The matrix values and this arithmetic come from the same A and B.</span>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function create(theme: ThemeMode = 'dark') {
|
|
106
|
+
return buildFrame(theme, { cell: 0, term: 0 })
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function createAnimation(theme: ThemeMode = 'dark') {
|
|
110
|
+
const timeline = []
|
|
111
|
+
for (let cell = 0; cell < product.length * product[0].length; cell += 1) {
|
|
112
|
+
if (cell > 0) {
|
|
113
|
+
timeline.push(keyframe<Partial<MultiplicationState>>({ cell, term: 0 }, `Select output C${Math.floor(cell / product[0].length) + 1}${cell % product[0].length + 1}`))
|
|
114
|
+
}
|
|
115
|
+
timeline.push(tween<Partial<MultiplicationState>>({ term: 1 }, { duration: 650, easing: 'ease-in-out', label: 'Follow the next pair of values' }))
|
|
116
|
+
timeline.push(tween<Partial<MultiplicationState>>({ term: 2 }, { duration: 650, easing: 'ease-in-out', label: 'Complete the dot product' }))
|
|
117
|
+
timeline.push(hold(800, 'Read the output value'))
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return defineAnimation<MultiplicationState>({
|
|
121
|
+
initial: { cell: 0, term: 0 },
|
|
122
|
+
timeline,
|
|
123
|
+
fps: 30,
|
|
124
|
+
render: state => buildFrame(theme, state),
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export default create('dark')
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { defineAnimation, hold } from 'vizmatic'
|
|
2
|
+
import { photoBlurFrame, photoBlurOptions, type PhotoBlurState } from '../catalog-photo-blur'
|
|
3
|
+
|
|
4
|
+
export const width = 1280
|
|
5
|
+
export const height = 720
|
|
6
|
+
|
|
7
|
+
export function create(theme: 'dark' | 'light' = 'dark') {
|
|
8
|
+
return photoBlurFrame(theme)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function createAnimation(theme: 'dark' | 'light' = 'dark') {
|
|
12
|
+
const blurSteps = Array.from(
|
|
13
|
+
{ length: photoBlurOptions.maxSigma / photoBlurOptions.sigmaStep },
|
|
14
|
+
(_, index) => index + 1,
|
|
15
|
+
)
|
|
16
|
+
const timeline = [
|
|
17
|
+
hold(1300, 'Start with the unblurred coffee photograph'),
|
|
18
|
+
{ type: 'tween' as const, to: { layout: 1 }, duration: 1200, easing: 'ease-out' as const, label: 'Move the sharp photo into the comparison layout' },
|
|
19
|
+
hold(300, 'Let the photograph settle before the comparison appears'),
|
|
20
|
+
{ type: 'tween' as const, to: { reveal: 1 }, duration: 500, easing: 'ease-out' as const, label: 'Reveal the Gaussian coefficient matrix excerpt and matching crop' },
|
|
21
|
+
hold(2000, 'Before blurring, sigma zero reproduces the sharp input; all kernel weights together sum to one'),
|
|
22
|
+
...blurSteps.flatMap(level => {
|
|
23
|
+
const sigma = level * photoBlurOptions.sigmaStep
|
|
24
|
+
return [
|
|
25
|
+
{ type: 'keyframe' as const, value: { level }, label: `Compute the actual photo at sigma ${sigma.toFixed(1)} pixels` },
|
|
26
|
+
hold(1150, `Compare the new Gaussian result at sigma ${sigma.toFixed(1)} pixels`),
|
|
27
|
+
]
|
|
28
|
+
}),
|
|
29
|
+
hold(1100, 'A larger sigma spreads edge details over a wider neighborhood'),
|
|
30
|
+
hold(4800, 'The final image uses the computed 25 by 25 Gaussian blur at sigma 4 pixels'),
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
return defineAnimation<PhotoBlurState>({
|
|
34
|
+
initial: { layout: 0, reveal: 0, level: 0 },
|
|
35
|
+
timeline,
|
|
36
|
+
fps: 30,
|
|
37
|
+
render: state => photoBlurFrame(theme, state),
|
|
38
|
+
})
|
|
39
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Two equal sinusoidal waves add algebraically at every coordinate.
|
|
3
|
+
* Relative phase is an author-controlled comparison parameter, not a simulation of its source.
|
|
4
|
+
* Source: https://openstax.org/books/university-physics-volume-1/pages/16-5-interference-of-waves
|
|
5
|
+
*/
|
|
6
|
+
import { WaveDiagram, defineAnimation, getThemeColors, hold, tween, type ThemeMode } from 'vizmatic'
|
|
7
|
+
|
|
8
|
+
export const width = 1280
|
|
9
|
+
export const height = 720
|
|
10
|
+
|
|
11
|
+
export function interferenceAmplitude(phase: number) {
|
|
12
|
+
if (!Number.isFinite(phase)) throw new Error('The phase must be finite')
|
|
13
|
+
return 2 * Math.abs(Math.cos(phase / 2))
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function buildFrame(theme: ThemeMode, phase: number, time: number) {
|
|
17
|
+
const c = getThemeColors(theme)
|
|
18
|
+
const firstColor = theme === 'dark' ? c.secondaryLight : c.secondaryDark
|
|
19
|
+
const secondColor = theme === 'dark' ? c.accentLight : c.accent
|
|
20
|
+
const sumColor = c.textPrimary
|
|
21
|
+
const amplitude = interferenceAmplitude(phase)
|
|
22
|
+
const phaseDegrees = phase * 180 / Math.PI
|
|
23
|
+
const state = amplitude < 0.03 ? 'Complete cancellation' : amplitude > 1.97 ? 'Constructive interference' : 'Partial interference'
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div style={{ display: 'flex', position: 'relative', width, height, overflow: 'hidden', backgroundColor: c.bg, color: c.textPrimary, fontFamily: c.fontSans }}>
|
|
27
|
+
<div style={{ display: 'flex', position: 'absolute', left: 64, top: 42, flexDirection: 'column', gap: 12 }}>
|
|
28
|
+
<span style={{ fontFamily: c.fontMono, color: c.textSecondary, fontSize: 14, letterSpacing: 2 }}>PHYSICS / THE SUPERPOSITION PRINCIPLE</span>
|
|
29
|
+
<span style={{ fontSize: 48, fontWeight: 750, letterSpacing: -1.5 }}>Two waves. One displacement.</span>
|
|
30
|
+
<span style={{ color: c.textSecondary, fontSize: 22 }}>Add the signed heights at each point, not their absolute values.</span>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<div style={{ display: 'flex', position: 'absolute', left: 64, top: 180 }}>
|
|
34
|
+
<WaveDiagram c={c} width={1152} height={380} xMin={0} xMax={8} yMin={-2.3} yMax={2.3}
|
|
35
|
+
waves={[
|
|
36
|
+
{ amplitude: 1, wavelength: 4, speed: 1, phase: 0, color: firstColor, label: 'Wave 1' },
|
|
37
|
+
{ amplitude: 1, wavelength: 4, speed: 1, phase, color: secondColor, label: 'Wave 2' },
|
|
38
|
+
]}
|
|
39
|
+
time={time} showComponents showSum probeX={2}
|
|
40
|
+
ariaLabel={`Two unit-amplitude waves with phase difference ${phaseDegrees.toFixed(0)} degrees; resultant amplitude ${amplitude.toFixed(2)}`} />
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<div style={{ display: 'flex', position: 'absolute', left: 88, top: 584, width: 1104, justifyContent: 'space-between' }}>
|
|
44
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 12, width: 290 }}>
|
|
45
|
+
<span style={{ fontFamily: c.fontMono, color: c.textSecondary, fontSize: 14 }}>PHASE DIFFERENCE</span>
|
|
46
|
+
<span style={{ fontFamily: c.fontMono, fontSize: 39, fontWeight: 700 }}>{phaseDegrees.toFixed(0)}°</span>
|
|
47
|
+
</div>
|
|
48
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 12, width: 310 }}>
|
|
49
|
+
<span style={{ fontFamily: c.fontMono, color: c.textSecondary, fontSize: 14 }}>RESULTANT AMPLITUDE</span>
|
|
50
|
+
<span style={{ fontFamily: c.fontMono, color: sumColor, fontSize: 39, fontWeight: 700 }}>{amplitude.toFixed(2)} × A</span>
|
|
51
|
+
</div>
|
|
52
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 12, width: 340 }}>
|
|
53
|
+
<span style={{ fontFamily: c.fontMono, color: c.textSecondary, fontSize: 14 }}>SAME SCALE THROUGHOUT</span>
|
|
54
|
+
<span style={{ color: sumColor, fontSize: 24, fontWeight: 700 }}>{state}</span>
|
|
55
|
+
<span style={{ color: c.textMuted, fontSize: 14 }}>Ideal linear waves; relative phase is varied.</span>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function create(theme: ThemeMode = 'dark') {
|
|
63
|
+
return buildFrame(theme, Math.PI, 2)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function createAnimation(theme: ThemeMode = 'dark') {
|
|
67
|
+
return defineAnimation({
|
|
68
|
+
initial: { phase: 0, time: 0 },
|
|
69
|
+
timeline: [
|
|
70
|
+
tween({ phase: Math.PI, time: 2 }, { duration: 2800, easing: 'linear', label: 'Shift the waves out of phase' }),
|
|
71
|
+
hold(900, 'Opposite displacements cancel'),
|
|
72
|
+
tween({ phase: 2 * Math.PI, time: 4 }, { duration: 2800, easing: 'linear', label: 'Return to constructive interference' }),
|
|
73
|
+
hold(1300, 'Equal displacements reinforce'),
|
|
74
|
+
],
|
|
75
|
+
fps: 30,
|
|
76
|
+
render: ({ phase, time }) => buildFrame(theme, phase, time),
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default create('dark')
|
|
@@ -3,37 +3,29 @@ height = 640;
|
|
|
3
3
|
|
|
4
4
|
<Scene
|
|
5
5
|
title="From TSX scene to rendered files"
|
|
6
|
-
|
|
6
|
+
density="comfortable"
|
|
7
7
|
>
|
|
8
8
|
<GraphDiagram
|
|
9
9
|
ariaLabel="Vizmatic rendering pipeline from an agent request through scene primitives and theme tokens to rendered assets"
|
|
10
|
-
width={900}
|
|
11
|
-
height={340}
|
|
12
|
-
nodeWidth={170}
|
|
13
|
-
nodeHeight={76}
|
|
14
|
-
labelFontSize={19}
|
|
15
|
-
arrowSize={7}
|
|
16
10
|
nodes={[
|
|
17
|
-
{ id: 'brief', label: 'Agent request'
|
|
18
|
-
{ id: 'primitives', label: 'Scene primitives'
|
|
19
|
-
{ id: 'theme', label: 'Theme tokens'
|
|
11
|
+
{ id: 'brief', label: 'Agent request' },
|
|
12
|
+
{ id: 'primitives', label: 'Scene primitives' },
|
|
13
|
+
{ id: 'theme', label: 'Theme tokens' },
|
|
20
14
|
{ id: 'render', label: 'Node renderer', tone: 'warm' },
|
|
21
15
|
{ id: 'asset', label: 'PNG / SVG / GIF', tone: 'green' },
|
|
22
16
|
]}
|
|
23
17
|
edges={[
|
|
24
|
-
{ from: 'brief', to: 'primitives'
|
|
25
|
-
{ from: 'brief', to: 'theme'
|
|
26
|
-
{ from: 'primitives', to: 'render'
|
|
27
|
-
{ from: 'theme', to: 'render'
|
|
28
|
-
{ from: 'render', to: 'asset'
|
|
18
|
+
{ from: 'brief', to: 'primitives' },
|
|
19
|
+
{ from: 'brief', to: 'theme' },
|
|
20
|
+
{ from: 'primitives', to: 'render' },
|
|
21
|
+
{ from: 'theme', to: 'render' },
|
|
22
|
+
{ from: 'render', to: 'asset' },
|
|
29
23
|
]}
|
|
30
24
|
/>
|
|
31
25
|
<Row width="100%" gap={14}>
|
|
32
26
|
<CalloutCard
|
|
33
27
|
title="Source stays editable"
|
|
34
|
-
tone="purple"
|
|
35
28
|
width={430}
|
|
36
|
-
minHeight={64}
|
|
37
29
|
padding={18}
|
|
38
30
|
titleFontSize={18}
|
|
39
31
|
/>
|
|
@@ -41,7 +33,6 @@ height = 640;
|
|
|
41
33
|
title="Bundled assets work offline"
|
|
42
34
|
tone="green"
|
|
43
35
|
width={430}
|
|
44
|
-
minHeight={64}
|
|
45
36
|
padding={18}
|
|
46
37
|
titleFontSize={18}
|
|
47
38
|
/>
|
|
@@ -16,19 +16,19 @@ export function create(theme: ThemeMode = 'dark') {
|
|
|
16
16
|
labelFontSize={19}
|
|
17
17
|
detailFontSize={13}
|
|
18
18
|
nodes={[
|
|
19
|
-
{ id: 'idea', label: 'Idea', detail: 'you or your agent', x: 0.11, y: 0.5
|
|
20
|
-
{ id: 'scene', label: 'Scene', detail: 'editable TSX', x: 0.37, y: 0.5
|
|
21
|
-
{ id: 'check', label: 'Check', detail: 'layout + contrast', x: 0.63, y: 0.5
|
|
19
|
+
{ id: 'idea', label: 'Idea', detail: 'you or your agent', x: 0.11, y: 0.5 },
|
|
20
|
+
{ id: 'scene', label: 'Scene', detail: 'editable TSX', x: 0.37, y: 0.5 },
|
|
21
|
+
{ id: 'check', label: 'Check', detail: 'layout + contrast', x: 0.63, y: 0.5 },
|
|
22
22
|
{ id: 'export', label: 'Export', detail: 'ready to share', x: 0.89, y: 0.5, tone: 'green' },
|
|
23
23
|
]}
|
|
24
24
|
edges={[
|
|
25
|
-
{ from: 'idea', to: 'scene'
|
|
26
|
-
{ from: 'scene', to: 'check'
|
|
27
|
-
{ from: 'check', to: 'export'
|
|
25
|
+
{ from: 'idea', to: 'scene' },
|
|
26
|
+
{ from: 'scene', to: 'check' },
|
|
27
|
+
{ from: 'check', to: 'export' },
|
|
28
28
|
]}
|
|
29
29
|
/>
|
|
30
30
|
<Row gap={12} justify="center">
|
|
31
|
-
<BadgePill c={c} text="Dark + light"
|
|
31
|
+
<BadgePill c={c} text="Dark + light" />
|
|
32
32
|
<BadgePill c={c} text="PNG / SVG / GIF" tone="green" />
|
|
33
33
|
</Row>
|
|
34
34
|
</Scene>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
density = "compact";
|
|
1
2
|
width = 1120;
|
|
2
3
|
height = 800;
|
|
3
4
|
background = "theme";
|
|
@@ -39,8 +40,8 @@ background = "theme";
|
|
|
39
40
|
]}
|
|
40
41
|
edges={[
|
|
41
42
|
{ from: 'cafe', to: 'garden', tone: 'warm' },
|
|
42
|
-
{ from: 'garden', to: 'books'
|
|
43
|
-
{ from: 'books', to: 'market'
|
|
43
|
+
{ from: 'garden', to: 'books' },
|
|
44
|
+
{ from: 'books', to: 'market' },
|
|
44
45
|
]}
|
|
45
46
|
/>
|
|
46
47
|
</Card>
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vizmatic",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "Code-driven animation, diagrams, and charts: vector films that play live in a browser and export to MP4, with typed components for dense technical figures.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Bruno Volpato",
|
|
@@ -28,13 +28,17 @@
|
|
|
28
28
|
"diagrams",
|
|
29
29
|
"presentations",
|
|
30
30
|
"animation",
|
|
31
|
+
"motion-graphics",
|
|
32
|
+
"mathematical-animation",
|
|
31
33
|
"video",
|
|
32
34
|
"mp4",
|
|
33
35
|
"theme-aware",
|
|
34
36
|
"ai-agents",
|
|
35
37
|
"structured-visuals"
|
|
36
38
|
],
|
|
37
|
-
"sideEffects":
|
|
39
|
+
"sideEffects": [
|
|
40
|
+
"./dist/stage-browser/**"
|
|
41
|
+
],
|
|
38
42
|
"main": "./dist/index.cjs",
|
|
39
43
|
"module": "./dist/index.js",
|
|
40
44
|
"types": "./dist/index.d.ts",
|
|
@@ -47,6 +51,7 @@
|
|
|
47
51
|
"examples",
|
|
48
52
|
"PROMPT.md",
|
|
49
53
|
"README.md",
|
|
54
|
+
"SCIENCE.md",
|
|
50
55
|
"ROADMAP.md",
|
|
51
56
|
"LICENSE"
|
|
52
57
|
],
|
|
@@ -62,8 +67,46 @@
|
|
|
62
67
|
}
|
|
63
68
|
},
|
|
64
69
|
"./scene-runtime": {
|
|
65
|
-
"import": {
|
|
66
|
-
|
|
70
|
+
"import": {
|
|
71
|
+
"types": "./dist/scene-runtime.d.ts",
|
|
72
|
+
"default": "./dist/scene-runtime.js"
|
|
73
|
+
},
|
|
74
|
+
"require": {
|
|
75
|
+
"types": "./dist/scene-runtime.d.cts",
|
|
76
|
+
"default": "./dist/scene-runtime.cjs"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"./scene-browser": {
|
|
80
|
+
"types": "./dist/scene-browser.d.ts",
|
|
81
|
+
"import": "./dist/scene-browser.js"
|
|
82
|
+
},
|
|
83
|
+
"./browser-assets": {
|
|
84
|
+
"types": "./dist/scene-browser-assets.d.ts",
|
|
85
|
+
"import": "./dist/scene-browser-assets.js"
|
|
86
|
+
},
|
|
87
|
+
"./stage": {
|
|
88
|
+
"import": {
|
|
89
|
+
"types": "./dist/stage.d.ts",
|
|
90
|
+
"default": "./dist/stage.js"
|
|
91
|
+
},
|
|
92
|
+
"require": {
|
|
93
|
+
"types": "./dist/stage.d.cts",
|
|
94
|
+
"default": "./dist/stage.cjs"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"./stage/export": {
|
|
98
|
+
"import": {
|
|
99
|
+
"types": "./dist/stage-export.d.ts",
|
|
100
|
+
"default": "./dist/stage-export.js"
|
|
101
|
+
},
|
|
102
|
+
"require": {
|
|
103
|
+
"types": "./dist/stage-export.d.cts",
|
|
104
|
+
"default": "./dist/stage-export.cjs"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
"./stage/browser": {
|
|
108
|
+
"types": "./dist/stage-browser/browser.d.ts",
|
|
109
|
+
"import": "./dist/stage-browser/stage.js"
|
|
67
110
|
}
|
|
68
111
|
},
|
|
69
112
|
"bin": {
|
|
@@ -71,7 +114,8 @@
|
|
|
71
114
|
"vizmatic-scene": "dist/scene-cli.js"
|
|
72
115
|
},
|
|
73
116
|
"scripts": {
|
|
74
|
-
"build": "tsup src/index.ts src/scene-runtime.ts --format esm --dts --target node20 --clean --external react && tsup src/index.ts src/scene-runtime.ts --format cjs --dts --target node20 --external react --define.import.meta.url undefined && tsup src/cli.ts src/scene-cli.ts --format esm --dts --target node20 --external react --minify-whitespace",
|
|
117
|
+
"build": "tsup src/index.ts src/scene-runtime.ts src/stage.ts src/stage-export.ts --format esm --dts --target node20 --clean --external react && tsup src/index.ts src/scene-runtime.ts src/stage.ts src/stage-export.ts --format cjs --dts --target node20 --external react --define.import.meta.url undefined && tsup src/cli.ts src/scene-cli.ts --format esm --dts --target node20 --external react --minify-whitespace && pnpm build:browser",
|
|
118
|
+
"build:browser": "tsup src/scene-browser.ts --dts-only --format esm --target es2022 --external react && tsup src/scene-browser-assets.ts --format esm --dts --target node20 && tsx scripts/build-scene-browser.ts && tsup src/stage/browser.ts --dts-only --format esm --target es2022 --out-dir dist/stage-browser && tsx scripts/build-stage-browser.ts",
|
|
75
119
|
"assets:emoji": "node scripts/build-emoji-bundle.mjs",
|
|
76
120
|
"assets:check": "node scripts/build-emoji-bundle.mjs --check",
|
|
77
121
|
"prepare": "pnpm build",
|
|
@@ -82,8 +126,13 @@
|
|
|
82
126
|
"render:video": "pnpm build && tsx scripts/render-video-example.ts",
|
|
83
127
|
"benchmark:quality": "pnpm build && tsx scripts/benchmark-quality.ts && pnpm site:build",
|
|
84
128
|
"check:examples": "tsx scripts/check-examples.ts",
|
|
129
|
+
"render:films": "tsx scripts/render-films.ts",
|
|
130
|
+
"check:films": "tsx src/cli.ts check examples/films",
|
|
131
|
+
"stage:build": "tsx scripts/build-stage.ts",
|
|
85
132
|
"playground:build": "tsx scripts/build-playground.ts",
|
|
86
133
|
"check:playground": "node scripts/check-playground.mjs",
|
|
134
|
+
"check:scene-browser": "node scripts/check-scene-browser.mjs",
|
|
135
|
+
"check:studio": "node scripts/check-studio.mjs",
|
|
87
136
|
"site:build": "tsx scripts/build-site.ts",
|
|
88
137
|
"site:fonts": "uv run scripts/build-site-fonts.py",
|
|
89
138
|
"docs:check": "tsx scripts/check-docs.ts",
|
|
@@ -93,11 +142,17 @@
|
|
|
93
142
|
"security:audit": "pnpm audit --audit-level low",
|
|
94
143
|
"deps:check": "pnpm security:audit && pnpm assets:check && publint && tsx scripts/check-package.ts && node scripts/check-consumer.mjs",
|
|
95
144
|
"verify": "pnpm lint && pnpm test && pnpm render:examples && pnpm check:examples && pnpm docs:check && pnpm deps:check",
|
|
96
|
-
"prepublishOnly": "pnpm verify"
|
|
145
|
+
"prepublishOnly": "pnpm verify",
|
|
146
|
+
"site:posters": "tsx scripts/build-film-posters.ts",
|
|
147
|
+
"site:measure": "tsx scripts/measure-site.ts",
|
|
148
|
+
"studio:build": "tsx scripts/build-studio.ts"
|
|
97
149
|
},
|
|
98
150
|
"dependencies": {
|
|
99
151
|
"@dagrejs/dagre": "3.1.1",
|
|
100
|
-
"@resvg/resvg-js": "
|
|
152
|
+
"@resvg/resvg-js": "2.7.0-alpha.2",
|
|
153
|
+
"@resvg/resvg-wasm": "2.6.2",
|
|
154
|
+
"fast-png": "8.0.0",
|
|
155
|
+
"fflate": "0.7.5",
|
|
101
156
|
"gifenc": "^1.0.3",
|
|
102
157
|
"mathjax-full": "3.2.2",
|
|
103
158
|
"parse-css-color": "0.2.1",
|
|
@@ -111,16 +166,15 @@
|
|
|
111
166
|
"react": ">=18"
|
|
112
167
|
},
|
|
113
168
|
"devDependencies": {
|
|
114
|
-
"@resvg/resvg-wasm": "2.6.2",
|
|
115
169
|
"@types/node": "^26.6.4",
|
|
116
170
|
"@types/react": "^19.2.18",
|
|
117
171
|
"esbuild": "0.28.2",
|
|
118
172
|
"github-actionlint": "1.7.12",
|
|
119
173
|
"harfbuzzjs": "0.10.0",
|
|
120
|
-
"playwright": "1.64.
|
|
174
|
+
"playwright": "1.64.1",
|
|
121
175
|
"publint": "0.3.25",
|
|
122
176
|
"shiki": "^4.5.0",
|
|
123
|
-
"tsup": "^
|
|
177
|
+
"tsup": "^9.0.0",
|
|
124
178
|
"typescript": ">=6.0.3 <7",
|
|
125
179
|
"vitest": "^5.0.3"
|
|
126
180
|
}
|