summaryrefslogtreecommitdiff
path: root/anim/scenes/sort.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 18:06:30 -0300
committerGabriel Schneider <[email protected]>2026-11-10 19:01:23 -0300
commite63b0624f57472d40af32a006c32cc47d403b822 (patch)
treeb7295da62acd96bc7aba425720eed95605526693 /anim/scenes/sort.zig
parent318e16181a28725e218121363555580725d6d0d4 (diff)
downloadcomputeranim-e63b0624f57472d40af32a006c32cc47d403b822.tar.gz
computeranim-e63b0624f57472d40af32a006c32cc47d403b822.zip
canim: what the review found; the band as two panels; list and sort by instruction
The first videos were reviewed frame by frame and the catalogue changed with them. A lens is a drawing over the program column and its view over the state column, so the stack keeps six slots, its window on the whole frame. Operands are whole. list and sort are recorded by instruction from main (record --from), so their registers strike, links reach nodes and cells, rows that ran are marked and jumps are drawn. A call's node is a projection of its return address; pins travel and keep their side; a mark covers the bytes that changed, at the element's width; a syscall's result is stored after the kernel returns it and every panel is of one moment; fast passes are veiled; the clock stands still during a step; captions get their reading time and a scene's first step comes by four seconds. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Diffstat (limited to 'anim/scenes/sort.zig')
-rw-r--r--anim/scenes/sort.zig29
1 files changed, 23 insertions, 6 deletions
diff --git a/anim/scenes/sort.zig b/anim/scenes/sort.zig
index 6ad41f9..06b35a9 100644
--- a/anim/scenes/sort.zig
+++ b/anim/scenes/sort.zig
@@ -22,14 +22,14 @@ fn frame(s: *anim.Frame) void {
while (rec.next(.over, rec.next(.over, start)) < rec.call("swap", 0).enter) start = rec.next(.over, start);
var at = canim.cursor(s, rec, start);
// The array is the idea; `i` and `j` are memory, and strike a beat before their tags slide.
- at.levels = .{ .cpu = false, .idea = .data, .follow = t.quick, .source_rows = 10 };
+ at.levels = .{ .idea = .data, .follow = t.quick, .source_rows = 10 };
// Its last compare: nothing larger is left of 20.
const last = rec.call("swap", 9);
const end = rec.next(.over, rec.next(.over, last.exit.?));
at.journey(.over, end);
// The context is the instrumented program's: its registers are unmarked.
const split = canim.layout.split.subject;
- const ctx = canim.context(s, at, .{ .split = split, .quiet = true });
+ const ctx = canim.context(s, at, .{ .split = split });
// The lens: the array as cells, and the two indices that walk it.
const cells = canim.array(s, .{ .cursor = at, .stage = ctx.stage, .variable = "a", .indices = &.{ "i", "j" }, .focus = true });
var says: canim.Narrator = .{};
@@ -41,23 +41,40 @@ fn frame(s: *anim.Frame) void {
}.step;
const joins = ctx.ties(s);
- canim.establish(s, .{ ctx.clock, ctx.registers, ctx.stack, ctx.source, ctx.disasm, cells, joins });
+ // The cells come in beside their bytes, one by one.
+ ctx.establish(s, .{ ctx.clock, ctx.registers, ctx.stack, ctx.source, ctx.disasm, cells, joins }, 8);
says.line(s, "`i` walks right. Everything left of it is in order,\nand 12 is not yet in its place.");
// The compare: both cells framed. It is the swap's anticipation.
at.walk(s, .over, rec.next(.over, start));
says.line(s, "While the one on the left is larger, they trade places,\nand `j` follows the smaller value down.");
- // The caption of the step the scene is about stands a second longer.
- s.wait(t.caption_lead);
+ // Nearer, for the swap: the cells at x1.5, the rest of the stage cleared.
+ var cam: canim.Camera = .{};
+ const others = .{ ctx.source, ctx.disasm, ctx.registers, ctx.stack };
+ // The drawing's view is cleared with the rest (it is not the subject).
+ const going = s.cursor;
+ s.cursor = going + t.quick;
+ s.play(.{ctx.stage.view.to(0)}, .{ .seconds = t.camera_clear, .ease = anim.ease.linear });
+ s.cursor = going;
+ cam.go(s, split.band, 1.5, others);
// Arcs: the two values fly past each other, one over, one under.
swap(at, s, rec);
at.walk(s, .over, rec.next(.over, at.moment(s)));
+ const coming = s.cursor;
+ cam.back(s, others);
+ const back_at = s.cursor;
+ s.cursor = coming + t.camera;
+ s.play(.{ctx.stage.view.to(1)}, .{ .seconds = t.cascade, .ease = anim.ease.linear });
+ s.cursor = @max(s.cursor, back_at);
// Pacing: the same again, so at a run; then the long way 5 has to go,
// at a sprint; slowing for the last swap.
+ says.line(s, "And so on: each value is carried left\nuntil the one before it is not larger.");
at.hurry(s, .over, rec.call("swap", 3).enter - 1, .{ .to = t.run, .settle = false });
at.hurry(s, .over, last.enter - 1, .{ .pace = t.sprint, .from = t.run });
+ says.line(s, "The last swap: 20 goes one place left, past 26.");
swap(at, s, rec);
at.walk(s, .over, end);
says.line(s, "Nothing larger is left of 20. The array is sorted.");
- s.wait(t.before_cut - t.caption_lead);
+ says.close(s);
+ cam.apply(s);
}