summaryrefslogtreecommitdiff
path: root/anim/scenes
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-11 17:42:07 -0300
committerGabriel Schneider <[email protected]>2026-11-11 19:11:00 -0300
commitb54c6776953d3243ab5b8e676e747713827ab320 (patch)
treed53be6cef4587b94531880af6479a1b5fa1aac39 /anim/scenes
parent3093eb55ac4a7054f51f06ea2786b5f9c9ec73f6 (diff)
downloadcomputeranim-b54c6776953d3243ab5b8e676e747713827ab320.tar.gz
computeranim-b54c6776953d3243ab5b8e676e747713827ab320.zip
canim: the disassembly under the source everywhere; rings
From the user. In every split the disassembly stays under the source; registers a scene never changes fold three to a row, and the stack takes the room: nine to twenty slots where it had six. The graph's first form is rings: a loop a ring its blocks sit on, an inner loop a smaller ring touching its parent, a way out leaving along the tangent; layers stay for functions without loops. Its layout comes from the code alone and it shows nothing from after the moment: a block not reached yet is quiet and is reached, a fold of what is not reached yet opens when the run arrives. A pane unrolls from its strip into its whole column and rolls back. The sqlite scene's strips move before their panes. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
Diffstat (limited to 'anim/scenes')
-rw-r--r--anim/scenes/fib.zig2
-rw-r--r--anim/scenes/gallery.zig109
-rw-r--r--anim/scenes/heap.zig2
-rw-r--r--anim/scenes/list.zig2
-rw-r--r--anim/scenes/sort.zig39
-rw-r--r--anim/scenes/sqlite.zig10
6 files changed, 94 insertions, 70 deletions
diff --git a/anim/scenes/fib.zig b/anim/scenes/fib.zig
index 7e5380c..5f958dd 100644
--- a/anim/scenes/fib.zig
+++ b/anim/scenes/fib.zig
@@ -27,7 +27,7 @@ fn frame(s: *anim.Frame) void {
const split = canim.layout.split.subject;
// From main's line, about to call fib(5), to where fib(5) has returned to it.
var at = canim.cursor(s, rec, rec.lineMoment(10, rec.call("main", 0).enter));
- at.levels = .{ .idea = .calls, .source_rows = 10 };
+ at.levels = .{ .idea = .calls, .source_rows = 8 };
at.journey(.line, call(rec, 0).exit.?);
const ctx = canim.context(s, at, .{ .split = split });
// The lens: every call of fib as a tree, beside the frames they are on the stack.
diff --git a/anim/scenes/gallery.zig b/anim/scenes/gallery.zig
index f8964bd..17d38ed 100644
--- a/anim/scenes/gallery.zig
+++ b/anim/scenes/gallery.zig
@@ -10,11 +10,11 @@
//! 3.6 s a step, mid-way: struck, read, projection, echo (mock 10)
//! 6 s `subject` (mock 11); 8 s `none`, with the backtrace
//! 10.8 s two loupes in depth, from rax and its node's `next` (mock 21)
-//! 21 s the `blocks` lens: at rest (blocks reached and not yet, the trail,
-//! an edge never taken), `leave` mid-way, `turn` landing, folds
-//! 24 s the graph with its rows, as the map draws it (here at half size):
-//! sort's (panned to its loop, the pc's block annotated) and libc's
-//! `open` at its syscall (the blocks not reached folded)
+//! 21 s the `blocks` lens in its two forms: sort in rings at rest (blocks
+//! reached and not yet, the trail, the turns), `leave` round the
+//! ring mid-way, `turn` just struck; libc's `open` in layers, folded
+//! 24 s a first time: `reach` (sort's first swap) landing, `unfold` (open
+//! past its syscall) making room; sort in layers; the unfold at rest
const std = @import("std");
const sk = @import("sketch");
const anim = @import("anim");
@@ -317,33 +317,23 @@ const GraphPages = struct {
pub fn draw(_: *const GraphPages, f: *sk.Frame, at: anim.Placed) void {
const u: ui.Ui = .{ .f = f, .at = at };
+ const spots = [_][2]f32{ .{ 64, 72 }, .{ 976, 72 }, .{ 64, 488 }, .{ 976, 488 } };
if (at.t >= 21 and at.t < 24) {
- title(u, 64, 40, "graph: the blocks lens");
- for ([_][2]f32{ .{ 64, 72 }, .{ 976, 72 }, .{ 64, 488 }, .{ 976, 488 } }, [_][]const u8{ "at rest: reached, not yet, the trail, not taken so far", "leave: the edge drawn gold, the mark on it", "turn: landed, the lane's count and the header's struck", "folds: libc's open, the blocks not reached" }) |p, words| note(u, p[0], p[1], words);
+ title(u, 64, 40, "graph: the blocks lens, its two forms");
+ for (spots, [_][]const u8{ "rings: sort at rest, reached and not yet, the trail, the turns", "leave: the edge drawn gold, the mark round the ring", "turn: landed, the ring's count struck", "layers: libc's open at its syscall, what it has not reached folded" }) |p, words| note(u, p[0], p[1], words);
} else if (at.t >= 24 and at.t < 27) {
- title(u, 64, 40, "graph: with its rows, as on the map (half size)");
+ title(u, 64, 40, "graph: a first time, reach and unfold");
+ for (spots, [_][]const u8{ "reach: the first swap, its pill filling as the mark lands", "unfold: open past its syscall, the way back from the kernel opening", "layers: sort, panned to the pc", "unfold, at rest: the fold open, the pane panned" }) |p, words| note(u, p[0], p[1], words);
}
}
};
-/// A component drawn at half its size (the map's rows as the map shows them filling a 1080p frame).
-fn Half(comptime T: type) type {
- return struct {
- inner: T,
- box: canim.Rect = .{ .x = 0, .y = 0, .w = 1920, .h = 1080 },
-
- pub fn draw(h: *const @This(), f: *sk.Frame, at: anim.Placed) void {
- var p = at;
- p.xf = p.xf.mul(.scale(0.5, 0.5));
- p.scale *= 0.5;
- h.inner.draw(f, p);
- }
- };
-}
-
-/// The graph pages: sort's blocks in the lens, at rest and in `leave` and
-/// `turn`, and libc's `open` folded; then the map's form of both.
-fn graphPages(s: *anim.Frame, at_time: f32) [3]anim.Obj {
+/// The graph pages, each four panes of the `blocks` lens (880 by 344): at
+/// 21 s sort in rings at rest, a `leave` round the ring mid-way, a `turn`
+/// just landed, libc's `open` in layers, folded; at 24 s a `reach` (the
+/// first swap) and an `unfold` (open past its syscall) caught in their
+/// moves, sort in layers, and the unfold at rest.
+fn graphPages(s: *anim.Frame) [9]anim.Obj {
const graph = canim.graph;
const sort = canim.open(recordings.gallery_sort);
const hello = canim.open(recordings.gallery_hello);
@@ -363,47 +353,64 @@ fn graphPages(s: *anim.Frame, at_time: f32) [3]anim.Obj {
break;
};
const place = struct {
- fn stage(s_: *anim.Frame, band: canim.Rect, disasm: canim.Rect) *canim.Stage {
+ fn stage(s_: *anim.Frame, band: canim.Rect) *canim.Stage {
var split = canim.layout.split.blocks;
split.band = band;
- split.disasm = disasm;
return canim.Stage.init(s_, split);
}
}.stage;
- const nowhere: canim.Rect = .{ .x = 0, .y = 0, .w = 0, .h = 0 };
+ const at = [_]canim.Rect{ .{ .x = 64, .y = 84, .w = 880, .h = 344 }, .{ .x = 976, .y = 84, .w = 880, .h = 344 }, .{ .x = 64, .y = 500, .w = 880, .h = 344 }, .{ .x = 976, .y = 500, .w = 880, .h = 344 } };
const rest = canim.cursor(s, sort, start);
- const leaving = canim.cursor(s, sort, jne);
+ // The scene's first leave: the inner test's `jle` not taken, round the ring's top to the compare.
+ const leaving = canim.cursor(s, sort, graph.blockEnd(sort, start));
const turning = canim.cursor(s, sort, back);
const open_at = canim.cursor(s, hello, syscall_at);
- const lenses = .{
- canim.add(s, graph.Blocks{ .cursor = rest, .stage = place(s, .{ .x = 64, .y = 84, .w = 880, .h = 296 }, nowhere) }),
- canim.add(s, graph.Blocks{ .cursor = leaving, .stage = place(s, .{ .x = 976, .y = 84, .w = 880, .h = 296 }, nowhere) }),
- canim.add(s, graph.Blocks{ .cursor = turning, .stage = place(s, .{ .x = 64, .y = 500, .w = 880, .h = 296 }, nowhere) }),
- canim.add(s, graph.Blocks{ .cursor = open_at, .stage = place(s, .{ .x = 976, .y = 500, .w = 880, .h = 296 }, nowhere) }),
+ const reaching = canim.cursor(s, sort, jne);
+ // Open from its syscall: the fold of the way back from the kernel opens as the run gets there.
+ const unfolding = canim.cursor(s, hello, syscall_at);
+ const unfolded = canim.cursor(s, hello, syscall_at);
+ const first = .{
+ canim.add(s, graph.Blocks{ .cursor = rest, .stage = place(s, at[0]) }),
+ canim.add(s, graph.Blocks{ .cursor = leaving, .stage = place(s, at[1]) }),
+ canim.add(s, graph.Blocks{ .cursor = turning, .stage = place(s, at[2]) }),
+ canim.add(s, graph.Blocks{ .cursor = open_at, .stage = place(s, at[3]) }),
+ };
+ const second = .{
+ canim.add(s, graph.Blocks{ .cursor = reaching, .stage = place(s, at[0]) }),
+ canim.add(s, graph.Blocks{ .cursor = unfolding, .stage = place(s, at[1]) }),
+ canim.add(s, graph.Blocks{ .cursor = rest, .stage = place(s, at[2]), .form = .layers }),
+ canim.add(s, graph.Blocks{ .cursor = unfolded, .stage = place(s, at[3]) }),
};
- // Each step played so that the page shows it at `at_time`: the leave with its mark mid-way, the turn just landed.
+ // Each step played so that its page shows it mid-move: the leave with its
+ // mark half-way, the turn just struck; the reach landed and filling, the
+ // unfold making room.
const l = canim.theme.time.leave;
- s.cursor = at_time - l.sets_off - l.mark / 2.0 - 0.05;
+ s.cursor = 0;
+ unfolding.jump(s, graph.blockEnd(hello, syscall_at));
+ unfolded.jump(s, graph.blockEnd(hello, syscall_at));
+ s.cursor = 21.8 - l.sets_off - 0.11;
graph.leave(leaving, s);
- s.cursor = at_time - l.sets_off - 0.30 - l.count;
+ s.cursor = 21.8 - l.sets_off - 0.22 - 0.12;
graph.leave(turning, s);
- // The map's form, at half size: the map's units, two columns wide each.
- const maps = .{
- canim.add(s, Half(graph.Map){ .inner = .{ .cursor = canim.cursor(s, sort, jne), .stage = place(s, nowhere, .{ .x = 128, .y = 176, .w = 1792, .h = 1688 }) } }),
- canim.add(s, Half(graph.Map){ .inner = .{ .cursor = canim.cursor(s, hello, syscall_at), .stage = place(s, nowhere, .{ .x = 1952, .y = 176, .w = 1792, .h = 1688 }) } }),
- };
+ s.cursor = 25.5 - l.sets_off - 0.24 - 0.10;
+ graph.leave(reaching, s);
+ s.cursor = 25.5 - l.sets_off - 0.18;
+ graph.leave(unfolding, s);
+ s.cursor = 23;
+ graph.leave(unfolded, s);
const pages = canim.add(s, GraphPages{});
- var all: [lenses.len]anim.Animation = undefined;
- inline for (lenses, 0..) |o, i| all[i] = o.fadeIn();
+ var all: [first.len]anim.Animation = undefined;
s.cursor = 21;
s.play(.{pages.fadeIn()}, .{ .seconds = 0 });
+ inline for (first, 0..) |o, i| all[i] = o.fadeIn();
s.play(all, .{ .seconds = 0 });
s.cursor = 24;
- inline for (lenses, 0..) |o, i| all[i] = o.fadeOut();
+ inline for (first, 0..) |o, i| all[i] = o.fadeOut();
+ s.play(all, .{ .seconds = 0 });
+ inline for (second, 0..) |o, i| all[i] = o.fadeIn();
s.play(all, .{ .seconds = 0 });
- s.play(.{ maps[0].fadeIn(), maps[1].fadeIn() }, .{ .seconds = 0 });
s.cursor = 27;
- return .{ pages, maps[0], maps[1] };
+ return .{ pages, first[0], first[1], first[2], first[3], second[0], second[1], second[2], second[3] };
}
fn frame(s: *anim.Frame) void {
@@ -414,7 +421,9 @@ fn frame(s: *anim.Frame) void {
const pages = canim.add(s, Pages{ .rec = rec, .moment = rest });
s.play(.{pages.fadeIn()}, .{ .seconds = 0 });
- const at = canim.cursor(s, rec, rest);
+ var at = canim.cursor(s, rec, rest);
+ // Its way, the one step it takes: the registers that step does not change are folded.
+ at.journey(.line, rec.next(.line, rest));
const ctx = canim.context(s, at, .{ .split = canim.layout.split.beside, .quiet = true });
const list = canim.nodes(s, .{ .cursor = at, .stage = ctx.stage, .root = "head", .track = &.{ "prev", "cur", "next" }, .quiet = true });
ctx.map.add(s, canim.Nodes{ .cursor = at, .stage = ctx.map.stage, .root = "head", .track = &.{ "prev", "cur", "next" }, .quiet = true });
@@ -448,5 +457,5 @@ fn frame(s: *anim.Frame) void {
// The graph's pages: the context stands aside.
inline for (panels, 0..) |o, i| all[i] = o.fadeOut();
s.play(all, .{ .seconds = 0 });
- _ = graphPages(s, 21.8);
+ _ = graphPages(s);
}
diff --git a/anim/scenes/heap.zig b/anim/scenes/heap.zig
index 1f82766..d42da12 100644
--- a/anim/scenes/heap.zig
+++ b/anim/scenes/heap.zig
@@ -423,7 +423,7 @@ fn frame(s: *anim.Frame) void {
// From main's first line, `push(7)`.
var at = canim.cursor(s, rec, rec.lineMoment(24, main.enter));
at.journey(.line, rec.lineMoment(30, main.enter));
- at.levels = .{ .idea = .data, .source_rows = 10 };
+ at.levels = .{ .idea = .data, .source_rows = 8 };
const ctx = canim.context(s, at, .{ .split = canim.layout.split.subject });
// `head`, the program's global: where line 13 (`n->next = head;`) reads it, `[rip + X]`.
const head_at = globalOf(rec, lineIn(rec, "push", 0, 13));
diff --git a/anim/scenes/list.zig b/anim/scenes/list.zig
index 71cdf53..d3d53ed 100644
--- a/anim/scenes/list.zig
+++ b/anim/scenes/list.zig
@@ -27,7 +27,7 @@ fn frame(s: *anim.Frame) void {
// From reverse's first line (the list of three is built) to its last.
var at = canim.cursor(s, rec, rec.lineMoment(18, reverse.enter));
// The nodes are the idea; a tag slides and an arrow grows after its strike.
- at.levels = .{ .idea = .data, .follow = t.move, .source_rows = 10 };
+ at.levels = .{ .idea = .data, .follow = t.move, .source_rows = 8 };
const end = rec.lineMoment(27, reverse.enter);
at.journey(.line, end);
// The idea is the subject: the lens a size up, the nodes over the bytes they are.
diff --git a/anim/scenes/sort.zig b/anim/scenes/sort.zig
index 81d55dd..454c3ad 100644
--- a/anim/scenes/sort.zig
+++ b/anim/scenes/sort.zig
@@ -1,16 +1,19 @@
-//! Insertion sort as its blocks: the graph of `sort` in the band (the
-//! `blocks` lens), the disassembly its view over the state column, the
-//! source alone in the program column; on the map the same graph with its
-//! rows.
+//! Insertion sort as its blocks: the graph of `sort` as rings over the
+//! program column (the `blocks` lens: the outer loop's ring, the inner's
+//! touching it at its header), the source and the disassembly under it,
+//! the registers and a stack of twenty beside; on the map the same
+//! drawing over the source, the disassembly linear beside it.
//!
//! How it moves (design/motion.md, "A block left"): it opens where `i` has
-//! reached 12, the first value out of order. One trip round the inner
-//! loop is walked a block at a time: each block's instructions a cascade
-//! onto its last row, then `leave` along the edge that row takes (the
-//! compare's chips framed, the edge drawn gold, the mark along it, the
-//! target's count struck), and `turn` up the inner loop's lane. The next
-//! trip is a run; the long middle is a sprint on the map (`surface`, the
-//! gold going block to block, `dive`); the last value's trip is walked
+//! reached 12, the first value out of order, the swap's block not reached
+//! yet. One trip round the inner loop is walked a block at a time: each block's
+//! instructions a cascade onto its last row, then `leave` along the edge
+//! that row takes (the compare's chips framed, the edge drawn gold, the
+//! mark along it, the target's count struck): the swap's first `reach`,
+//! then the inner ring's first `turn`; the disassembly unrolls for a beat,
+//! the function whole. The next trip is a run; the long
+//! middle a sprint on the map (`surface`, the gold going round the rings
+//! and down the linear column, `dive`); the last value's trip is walked
//! again, and the way out run.
const anim = @import("anim");
const canim = @import("canim");
@@ -29,7 +32,7 @@ fn frame(s: *anim.Frame) void {
// The inner loop's test (`j > 0`): where each of its trips begins.
const test_pc = rec.register(start, "rip");
var at = canim.cursor(s, rec, start);
- at.levels = .{ .fire = .disasm, .source_rows = 20 };
+ at.levels = .{ .fire = .disasm, .source_rows = 6 };
const last = rec.call("swap", 9);
// The last value's trip: from its test, before the compare that leads to the last swap.
var last_trip = last.enter;
@@ -48,13 +51,19 @@ fn frame(s: *anim.Frame) void {
}.walk;
canim.establish(s, .{ ctx.clock, ctx.registers, ctx.stack, ctx.source, ctx.disasm, blocks, joins });
- says.line(s, "`sort` as its blocks: two loops. `j > 0`, so its `jle`\nis not taken, and the inner loop goes on to its compare.");
+ says.line(s, "`sort` as its blocks: each loop a ring, the inner touching\nthe outer. `j > 0`, so `jle` goes on to the compare.");
block(at, s);
- says.line(s, "31 > 12: `setg` leaves 1, and `jne` takes the swap.");
+ says.line(s, "31 > 12: `setg` leaves 1, and `jne` takes the swap,\nthe first time it is reached.");
block(at, s);
block(at, s);
- says.line(s, "The swap and `j--`; then the inner loop turns,\nback up to `j > 0`.");
+ says.line(s, "The swap and `j--`; then the inner loop turns,\nback up to `j > 0`: its first turn.");
block(at, s);
+ // The whole function for a beat: the disassembly unrolled, each block's first row ruled with its visits.
+ says.line(s, "The function whole: each block under a rule, with its visits.");
+ ctx.map.unroll(s, .disasm);
+ // Held while the caption is read: rolled back in as its reading time ends.
+ s.wait(@max(says.read_by - s.cursor - t.unroll.roll - t.unroll.veil, t.unroll.hold));
+ ctx.map.roll(s);
// Pacing: the next trip at a run; then the long middle on the map, at a sprint.
says.line(s, "Once more at a run: 17 > 12, a second swap.");
diff --git a/anim/scenes/sqlite.zig b/anim/scenes/sqlite.zig
index e19a7be..36630bd 100644
--- a/anim/scenes/sqlite.zig
+++ b/anim/scenes/sqlite.zig
@@ -103,7 +103,7 @@ fn frame(s: *anim.Frame) void {
const start = stopAt(rec, "sqlite3_step+", first);
var at = canim.cursor(s, rec, start);
- at.levels = .{ .source_rows = 10 };
+ at.levels = .{ .source_rows = 8 };
at.journey(.moment, back);
// The lens is the subject: the backtrace, eleven rows, over the
// program column (where the kernel's side comes later), and over the
@@ -213,7 +213,13 @@ fn frame(s: *anim.Frame) void {
fade.in(s, kernel);
s.wait(t.beat);
const crossing = canim.syscalls.Plan.of(write);
- at.step(s, back, crossing.step(), crossing.total);
+ // Back in `unixWrite`, 44 lines up from the call it waited on (more
+ // than the map's column of sqlite3.c holds round it): the panes fade
+ // through (24 f each way), the strips going over first.
+ var coming_back = crossing.step();
+ coming_back.travel = 2 * t.move;
+ coming_back.total += coming_back.travel - t.step;
+ at.step(s, back, coming_back, coming_back.total);
// Each field as the caption reaches it, 2 s apart: the picture is never still longer.
says.line(s, "Page 2 as the kernel took it: `0d`, a table's leaf; 3 cells,\nat `0ff7 0fef 0fe6`: each a row at the page's end.");