diff options
Diffstat (limited to 'anim/scenes/intro_memory.zig')
| -rw-r--r-- | anim/scenes/intro_memory.zig | 52 |
1 files changed, 23 insertions, 29 deletions
diff --git a/anim/scenes/intro_memory.zig b/anim/scenes/intro_memory.zig index 2dfda5e..7b25098 100644 --- a/anim/scenes/intro_memory.zig +++ b/anim/scenes/intro_memory.zig @@ -1,5 +1,6 @@ //! The introduction, chapter I: memory (design/motion.md, "A scene: the -//! introduction", I1 to I10; mocks 29, 30, 34, 37). The frame built from +//! introduction", I1 to I10; mocks 29, 30, 34, 37), a function the scene +//! `intro` calls after its title (`chapter`). The frame built from //! its bytes up, on the `intro` recording (the list program from main's //! call of `reverse`) at reverse's first instruction, its `push rbp` (the //! push chapter II walks; rsp holds the way back to main), each part in @@ -13,33 +14,27 @@ const std = @import("std"); const anim = @import("anim"); const canim = @import("canim"); -const recordings = @import("recordings"); - -pub const background = canim.background; -pub const scene = anim.Live(frame, struct {}); +const intro = @import("intro.zig"); const t = canim.theme.time; +const f = intro.f; +const run = intro.run; +const start = intro.start; -fn f(frames: f32) f32 { - return frames / 60; -} +/// The chapter's last picture, which chapter II opens on: the address +/// space, the 128 bytes and their place's tie (each an object of its +/// own), the last text, and `e`, the frame it has been read by. +pub const One = struct { + space: *canim.Segments, + dump: *canim.Words, + objs: [3]anim.Obj, + caption: anim.Obj, + e: f32, +}; -/// Clock `v` from 0 to `frames`, linear, from the cursor; the cursor after it. -fn run(s: *anim.Frame, v: anim.Value, frames: f32) void { - s.play(.{v.to(0)}, .{ .seconds = 0 }); - s.play(.{v.to(frames)}, .{ .seconds = f(frames), .ease = anim.ease.linear }); -} - -/// The same, the cursor left where it was. -fn start(s: *anim.Frame, v: anim.Value, frames: f32) void { - const at = s.cursor; - run(s, v, frames); - s.cursor = at; -} - -fn frame(s: *anim.Frame) void { - const rec = canim.open(recordings.intro); - // reverse's first instruction (its call's first moment): its `push rbp`, which chapter II walks. +/// From the cursor, where its first text arrives. +pub fn chapter(s: *anim.Frame, rec: *canim.Recording) One { + // reverse's first instruction (its call's first moment): its `push rbp`, which chapter III walks. const moment = rec.call("reverse", 0).enter; const ui = canim.ui; const at = canim.regroup.at; @@ -62,7 +57,7 @@ fn frame(s: *anim.Frame) void { } space.n_echoes = order.len; - const objs = .{ s.custom(space, .{ .x = -640, .y = -360, .scale = ui.scale }), s.custom(dump, .{ .x = -640, .y = -360, .scale = ui.scale }), s.custom(place, .{ .x = -640, .y = -360, .scale = ui.scale }) }; + const objs = [3]anim.Obj{ s.custom(space, .{ .x = -640, .y = -360, .scale = ui.scale }), s.custom(dump, .{ .x = -640, .y = -360, .scale = ui.scale }), s.custom(place, .{ .x = -640, .y = -360, .scale = ui.scale }) }; inline for (objs) |o| s.play(.{o.fadeIn()}, .{ .seconds = 0 }); // The camera at x2 on the dump from the first frame (I1 to I3), with the @@ -78,7 +73,6 @@ fn frame(s: *anim.Frame) void { // I1: the bytes, a row at a time (18 f apart), a text's lead (60 f) after it lands, not // the first's 120: little "here" over an empty stage, and they come while it is read. - s.wait(1.0); const said_at = s.cursor; says.line(s, "A running program is bytes in memory:\nhere are 128 of them."); const lead_end = s.cursor; @@ -182,8 +176,8 @@ fn frame(s: *anim.Frame) void { says.line(s, "Follow an address and you reach another word: a chain.\n`→` points to a word, `←` holds a value."); run(s, dump.left, 24); run(s, dump.chains, 36 * 2 + 30); - s.wait(t.beat); - // The chapter's last picture. - says.close(s); + // The chapter's last picture, held until its text is read: then the seam. + s.wait(@max(says.read_by - s.cursor, 0)); cam.apply(s); + return .{ .space = space, .dump = dump, .objs = objs, .caption = says.current.?, .e = s.cursor }; } |
