vizmatic 0.8.3 → 0.9.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 +32 -0
- package/README.md +8 -3
- package/ROADMAP.md +4 -2
- package/SCIENCE.md +69 -3
- package/dist/chunk-6JI55YX4.js +604 -0
- package/dist/{chunk-LTX44BAE.js → chunk-BYKXNUX7.js} +25 -4
- package/dist/{chunk-4MXGLMBG.js → chunk-EPZLNABN.js} +107 -37
- package/dist/chunk-EWCO6ZT6.js +696 -0
- package/dist/{chunk-JZPMGVBP.js → chunk-G7HRSKHV.js} +1 -1
- package/dist/{chunk-RPAHMKAR.js → chunk-JTWC2OPN.js} +7 -5
- package/dist/chunk-LJZO36IR.js +124 -0
- package/dist/chunk-REL2BZ2B.js +88 -0
- package/dist/chunk-RLPEOWST.js +1 -0
- package/dist/chunk-VMHOWCDL.js +296 -0
- package/dist/chunk-YDD63HHD.js +1 -0
- package/dist/{chunk-I745F4QK.js → chunk-YNGDEARY.js} +1134 -643
- package/dist/cli.js +80 -543
- package/dist/gpu-selection-CDWCZH27.js +1 -0
- package/dist/gpu-selection-MX6NHMNA.js +635 -0
- package/dist/index.cjs +473 -155
- package/dist/index.d.cts +30 -239
- package/dist/index.d.ts +30 -239
- package/dist/index.js +410 -457
- package/dist/math-E7W5LFWO.js +1 -0
- package/dist/{math-LXB4FH4E.js → math-NEFQUPRV.js} +3 -1
- package/dist/scene-browser.js +17 -17
- package/dist/scene-cli.js +1 -1
- package/dist/scene-runtime.cjs +4 -2
- package/dist/scene-runtime.js +2 -2
- package/dist/stage-browser/browser.d.ts +1206 -854
- package/dist/stage-browser/gpu-renderer.js +138 -0
- package/dist/stage-browser/{math-4WFNHVV2.js → math-KYHUOK7A.js} +46 -10
- package/dist/stage-browser/stage.js +107 -19
- package/dist/stage-export.cjs +8221 -6784
- package/dist/stage-export.d.cts +13 -5
- package/dist/stage-export.d.ts +13 -5
- package/dist/stage-export.js +111 -601
- package/dist/stage.cjs +6243 -3474
- package/dist/stage.d.cts +1064 -765
- package/dist/stage.d.ts +1064 -765
- package/dist/stage.js +3571 -2405
- package/dist/{svg-import-B5BGbC1t.d.cts → svg-import-CSCFWYaB.d.cts} +21 -12
- package/dist/{svg-import-B5BGbC1t.d.ts → svg-import-CSCFWYaB.d.ts} +21 -12
- package/dist/teaching-math-DTKc0XsB.d.cts +243 -0
- package/dist/teaching-math-ydDBhJ2M.d.ts +243 -0
- package/dist/{video-CiN1MDCS.d.cts → theme-DhVdDQKO.d.cts} +4 -237
- package/dist/{video-CiN1MDCS.d.ts → theme-DhVdDQKO.d.ts} +4 -237
- package/dist/video-BYCeOz8F.d.ts +259 -0
- package/dist/video-CGLxJXqu.d.cts +259 -0
- package/examples/catalog-science-physics.tsx +6 -6
- package/examples/films/_boltzmann-entropy/model.ts +63 -0
- package/examples/films/_catalysis/model.ts +49 -0
- package/examples/films/_gravitational-waves/model.ts +32 -0
- package/examples/films/_heat-equation/model.ts +54 -0
- package/examples/films/_hydrogen-orbitals/model.ts +31 -0
- package/examples/films/_maxwell/model.ts +84 -0
- package/examples/films/_planetary-orbits/appearance.ts +71 -0
- package/examples/films/_planetary-orbits/model.ts +152 -0
- package/examples/films/_planetary-orbits/saturn.ts +142 -0
- package/examples/films/_quantum-tunneling/model.ts +58 -0
- package/examples/films/_reaction-diffusion/model.ts +61 -0
- package/examples/films/_stationary-action/model.ts +38 -0
- package/examples/films/attention.ts +309 -253
- package/examples/films/beam-search.ts +321 -49
- package/examples/films/boltzmann-entropy.ts +104 -0
- package/examples/films/cache-miss.ts +387 -394
- package/examples/films/catalog.json +238 -77
- package/examples/films/catalysis.ts +128 -0
- package/examples/films/central-limit.ts +27 -22
- package/examples/films/complex-maps.ts +70 -56
- package/examples/films/deck-example.ts +261 -200
- package/examples/films/euler-circle.ts +72 -28
- package/examples/films/flash-attention.ts +549 -0
- package/examples/films/forecast.ts +2 -2
- package/examples/films/fourier-epicycles.ts +21 -20
- package/examples/films/gradient-descent.ts +23 -49
- package/examples/films/gravitational-waves.ts +179 -0
- package/examples/films/heat-equation.ts +124 -0
- package/examples/films/hydrogen-orbitals.ts +135 -0
- package/examples/films/io-uring.ts +635 -0
- package/examples/films/linear-maps.ts +42 -31
- package/examples/films/lorenz.ts +42 -79
- package/examples/films/maxwell.ts +197 -0
- package/examples/films/pathlines.ts +85 -0
- package/examples/films/planetary-orbits.ts +146 -0
- package/examples/films/pythagoras.ts +18 -10
- package/examples/films/quantum-tunneling.ts +116 -0
- package/examples/films/rag-citations.ts +423 -0
- package/examples/films/reaction-diffusion.ts +70 -0
- package/examples/films/ring-allreduce.ts +531 -0
- package/examples/films/stationary-action.ts +170 -0
- package/examples/films/svd-3d.ts +605 -0
- package/examples/films/taylor-series.ts +9 -9
- package/examples/films/vizmatic-title.ts +1 -0
- package/examples/vizmatic-hero.tsx +102 -32
- package/package.json +3 -1
- package/dist/chunk-3F2VQ7NW.js +0 -1
- package/dist/chunk-GGFDBJ25.js +0 -88
- package/dist/math-QVCETQDQ.js +0 -1
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* is measured from the drawn geometry, not assumed.
|
|
6
6
|
*/
|
|
7
7
|
import {
|
|
8
|
-
Node, dot, dynamic, fade, fadeIn, film, flash, line, morphMatching, polyPath, rect, shape, smooth, smoother, smoothPath, text, tex, write,
|
|
8
|
+
Node, dot, dynamic, fade, fadeIn, fadeOut, film, flash, line, morphMatching, polyPath, rect, shape, smooth, smoother, smoothPath, text, tex, write,
|
|
9
9
|
type Vec,
|
|
10
10
|
} from 'vizmatic/stage'
|
|
11
11
|
|
|
@@ -131,8 +131,13 @@ export default film({
|
|
|
131
131
|
return strokes(secondGrid, (z) => toStageB(mobius(z, k.value)), reveal2.value, secondAlpha.value)
|
|
132
132
|
})
|
|
133
133
|
|
|
134
|
+
const markerAAlpha = s.value(0)
|
|
135
|
+
const markerBAlpha = s.value(0)
|
|
136
|
+
const pointsBAlpha = s.value(0)
|
|
137
|
+
|
|
134
138
|
/** A right-angle marker built from the images of two short steps along the grid directions. */
|
|
135
|
-
const marker = (map: (z: C) => Vec, at: C, color: string, label: string): Node[] => {
|
|
139
|
+
const marker = (map: (z: C) => Vec, at: C, color: string, label: string, alpha: number): Node[] | null => {
|
|
140
|
+
if (alpha <= 0.001) return null
|
|
136
141
|
const z = zoom.value
|
|
137
142
|
const scale = 1 / Math.pow(z, 0.85)
|
|
138
143
|
const h = 1e-4
|
|
@@ -145,36 +150,47 @@ export default film({
|
|
|
145
150
|
[o[0], o[1]], [o[0] + u[0] * size, o[1] + u[1] * size],
|
|
146
151
|
[o[0] + (u[0] + v[0]) * size, o[1] + (u[1] + v[1]) * size], [o[0] + v[0] * size, o[1] + v[1] * size],
|
|
147
152
|
], true)
|
|
148
|
-
const
|
|
149
|
-
|
|
153
|
+
const diagLen = Math.hypot(u[0] + v[0], u[1] + v[1]) || 1
|
|
154
|
+
const du = (u[0] + v[0]) / diagLen, dv = (u[1] + v[1]) / diagLen
|
|
155
|
+
const tag = tex(label, { size: 32 * scale, color, display: false })
|
|
156
|
+
tag.moveTo([o[0] - du * 48 * scale, o[1] - dv * 48 * scale]).opacity(alpha)
|
|
150
157
|
const b2 = tag.bounds()
|
|
151
158
|
return [
|
|
152
|
-
shape(corner, { fill: color, stroke: color, width: 2.6 * scale }).set('fillOpacity', 0.28),
|
|
153
|
-
dot(6.5 * scale, color).at(o),
|
|
154
|
-
rect(b2.width +
|
|
155
|
-
.at(b2.x + b2.width / 2, b2.y + b2.height / 2)
|
|
159
|
+
shape(corner, { fill: color, stroke: color, width: 2.6 * scale }).set('fillOpacity', 0.28 * alpha).opacity(alpha),
|
|
160
|
+
dot(6.5 * scale, color).at(o).opacity(alpha),
|
|
161
|
+
rect(b2.width + 26 * scale, b2.height + 24 * scale, { fill: 'bg', stroke: null, radius: 6 * scale })
|
|
162
|
+
.at(b2.x + b2.width / 2, b2.y + b2.height / 2),
|
|
156
163
|
tag,
|
|
157
164
|
]
|
|
158
165
|
}
|
|
159
166
|
|
|
160
|
-
const markerA = dynamic(() => firstAlpha.value <= 0 ? null : marker((z) => toStageA(power(z, p.value)), Z0, 'yellow', 'z_0'))
|
|
161
|
-
const markerB = dynamic(() => secondAlpha.value <= 0 ? null : marker((z) => toStageB(mobius(z, k.value)), Z1, 'yellow', 'z_0'))
|
|
167
|
+
const markerA = dynamic(() => firstAlpha.value <= 0 ? null : marker((z) => toStageA(power(z, p.value)), Z0, 'yellow', 'z_0', markerAAlpha.value)).zIndex(2)
|
|
168
|
+
const markerB = dynamic(() => secondAlpha.value <= 0 ? null : marker((z) => toStageB(mobius(z, k.value)), Z1, 'yellow', 'z_0', markerBAlpha.value)).zIndex(2)
|
|
162
169
|
|
|
163
170
|
// Four landmarks of the second map.
|
|
164
|
-
const landmarks: readonly [C, string
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
171
|
+
const landmarks: readonly [C, string, Vec][] = [
|
|
172
|
+
[[0, 1], 'i', [36, -30]],
|
|
173
|
+
[[0, 0], '0', [-36, 32]],
|
|
174
|
+
[[1, 0], '1', [36, 32]],
|
|
175
|
+
[[-1, 0], '-1', [-42, -32]],
|
|
176
|
+
]
|
|
177
|
+
const pointsB = dynamic(() => {
|
|
178
|
+
const a = pointsBAlpha.value
|
|
179
|
+
if (a <= 0.001 || secondAlpha.value <= 0) return null
|
|
180
|
+
return landmarks.flatMap(([z, label, off]) => {
|
|
181
|
+
const at = toStageB(mobius(z, k.value))
|
|
182
|
+
const tag = tex(label, { size: 32, color: 'ink', display: false })
|
|
183
|
+
tag.moveTo([at[0] + off[0], at[1] + off[1]]).opacity(a)
|
|
184
|
+
const b = tag.bounds()
|
|
185
|
+
return [
|
|
186
|
+
dot(7, 'teal').at(at).opacity(a),
|
|
187
|
+
rect(b.width + 26, b.height + 24, { fill: 'bg', stroke: null, radius: 6 }).at(b.x + b.width / 2, b.y + b.height / 2),
|
|
188
|
+
tag,
|
|
189
|
+
]
|
|
190
|
+
})
|
|
191
|
+
}).zIndex(2)
|
|
176
192
|
|
|
177
|
-
const infinityMark = tex('\\infty', { size: 38, color: 'teal', display: false }).moveTo([ORIGIN_X + 410 +
|
|
193
|
+
const infinityMark = tex('\\infty', { size: 38, color: 'teal', display: false }).moveTo([ORIGIN_X + 410 + 46, -38]).zIndex(2)
|
|
178
194
|
|
|
179
195
|
// ── Column ──────────────────────────────────────────────────────────────
|
|
180
196
|
|
|
@@ -185,18 +201,18 @@ export default film({
|
|
|
185
201
|
node.pin().zIndex(6)
|
|
186
202
|
return node
|
|
187
203
|
}
|
|
188
|
-
const label = (content: string, top: number) => place(text(content, { size:
|
|
204
|
+
const label = (content: string, top: number) => place(text(content, { size: 26, color: 'dim', weight: 600 }), top)
|
|
189
205
|
|
|
190
|
-
const title = place(text('The grid bends. Its right angles survive.', { font: 'text-serif', size:
|
|
191
|
-
const eqIdentity = place(tex('w = z', { size:
|
|
192
|
-
const eqPower = place(tex('w = z^{p}', { size:
|
|
193
|
-
const eqSquare = place(tex('w = z^{2}', { size:
|
|
194
|
-
const eqMobius = place(tex('w = \\frac{z - i}{z + i}', { size:
|
|
206
|
+
const title = place(text('The grid bends. Its right angles survive.', { font: 'text-serif', size: 44, maxWidth: 430, leading: 1.08 }), -496)
|
|
207
|
+
const eqIdentity = place(tex('w = z', { size: 52 }), -366)
|
|
208
|
+
const eqPower = place(tex('w = z^{p}', { size: 52 }), -366)
|
|
209
|
+
const eqSquare = place(tex('w = z^{2}', { size: 52, color: 'ink' }), -366)
|
|
210
|
+
const eqMobius = place(tex('w = \\frac{z - i}{z + i}', { size: 44 }), -384)
|
|
195
211
|
|
|
196
|
-
const pLabel = label('Exponent', -
|
|
197
|
-
const pRead = dynamic(() => place(text(`p = ${p.value.toFixed(2)}`, { font: 'mono', size:
|
|
198
|
-
const kLabel = label('
|
|
199
|
-
const kRead = dynamic(() => place(text(`k = ${k.value.toFixed(2)}`, { font: 'mono', size:
|
|
212
|
+
const pLabel = label('Exponent', -256)
|
|
213
|
+
const pRead = dynamic(() => place(text(`p = ${p.value.toFixed(2)}`, { font: 'mono', size: 42, color: 'ink' }), -220)).pin().zIndex(6)
|
|
214
|
+
const kLabel = label('Mobius family parameter', -256)
|
|
215
|
+
const kRead = dynamic(() => place(text(`k = ${k.value.toFixed(2)}`, { font: 'mono', size: 42, color: 'ink' }), -220)).pin().zIndex(6)
|
|
200
216
|
|
|
201
217
|
const derivative = (): { size: number; angle: number; crossing: number } => {
|
|
202
218
|
const act = secondAlpha.value > 0.5
|
|
@@ -208,35 +224,34 @@ export default film({
|
|
|
208
224
|
const crossing = Math.abs(Math.atan2(dx[0] * dy[1] - dx[1] * dy[0], dx[0] * dy[0] + dx[1] * dy[1])) * 180 / Math.PI
|
|
209
225
|
return { size: abs(dx), angle: Math.atan2(dx[1], dx[0]) * 180 / Math.PI, crossing }
|
|
210
226
|
}
|
|
211
|
-
const angleLabel = label('Angle between grid lines at
|
|
212
|
-
const angleRead = dynamic(() => place(text(`${derivative().crossing.toFixed(2)}
|
|
213
|
-
const scaleLabel = label('Local stretch',
|
|
214
|
-
const scaleRead = dynamic(() => place(text(derivative().size.toFixed(2), { font: 'mono', size: 36, color: 'ink' }),
|
|
215
|
-
const turnLabel = label('Local turn',
|
|
216
|
-
turnLabel.alignTo([COLUMN +
|
|
227
|
+
const angleLabel = label('Angle between grid lines at z₀', -144)
|
|
228
|
+
const angleRead = dynamic(() => place(text(`${derivative().crossing.toFixed(2)}°`, { font: 'mono', size: 42, color: 'yellow' }), -108)).pin().zIndex(6)
|
|
229
|
+
const scaleLabel = label('Local stretch', -30)
|
|
230
|
+
const scaleRead = dynamic(() => place(text(derivative().size.toFixed(2), { font: 'mono', size: 36, color: 'ink' }), 6)).pin().zIndex(6)
|
|
231
|
+
const turnLabel = label('Local turn', -30)
|
|
232
|
+
turnLabel.alignTo([COLUMN + 216, 0], 'left')
|
|
217
233
|
const turnRead = dynamic(() => {
|
|
218
|
-
const node = place(text(`${derivative().angle.toFixed(1)}
|
|
219
|
-
node.alignTo([COLUMN +
|
|
234
|
+
const node = place(text(`${derivative().angle.toFixed(1)}°`, { font: 'mono', size: 36, color: 'ink' }), 6)
|
|
235
|
+
node.alignTo([COLUMN + 216, 0], 'left')
|
|
220
236
|
return node
|
|
221
237
|
}).pin().zIndex(6)
|
|
222
238
|
const note = place(text('Near any point, a complex derivative is one rotation and one scale. A small square can only come out as another square.', {
|
|
223
|
-
size:
|
|
224
|
-
}),
|
|
225
|
-
const deriv = place(tex("f(z_0 + h) \\approx f(z_0) + f'(z_0)\\, h", { size: 30 }),
|
|
239
|
+
size: 26, color: 'dim', maxWidth: 420, leading: 1.35,
|
|
240
|
+
}), 80)
|
|
241
|
+
const deriv = place(tex("f(z_0 + h) \\approx f(z_0) + f'(z_0)\\, h", { size: 30 }), 262)
|
|
226
242
|
const note2 = place(text('A map of this kind sends lines to circles. The whole upper half-plane lands inside the unit disk.', {
|
|
227
|
-
size:
|
|
228
|
-
}),
|
|
229
|
-
const landing = place(tex('i \\mapsto 0, \\quad 0 \\mapsto -1', { size: 32, color: 'teal' }),
|
|
230
|
-
const landing2 = place(tex('1 \\mapsto -i, \\quad -1 \\mapsto i', { size: 32, color: 'teal' }),
|
|
243
|
+
size: 26, color: 'dim', maxWidth: 420, leading: 1.35,
|
|
244
|
+
}), 80)
|
|
245
|
+
const landing = place(tex('i \\mapsto 0, \\quad 0 \\mapsto -1', { size: 32, color: 'teal' }), 242)
|
|
246
|
+
const landing2 = place(tex('1 \\mapsto -i, \\quad -1 \\mapsto i', { size: 32, color: 'teal' }), 300)
|
|
231
247
|
|
|
232
248
|
// ── Timeline ────────────────────────────────────────────────────────────
|
|
233
249
|
|
|
234
250
|
s.add(firstField, markerA)
|
|
235
|
-
markerA.opacity(0)
|
|
236
251
|
s.add(backing, rule)
|
|
237
252
|
s.chapter('The grid')
|
|
238
253
|
s.play(reveal.to(1, { ease: smooth }), write(title), { duration: 2.4 })
|
|
239
|
-
s.play(write(eqIdentity),
|
|
254
|
+
s.play(write(eqIdentity), markerAAlpha.to(1), fadeIn([angleLabel, angleRead, scaleLabel, scaleRead, turnLabel, turnRead]), { duration: 1.2 })
|
|
240
255
|
s.play(fadeIn(note, { shift: [0, 8] }), write(deriv), { duration: 1.2 })
|
|
241
256
|
s.wait(0.8)
|
|
242
257
|
|
|
@@ -255,17 +270,16 @@ export default film({
|
|
|
255
270
|
})
|
|
256
271
|
const offset = 240
|
|
257
272
|
s.play(zoom.to(3.4, { ease: smoother }), focusX.to(target[0] + offset / 3.4, { ease: smoother }), focusY.to(target[1], { ease: smoother }), fade(title, 0.25), { duration: 3 })
|
|
258
|
-
s.play(flash(
|
|
273
|
+
s.play(flash(target, { color: 'yellow', radius: 26 }), { duration: 0.8 })
|
|
259
274
|
s.wait(2)
|
|
260
275
|
s.play(zoom.to(1, { ease: smoother }), focusX.to(0, { ease: smoother }), focusY.to(0, { ease: smoother }), fade(title, 1), { duration: 2.4 })
|
|
261
276
|
|
|
262
277
|
s.chapter('A different map')
|
|
263
|
-
s.add(secondField, markerB)
|
|
264
|
-
markerB.opacity(0)
|
|
278
|
+
s.add(secondField, markerB, pointsB)
|
|
265
279
|
backing.zIndex(5)
|
|
266
|
-
s.play(firstAlpha.to(0),
|
|
267
|
-
s.play(reveal2.to(1), secondAlpha.to(1, { ease: smoother }), fadeIn([kLabel, kRead]), fadeIn(note2, { shift: [0, 8] }), { duration: 2
|
|
268
|
-
s.play(
|
|
280
|
+
s.play(firstAlpha.to(0), markerAAlpha.to(0), fadeOut([eqSquare, pLabel, pRead, note, deriv]), { duration: 0.8 })
|
|
281
|
+
s.play(write(eqMobius), reveal2.to(1), secondAlpha.to(1, { ease: smoother }), fadeIn([kLabel, kRead]), fadeIn(note2, { shift: [0, 8] }), { duration: 2 })
|
|
282
|
+
s.play(markerBAlpha.to(1), pointsBAlpha.to(1), { duration: 0.8 })
|
|
269
283
|
s.wait(0.6)
|
|
270
284
|
s.play(k.to(1, { ease: smoother }), { duration: 8 })
|
|
271
285
|
s.play(write(landing), write(landing2), write(infinityMark), { duration: 1.6 })
|