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.
Files changed (99) hide show
  1. package/PROMPT.md +32 -0
  2. package/README.md +8 -3
  3. package/ROADMAP.md +4 -2
  4. package/SCIENCE.md +69 -3
  5. package/dist/chunk-6JI55YX4.js +604 -0
  6. package/dist/{chunk-LTX44BAE.js → chunk-BYKXNUX7.js} +25 -4
  7. package/dist/{chunk-4MXGLMBG.js → chunk-EPZLNABN.js} +107 -37
  8. package/dist/chunk-EWCO6ZT6.js +696 -0
  9. package/dist/{chunk-JZPMGVBP.js → chunk-G7HRSKHV.js} +1 -1
  10. package/dist/{chunk-RPAHMKAR.js → chunk-JTWC2OPN.js} +7 -5
  11. package/dist/chunk-LJZO36IR.js +124 -0
  12. package/dist/chunk-REL2BZ2B.js +88 -0
  13. package/dist/chunk-RLPEOWST.js +1 -0
  14. package/dist/chunk-VMHOWCDL.js +296 -0
  15. package/dist/chunk-YDD63HHD.js +1 -0
  16. package/dist/{chunk-I745F4QK.js → chunk-YNGDEARY.js} +1134 -643
  17. package/dist/cli.js +80 -543
  18. package/dist/gpu-selection-CDWCZH27.js +1 -0
  19. package/dist/gpu-selection-MX6NHMNA.js +635 -0
  20. package/dist/index.cjs +473 -155
  21. package/dist/index.d.cts +30 -239
  22. package/dist/index.d.ts +30 -239
  23. package/dist/index.js +410 -457
  24. package/dist/math-E7W5LFWO.js +1 -0
  25. package/dist/{math-LXB4FH4E.js → math-NEFQUPRV.js} +3 -1
  26. package/dist/scene-browser.js +17 -17
  27. package/dist/scene-cli.js +1 -1
  28. package/dist/scene-runtime.cjs +4 -2
  29. package/dist/scene-runtime.js +2 -2
  30. package/dist/stage-browser/browser.d.ts +1206 -854
  31. package/dist/stage-browser/gpu-renderer.js +138 -0
  32. package/dist/stage-browser/{math-4WFNHVV2.js → math-KYHUOK7A.js} +46 -10
  33. package/dist/stage-browser/stage.js +107 -19
  34. package/dist/stage-export.cjs +8221 -6784
  35. package/dist/stage-export.d.cts +13 -5
  36. package/dist/stage-export.d.ts +13 -5
  37. package/dist/stage-export.js +111 -601
  38. package/dist/stage.cjs +6243 -3474
  39. package/dist/stage.d.cts +1064 -765
  40. package/dist/stage.d.ts +1064 -765
  41. package/dist/stage.js +3571 -2405
  42. package/dist/{svg-import-B5BGbC1t.d.cts → svg-import-CSCFWYaB.d.cts} +21 -12
  43. package/dist/{svg-import-B5BGbC1t.d.ts → svg-import-CSCFWYaB.d.ts} +21 -12
  44. package/dist/teaching-math-DTKc0XsB.d.cts +243 -0
  45. package/dist/teaching-math-ydDBhJ2M.d.ts +243 -0
  46. package/dist/{video-CiN1MDCS.d.cts → theme-DhVdDQKO.d.cts} +4 -237
  47. package/dist/{video-CiN1MDCS.d.ts → theme-DhVdDQKO.d.ts} +4 -237
  48. package/dist/video-BYCeOz8F.d.ts +259 -0
  49. package/dist/video-CGLxJXqu.d.cts +259 -0
  50. package/examples/catalog-science-physics.tsx +6 -6
  51. package/examples/films/_boltzmann-entropy/model.ts +63 -0
  52. package/examples/films/_catalysis/model.ts +49 -0
  53. package/examples/films/_gravitational-waves/model.ts +32 -0
  54. package/examples/films/_heat-equation/model.ts +54 -0
  55. package/examples/films/_hydrogen-orbitals/model.ts +31 -0
  56. package/examples/films/_maxwell/model.ts +84 -0
  57. package/examples/films/_planetary-orbits/appearance.ts +71 -0
  58. package/examples/films/_planetary-orbits/model.ts +152 -0
  59. package/examples/films/_planetary-orbits/saturn.ts +142 -0
  60. package/examples/films/_quantum-tunneling/model.ts +58 -0
  61. package/examples/films/_reaction-diffusion/model.ts +61 -0
  62. package/examples/films/_stationary-action/model.ts +38 -0
  63. package/examples/films/attention.ts +309 -253
  64. package/examples/films/beam-search.ts +321 -49
  65. package/examples/films/boltzmann-entropy.ts +104 -0
  66. package/examples/films/cache-miss.ts +387 -394
  67. package/examples/films/catalog.json +238 -77
  68. package/examples/films/catalysis.ts +128 -0
  69. package/examples/films/central-limit.ts +27 -22
  70. package/examples/films/complex-maps.ts +70 -56
  71. package/examples/films/deck-example.ts +261 -200
  72. package/examples/films/euler-circle.ts +72 -28
  73. package/examples/films/flash-attention.ts +549 -0
  74. package/examples/films/forecast.ts +2 -2
  75. package/examples/films/fourier-epicycles.ts +21 -20
  76. package/examples/films/gradient-descent.ts +23 -49
  77. package/examples/films/gravitational-waves.ts +179 -0
  78. package/examples/films/heat-equation.ts +124 -0
  79. package/examples/films/hydrogen-orbitals.ts +135 -0
  80. package/examples/films/io-uring.ts +635 -0
  81. package/examples/films/linear-maps.ts +42 -31
  82. package/examples/films/lorenz.ts +42 -79
  83. package/examples/films/maxwell.ts +197 -0
  84. package/examples/films/pathlines.ts +85 -0
  85. package/examples/films/planetary-orbits.ts +146 -0
  86. package/examples/films/pythagoras.ts +18 -10
  87. package/examples/films/quantum-tunneling.ts +116 -0
  88. package/examples/films/rag-citations.ts +423 -0
  89. package/examples/films/reaction-diffusion.ts +70 -0
  90. package/examples/films/ring-allreduce.ts +531 -0
  91. package/examples/films/stationary-action.ts +170 -0
  92. package/examples/films/svd-3d.ts +605 -0
  93. package/examples/films/taylor-series.ts +9 -9
  94. package/examples/films/vizmatic-title.ts +1 -0
  95. package/examples/vizmatic-hero.tsx +102 -32
  96. package/package.json +3 -1
  97. package/dist/chunk-3F2VQ7NW.js +0 -1
  98. package/dist/chunk-GGFDBJ25.js +0 -88
  99. 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 tag = tex(label, { size: 30 * scale, color, display: false })
149
- tag.moveTo([o[0] - (u[0] + v[0]) * 30 * scale, o[1] - (u[1] + v[1]) * 30 * scale])
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 + 10 * scale, b2.height + 8 * scale, { fill: 'bg', stroke: null, radius: 5 * scale })
155
- .at(b2.x + b2.width / 2, b2.y + b2.height / 2).opacity(0.94),
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][] = [[[0, 1], 'i'], [[0, 0], '0'], [[1, 0], '1'], [[-1, 0], '-1']]
165
- const pointsB = dynamic(() => landmarks.flatMap(([z, label]) => {
166
- const at = toStageB(mobius(z, k.value))
167
- const tag = tex(label, { size: 30, color: 'ink', display: false })
168
- tag.moveTo([at[0] + 26, at[1] - 22])
169
- const b = tag.bounds()
170
- return [
171
- dot(7, 'teal').at(at),
172
- rect(b.width + 10, b.height + 8, { fill: 'bg', stroke: null, radius: 5 }).at(b.x + b.width / 2, b.y + b.height / 2).opacity(0.94),
173
- tag,
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 + 34, -32])
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: 19, color: 'dim', uppercase: true, tracking: 0.08, weight: 600 }), top)
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: 46, maxWidth: 440, leading: 1.08 }), -490)
191
- const eqIdentity = place(tex('w = z', { size: 54 }), -296)
192
- const eqPower = place(tex('w = z^{p}', { size: 54 }), -296)
193
- const eqSquare = place(tex('w = z^{2}', { size: 54, color: 'ink' }), -296)
194
- const eqMobius = place(tex('w = \\frac{z - i}{z + i}', { size: 46 }), -356)
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', -196)
197
- const pRead = dynamic(() => place(text(`p = ${p.value.toFixed(2)}`, { font: 'mono', size: 44, color: 'ink' }), -168)).pin().zIndex(6)
198
- const kLabel = label('Along the Mobius family', -196)
199
- const kRead = dynamic(() => place(text(`k = ${k.value.toFixed(2)}`, { font: 'mono', size: 44, color: 'ink' }), -168)).pin().zIndex(6)
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 z0', -92)
212
- const angleRead = dynamic(() => place(text(`${derivative().crossing.toFixed(2)} deg`, { font: 'mono', size: 44, color: 'yellow' }), -64)).pin().zIndex(6)
213
- const scaleLabel = label('Local stretch', 20)
214
- const scaleRead = dynamic(() => place(text(derivative().size.toFixed(2), { font: 'mono', size: 36, color: 'ink' }), 48)).pin().zIndex(6)
215
- const turnLabel = label('Local turn', 20)
216
- turnLabel.alignTo([COLUMN + 200, 0], 'left')
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)} deg`, { font: 'mono', size: 36, color: 'ink' }), 48)
219
- node.alignTo([COLUMN + 200, 0], 'left')
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: 24, color: 'dim', maxWidth: 400, leading: 1.42,
224
- }), 130)
225
- const deriv = place(tex("f(z_0 + h) \\approx f(z_0) + f'(z_0)\\, h", { size: 30 }), 316)
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: 24, color: 'dim', maxWidth: 400, leading: 1.42,
228
- }), 130)
229
- const landing = place(tex('i \\mapsto 0, \\quad 0 \\mapsto -1', { size: 32, color: 'teal' }), 300)
230
- const landing2 = place(tex('1 \\mapsto -i, \\quad -1 \\mapsto i', { size: 32, color: 'teal' }), 354)
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), fade(markerA, 1), fadeIn([angleLabel, angleRead, scaleLabel, scaleRead, turnLabel, turnRead]), { duration: 1.2 })
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([-240, 0], { color: 'yellow', radius: 74 }), { duration: 0.8 })
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), fade(markerA, 0), fadeIn(eqMobius), fade(eqSquare, 0), fade(pLabel, 0), fade(pRead, 0), fade(note, 0), fade(deriv, 0), { duration: 1 })
267
- s.play(reveal2.to(1), secondAlpha.to(1, { ease: smoother }), fadeIn([kLabel, kRead]), fadeIn(note2, { shift: [0, 8] }), { duration: 2.2 })
268
- s.play(fade(markerB, 1), fadeIn(pointsB), { duration: 0.8 })
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 })