vizmatic 0.7.1 → 0.7.3

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 (35) hide show
  1. package/PROMPT.md +25 -1
  2. package/ROADMAP.md +1 -1
  3. package/dist/{chunk-DTD35LPT.js → chunk-F6QI6QJY.js} +60 -2
  4. package/dist/chunk-QVYHYC7T.js +88 -0
  5. package/dist/cli.js +10 -9
  6. package/dist/index.cjs +70 -3
  7. package/dist/index.d.cts +4 -2
  8. package/dist/index.d.ts +4 -2
  9. package/dist/index.js +14 -3
  10. package/dist/scene-cli.js +1 -1
  11. package/dist/stage-browser/browser.d.ts +144 -5
  12. package/dist/stage-browser/stage.js +5 -5
  13. package/dist/stage-export.cjs +67 -1
  14. package/dist/stage-export.d.cts +5 -1
  15. package/dist/stage-export.d.ts +5 -1
  16. package/dist/stage-export.js +11 -1
  17. package/dist/stage.cjs +286 -22
  18. package/dist/stage.d.cts +146 -7
  19. package/dist/stage.d.ts +146 -7
  20. package/dist/stage.js +268 -9
  21. package/dist/{svg-import-Djj2q7Pc.d.cts → svg-import-5_oTbEJR.d.cts} +2 -2
  22. package/dist/{svg-import-Djj2q7Pc.d.ts → svg-import-5_oTbEJR.d.ts} +2 -2
  23. package/dist/{video-CcHW1qhV.d.cts → video-BSwNJZkn.d.cts} +25 -1
  24. package/dist/{video-CcHW1qhV.d.ts → video-BSwNJZkn.d.ts} +25 -1
  25. package/examples/_teaching/categorical-tail-loss.ts +3 -3
  26. package/examples/_teaching/teaching-byte-diff.ts +3 -3
  27. package/examples/_teaching/teaching-routed-transfer.ts +3 -3
  28. package/examples/_teaching/teaching-token-history.ts +2 -2
  29. package/examples/_teaching/teaching-weighted-vector.ts +3 -3
  30. package/examples/films/attention.ts +5 -4
  31. package/examples/films/fourier-epicycles.ts +5 -2
  32. package/examples/films/pythagoras.ts +2 -2
  33. package/examples/films/taylor-series.ts +3 -2
  34. package/package.json +1 -1
  35. package/dist/chunk-3LQLKLGH.js +0 -79
package/dist/stage.js CHANGED
@@ -357,6 +357,45 @@ function regularPolygon(sides, radius, style = {}) {
357
357
  }
358
358
  return polygon(points, style);
359
359
  }
360
+ function intrinsicSize(src) {
361
+ const match = /^data:image\/(png|gif|jpeg|jpg);base64,/.exec(src);
362
+ if (!match || typeof atob !== "function") return null;
363
+ let head;
364
+ try {
365
+ head = atob(src.slice(match[0].length, match[0].length + (match[1] === "jpeg" || match[1] === "jpg" ? 87384 : 44)));
366
+ } catch {
367
+ return null;
368
+ }
369
+ const byte = (i) => head.charCodeAt(i);
370
+ if (match[1] === "png") return head.length >= 24 ? [byte(16) * 16777216 + byte(17) * 65536 + byte(18) * 256 + byte(19), byte(20) * 16777216 + byte(21) * 65536 + byte(22) * 256 + byte(23)] : null;
371
+ if (match[1] === "gif") return head.length >= 10 ? [byte(6) + byte(7) * 256, byte(8) + byte(9) * 256] : null;
372
+ for (let i = 2; i + 9 < head.length; ) {
373
+ if (byte(i) !== 255) return null;
374
+ const marker = byte(i + 1);
375
+ if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) return [byte(i + 7) * 256 + byte(i + 8), byte(i + 5) * 256 + byte(i + 6)];
376
+ i += 2 + byte(i + 2) * 256 + byte(i + 3);
377
+ }
378
+ return null;
379
+ }
380
+ function image(src, options = {}) {
381
+ const natural = intrinsicSize(src);
382
+ let width = options.width, height = options.height;
383
+ if (width === void 0 && height === void 0) {
384
+ if (!natural) throw new Error("image() needs a width or a height when the picture is not a PNG, GIF, or JPEG data URL.");
385
+ [width, height] = natural;
386
+ } else if (width === void 0 || height === void 0) {
387
+ if (!natural) throw new Error("image() needs both width and height when the picture is not a PNG, GIF, or JPEG data URL.");
388
+ if (width === void 0) width = height * natural[0] / natural[1];
389
+ else height = width * natural[1] / natural[0];
390
+ }
391
+ if (!(width > 0) || !(height > 0)) throw new Error("image() needs a positive width and height.");
392
+ const picture = new Node().at(-width / 2, -height / 2);
393
+ picture.base.image = { src, width, height };
394
+ const out = new Node();
395
+ out.add(picture);
396
+ if (options.opacity !== void 0) out.opacity(options.opacity);
397
+ return out;
398
+ }
360
399
  function dot(radius = 9, color = "ink", style = {}) {
361
400
  return styled(new Node(circlePath(0, 0, radius)), style, { fill: color });
362
401
  }
@@ -631,6 +670,9 @@ var MIN_RESTING_MOMENTS = 5;
631
670
  var AUTO_SAMPLES = 12;
632
671
  var CUBIC_STEPS = 6;
633
672
  var CROSSING_ERROR_WIDTH = 2;
673
+ var BLANK_ALPHA = 0.25;
674
+ var BLANK_EDGE_SECONDS = 0.5;
675
+ var BLANK_MIN_SECONDS = 0.2;
634
676
  var CROSSING_ERROR_CONTRAST = 2;
635
677
  var MIN_STROKE_CONTRAST = 1.6;
636
678
  var OPAQUE = 0.9;
@@ -907,6 +949,16 @@ function inspect(frame, time, zoomed, bleed) {
907
949
  }
908
950
  return findings;
909
951
  }
952
+ function hasContent(frame, top) {
953
+ return frame.ops.some((op) => {
954
+ if (op.kind !== "path") return op.alpha >= BLANK_ALPHA;
955
+ const filled = op.fill !== null && op.fillAlpha >= BLANK_ALPHA;
956
+ const stroked = op.stroke !== null && op.strokeAlpha >= BLANK_ALPHA && op.strokeWidth > 0;
957
+ if (!filled && !stroked) return false;
958
+ const box = pathBounds(filled ? op.path : op.strokePath);
959
+ return box !== null && box.y + box.height > top && box.y < frame.height && box.x + box.width > 0 && box.x < frame.width;
960
+ });
961
+ }
910
962
  async function checkFilm(film2, options = {}) {
911
963
  const compiled = isFilm(film2) ? await film2.compile(options) : film2;
912
964
  const times = options.times ? [...options.times] : restingMoments(compiled, options.samples ?? 0);
@@ -927,6 +979,57 @@ async function checkFilm(film2, options = {}) {
927
979
  }
928
980
  }
929
981
  }
982
+ const frameCount = options.motion ? Math.max(1, Math.round(compiled.duration * compiled.fps)) : 0;
983
+ const step = 1 / compiled.fps;
984
+ if (options.motion) {
985
+ const top = options.contentTop ?? 0;
986
+ const moving = /* @__PURE__ */ new Map();
987
+ const blanks = [];
988
+ for (let index = 0; index < frameCount; index++) {
989
+ const time = index * step;
990
+ const frame = await frameAt(compiled, time);
991
+ for (const finding of inspect(frame, time, zoomAt(compiled, time) !== 1, compiled.bleed)) {
992
+ if (merged.has(finding.key)) continue;
993
+ let runs = moving.get(finding.key);
994
+ if (!runs) moving.set(finding.key, runs = []);
995
+ const last = runs[runs.length - 1];
996
+ if (last && last.to === index - 1) last.to = index;
997
+ else runs.push({ from: index, to: index, first: finding });
998
+ }
999
+ const edge = time < BLANK_EDGE_SECONDS || time > compiled.duration - BLANK_EDGE_SECONDS;
1000
+ if (!edge && !hasContent(frame, top)) {
1001
+ const last = blanks[blanks.length - 1];
1002
+ if (last && last.to === index - 1) last.to = index;
1003
+ else blanks.push({ from: index, to: index });
1004
+ }
1005
+ }
1006
+ const seconds = (frames) => Math.round(frames * step * 100) / 100;
1007
+ for (const [key, runs] of moving) {
1008
+ const longest = runs.reduce((best, run) => run.to - run.from > best.to - best.from ? run : best);
1009
+ const { key: _, ...finding } = longest.first;
1010
+ merged.set(key, {
1011
+ ...finding,
1012
+ severity: "warning",
1013
+ until: longest.to * step,
1014
+ stage: { x: 0, y: 0 },
1015
+ motion: { spans: runs.length, seconds: seconds(runs.reduce((sum, run) => sum + run.to - run.from + 1, 0)) }
1016
+ });
1017
+ }
1018
+ for (const run of blanks) {
1019
+ const length = seconds(run.to - run.from + 1);
1020
+ if (length < BLANK_MIN_SECONDS) continue;
1021
+ merged.set(`film.blank:${run.from}`, {
1022
+ code: "film.blank",
1023
+ severity: "warning",
1024
+ message: `Nothing is visible${top > 0 ? ` below y=${top}` : ""} for ${length} s.`,
1025
+ time: run.from * step,
1026
+ until: run.to * step,
1027
+ box: { x: 0, y: top, width: compiled.width, height: compiled.height - top },
1028
+ stage: { x: 0, y: 0 },
1029
+ motion: { spans: 1, seconds: length }
1030
+ });
1031
+ }
1032
+ }
930
1033
  const round = (value) => Math.round(value * 100) / 100;
931
1034
  const diagnostics = [...merged.values()].map((entry) => ({
932
1035
  ...entry,
@@ -945,6 +1048,7 @@ async function checkFilm(film2, options = {}) {
945
1048
  height: compiled.height,
946
1049
  duration: compiled.duration,
947
1050
  sampled: times.map((time) => Math.round(time * 1e3) / 1e3),
1051
+ ...options.motion ? { frames: frameCount } : {},
948
1052
  diagnostics,
949
1053
  summary: { errors, warnings: diagnostics.length - errors }
950
1054
  };
@@ -3138,7 +3242,7 @@ var CodeBlock = class extends Node {
3138
3242
  const font = fontFor("mono", 400);
3139
3243
  const scale = size / font.unitsPerEm;
3140
3244
  const advance = font.advance(font.glyphFor(48)) * scale;
3141
- const tokens2 = tokenize(source, options.language ?? "ts");
3245
+ const tokens3 = tokenize(source, options.language ?? "ts");
3142
3246
  const rows = source.split("\n");
3143
3247
  const gutter = options.lineNumbers ? (String(rows.length).length + 2) * advance : 0;
3144
3248
  const pad2 = options.padding ?? size * 0.9;
@@ -3170,7 +3274,7 @@ var CodeBlock = class extends Node {
3170
3274
  }
3171
3275
  const colors = { ...CODE_COLORS, ...options.colors };
3172
3276
  const column = /* @__PURE__ */ new Map();
3173
- for (const token of tokens2) {
3277
+ for (const token of tokens3) {
3174
3278
  const start = column.get(token.line) ?? 0;
3175
3279
  column.set(token.line, start + token.text.length);
3176
3280
  const entry = { ...token, glyphs: [] };
@@ -4184,6 +4288,144 @@ function highlightSweep(target, options = {}) {
4184
4288
  };
4185
4289
  }
4186
4290
 
4291
+ // src/stage/narration.ts
4292
+ var tokens2 = (text2) => text2.toLowerCase().replace(/[^a-z0-9.]+/g, " ").split(" ").map((token) => token.replace(/^\.+|\.+$/g, "")).filter(Boolean);
4293
+ function captionLines(text2, length = 74) {
4294
+ const lines = [];
4295
+ for (const sentence of text2.match(/[^.?!]+(?:[.?!]+(?=\s|$)|\.\d[^.?!]*[.?!]?|$)/g) ?? []) {
4296
+ let line2 = "";
4297
+ for (const word of sentence.split(/\s+/).filter(Boolean)) {
4298
+ if (line2 && line2.length + word.length + 1 > length) {
4299
+ lines.push(line2);
4300
+ line2 = word;
4301
+ } else {
4302
+ line2 = line2 ? `${line2} ${word}` : word;
4303
+ }
4304
+ }
4305
+ if (line2) lines.push(line2);
4306
+ }
4307
+ return lines;
4308
+ }
4309
+ var SceneClock = class {
4310
+ constructor(stage, id, start, end, beats) {
4311
+ this.stage = stage;
4312
+ this.id = id;
4313
+ this.start = start;
4314
+ this.end = end;
4315
+ this.beats = beats;
4316
+ }
4317
+ stage;
4318
+ id;
4319
+ start;
4320
+ end;
4321
+ beats;
4322
+ /** When the voice says a phrase. Pass a beat index to search one beat only. Throws if the phrase is not spoken. */
4323
+ cue(phrase, beat) {
4324
+ const want = tokens2(phrase);
4325
+ if (want.length === 0) throw new Error(`narration: scene "${this.id}": a cue needs at least one word`);
4326
+ if (beat !== void 0 && !this.beats[beat]) throw new Error(`narration: scene "${this.id}" has no beat ${beat}`);
4327
+ const list2 = beat === void 0 ? this.beats : [this.beats[beat]];
4328
+ for (const placed of list2) {
4329
+ const spoken = placed.words.flatMap((word) => tokens2(word.text).map((token) => ({ token, start: word.start, end: word.end })));
4330
+ for (let i = 0; i + want.length <= spoken.length; i++) {
4331
+ if (want.every((token, j) => spoken[i + j].token === token)) {
4332
+ return { start: placed.start + spoken[i].start, end: placed.start + spoken[i + want.length - 1].end };
4333
+ }
4334
+ }
4335
+ }
4336
+ const where = beat === void 0 ? "" : ` in beat ${beat}`;
4337
+ throw new Error(`narration: scene "${this.id}": the voice never says "${phrase}"${where}`);
4338
+ }
4339
+ /** Build when the voice starts a phrase. `offset` moves it, in seconds. */
4340
+ on(phrase, build, offset = 0, beat) {
4341
+ this.stage.at(Math.max(0, this.cue(phrase, beat).start + offset), build);
4342
+ return this;
4343
+ }
4344
+ /** Build when the voice finishes a phrase. */
4345
+ after(phrase, build, offset = 0, beat) {
4346
+ this.stage.at(Math.max(0, this.cue(phrase, beat).end + offset), build);
4347
+ return this;
4348
+ }
4349
+ /** Build when a beat starts. */
4350
+ onBeat(index, build, offset = 0) {
4351
+ const beat = this.beats[index];
4352
+ if (!beat) throw new Error(`narration: scene "${this.id}" has no beat ${index}`);
4353
+ this.stage.at(Math.max(0, beat.start + offset), build);
4354
+ return this;
4355
+ }
4356
+ /** Build at a time counted from the start of the scene. */
4357
+ at(seconds, build) {
4358
+ this.stage.at(Math.max(0, this.start + seconds), build);
4359
+ return this;
4360
+ }
4361
+ /** Fade nodes out just before the scene ends, so the next picture starts on a clean frame. */
4362
+ clear(nodes, lead = 0.24, duration = 0.26) {
4363
+ this.stage.at(this.end - lead, () => this.stage.play(...nodes.map((node) => fade(node, 0, { duration }))));
4364
+ return this;
4365
+ }
4366
+ };
4367
+ var Narration = class {
4368
+ scenes;
4369
+ /** The end of the last scene, in seconds. Hold the film at least this long, or the voice is cut. */
4370
+ duration;
4371
+ lead;
4372
+ gap;
4373
+ constructor(stage, timing, options = {}) {
4374
+ this.lead = options.lead ?? timing.lead ?? 0.6;
4375
+ this.gap = options.gap ?? timing.gap ?? 0.4;
4376
+ if (!(this.lead >= 0) || !(this.gap >= 0)) throw new Error("narration: lead and gap must be zero or more seconds");
4377
+ const seen = /* @__PURE__ */ new Set();
4378
+ const scenes = [];
4379
+ let now = this.lead;
4380
+ let last = now;
4381
+ for (const scene of timing.scenes) {
4382
+ if (seen.has(scene.id)) throw new Error(`narration: two scenes are named "${scene.id}"`);
4383
+ seen.add(scene.id);
4384
+ const start = now;
4385
+ const beats = [];
4386
+ for (const beat of scene.beats) {
4387
+ if (!(beat.duration > 0)) throw new Error(`narration: scene "${scene.id}" has a beat without a measured duration: "${beat.say}"`);
4388
+ const hold = beat.hold ?? 0;
4389
+ beats.push({ start: now, end: now + beat.duration, until: now + beat.duration + hold, text: beat.say, words: beat.words ?? [] });
4390
+ now += beat.duration + hold;
4391
+ }
4392
+ scenes.push(new SceneClock(stage, scene.id, start, now, beats));
4393
+ if (options.chapters !== false && scene.title) stage.chapters.push({ title: scene.title, time: scenes.length === 1 ? 0 : start });
4394
+ if (options.captions !== false) {
4395
+ for (const beat of beats) {
4396
+ const lines = captionLines(beat.text, options.captionLength);
4397
+ const total = lines.reduce((sum, line2) => sum + line2.length, 0);
4398
+ let t0 = beat.start;
4399
+ for (const line2 of lines) {
4400
+ const t1 = t0 + (beat.end - beat.start) * line2.length / total;
4401
+ stage.captions.push({ t0, t1, text: line2 });
4402
+ t0 = t1;
4403
+ }
4404
+ }
4405
+ }
4406
+ last = now;
4407
+ now += this.gap;
4408
+ }
4409
+ this.scenes = scenes;
4410
+ this.duration = last;
4411
+ stage.at(last, () => {
4412
+ });
4413
+ }
4414
+ /** The clock of one scene. */
4415
+ scene(id) {
4416
+ const found = this.scenes.find((scene) => scene.id === id);
4417
+ if (!found) throw new Error(`narration: no scene "${id}". The scenes are: ${this.scenes.map((scene) => scene.id).join(", ")}`);
4418
+ return found;
4419
+ }
4420
+ /** Where every beat's recording starts, in order, for the script that mixes the sound. */
4421
+ placements() {
4422
+ return this.scenes.flatMap((scene) => scene.beats.map((beat, index) => ({ scene: scene.id, beat: index, start: beat.start, end: beat.end })));
4423
+ }
4424
+ };
4425
+ function narration(stage, timing, options = {}) {
4426
+ return new Narration(stage, timing, options);
4427
+ }
4428
+
4187
4429
  // src/stage/three/index.ts
4188
4430
  var read3 = (value) => typeof value === "function" ? value() : value;
4189
4431
  var normalize = (v) => {
@@ -4863,6 +5105,7 @@ var Vector3D = class extends Line3D {
4863
5105
  from3;
4864
5106
  to3;
4865
5107
  tipSize;
5108
+ tipBias;
4866
5109
  constructor(from, to2, style = {}) {
4867
5110
  super(from, () => {
4868
5111
  const a = read3(from), b = read3(to2);
@@ -4873,6 +5116,7 @@ var Vector3D = class extends Line3D {
4873
5116
  this.from3 = from;
4874
5117
  this.to3 = to2;
4875
5118
  this.tipSize = style.tip ?? 24;
5119
+ this.tipBias = style.onTop ? ON_TOP : style.bias ?? 0;
4876
5120
  }
4877
5121
  emit(view) {
4878
5122
  super.emit(view);
@@ -4891,7 +5135,7 @@ var Vector3D = class extends Line3D {
4891
5135
  const rgb = solidOf(this.get("stroke"));
4892
5136
  const color = view.fogged(rgb[0], rgb[1], rgb[2], depth);
4893
5137
  const ring2 = polygonRing([bx, by, bx - ux * size - uy * half, by - uy * size + ux * half, bx - ux * size + uy * half, by - uy * size - ux * half]);
4894
- view.push(fillOp([ring2], color, alpha, null, 0, 0), depth + 0.01);
5138
+ view.push(fillOp([ring2], color, alpha, null, 0, 0), depth + 0.01 + this.tipBias);
4895
5139
  }
4896
5140
  };
4897
5141
  function vector3d(from, to2, style = {}) {
@@ -4914,7 +5158,7 @@ var Points3D = class extends Object3D {
4914
5158
  const trim = this.get("trimTo");
4915
5159
  const shown = Math.ceil(points.length * trim);
4916
5160
  const base = solidOf(this.get("fill"));
4917
- const bias = this.style.onTop ? ON_TOP : 0;
5161
+ const bias = this.style.onTop ? ON_TOP : this.style.bias ?? 0;
4918
5162
  for (let i = 0; i < shown; i++) {
4919
5163
  const point = points[i];
4920
5164
  if (!view.project(point[0], point[1], point[2])) continue;
@@ -4973,13 +5217,23 @@ var Trail3D = class extends Object3D {
4973
5217
  const fade2 = this.style.fade ?? (tail !== void 0 ? 0 : 1);
4974
5218
  const bias = this.style.onTop ? ON_TOP : this.style.bias ?? 0;
4975
5219
  const glow = (this.style.glow ?? 0) * view.scale;
4976
- const piece = Math.max(1, Math.ceil((i1 - i0) / 48));
4977
- for (let i = i0; i < i1; i += piece) {
5220
+ const moved = [];
5221
+ let last = null;
5222
+ for (let k = i0; k <= i1; k++) {
5223
+ const p = this.sample(k, rate);
5224
+ if (last && Math.abs(p[0] - last[0]) + Math.abs(p[1] - last[1]) + Math.abs(p[2] - last[2]) < 1e-9) continue;
5225
+ moved.push(p);
5226
+ last = p;
5227
+ }
5228
+ const span = moved.length - 1;
5229
+ if (span < 1) return;
5230
+ const piece = Math.max(1, Math.ceil(span / 48));
5231
+ for (let i = 0; i < span; i += piece) {
4978
5232
  const coords = [];
4979
5233
  let depth = 0;
4980
5234
  let scale = 0;
4981
- for (let k = i; k <= Math.min(i1, i + piece); k++) {
4982
- const p = this.sample(k, rate);
5235
+ for (let k = i; k <= Math.min(span, i + piece); k++) {
5236
+ const p = moved[k];
4983
5237
  if (!view.project(p[0], p[1], p[2])) continue;
4984
5238
  coords.push([view.px, view.py]);
4985
5239
  depth += view.pz;
@@ -4988,7 +5242,7 @@ var Trail3D = class extends Object3D {
4988
5242
  if (coords.length < 2) continue;
4989
5243
  depth /= coords.length;
4990
5244
  scale /= coords.length;
4991
- const fraction = (i + piece / 2 - i0) / (i1 - i0);
5245
+ const fraction = Math.min(1, (i + piece / 2) / span);
4992
5246
  const light = fade2 + (1 - fade2) * Math.pow(fraction, 1.6);
4993
5247
  const color = view.fogged(base[0], base[1], base[2], depth);
4994
5248
  view.push(strokeOp([chain(coords)], color, alpha * light, width * scale, glow, "butt"), depth + bias);
@@ -5187,6 +5441,7 @@ export {
5187
5441
  Line3D,
5188
5442
  LineChart,
5189
5443
  MatrixNode,
5444
+ Narration,
5190
5445
  NeuralNet,
5191
5446
  Node,
5192
5447
  NumberLine,
@@ -5196,6 +5451,7 @@ export {
5196
5451
  Points3D,
5197
5452
  Scatter,
5198
5453
  Scene3D,
5454
+ SceneClock,
5199
5455
  Stage,
5200
5456
  StreamLines,
5201
5457
  Surface3D,
@@ -5232,6 +5488,7 @@ export {
5232
5488
  buildOps,
5233
5489
  call,
5234
5490
  callout,
5491
+ captionLines,
5235
5492
  chalk,
5236
5493
  checkFilm,
5237
5494
  circle,
@@ -5291,6 +5548,7 @@ export {
5291
5548
  heatmap,
5292
5549
  highlightSweep,
5293
5550
  histogram,
5551
+ image,
5294
5552
  indicate,
5295
5553
  infoBox,
5296
5554
  invert,
@@ -5316,6 +5574,7 @@ export {
5316
5574
  morphMatching,
5317
5575
  moveTo,
5318
5576
  mul,
5577
+ narration,
5319
5578
  neon,
5320
5579
  neuralNet,
5321
5580
  notQuiteThere,
@@ -738,5 +738,5 @@ declare class SvgNode extends Node {
738
738
  */
739
739
  declare function fromSvg(source: string, options?: FromSvgOptions): SvgNode;
740
740
 
741
- export { bounce as $, IDENTITY as I, Stage as K, LOOKS as L, Node as N, Suspend as Q, SvgNode as S, along as U, appear as W, apply as X, applyMatrix as Y, arcPath as Z, blueprint as _, CompiledFilm as a, pathToD as a$, buildOps as a0, call as a1, chalk as a2, circlePath as a3, circumscribe as a4, along$1 as a5, compileFilm as a6, compose as a7, concat as a8, css as a9, indicate as aA, invert as aB, isFilm as aC, isSuspend as aD, lagged as aE, linePath as aF, linear as aG, linearGradient as aH, lingering as aI, matScale as aJ, midnight as aK, mixColor as aL, morph as aM, morphMatching as aN, moveTo as aO, mul as aP, neon as aQ, notQuiteThere as aR, overshoot as aS, paintFrame as aT, paper as aU, par as aV, parametricPath as aW, parseColor as aX, parseSvgPath as aY, pathBounds as aZ, pathLength as a_, cubicBezier as aa, curveThrough as ab, delay as ac, draw as ad, during as ae, dynamic as af, easeInCubic as ag, easeInExpo as ah, easeInOutCubic as ai, easeInOutQuint as aj, easeInQuad as ak, easeOutCubic as al, easeOutExpo as am, easeOutQuad as an, easeOutQuint as ao, erase as ap, fade as aq, fadeIn as ar, fadeOut as as, film as at, flash as au, frameInkBounds as av, frameToSvg as aw, fromSvg as ax, group as ay, grow as az, pointAt as b0, polyPath as b1, pulse as b2, radialGradient as b3, ramp as b4, recolor as b5, rectPath as b6, resolveLook as b7, retime as b8, reverseRing as b9, transformPath as bA, trimPath as bB, trimRing as bC, unionBounds as bD, vanish as bE, warp as bF, warpPath as bG, wiggle as bH, write as bI, ring as ba, ringCenter as bb, ringLength as bc, ripple as bd, rotate as be, runningStart as bf, rushFrom as bg, rushInto as bh, scaleBy as bi, segmentCount as bj, seq as bk, shake as bl, shift as bm, signedArea as bn, slowInto as bo, smooth as bp, smoothBy as bq, smoothPath as br, smoother as bs, spring as bt, subdivideEach as bu, tangentAt as bv, thereAndBack as bw, thereAndBackWithPause as bx, to as by, toPaint as bz, Value as f, EMPTY_BOUNDS as o };
742
- export type { AnimOptions as A, Bounds as B, CompileOverrides as C, DrawOp as D, Edge as E, FromSvgOptions as F, Gradient as G, PropName as H, Ring as J, Mat as M, StageImage as O, Path as P, Rgba as R, Target as T, Vec as V, FilmDefinition as b, ColorInput as c, Side as d, Anim as e, PathOp as g, AnimContext as h, Aspect as i, BlendMode as j, Canvas2D as k, Caption as l, Chapter as m, Clip as n, Ease as p, FadeOptions as q, FilmOptions as r, Frame as s, ImageOp as t, Look as u, LookName as v, LookToken as w, NodeProps as x, Paint as y, PlayOptions as z };
741
+ export { bounce as $, IDENTITY as I, LOOKS as L, Node as N, Suspend as Q, SvgNode as S, along as U, appear as W, apply as X, applyMatrix as Y, arcPath as Z, blueprint as _, CompiledFilm as a, pathToD as a$, buildOps as a0, call as a1, chalk as a2, circlePath as a3, circumscribe as a4, along$1 as a5, compileFilm as a6, compose as a7, concat as a8, css as a9, indicate as aA, invert as aB, isFilm as aC, isSuspend as aD, lagged as aE, linePath as aF, linear as aG, linearGradient as aH, lingering as aI, matScale as aJ, midnight as aK, mixColor as aL, morph as aM, morphMatching as aN, moveTo as aO, mul as aP, neon as aQ, notQuiteThere as aR, overshoot as aS, paintFrame as aT, paper as aU, par as aV, parametricPath as aW, parseColor as aX, parseSvgPath as aY, pathBounds as aZ, pathLength as a_, cubicBezier as aa, curveThrough as ab, delay as ac, draw as ad, during as ae, dynamic as af, easeInCubic as ag, easeInExpo as ah, easeInOutCubic as ai, easeInOutQuint as aj, easeInQuad as ak, easeOutCubic as al, easeOutExpo as am, easeOutQuad as an, easeOutQuint as ao, erase as ap, fade as aq, fadeIn as ar, fadeOut as as, film as at, flash as au, frameInkBounds as av, frameToSvg as aw, fromSvg as ax, group as ay, grow as az, pointAt as b0, polyPath as b1, pulse as b2, radialGradient as b3, ramp as b4, recolor as b5, rectPath as b6, resolveLook as b7, retime as b8, reverseRing as b9, transformPath as bA, trimPath as bB, trimRing as bC, unionBounds as bD, vanish as bE, warp as bF, warpPath as bG, wiggle as bH, write as bI, ring as ba, ringCenter as bb, ringLength as bc, ripple as bd, rotate as be, runningStart as bf, rushFrom as bg, rushInto as bh, scaleBy as bi, segmentCount as bj, seq as bk, shake as bl, shift as bm, signedArea as bn, slowInto as bo, smooth as bp, smoothBy as bq, smoothPath as br, smoother as bs, spring as bt, subdivideEach as bu, tangentAt as bv, thereAndBack as bw, thereAndBackWithPause as bx, to as by, toPaint as bz, Value as f, Stage as g, EMPTY_BOUNDS as p };
742
+ export type { AnimOptions as A, Bounds as B, CompileOverrides as C, DrawOp as D, Edge as E, FromSvgOptions as F, Gradient as G, PlayOptions as H, PropName as J, Ring as K, Mat as M, StageImage as O, Path as P, Rgba as R, Target as T, Vec as V, FilmDefinition as b, ColorInput as c, Side as d, Anim as e, PathOp as h, AnimContext as i, Aspect as j, BlendMode as k, Canvas2D as l, Caption as m, Chapter as n, Clip as o, Ease as q, FadeOptions as r, FilmOptions as s, Frame as t, ImageOp as u, Look as v, LookName as w, LookToken as x, NodeProps as y, Paint as z };
@@ -738,5 +738,5 @@ declare class SvgNode extends Node {
738
738
  */
739
739
  declare function fromSvg(source: string, options?: FromSvgOptions): SvgNode;
740
740
 
741
- export { bounce as $, IDENTITY as I, Stage as K, LOOKS as L, Node as N, Suspend as Q, SvgNode as S, along as U, appear as W, apply as X, applyMatrix as Y, arcPath as Z, blueprint as _, CompiledFilm as a, pathToD as a$, buildOps as a0, call as a1, chalk as a2, circlePath as a3, circumscribe as a4, along$1 as a5, compileFilm as a6, compose as a7, concat as a8, css as a9, indicate as aA, invert as aB, isFilm as aC, isSuspend as aD, lagged as aE, linePath as aF, linear as aG, linearGradient as aH, lingering as aI, matScale as aJ, midnight as aK, mixColor as aL, morph as aM, morphMatching as aN, moveTo as aO, mul as aP, neon as aQ, notQuiteThere as aR, overshoot as aS, paintFrame as aT, paper as aU, par as aV, parametricPath as aW, parseColor as aX, parseSvgPath as aY, pathBounds as aZ, pathLength as a_, cubicBezier as aa, curveThrough as ab, delay as ac, draw as ad, during as ae, dynamic as af, easeInCubic as ag, easeInExpo as ah, easeInOutCubic as ai, easeInOutQuint as aj, easeInQuad as ak, easeOutCubic as al, easeOutExpo as am, easeOutQuad as an, easeOutQuint as ao, erase as ap, fade as aq, fadeIn as ar, fadeOut as as, film as at, flash as au, frameInkBounds as av, frameToSvg as aw, fromSvg as ax, group as ay, grow as az, pointAt as b0, polyPath as b1, pulse as b2, radialGradient as b3, ramp as b4, recolor as b5, rectPath as b6, resolveLook as b7, retime as b8, reverseRing as b9, transformPath as bA, trimPath as bB, trimRing as bC, unionBounds as bD, vanish as bE, warp as bF, warpPath as bG, wiggle as bH, write as bI, ring as ba, ringCenter as bb, ringLength as bc, ripple as bd, rotate as be, runningStart as bf, rushFrom as bg, rushInto as bh, scaleBy as bi, segmentCount as bj, seq as bk, shake as bl, shift as bm, signedArea as bn, slowInto as bo, smooth as bp, smoothBy as bq, smoothPath as br, smoother as bs, spring as bt, subdivideEach as bu, tangentAt as bv, thereAndBack as bw, thereAndBackWithPause as bx, to as by, toPaint as bz, Value as f, EMPTY_BOUNDS as o };
742
- export type { AnimOptions as A, Bounds as B, CompileOverrides as C, DrawOp as D, Edge as E, FromSvgOptions as F, Gradient as G, PropName as H, Ring as J, Mat as M, StageImage as O, Path as P, Rgba as R, Target as T, Vec as V, FilmDefinition as b, ColorInput as c, Side as d, Anim as e, PathOp as g, AnimContext as h, Aspect as i, BlendMode as j, Canvas2D as k, Caption as l, Chapter as m, Clip as n, Ease as p, FadeOptions as q, FilmOptions as r, Frame as s, ImageOp as t, Look as u, LookName as v, LookToken as w, NodeProps as x, Paint as y, PlayOptions as z };
741
+ export { bounce as $, IDENTITY as I, LOOKS as L, Node as N, Suspend as Q, SvgNode as S, along as U, appear as W, apply as X, applyMatrix as Y, arcPath as Z, blueprint as _, CompiledFilm as a, pathToD as a$, buildOps as a0, call as a1, chalk as a2, circlePath as a3, circumscribe as a4, along$1 as a5, compileFilm as a6, compose as a7, concat as a8, css as a9, indicate as aA, invert as aB, isFilm as aC, isSuspend as aD, lagged as aE, linePath as aF, linear as aG, linearGradient as aH, lingering as aI, matScale as aJ, midnight as aK, mixColor as aL, morph as aM, morphMatching as aN, moveTo as aO, mul as aP, neon as aQ, notQuiteThere as aR, overshoot as aS, paintFrame as aT, paper as aU, par as aV, parametricPath as aW, parseColor as aX, parseSvgPath as aY, pathBounds as aZ, pathLength as a_, cubicBezier as aa, curveThrough as ab, delay as ac, draw as ad, during as ae, dynamic as af, easeInCubic as ag, easeInExpo as ah, easeInOutCubic as ai, easeInOutQuint as aj, easeInQuad as ak, easeOutCubic as al, easeOutExpo as am, easeOutQuad as an, easeOutQuint as ao, erase as ap, fade as aq, fadeIn as ar, fadeOut as as, film as at, flash as au, frameInkBounds as av, frameToSvg as aw, fromSvg as ax, group as ay, grow as az, pointAt as b0, polyPath as b1, pulse as b2, radialGradient as b3, ramp as b4, recolor as b5, rectPath as b6, resolveLook as b7, retime as b8, reverseRing as b9, transformPath as bA, trimPath as bB, trimRing as bC, unionBounds as bD, vanish as bE, warp as bF, warpPath as bG, wiggle as bH, write as bI, ring as ba, ringCenter as bb, ringLength as bc, ripple as bd, rotate as be, runningStart as bf, rushFrom as bg, rushInto as bh, scaleBy as bi, segmentCount as bj, seq as bk, shake as bl, shift as bm, signedArea as bn, slowInto as bo, smooth as bp, smoothBy as bq, smoothPath as br, smoother as bs, spring as bt, subdivideEach as bu, tangentAt as bv, thereAndBack as bw, thereAndBackWithPause as bx, to as by, toPaint as bz, Value as f, Stage as g, EMPTY_BOUNDS as p };
742
+ export type { AnimOptions as A, Bounds as B, CompileOverrides as C, DrawOp as D, Edge as E, FromSvgOptions as F, Gradient as G, PlayOptions as H, PropName as J, Ring as K, Mat as M, StageImage as O, Path as P, Rgba as R, Target as T, Vec as V, FilmDefinition as b, ColorInput as c, Side as d, Anim as e, PathOp as h, AnimContext as i, Aspect as j, BlendMode as k, Canvas2D as l, Caption as m, Chapter as n, Clip as o, Ease as q, FadeOptions as r, FilmOptions as s, Frame as t, ImageOp as u, Look as v, LookName as w, LookToken as x, NodeProps as y, Paint as z };
@@ -494,9 +494,33 @@ interface RgbaVideoOptions {
494
494
  tune?: string;
495
495
  crf?: number;
496
496
  threads?: number;
497
+ /** Title in the file's metadata. MP4 only. */
498
+ title?: string;
499
+ /** Chapter markers, in seconds from the start of the video. MP4 only. Players show them on the timeline. */
500
+ chapters?: readonly {
501
+ title: string;
502
+ time: number;
503
+ }[];
504
+ /** A caption track that the viewer can switch on, in seconds from the start of the video. MP4 only. */
505
+ captions?: readonly {
506
+ t0: number;
507
+ t1: number;
508
+ text: string;
509
+ }[];
497
510
  signal?: AbortSignal;
498
511
  onProgress?: (frame: VideoFrameInfo) => void | Promise<void>;
499
512
  }
513
+ /** FFmpeg metadata with a title and chapters. Each chapter ends where the next one starts. */
514
+ declare function chapterMetadata(title: string | undefined, chapters: readonly {
515
+ title: string;
516
+ time: number;
517
+ }[], duration: number): string;
518
+ /** Captions as SubRip text, clipped to the video. */
519
+ declare function captionsToSrt(captions: readonly {
520
+ t0: number;
521
+ t1: number;
522
+ text: string;
523
+ }[], duration: number): string;
500
524
  interface RgbaVideoOutput {
501
525
  width: number;
502
526
  height: number;
@@ -528,5 +552,5 @@ declare function renderAnimationVideo<S extends object>(animation: DefinedAnimat
528
552
  */
529
553
  declare function renderRgbaVideo(renderFrame: RgbaVideoFrameRenderer, options: RgbaVideoOptions): Promise<RgbaVideoOutput>;
530
554
 
531
- export { densityTokens as $, Watermark as K, analyzeAnimationCadence as P, assertDensity as Q, canvas as U, colors as X, compositeColor as Y, defineAnimation as Z, densityOf as _, getColor as a0, getGradient as a1, getReadableColor as a2, getReadableTextColor as a3, getReadableToneColor as a4, getStyles as a5, getThemeColors as a6, getToneColor as a7, getToneFill as a8, getToneGradient as a9, gradients as aa, hasShadow as ab, heatColor as ac, hold as ad, keyframe as ae, normalizeWatermark as af, parallel as ag, parseDensity as ah, renderAnimationVideo as ai, renderRgbaVideo as aj, sampleAnimation as ak, sampleAnimationFrame as al, sampleAnimationFrames as am, setDefaultDensity as an, setDensityResolver as ao, styles as ap, toneGradients as aq, tween as ar, typeOf as as, videoFrameSchedule as at, withColorAlpha as au, withDensity as av, wrapWithBrand as aw, wrapWithWatermark as ax, DEFAULT_DENSITY as q, DENSITY_NAMES as r, typography as t };
555
+ export { defineAnimation as $, Watermark as K, analyzeAnimationCadence as P, assertDensity as Q, canvas as U, captionsToSrt as X, chapterMetadata as Y, colors as Z, compositeColor as _, densityOf as a0, densityTokens as a1, getColor as a2, getGradient as a3, getReadableColor as a4, getReadableTextColor as a5, getReadableToneColor as a6, getStyles as a7, getThemeColors as a8, getToneColor as a9, getToneFill as aa, getToneGradient as ab, gradients as ac, hasShadow as ad, heatColor as ae, hold as af, keyframe as ag, normalizeWatermark as ah, parallel as ai, parseDensity as aj, renderAnimationVideo as ak, renderRgbaVideo as al, sampleAnimation as am, sampleAnimationFrame as an, sampleAnimationFrames as ao, setDefaultDensity as ap, setDensityResolver as aq, styles as ar, toneGradients as as, tween as at, typeOf as au, videoFrameSchedule as av, withColorAlpha as aw, withDensity as ax, wrapWithBrand as ay, wrapWithWatermark as az, DEFAULT_DENSITY as q, DENSITY_NAMES as r, typography as t };
532
556
  export type { AnimationCadenceAnalysis as A, RgbaVideoOptions as B, ColorName as C, Density as D, RgbaVideoOutput as E, SampledAnimationFrame as F, ThemeOptions as G, ThemePreset as H, TypographyVariant as I, VideoFrameInfo as J, WatermarkElementProps as L, WatermarkImageOptions as M, WatermarkOptions as N, WatermarkPosition as O, RenderBackground as R, SampleAnimationOptions as S, ThemeColors as T, VideoCodec as V, WatermarkInput as W, ToneName as a, ThemeMode as b, DefinedAnimation as c, AnimationDefinition as d, AnimationEasing as e, AnimationEasingName as f, AnimationFrameContext as g, AnimationHoldStep as h, AnimationInterpolator as i, AnimationKeyframeStep as j, AnimationParallelStep as k, AnimationParallelTracks as l, AnimationPropertyStep as m, AnimationTimelineStep as n, AnimationTweenStep as o, AnimationVideoOptions as p, DensityName as s, DensityRadiusScale as u, DensitySpaceScale as v, DensityStrokeScale as w, DensityTokens as x, DensityTypeScale as y, RgbaVideoFrameRenderer as z };
@@ -494,9 +494,33 @@ interface RgbaVideoOptions {
494
494
  tune?: string;
495
495
  crf?: number;
496
496
  threads?: number;
497
+ /** Title in the file's metadata. MP4 only. */
498
+ title?: string;
499
+ /** Chapter markers, in seconds from the start of the video. MP4 only. Players show them on the timeline. */
500
+ chapters?: readonly {
501
+ title: string;
502
+ time: number;
503
+ }[];
504
+ /** A caption track that the viewer can switch on, in seconds from the start of the video. MP4 only. */
505
+ captions?: readonly {
506
+ t0: number;
507
+ t1: number;
508
+ text: string;
509
+ }[];
497
510
  signal?: AbortSignal;
498
511
  onProgress?: (frame: VideoFrameInfo) => void | Promise<void>;
499
512
  }
513
+ /** FFmpeg metadata with a title and chapters. Each chapter ends where the next one starts. */
514
+ declare function chapterMetadata(title: string | undefined, chapters: readonly {
515
+ title: string;
516
+ time: number;
517
+ }[], duration: number): string;
518
+ /** Captions as SubRip text, clipped to the video. */
519
+ declare function captionsToSrt(captions: readonly {
520
+ t0: number;
521
+ t1: number;
522
+ text: string;
523
+ }[], duration: number): string;
500
524
  interface RgbaVideoOutput {
501
525
  width: number;
502
526
  height: number;
@@ -528,5 +552,5 @@ declare function renderAnimationVideo<S extends object>(animation: DefinedAnimat
528
552
  */
529
553
  declare function renderRgbaVideo(renderFrame: RgbaVideoFrameRenderer, options: RgbaVideoOptions): Promise<RgbaVideoOutput>;
530
554
 
531
- export { densityTokens as $, Watermark as K, analyzeAnimationCadence as P, assertDensity as Q, canvas as U, colors as X, compositeColor as Y, defineAnimation as Z, densityOf as _, getColor as a0, getGradient as a1, getReadableColor as a2, getReadableTextColor as a3, getReadableToneColor as a4, getStyles as a5, getThemeColors as a6, getToneColor as a7, getToneFill as a8, getToneGradient as a9, gradients as aa, hasShadow as ab, heatColor as ac, hold as ad, keyframe as ae, normalizeWatermark as af, parallel as ag, parseDensity as ah, renderAnimationVideo as ai, renderRgbaVideo as aj, sampleAnimation as ak, sampleAnimationFrame as al, sampleAnimationFrames as am, setDefaultDensity as an, setDensityResolver as ao, styles as ap, toneGradients as aq, tween as ar, typeOf as as, videoFrameSchedule as at, withColorAlpha as au, withDensity as av, wrapWithBrand as aw, wrapWithWatermark as ax, DEFAULT_DENSITY as q, DENSITY_NAMES as r, typography as t };
555
+ export { defineAnimation as $, Watermark as K, analyzeAnimationCadence as P, assertDensity as Q, canvas as U, captionsToSrt as X, chapterMetadata as Y, colors as Z, compositeColor as _, densityOf as a0, densityTokens as a1, getColor as a2, getGradient as a3, getReadableColor as a4, getReadableTextColor as a5, getReadableToneColor as a6, getStyles as a7, getThemeColors as a8, getToneColor as a9, getToneFill as aa, getToneGradient as ab, gradients as ac, hasShadow as ad, heatColor as ae, hold as af, keyframe as ag, normalizeWatermark as ah, parallel as ai, parseDensity as aj, renderAnimationVideo as ak, renderRgbaVideo as al, sampleAnimation as am, sampleAnimationFrame as an, sampleAnimationFrames as ao, setDefaultDensity as ap, setDensityResolver as aq, styles as ar, toneGradients as as, tween as at, typeOf as au, videoFrameSchedule as av, withColorAlpha as aw, withDensity as ax, wrapWithBrand as ay, wrapWithWatermark as az, DEFAULT_DENSITY as q, DENSITY_NAMES as r, typography as t };
532
556
  export type { AnimationCadenceAnalysis as A, RgbaVideoOptions as B, ColorName as C, Density as D, RgbaVideoOutput as E, SampledAnimationFrame as F, ThemeOptions as G, ThemePreset as H, TypographyVariant as I, VideoFrameInfo as J, WatermarkElementProps as L, WatermarkImageOptions as M, WatermarkOptions as N, WatermarkPosition as O, RenderBackground as R, SampleAnimationOptions as S, ThemeColors as T, VideoCodec as V, WatermarkInput as W, ToneName as a, ThemeMode as b, DefinedAnimation as c, AnimationDefinition as d, AnimationEasing as e, AnimationEasingName as f, AnimationFrameContext as g, AnimationHoldStep as h, AnimationInterpolator as i, AnimationKeyframeStep as j, AnimationParallelStep as k, AnimationParallelTracks as l, AnimationPropertyStep as m, AnimationTimelineStep as n, AnimationTweenStep as o, AnimationVideoOptions as p, DensityName as s, DensityRadiusScale as u, DensitySpaceScale as v, DensityStrokeScale as w, DensityTokens as x, DensityTypeScale as y, RgbaVideoFrameRenderer as z };
@@ -1,6 +1,6 @@
1
- import { createTeachingCategoricalSampling, categoricalSampling } from '../../src/teaching-categorical-sampling'
2
- import type { TeachingPainter } from '../../src/teaching-canvas'
3
- import type { CanvasBounds } from '../../src/canvas-components'
1
+ import { createTeachingCategoricalSampling, categoricalSampling } from 'vizmatic'
2
+ import type { TeachingPainter } from 'vizmatic'
3
+ import type { CanvasBounds } from 'vizmatic'
4
4
 
5
5
  /** Supplied deterministic draws illustrate one possible sample, not a randomly executed experiment. */
6
6
  export const tailLossFixture = {
@@ -1,13 +1,13 @@
1
1
  import { createHash } from 'node:crypto'
2
2
  import { pathToFileURL } from 'node:url'
3
- import { createTeachingByteDifference } from '../../src/teaching-byte-diff'
4
- import type { CanvasBounds, CanvasPainter } from '../../src/canvas-components'
3
+ import { createTeachingByteDifference } from 'vizmatic'
4
+ import type { CanvasBounds, CanvasPainter } from 'vizmatic'
5
5
 
6
6
  const xml = (value: string) => value.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('"', '&quot;')
7
7
  const bytes = (value: string) => new TextEncoder().encode(value)
8
8
  const digest = (value: Uint8Array) => createHash('sha256').update(value).digest('hex').slice(0, 12)
9
9
 
10
- /** Run: pnpm exec tsx examples/teaching-byte-diff.ts [--reveal] > /tmp/byte-diff.svg */
10
+ /** Run: npx tsx examples/_teaching/teaching-byte-diff.ts [--reveal] > /tmp/byte-diff.svg */
11
11
  export function renderByteDifferenceExample(revealVerdict = false, scanProgress = 1): string {
12
12
  const content: string[] = []
13
13
  const painter: CanvasPainter<CanvasBounds> = {
@@ -1,6 +1,6 @@
1
- import type { CanvasBounds } from '../../src/canvas-components'
2
- import type { TeachingPainter } from '../../src/teaching-canvas'
3
- import { createTeachingRoutedTransfer } from '../../src/teaching-routed-transfer'
1
+ import type { CanvasBounds } from 'vizmatic'
2
+ import type { TeachingPainter } from 'vizmatic'
3
+ import { createTeachingRoutedTransfer } from 'vizmatic'
4
4
 
5
5
  /** A new parameter copy passes around three completed rank replicas. */
6
6
  export function drawRoutedParameterBroadcast<Shape extends CanvasBounds>(painter: TeachingPainter<Shape>, progress: number) {
@@ -1,5 +1,5 @@
1
- import type { CanvasPainter } from '../../src/canvas-components'
2
- import { createTeachingTokenHistory, type TokenHistoryPhase } from '../../src/teaching-token-history'
1
+ import type { CanvasPainter } from 'vizmatic'
2
+ import { createTeachingTokenHistory, type TokenHistoryPhase } from 'vizmatic'
3
3
 
4
4
  // Vocabulary IDs can repeat; these IDs identify their immutable occurrences.
5
5
  const prompt = [101, 102, 103].map((token, i) => ({ id: `prompt-${i}`, token }))
@@ -1,6 +1,6 @@
1
- import { createTeachingCanvas, type TeachingPainter } from '../../src/teaching-canvas'
2
- import { createTeachingVectorAccumulation, type WeightedVectorTerm } from '../../src/teaching-vector'
3
- import type { CanvasBounds } from '../../src/canvas-components'
1
+ import { createTeachingCanvas, type TeachingPainter } from 'vizmatic'
2
+ import { createTeachingVectorAccumulation, type WeightedVectorTerm } from 'vizmatic'
3
+ import type { CanvasBounds } from 'vizmatic'
4
4
 
5
5
  // A supplied two-coordinate EMA example, with beta=0.75.
6
6
  const terms: readonly WeightedVectorTerm[] = [
@@ -4,7 +4,7 @@
4
4
  * Q K^T, scaling by sqrt(d), softmax per row, and the weighted sum of values.
5
5
  */
6
6
  import {
7
- Node, dynamic, fade, fadeIn, fadeOut, film, line, linear, morphMatching, parseColor, parseSvgPath, rect, smoother, text, tex, to, write, mixColor,
7
+ Node, dynamic, fade, fadeIn, fadeOut, film, line, linear, morphMatching, parseColor, parseSvgPath, rect, seq, smoother, text, tex, to, write, mixColor,
8
8
  type Rgba,
9
9
  } from 'vizmatic/stage'
10
10
 
@@ -256,12 +256,13 @@ export default film({
256
256
  s.wait(0.6)
257
257
 
258
258
  s.chapter('Scale')
259
- s.play(morphMatching(eq0, eq1), fadeOut(note0), fadeIn(note1), { duration: 1.3 })
259
+ // One note leaves before the next arrives, so two sentences never share the same lines.
260
+ s.play(morphMatching(eq0, eq1), seq(fadeOut(note0), fadeIn(note1)), { duration: 1.3 })
260
261
  s.play(scaled.to(1, { ease: smoother }), { duration: 1.8 })
261
262
  s.wait(0.8)
262
263
 
263
264
  s.chapter('Softmax')
264
- s.play(morphMatching(eq1, eq2), fadeOut(note1), fadeIn(note2), { duration: 1.3 })
265
+ s.play(morphMatching(eq1, eq2), seq(fadeOut(note1), fadeIn(note2)), { duration: 1.3 })
265
266
  s.add(sums, shares)
266
267
  s.play(soft.to(1, { ease: smoother }), fadeIn(shareLabel), focus.to(1), { duration: 2.6 })
267
268
  s.wait(0.6)
@@ -270,7 +271,7 @@ export default film({
270
271
  s.wait(1.2)
271
272
 
272
273
  s.chapter('Values')
273
- s.play(morphMatching(eq2, eq3), fadeOut(note2), fadeIn(note3), fadeIn(vStrips, { lag: 0.01 }), fadeIn(vTag), { duration: 1.5 })
274
+ s.play(morphMatching(eq2, eq3), seq(fadeOut(note2), fadeIn(note3)), fadeIn(vStrips, { lag: 0.01 }), fadeIn(vTag), { duration: 1.5 })
274
275
  s.add(output)
275
276
  s.play(flow.to(1, { ease: linear }), fadeIn(outTag), { duration: 3.2 })
276
277
  s.play(fadeIn(caveat), { duration: 0.8 })
@@ -267,9 +267,12 @@ export default film({
267
267
  camera.at((tx + 240 / z) * a, (ty) * a)
268
268
  camera.set('sx', z)
269
269
  })
270
- s.play(fade(title, 0), fade(target, 0), follow.to(1, { ease: smoother }), zoom.to(9, { ease: smoother }), phase.to(phase.value + 0.06, { ease: linear }), { duration: 3 })
270
+ // The title leaves before the zoom carries the curve through it, and returns when the curve is back in place.
271
+ s.at(s.time, () => s.play(fade(title, 0), { duration: 0.3 }))
272
+ s.play(fade(target, 0), follow.to(1, { ease: smoother }), zoom.to(9, { ease: smoother }), phase.to(phase.value + 0.06, { ease: linear }), { duration: 3 })
271
273
  s.play(phase.to(phase.value + 0.14, { ease: linear }), { duration: 6 })
272
- s.play(fade(title, 1), follow.to(0, { ease: smoother }), zoom.to(1, { ease: smoother }), phase.to(phase.value + 0.08, { ease: linear }), { duration: 3 })
274
+ s.at(s.time + 2.6, () => s.play(fade(title, 1), { duration: 0.4 }))
275
+ s.play(follow.to(0, { ease: smoother }), zoom.to(1, { ease: smoother }), phase.to(phase.value + 0.08, { ease: linear }), { duration: 3 })
273
276
 
274
277
  s.chapter('The whole curve')
275
278
  s.play(phase.to(phase.value + 1, { ease: linear }), { duration: 4.6 })