summaryrefslogtreecommitdiff
path: root/anim/scenes/list.zig
diff options
context:
space:
mode:
Diffstat (limited to 'anim/scenes/list.zig')
-rw-r--r--anim/scenes/list.zig30
1 files changed, 19 insertions, 11 deletions
diff --git a/anim/scenes/list.zig b/anim/scenes/list.zig
index 53df4d5..d6f1a76 100644
--- a/anim/scenes/list.zig
+++ b/anim/scenes/list.zig
@@ -15,8 +15,8 @@ const recordings = @import("recordings");
pub const background = canim.background;
pub const scene = anim.Live(frame, struct {});
-/// Each a pigment, the same on its tag in the list and in the table.
-const tracked = [_][]const u8{ "prev", "cur", "next" };
+/// The variables whose tags the nodes carry: the three the loop moves, and `head`.
+const tracked = [_][]const u8{ "prev", "cur", "next", "head" };
fn frame(s: *anim.Frame) void {
const rec = canim.open(recordings.list);
@@ -25,26 +25,34 @@ 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 = .{ .cpu = false, .idea = .data, .follow = t.move, .source_rows = 5 };
+ at.levels = .{ .idea = .data, .follow = t.move, .source_rows = 10 };
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.
const split = canim.layout.split.subject;
- const ctx = canim.context(s, at, .{ .split = split, .quiet = true });
- const list = canim.nodes(s, .{ .cursor = at, .stage = ctx.stage, .root = "head", .track = &tracked, .quiet = true });
+ const ctx = canim.context(s, at, .{ .split = split });
+ const list = canim.nodes(s, .{ .cursor = at, .stage = ctx.stage, .root = "head", .track = &tracked });
var says: canim.Narrator = .{};
const joins = ctx.ties(s);
- canim.establish(s, .{ ctx.clock, ctx.registers, ctx.stack, ctx.source, ctx.disasm, list, joins });
+ // The nodes come in beside their bytes, one by one: three of them.
+ ctx.establish(s, .{ ctx.clock, ctx.registers, ctx.stack, ctx.source, ctx.disasm, list, joins }, 3);
says.line(s, "A list is nodes on the heap, each holding the address of the next.\nReversing it moves no node: it rewrites every `next`.");
- // Three names are set up, then the first trip round the loop, in full.
- at.walk(s, .line, rec.lineMoment(20, rec.lineMoment(24, reverse.enter)));
+ // Three names are set up.
+ const first_trip = rec.lineMoment(21, reverse.enter);
+ at.walk(s, .line, first_trip);
+ // The loop's caption leads the loop.
says.line(s, "`next` remembers the way on, `cur->next` is turned round,\nand `prev` and `cur` each step along.");
+ const second_trip = rec.lineMoment(21, rec.lineMoment(24, first_trip));
+ at.walk(s, .line, second_trip);
// Pacing: the second trip is the same, so hurried; it keeps its rest.
- at.hurry(s, .line, rec.lineMoment(20, rec.lineMoment(24, at.moment(s))), .{});
+ says.line(s, "The second node, the same way, faster:\nits `next` turns back to the first.");
+ const third_trip = rec.lineMoment(21, rec.lineMoment(24, second_trip));
+ at.hurry(s, .line, third_trip, .{});
// The third in full again: the last `next` turns, and `cur` runs off the end.
- at.walk(s, .line, rec.lineMoment(26, at.moment(s)));
+ says.line(s, "The last node: its `next` turns too,\nand `cur` runs off the end of the list.");
+ at.walk(s, .line, rec.lineMoment(26, third_trip));
says.line(s, "`head` takes the last node: the same three nodes,\nin the same places, read the other way.");
at.walk(s, .line, end);
- s.wait(t.before_cut);
+ says.close(s);
}