summaryrefslogtreecommitdiff
path: root/anim/src/theme.zig
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/src/theme.zig
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/src/theme.zig')
-rw-r--r--anim/src/theme.zig238
1 files changed, 137 insertions, 101 deletions
diff --git a/anim/src/theme.zig b/anim/src/theme.zig
index 156088c..8d4b044 100644
--- a/anim/src/theme.zig
+++ b/anim/src/theme.zig
@@ -135,43 +135,53 @@ pub const layout = struct {
/// and the stack point at, the loupes open and the key (`map.Spare`).
spare: [2]Rect = @splat(.{ .x = 0, .y = 0, .w = 0, .h = 0 }),
};
+ /// Layout A (design/README.md, "5. The frame"): the disassembly under
+ /// the source in every split; the registers as tall as their rows (the
+ /// scene's: `fit`), the stack what the state column has left. The
+ /// splits here are for a panel of eleven rows (sort's), as the
+ /// catalogue's table is.
pub const split = struct {
/// The machine alone: fourteen lines over seventeen instructions;
- /// the registers, eight words and four frames of backtrace.
- pub const none: Split = blk: {
- const registers = rows(state, 0, 17);
- const stack = below(registers, 8);
- break :blk .{ .band = .{ .x = program.x, .y = canvas.stage.y, .w = program.w, .h = 0 }, .view = .{ .x = state.x, .y = canvas.stage.y, .w = state.w, .h = 0 }, .source = rows(program, 0, 14), .disasm = below(rows(program, 0, 14), 17), .registers = registers, .stack = stack, .backtrace = below(stack, 4), .dump_rows = 0 };
- };
+ /// the registers, the stack and four frames of backtrace at the foot.
+ pub const none: Split = shared(0, 0, 14, 17, 0, 4);
/// The machine is the subject and the lens beside it: a drawing
/// and its view of 152 (a dump of five); eight lines over
- /// seventeen instructions; the registers over eight words.
- pub const beside: Split = shared(152, 152, 8, 17, 8, 5);
+ /// seventeen instructions; the registers over the stack.
+ pub const beside: Split = shared(152, 152, 8, 17, 5, 0);
/// The idea is the subject: the drawing 296 high and a size up,
- /// its view 200 (a dump of seven); ten lines over nine
- /// instructions; the registers over six words, a small frame whole.
- pub const subject: Split = shared(296, 200, 10, 9, 6, 7);
- /// The `blocks` lens: its drawing (the graph as shapes) 296 high
- /// over the program column, which then holds the source alone
- /// (twenty lines); its view the disassembly itself, seven rows over
- /// the state column; the registers over six words.
- pub const blocks: Split = blk: {
- var s = subject;
- s.disasm = .{ .x = state.x, .y = canvas.stage.y, .w = state.w, .h = panelH(7) };
- s.view = .{ .x = state.x, .y = canvas.stage.y, .w = state.w, .h = 0 };
- s.source.h = panelH(20);
- break :blk s;
- };
+ /// its view 200 (a dump of seven); eight lines over eleven
+ /// instructions; the registers over the stack.
+ pub const subject: Split = shared(296, 200, 8, 11, 7, 0);
+ /// The `blocks` lens: its drawing (the graph) 880 by 344 over the
+ /// program column and no view (its rows are the disassembly under
+ /// the source: six lines over eleven); the state column the
+ /// registers' and the stack's from the top.
+ pub const blocks: Split = shared(344, 0, 6, 11, 0, 0);
- fn shared(drawing_h: f32, view_h: f32, source_rows: f32, disasm_rows: f32, slots: f32, dump_rows: u32) Split {
+ fn shared(drawing_h: f32, view_h: f32, source_rows: f32, disasm_rows: f32, dump_rows: u32, backtrace_rows: f32) Split {
const band: Rect = .{ .x = program.x, .y = canvas.stage.y, .w = program.w, .h = drawing_h };
const view: Rect = .{ .x = state.x, .y = canvas.stage.y, .w = state.w, .h = view_h };
- const source: Rect = .{ .x = program.x, .y = band.y + band.h + canvas.row_gap, .w = program.w, .h = panelH(source_rows) };
- const registers: Rect = .{ .x = state.x, .y = view.y + view.h + canvas.row_gap, .w = state.w, .h = panelH(17) };
- return .{ .band = band, .view = view, .source = source, .disasm = below(source, disasm_rows), .registers = registers, .stack = below(registers, slots), .backtrace = .{ .x = state.x, .y = canvas.stage.y + canvas.stage.h, .w = state.w, .h = 0 }, .dump_rows = dump_rows };
+ const source: Rect = .{ .x = program.x, .y = if (drawing_h > 0) band.y + band.h + canvas.row_gap else canvas.stage.y, .w = program.w, .h = panelH(source_rows) };
+ const registers: Rect = .{ .x = state.x, .y = if (view_h > 0) view.y + view.h + canvas.row_gap else canvas.stage.y, .w = state.w, .h = 0 };
+ const bottom = canvas.stage.y + canvas.stage.h;
+ const backtrace: Rect = .{ .x = state.x, .y = bottom - panelH(backtrace_rows), .w = state.w, .h = if (backtrace_rows > 0) panelH(backtrace_rows) else 0 };
+ return fit(.{ .band = band, .view = view, .source = source, .disasm = below(source, disasm_rows), .registers = registers, .stack = registers, .backtrace = backtrace, .dump_rows = dump_rows }, 11);
}
};
+ /// `s` with a registers panel of `rows` rows (the scene's: its
+ /// registers, the quiet ones folded) and the stack the rest of the
+ /// state column above the backtrace, whole slots, any rest above it.
+ pub fn fit(s: Split, registers_rows: f32) Split {
+ var out = s;
+ out.registers.h = panelH(registers_rows);
+ const top = out.registers.y + out.registers.h + canvas.row_gap;
+ const bottom = if (s.backtrace.h > 0) s.backtrace.y - canvas.row_gap else canvas.stage.y + canvas.stage.h;
+ const slots = @floor((bottom - top - panelH(0)) / metric.context.row);
+ out.stack = .{ .x = state.x, .y = bottom - panelH(slots), .w = state.w, .h = panelH(slots) };
+ return out;
+ }
+
/// A panel of `n` rows: a tag, the padding, the rows.
pub fn panelH(n: f32) f32 {
return metric.context.tag + 2 * metric.context.pad + n * metric.context.row;
@@ -182,10 +192,6 @@ pub const layout = struct {
return @intFromFloat(@max(@floor((h - metric.context.tag - 2 * metric.context.pad) / metric.context.row), 0));
}
- fn rows(column: Rect, y: f32, n: f32) Rect {
- return .{ .x = column.x, .y = column.y + y, .w = column.w, .h = panelH(n) };
- }
-
fn below(r: Rect, n: f32) Rect {
return .{ .x = r.x, .y = r.y + r.h + canvas.row_gap, .w = r.w, .h = panelH(n) };
}
@@ -563,6 +569,17 @@ pub const metric = struct {
pub const source_chars = 67;
};
+ /// `registers` `quiet`: a register no step of the scene changes, folded
+ /// three to a row on a pitch of 285 from 12, under a 2-unit `rule`
+ /// across: its name faint at the cell's start, its value 48 in (60 from
+ /// the panel's edge), a pointer's chain cut to `more` at once.
+ pub const registers = struct {
+ pub const quiet_from = 12;
+ pub const quiet_pitch = 285;
+ pub const quiet_value = 48;
+ pub const quiet_per_row = 3;
+ };
+
/// `insn`: columns, from the panel's left edge.
pub const insn = struct {
pub const mark = 2;
@@ -703,64 +720,46 @@ pub const metric = struct {
pub const bottom_lane = 8;
};
- /// `graph` (design/README.md, "graph"): on the map a block is a head of
- /// 24 and its rows: the offset ranged right at 72, the line at 116, the
- /// mnemonic at 128, the operands at 212; 300 wide at least; over 16
- /// rows, where the graph is too tall, its first four, `more` and its
- /// last four. Layers 48 apart, blocks 56; lanes 16 apart from 24 in, the
- /// blocks 24 right of the last; the first layer 36 under the tag; a back
- /// edge down 14; ports 40 in; arrivals 48 apart; the right channel 32
- /// out; corners 8; the way out's stub 14 and bar 28; a call's hook 14
- /// out and back a row down. A fold of blocks never reached: 520 wide.
- /// Columns are as far apart as the pc's block is wide with its annotation.
- /// The `blocks` lens at half measure: boxes 24 high, 60 and 10 a row
- /// wide, 132 at least, columns 300 apart; layers 12 apart, lanes 10.
+ /// `graph` (design/README.md, "graph"), the `blocks` lens's drawing (and
+ /// the map's, at its size). A block a pill 24 high, its ends half
+ /// circles: its offset 12 in, the functions it calls after it, its
+ /// visits ranged right 12 from its end, room kept for `×99` (and 8 to
+ /// spare) so that it never widens as the run counts; any two pills 12
+ /// apart. `rings`: an arc between two pills 24 long at least to read; a
+ /// fork 30 inside its ring; a way out 30 in from the pill's far end,
+ /// its bends quarter circles of 16; the turns 30 under the centre; the
+ /// way in 48 long from the left. `layers`: layers 12 apart, lanes 10
+ /// from 24 in, the blocks 76 right of them, columns 300 apart, the first
+ /// layer 14 down, ports 16 in, the right channel 20 out, a back edge
+ /// down 8, every corner a quarter circle of 12. Heads 8 by 8; the pc's
+ /// pill framed gold 3; the mark a gold plaque 22 with its point 12 by 10.
pub const graph = struct {
- pub const offset = 72;
- pub const line = 116;
- pub const mnemonic = 128;
- pub const operands = 212;
- pub const least = 300;
- pub const long = 16;
- pub const keep = 4;
- pub const layer_gap = 48;
- pub const block_gap = 56;
- pub const lane = 16;
+ pub const pill = 24;
+ pub const pill_in = 12;
+ pub const count_chars = 3;
+ pub const spare = 8;
+ pub const apart = 12;
+ pub const arc_least = 24;
+ pub const fork_in = 30;
+ pub const exit_in = 30;
+ pub const bend = 16;
+ pub const turns_down = 30;
+ pub const way_in = 48;
+ pub const layer_gap = 12;
+ pub const lane = 10;
pub const lane_in = 24;
- pub const top = 36;
- pub const back_down = 14;
- pub const port = 40;
- pub const arrivals = 48;
- pub const channel = 32;
- pub const corner = 8;
- pub const exit_stub = 14;
- pub const exit_bar = 28;
- pub const hook = 14;
- pub const fold_w = 520;
- pub const head = [2]f32{ 10, 10 };
- /// The rows are `insn`'s, `shift` left (its address column given to
- /// the offset); the pc's block widens to its column for the
- /// annotation, 30 characters from where `insn` puts it.
- pub const shift = 52;
- pub const note = 360;
- pub const lens = struct {
- pub const box = 24;
- pub const lead = 60;
- pub const per_row = 10;
- pub const least = 132;
- pub const pitch = 300;
- pub const layer_gap = 12;
- pub const lane = 10;
- pub const blocks_in = 76;
- pub const top = 14;
- pub const port = 16;
- pub const channel = 20;
- pub const back_down = 8;
- pub const corner = 4;
- pub const head = [2]f32{ 7, 8 };
- /// The pc's box: framed gold this wide.
- pub const gold = 3;
- };
+ pub const blocks_in = 76;
+ pub const pitch = 300;
+ pub const top = 14;
+ pub const port = 16;
+ pub const channel = 20;
+ pub const back_down = 8;
+ pub const track = 4;
+ pub const corner = 12;
+ pub const head = [2]f32{ 8, 8 };
+ pub const gold = 3;
+ pub const mark = 22;
+ pub const mark_point = [2]f32{ 12, 10 };
};
/// The ties' channels: the thread in the left margin, the gutter's two
@@ -953,7 +952,22 @@ pub const time = struct {
pub const veil = 0.30;
/// A telescope extends: the links after one that changed are followed
/// again one at a time, this far apart.
- pub const unroll = 4.0 / 60.0;
+ pub const extend = 4.0 / 60.0;
+ /// `unroll` and `roll`: a pane's column out of its strip for a beat and
+ /// back (design/motion.md, "The map and the working frame"): the panes
+ /// it covers veiled first (`veil`), the column growing (`grow`, glide),
+ /// held at least `hold`, rolled back (`roll`), the veil lifting
+ /// (`veil`). A far jump in the same column at a walk: `grow`, the
+ /// window travelling along the column (`travel`, glide), `roll`: 96 f.
+ pub const unroll = struct {
+ pub const veil = 0.30;
+ pub const grow = 0.60;
+ pub const hold = 1.00;
+ pub const roll = 0.60;
+ pub const travel = 0.40;
+ /// The strip's window framed bright as it begins.
+ pub const bright = 0.10;
+ };
/// A tie between two panes: this long to draw (after what it leaves
/// from has struck), and to go, as the marks advance.
/// `link`: 6 f after the register's strike its old pin fades
@@ -1020,25 +1034,42 @@ pub const time = struct {
pub const out = 0.20;
pub const names = 0.20;
};
- /// `leave` (and `turn`, along a loop's lane): the jump fires; the
+ /// `leave` (and `turn`, round a ring's foot): the jump fires; the
/// compare's chips framed as read from `chips` (the CPU's slot); the
/// edge it takes drawn gold over `edge`, ending as the mark sets off at
- /// `sets_off`; the mark along it `mark` and `per_100` a 100 units,
- /// `mark_most` at most (`run` at a run); the target's count struck
- /// `count` after it lands; the oldest trail edge cooled over `trail`;
- /// `rest` from the landing to the step's end.
+ /// `sets_off`; the mark along it (arcs and all) `mark` and `per_100` a
+ /// 100 units, `mark_most` at most (`run` at a run, the edge flashing
+ /// gold and cooling over it); the target's count struck `count` after
+ /// it lands (a ring's turns as it lands); the oldest trail edge cooled
+ /// over `trail`; `rest` from the landing to the step's end.
pub const leave = struct {
pub const chips = 0.30;
pub const edge = 0.30;
pub const sets_off = 0.70;
pub const mark = 0.20;
pub const per_100 = 2.0 / 60.0;
- pub const mark_most = 0.50;
+ pub const mark_most = 0.70;
pub const count = 0.10;
pub const trail = 0.30;
pub const rest = 0.70;
pub const run = 8.0 / 60.0;
};
+ /// `reach`: a block's first entry. As the mark lands its pill fills from
+ /// the page to `raised` over `fill`, its offset brightening with it,
+ /// and `×1` fades in over `count`, then is struck (the leave's own).
+ pub const reach = struct {
+ pub const fill = 0.20;
+ pub const count = 0.10;
+ };
+ /// `unfold`: a fold the run reaches opens. From the mark setting off,
+ /// the pills beyond make room over `room` (`glide`), the fold's blocks
+ /// fade in, quiet, over `fade`, `apart` in address order; the mark
+ /// lands on the one reached no sooner than the room is made.
+ pub const unfold = struct {
+ pub const room = 0.40;
+ pub const fade = 0.20;
+ pub const apart = 2.0 / 60.0;
+ };
/// A return in the calls tree: its frame leaves the backtrace as the
/// idea strikes, and the result on the node's shoulder this long after.
pub const badge_after = 0.20;
@@ -1193,14 +1224,19 @@ test "the splits fill the stage, panels 12 apart" {
try expect(layout.program.w == 880 and layout.state.x == 976);
const bottom = canvas.stage.y + canvas.stage.h;
const sp = layout.split;
- // design/README.md, "5. The frame".
- try expect(sp.none.source.h == 368 and sp.none.disasm.y == 428 and sp.none.disasm.y + sp.none.disasm.h == 868);
- try expect(sp.none.registers.h == 440 and sp.none.stack.y == 500 and sp.none.backtrace.y == 736 and sp.none.backtrace.y + sp.none.backtrace.h == 864);
- try expect(sp.beside.band.h == 152 and sp.beside.view.h == 152 and sp.beside.source.y == 212 and sp.beside.disasm.y == 448 and sp.beside.disasm.y + sp.beside.disasm.h == bottom);
- try expect(sp.beside.registers.y == 212 and sp.beside.stack.y == 664 and sp.beside.stack.y + sp.beside.stack.h == bottom);
- try expect(sp.subject.band.h == 296 and sp.subject.view.h == 200 and sp.subject.source.y == 356 and sp.subject.disasm.y == 640 and sp.subject.disasm.y + sp.subject.disasm.h == bottom);
- try expect(sp.subject.registers.y == 260 and sp.subject.stack.y == 712 and sp.subject.stack.y + sp.subject.stack.h == bottom);
- try expect(layout.rowsIn(sp.beside.disasm.h) == 17 and layout.rowsIn(sp.subject.disasm.h) == 9 and layout.rowsIn(sp.subject.stack.h) == 6 and layout.rowsIn(sp.subject.view.h) == 7);
+ const rows = layout.rowsIn;
+ // design/README.md, "5. The frame": layout A, for a registers panel of eleven rows.
+ try expect(sp.none.source.y == 48 and sp.none.source.h == 368 and sp.none.disasm.y == 428 and sp.none.disasm.y + sp.none.disasm.h == 868);
+ try expect(sp.none.registers.y == 48 and sp.none.registers.h == 296 and sp.none.stack.y == 356 and rows(sp.none.stack.h) == 15 and sp.none.backtrace.y == 760 and sp.none.backtrace.y + sp.none.backtrace.h == bottom);
+ try expect(sp.beside.band.h == 152 and sp.beside.view.h == 152 and sp.beside.source.y == 212 and rows(sp.beside.source.h) == 8 and sp.beside.disasm.y == 448 and sp.beside.disasm.y + sp.beside.disasm.h == bottom);
+ try expect(sp.beside.registers.y == 212 and sp.beside.stack.y == 520 and rows(sp.beside.stack.h) == 14 and sp.beside.stack.y + sp.beside.stack.h == bottom);
+ try expect(sp.subject.band.h == 296 and sp.subject.view.h == 200 and sp.subject.source.y == 356 and rows(sp.subject.source.h) == 8 and sp.subject.disasm.y == 592 and sp.subject.disasm.y + sp.subject.disasm.h == bottom);
+ try expect(sp.subject.registers.y == 260 and sp.subject.stack.y == 568 and rows(sp.subject.stack.h) == 12 and sp.subject.stack.y + sp.subject.stack.h == bottom);
+ try expect(sp.blocks.band.h == 344 and sp.blocks.view.h == 0 and sp.blocks.source.y == 404 and rows(sp.blocks.source.h) == 6 and sp.blocks.disasm.y == 592 and rows(sp.blocks.disasm.h) == 11);
+ try expect(sp.blocks.registers.y == 48 and sp.blocks.stack.y == 376 and rows(sp.blocks.stack.h) == 20 and sp.blocks.stack.y + sp.blocks.stack.h == bottom);
+ try expect(rows(sp.beside.disasm.h) == 17 and rows(sp.subject.disasm.h) == 11 and rows(sp.subject.view.h) == 7 and rows(sp.beside.view.h) == 5);
+ // A scene that folds none (17 rows) has six slots fewer; one that folds more, more.
+ try expect(rows(layout.fit(sp.subject, 17).stack.h) == 6 and rows(layout.fit(sp.subject, 10).stack.h) == 13 and rows(layout.fit(sp.none, 17).stack.h) == 9);
// The band's two panels are the columns' width, the gutter between them the ties'.
try expect(sp.subject.band.x == layout.program.x and sp.subject.band.w == 880 and sp.subject.view.x == layout.state.x);
}