From eab50d1c040774351f332a1568fa332c377860bd Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 12 Nov 2026 11:32:59 -0300 Subject: canim: the introduction as one video, with a chapter on registers From the user. One scene, intro, in four chapters: memory, registers, the stack, code and meaning (210 s). The registers chapter builds the panel before the stack needs it: sixteen rows with their chains, rip pinned on the code band and rsp and rbp on the stack's, rdi opened into its parts as mov edi changes one byte, a call to malloc stepped over with its result in rax, the registers a scene never changes folded. The chapters join at seams that say their title and keep it as the clock's label; one recording (from push(9), no agent, the heap from --heap) and one clock. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa --- anim/src/words.zig | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'anim/src/words.zig') diff --git a/anim/src/words.zig b/anim/src/words.zig index 6549dfb..9bec54c 100644 --- a/anim/src/words.zig +++ b/anim/src/words.zig @@ -110,6 +110,59 @@ pub const Caption = struct { } }; +/// A chapter's title (design/README.md, `chapter`, `title`): said, not +/// carded, in the caption's place, one line of Go Medium 40, its numeral +/// faint and its name bright (`II Registers`); it arrives rising as a +/// caption does, over the picture it grows from. +pub const Title = struct { + numeral: []const u8, + name: []const u8, + box: Rect = theme.canvas.caption, + + pub fn draw(c: *const Title, f: *sk.Frame, at: anim.Placed) void { + const u = fixed(f, at, (1 - at.pose.opacity) * theme.time.caption_rise); + const size = theme.size.sans.caption; + const base = theme.canvas.caption_baseline[0]; + u.text(.sans_medium, size, theme.canvas.margin_x, base, c.numeral, t.faint); + const x = theme.canvas.margin_x + u.width(.sans_medium, size, c.numeral) + 2 * u.width(.sans_medium, size, " "); + u.text(.sans_medium, size, x, base, c.name, t.bright); + } +}; + +/// The clock's label (design/README.md, `clock`): the chapter, Go 18, +/// faint, ranged right 24 left of the clock's count (its widest, so that it +/// stands still as the count grows), or alone at 1856 where there is no +/// clock yet. `which` is the chapter (between two, their names +/// crossfading); `docked` 0 alone, 1 beside the count (out over its first +/// half, in over its second, with the clock: it is secondary, it only fades). +pub const ChapterLabel = struct { + names: []const []const u8, + which: anim.Value, + docked: anim.Value, + /// The count at its widest, `moment 193 of 193`. + widest: []const u8, + + pub fn draw(l: *const ChapterLabel, f: *sk.Frame, at: anim.Placed) void { + const u = fixed(f, at, 0); + const size = theme.size.sans.micro; + const base = theme.canvas.clock_y + 28; + const right = theme.canvas.stage.x + theme.canvas.stage.w; + const ends = [2]f32{ right, right - u.width(.mono, theme.size.mono.context, l.widest) - 24 }; + const which = std.math.clamp(at.value(l.which), 0, @as(f32, @floatFromInt(l.names.len - 1))); + const lo: usize = @intFromFloat(@floor(which)); + const hi = @min(lo + 1, l.names.len - 1); + const k = which - @floor(which); + const docked = std.math.clamp(at.value(l.docked), 0, 1); + for ([2]usize{ lo, hi }, [2]f32{ 1 - k, k }) |n, shows| { + if (shows <= 0) continue; + const name = l.names[n]; + const w = u.width(.sans, size, name); + // Gone from where it stood alone before it comes beside the count: never over it. + for (ends, [2]f32{ std.math.clamp(1 - 2 * docked, 0, 1), std.math.clamp(2 * docked - 1, 0, 1) }) |end, here| if (here > 0) u.faded(shows * here).text(.sans, size, end - w, base, name, t.faint); + } + } +}; + /// Text with `code` between backticks set in mono, from `x` on `baseline`. /// Returns where it ends. pub fn runs(u: ui.Ui, x: f32, baseline: f32, text: []const u8, face: ui.Face, size: f32, mono_size: f32, ink: anytype) f32 { -- cgit v1.3