summaryrefslogtreecommitdiff
path: root/anim/src/theme.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 16:05:20 -0300
committerGabriel Schneider <[email protected]>2026-11-10 16:43:58 -0300
commit165bb6c1344b98de7bef1d3c2b72147b4a40797a (patch)
tree0e70e6222700063f604f78673f6ab3a5bfb9242d /anim/src/theme.zig
parent66a2a7cf733f6abc1f79561c52d901ce67019fb1 (diff)
downloadcomputeranim-165bb6c1344b98de7bef1d3c2b72147b4a40797a.tar.gz
computeranim-165bb6c1344b98de7bef1d3c2b72147b4a40797a.zip
canim: the renderer speaks the design language
The blocks, their states and the tokens carry the catalogue's names: atoms in ui, chain/reg/slot in rows, insn with its line column, jump lane and annotations (read, write, taken or not, a call with its arguments, a return, a syscall) in disasm, bytes and hexdump with field paper and the reading column, the three splits and relayout in stage, the ties (thread, link and pin, projection, echo). A lens is a band over the whole context, its drawing left and its bytes right. Frames' spans on the stack, each instruction's line and a callee's parameter count come from the tracer. A gallery scene draws every block; the test compares six of its pages with pictures kept in test/gallery, drawn from a recording kept there too. The scenes are ported; the motion checks report no pop and no metronome in any of them. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Diffstat (limited to 'anim/src/theme.zig')
-rw-r--r--anim/src/theme.zig419
1 files changed, 230 insertions, 189 deletions
diff --git a/anim/src/theme.zig b/anim/src/theme.zig
index 9b18e59..ac01bd7 100644
--- a/anim/src/theme.zig
+++ b/anim/src/theme.zig
@@ -59,41 +59,51 @@ pub fn cols(first: u8, n: u8, y: f32, h: f32) Rect {
return .{ .x = colX(first), .y = canvas.stage.y + y, .w = span(n), .h = h };
}
-/// How views share the stage. The order in each is the order of abstraction:
-/// source is leftmost, then the CPU, then memory; a lower level is never left
-/// of or above a higher one, and the kernel is always underneath.
+/// The stage (design/README.md, "5. The frame"): the lens band across the
+/// top, and under it two columns. The program column (left): the source
+/// over the disassembly, what was written over what runs. The state column
+/// (right): the registers over the stack, what they act on. The split is
+/// the one thing about the layout a scene chooses.
pub const layout = struct {
- /// Two columns of 880. The program column: the lens, the source, the
- /// disassembly, top to bottom (the idea, its text, its instructions).
- /// The state column: what they act on, the same in every frame of
- /// every scene.
+ /// Two columns of 880, at x 64 and 976; the gutter between them belongs to the ties.
pub const program = cols(0, 6, 0, canvas.stage.h);
pub const state = cols(6, 6, 0, canvas.stage.h);
- /// The state column: every register (sixteen, rip, the flags), eight
- /// words of stack, three frames of backtrace.
- pub const registers = rows(state, 0, 18);
- pub const stack = below(registers, 8);
- pub const backtrace = below(stack, 3);
-
- /// How the program column is shared: the one thing about the layout a
- /// scene chooses. `lens` has no height where there is none.
- pub const Split = struct { lens: Rect, source: Rect, disasm: Rect };
+ /// Where every panel is in one split. `band` (the lens: a drawing and
+ /// the bytes it is drawn from, across both columns) and `backtrace`
+ /// have no height where the split has none.
+ pub const Split = struct {
+ band: Rect,
+ source: Rect,
+ disasm: Rect,
+ registers: Rect,
+ stack: Rect,
+ backtrace: Rect,
+ /// `bytes` rows of the lens's dump.
+ dump_rows: u32,
+ };
pub const split = struct {
- /// The machine alone: the source over the disassembly, eight
- /// instructions above the pc and eight below.
- pub const none: Split = .{ .lens = .{ .x = program.x, .y = program.y, .w = program.w, .h = 0 }, .source = rows(program, 0, 14), .disasm = below(rows(program, 0, 14), 17) };
- /// The default: the machine is the subject, the lens beside it.
- /// (The user's direction after the design's revision: more of the
- /// disassembly, so the source's window is shorter than the design's.)
- pub const beside: Split = shared(312, 8, 10);
- /// The idea is the subject: the lens a size up.
- pub const subject: Split = shared(432, 5, 8);
+ /// 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 = canvas.stage.x, .y = canvas.stage.y, .w = canvas.stage.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 machine is the subject and the lens beside it: a band of
+ /// 152 and a dump of five rows; eight lines over seventeen
+ /// instructions; the registers over eight words.
+ pub const beside: Split = shared(152, 8, 17, 8, 5);
+ /// The idea is the subject: a band of 248, the drawing a size up
+ /// and a dump of nine; ten lines over eleven instructions; four words.
+ pub const subject: Split = shared(248, 10, 11, 4, 9);
- fn shared(lens_h: f32, source_rows: f32, disasm_rows: f32) Split {
- const lens: Rect = .{ .x = program.x, .y = program.y, .w = program.w, .h = lens_h };
- const source: Rect = .{ .x = program.x, .y = lens.y + lens.h + canvas.row_gap, .w = program.w, .h = panelH(source_rows) };
- return .{ .lens = lens, .source = source, .disasm = below(source, disasm_rows) };
+ fn shared(band_h: f32, source_rows: f32, disasm_rows: f32, slots: f32, dump_rows: u32) Split {
+ const band: Rect = .{ .x = canvas.stage.x, .y = canvas.stage.y, .w = canvas.stage.w, .h = band_h };
+ const top = band.y + band.h + canvas.row_gap;
+ const source: Rect = .{ .x = program.x, .y = top, .w = program.w, .h = panelH(source_rows) };
+ const registers: Rect = .{ .x = state.x, .y = top, .w = state.w, .h = panelH(17) };
+ return .{ .band = band, .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 };
}
};
@@ -102,6 +112,11 @@ pub const layout = struct {
return metric.context.tag + 2 * metric.context.pad + n * metric.context.row;
}
+ /// How many rows a panel `h` high holds.
+ pub fn rowsIn(h: f32) usize {
+ 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) };
}
@@ -197,9 +212,14 @@ pub const color = struct {
0x2f5fc4, // azurite
};
- /// Drawn over everything that is not the subject, to dim it.
+ /// A node's pointer half.
+ pub const well: u24 = 0x101a48;
+
+ /// Drawn over everything that is not the subject, to dim it: for a
+ /// beat, and (deeper) under the camera.
pub const veil: u24 = page;
- pub const veil_alpha: f32 = 0.65;
+ pub const veil_alpha: f32 = 0.50;
+ pub const veil_alpha_camera: f32 = 0.65;
};
/// What a mark means. The same everywhere: a byte, a register, a source line,
@@ -211,8 +231,9 @@ pub const Role = enum {
write,
/// Read by this step.
read,
- /// Holds an address, and the arrow to it.
- pointer,
+ /// This register now points at that: a line 3 wide in the ink of the
+ /// region pointed into, ending in the target's pin.
+ link,
/// Handed out by an allocator.
allocated,
/// Handed back. No colour: its bytes are still there, and nobody owns them.
@@ -237,8 +258,8 @@ pub const Form = enum {
fill,
/// A frame, with its ember inside.
frame,
- /// A frame round the bytes and an arrow from it, elbows filleted, head filled.
- arrow,
+ /// A line along the ties' channels, corners filleted, head filled, and a pin at its end.
+ line,
/// Its ember inside a solid frame.
block,
/// Nothing inside a dashed frame; hatched where there is room.
@@ -271,7 +292,8 @@ pub fn mark(role: Role) Mark {
.current => .{ .solid = 0xe8c46a, .ember = 0x4a3d1c, .on_solid = t.ink, .form = .plaque },
.write => .{ .solid = 0xff6a4a, .ember = 0x5a2218, .on_solid = t.ink, .form = .fill },
.read => .{ .solid = 0x6fd6e6, .ember = 0x1c4652, .on_solid = t.ink, .form = .frame },
- .pointer => .{ .solid = 0xd59cf5, .ember = 0x45305a, .on_solid = t.ink, .form = .arrow },
+ // Its colour is the region's it points into (`color.region`); this is heap's.
+ .link => .{ .solid = color.region.heap, .ember = color.region.heap, .on_solid = t.ink, .form = .line },
.allocated => .{ .solid = 0x7fdc9a, .ember = 0x1f4a33, .on_solid = t.ink, .form = .block },
// The dashed frame, and the hatch.
.freed => .{ .solid = t.dim, .ember = color.rule, .on_solid = t.ink, .form = .hollow },
@@ -284,7 +306,7 @@ pub fn mark(role: Role) Mark {
};
}
-pub const roles = [_]Role{ .current, .write, .read, .pointer, .allocated, .freed, .fault, .attention, .flow, .unknown, .kernel };
+pub const roles = [_]Role{ .current, .write, .read, .link, .allocated, .freed, .fault, .attention, .flow, .unknown, .kernel };
/// WCAG relative luminance of 0xRRGGBB.
pub fn luminance(rgb: u24) f64 {
@@ -307,17 +329,20 @@ pub fn contrast(a: u24, b: u24) f64 {
// ------------------------------------------------------------------ type
-/// The Go fonts (Bigelow & Holmes; BSD-3-Clause, the Go licence), from
-/// golang.org/x/image/font/gofont/ttfs or the `ttf-go` package. Mono is for
-/// what the machine holds, sans for what is said about it.
+/// Mono is for what the machine holds: JetBrains Mono NL (OFL; NL, because
+/// the plain family's ligatures turn `->` into a sign that is not in the
+/// source). Sans is for what is said about it: the Go fonts (Bigelow &
+/// Holmes; BSD-3-Clause). `ui.Ui.text` sets a mono face by its size.
pub const Face = struct { family: []const u8, file: []const u8 };
pub const font = struct {
- /// Data and code. The renderer's built-in face.
- pub const mono: Face = .{ .family = "Go Mono", .file = "Go-Mono.ttf" };
- /// Keywords, a struck value, the letters on a plaque.
- pub const mono_bold: Face = .{ .family = "Go Mono", .file = "Go-Mono-Bold.ttf" };
+ /// Mono at 30 and over.
+ pub const mono: Face = .{ .family = "JetBrains Mono NL", .file = "JetBrainsMonoNL-Regular.ttf" };
+ /// All mono under 30: thin strokes on a dark ground die first in a stream.
+ pub const mono_medium: Face = .{ .family = "JetBrains Mono NL Medium", .file = "JetBrainsMonoNL-Medium.ttf" };
+ /// Keywords, mnemonics, a struck value, plaques, pins.
+ pub const mono_bold: Face = .{ .family = "JetBrains Mono NL", .file = "JetBrainsMonoNL-Bold.ttf" };
/// Comments.
- pub const mono_italic: Face = .{ .family = "Go Mono", .file = "Go-Mono-Italic.ttf" };
+ pub const mono_italic: Face = .{ .family = "JetBrains Mono NL", .file = "JetBrainsMonoNL-Italic.ttf" };
/// Captions, notes.
pub const sans: Face = .{ .family = "Go", .file = "Go-Regular.ttf" };
/// Tags, labels, the running head.
@@ -327,8 +352,8 @@ pub const font = struct {
};
pub const size = struct {
- /// Mono sizes are multiples of 5: Go Mono advances 0.6 em, so a character
- /// is a whole number of units (15, 18, 21, 27, 36), a hex pair is 36, and
+ /// Mono sizes are multiples of 5: the mono face advances 0.6 em, so a
+ /// character is a whole number of units (12, 15, 18, 21, 27, 36), and
/// the layout is the same arithmetic at 1080p and at 4K.
pub const mono = struct {
/// The debugger's context, where a lot is on screen at once:
@@ -339,9 +364,9 @@ pub const size = struct {
/// Bytes, words, registers, code. The smallest size for anything the
/// narration depends on; nothing mono that must be read is smaller.
pub const data = 30;
- /// Values in nodes and chunks.
+ /// Code inside a caption.
pub const value = 35;
- /// A value in flight.
+ /// A value in flight; a subject lens's values.
pub const flight = 45;
/// Values in hero cells, a system call's name.
pub const hero = 60;
@@ -370,20 +395,13 @@ pub const size = struct {
pub const min_any = 18;
};
-/// Width of one Go Mono character at a mono size.
+/// Width of one mono character at a mono size: JetBrains Mono advances 0.6
+/// em, a whole number of units at every size here (20: 12). Hex is
+/// unbroken, lower case, no `0x` on an address: a digit is an advance.
pub fn monoAdvance(mono_size: u16) u16 {
return mono_size * 3 / 5;
}
-/// Hex is set in groups of four digits, half a character apart, lower case,
-/// no `0x`. A register is 16 digits, an address 12 (or its last 8 in a narrow
-/// panel whose tag gives the rest); leading zeros are `text.faint`, and in an
-/// address gutter only the last group is `text.primary`.
-pub fn hexWidth(digits: u16, mono_size: u16) u16 {
- const adv = monoAdvance(mono_size);
- return digits * adv + (digits / 4 - 1) * ((adv + 1) / 2);
-}
-
/// Baseline that centres capitals and digits of `text_size` in a box at `y`, `h` tall.
pub fn baseline(y: f32, h: f32, text_size: f32) f32 {
return y + h / 2 + 0.36 * text_size;
@@ -417,140 +435,153 @@ pub const stroke = struct {
pub const hazard = 12;
/// Elision marks and the dots of an unknown byte: squares this big.
pub const dot = 6;
+ /// The ties: the thread and a link 3, a projection 2.
+ pub const tie = struct {
+ pub const thread = 3;
+ pub const link = 3;
+ pub const projection = 2;
+ };
};
// ------------------------------------------------------------ components
pub const metric = struct {
- /// A panel is an acme window: a tag with a square box, a rule, a body.
+ /// A panel of a card (the title, the legend): the first pass's sizes.
pub const panel = struct {
- pub const tag_h = 48;
- /// The box: filled `current` in the panel the narration is in, hollow elsewhere.
- pub const box = 20;
- pub const box_inset = 14;
- pub const title_x = 48;
- pub const title_baseline = 34;
pub const pad_x = 20;
- pub const pad_y = 16;
};
- /// One byte: two hex digits in a 46 square on a 48 pitch.
- pub const byte = struct {
- pub const pitch = 48;
- pub const side = 46;
- /// A character over its byte, for strings: this tall.
- pub const text_h = 84;
- };
- /// Memory rows, bytes or words: 60 apart, which leaves room for a pointer's frame.
- pub const row_pitch = 60;
- /// A word is drawn on the footprint of its bytes (8 of them: 382 wide), so
- /// bytes and their number can change into each other in place.
- pub const pointer_frame_outset = 6;
- /// The bar along the bottom of a cooled change.
- pub const ember_bar = 6;
- /// Bytes not shown: three dots and a note, this tall.
- pub const elision_h = 24;
- /// Left of an address gutter: register and variable marks that point at the row.
- pub const mark_lane = 88;
- /// Between gutter and bytes: where pointer arrows run.
- pub const arrow_lane = 52;
-
- /// Registers, and any table of names and values.
- pub const table = struct {
- pub const row_h = 48;
- pub const name_x = 18;
- /// The value cell overhangs its digits by this on each side.
- pub const value_pad = 10;
- pub const flag = [2]f32{ 60, 36 };
- pub const flag_gap = 12;
- };
- /// Shown unless a scene says otherwise, in this order: where it is, the
- /// result, the arguments, the frame. Any other register appears when a
- /// step touches it and leaves once its ember has gone.
- pub const default_registers = [_][]const u8{ "rip", "rax", "rdi", "rsi", "rdx", "rcx", "rsp", "rbp" };
- pub const default_flags = [_][]const u8{ "CF", "ZF", "SF", "OF" };
- /// The registers' rows, in pwndbg's order: sixteen, rip, the flags.
- pub const all_registers = [_][]const u8{ "rax", "rbx", "rcx", "rdx", "rsi", "rdi", "rbp", "rsp", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "rip", "flags" };
-
- /// The context: every panel of it is rows of 24 under a tag of 24.
+ /// The context: every panel of it is rows of 24 under a tag of 24
+ /// (`tag`, design/README.md), 4 of padding above and below the rows,
+ /// 12 at the sides.
pub const context = struct {
pub const row = 24;
pub const tag = 24;
- /// Above and below the rows; at a panel's sides.
- pub const pad = 6;
+ pub const pad = 4;
pub const side = 12;
- /// A register's name: five characters. Its value starts here.
- pub const name_w = 60;
+ /// `reg`: a register's name 12 in, its chain from 72.
pub const chain_x = 72;
- /// Both arrows of a chain: a 2-unit shaft, a head 8 by 10.
+ /// `arrow`: 30 wide, a 2-unit shaft, a head 8 by 10.
pub const arrow_w = 30;
pub const arrow_head = [2]f32{ 8, 10 };
- /// Between groups of four hex digits: half an advance.
- pub const group_gap = 6;
- /// Changed a moment ago: a tick at the value's left.
+ /// `address` `lead`: the digits every row of a column shares, this
+ /// far toward the page; `byte` `pad`: a word's bytes above its
+ /// highest non-zero one, this far.
+ pub const lead_alpha = 0.6;
+ pub const pad_alpha = 0.45;
+ /// `held`: a tick 4 wide, the row less 6 tall, at the value's left.
pub const tick = 4;
+ /// `read`: a 2-unit frame, 6 out at the sides.
pub const read_frame = 2;
+ /// `struck`: solid 5 wider each side; its edges pulse out 3.
+ pub const strike_out = 5;
pub const pulse_outset = 3;
+ /// A string is never cut shorter than this.
pub const string_min = 6;
+ /// `line`: the number ranged right in three characters, the text from 64, 67 characters.
+ pub const line_number_end = 46;
+ pub const line_text = 64;
pub const source_chars = 67;
};
- pub const code = struct {
- pub const line_h = 48;
- /// Line numbers: three digits and this, then the code.
- pub const gutter_pad = 16;
- pub const text_gap = 20;
- /// Characters a panel of n columns holds at `size.mono.data`: write the
- /// C for a video to fit the panel it will be shown in.
- pub const chars_in_5_columns = 34;
- pub const chars_in_6_columns = 42;
- pub const chars_in_7_columns = 51;
- /// The trail bar at the left edge, and the instruction marker in an unfolded line.
- pub const trail_bar = 6;
- pub const unfold_indent = 36;
- pub const instruction_bar = 8;
+ /// `insn`: columns, from the panel's left edge.
+ pub const insn = struct {
+ pub const mark = 2;
+ pub const jump_lane = 31;
+ pub const address = 40;
+ pub const line = 134;
+ pub const mnemonic = 180;
+ pub const operands = 264;
+ pub const annotation = 564;
+ pub const operand_chars = 24;
+ pub const annotation_chars = 25;
+ };
+
+ /// `bytes`: a hexdump row, from its panel's left edge (the band's right half).
+ pub const bytes = struct {
+ pub const bracket = 7;
+ pub const address = 18;
+ pub const first = 132;
+ /// Two digits in 24 units on a pitch of 30, 12 more after the eighth.
+ pub const pitch = 30;
+ pub const middle = 12;
+ pub const reading = 640;
+ };
+
+ /// `slot`: a lane for `row` pins, the chain from 122, room to 136 from
+ /// the right edge (which belongs to the `call` spans, 14 in).
+ pub const slot = struct {
+ pub const lane = 10;
+ pub const lane_end = 112;
+ pub const chain = 122;
+ pub const room = 136;
+ pub const span = 14;
+ };
+
+ /// `reg` rip: the flags at the right end, eight names on a pitch of 42,
+ /// a set one on a chip 32 by 20.
+ pub const flags = struct {
+ pub const pitch = 42;
+ pub const chip = [2]f32{ 32, 20 };
};
- /// Call stack cards, newest on top.
- pub const card = struct {
- pub const h = 56;
- pub const gap = 12;
- pub const spine = 12;
+ /// `pin`. `row`: the names, 5, a head 9 by 12. `under`: a stub 3 wide,
+ /// the mono size and 10 long, a head 10 by 10, the names 9 either side.
+ pub const pin = struct {
+ pub const row_head = [2]f32{ 9, 12 };
+ pub const row_gap = 5;
+ pub const stub = 3;
+ pub const under_head = [2]f32{ 10, 10 };
+ pub const under_names = 9;
};
- /// A linked-list node: value, then a pointer compartment.
+
+ /// `bracket`: a stroke and a serif at each end. `quiet` 2 and 5; `tie` 3 and 6 (the thread's 7).
+ pub const bracket = struct {
+ pub const quiet = [2]f32{ 2, 5 };
+ pub const tie = [2]f32{ 3, 6 };
+ pub const thread = [2]f32{ 3, 7 };
+ };
+
+ /// `plaque`, gold only: the row high, this wide.
+ pub const plaque = struct {
+ pub const rip = 54;
+ pub const line = 50;
+ pub const pc = 24;
+ };
+
+ /// `nodes`: boxes 116 by 44, 28 apart beside the context; 124 by 72,
+ /// 22 apart as the subject. The pointer half is 48 wide, its square 10.
pub const node = struct {
- pub const w = 180;
- pub const h = 72;
- pub const pointer_w = 72;
- /// The square in the pointer compartment that its arrow leaves from.
- pub const origin = 14;
+ pub const beside = [3]f32{ 116, 44, 28 };
+ pub const subject = [3]f32{ 124, 72, 22 };
+ pub const pointer_w = 48;
+ pub const origin = 10;
+ pub const arrow_head = [2]f32{ 12, 10 };
};
- /// Tree and graph nodes: circles; the tree's levels this far apart.
- pub const tree = struct {
- pub const radius = 24;
- pub const radius_solo = 36;
- pub const level = 54;
- pub const badge = 28;
+
+ /// A lens's lanes: projections 4 under its tag, links 8 above its bottom edge.
+ pub const lens = struct {
+ pub const top_lane = 4;
+ pub const bottom_lane = 8;
};
- /// Array cells: in a panel among others, and as the subject.
+
+ /// The ties' channels: the thread in the left margin, the gutter's two
+ /// lanes (a link comes up the left, a projection down the right).
+ pub const tie = struct {
+ pub const thread_x = 54;
+ pub const link_lane = 950;
+ pub const projection_lane = 962;
+ pub const radius = 8;
+ pub const projection_radius = 6;
+ };
+
+ /// A lens's cell, as the first pass drew them.
+ pub const ember_bar = 4;
+ pub const pointer_frame_outset = 6;
+ pub const elision_h = 24;
pub const cell = [2]f32{ 96, 84 };
pub const hero_cell = [2]f32{ 168, 132 };
- /// A value in flight: its card.
pub const flight_card = [2]f32{ 100, 60 };
-
- /// The heap, to scale.
- pub const heap = struct {
- pub const units_per_byte = 4;
- pub const strip_h = 88;
- pub const strip_h_stacked = 56;
- };
- /// The page map: one square a page.
- pub const page = struct {
- pub const pitch = 24;
- pub const side = 22;
- pub const row_pitch = 42;
- };
- /// The system call strip: time spent in the kernel hangs below the line.
pub const timeline = struct {
pub const baseline = 3;
pub const block_h = 44;
@@ -563,14 +594,9 @@ pub const metric = struct {
pub const text_x = 110;
pub const row_h = 96;
};
- /// A plaque: a name in a box (hollow for a value, filled for a place).
- pub const plaque = struct {
- pub const h = 40;
- pub const pad = 12;
- };
- /// No panel shows more rows of data than this; past it, elide or zoom.
- pub const max_rows = 10;
+ /// The registers' rows, in pwndbg's order: sixteen, then rip (with the flags).
+ pub const all_registers = [_][]const u8{ "rax", "rbx", "rcx", "rdx", "rsi", "rdi", "rbp", "rsp", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "rip" };
/// No scene tracks more objects by pigment.
pub const max_pigments = 4;
};
@@ -726,14 +752,30 @@ pub const time = struct {
pub const unroll = 4.0 / 60.0;
/// 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
+ /// (`pin_out`), and the line draws to the target, head first (`in`,
+ /// `in_far` over 400 units); the pin lands with the head and settles;
+ /// at the advance the line draws back into the pin (`out`).
pub const link = struct {
+ pub const after = 6.0 / 60.0;
+ pub const pin_out = 0.20;
pub const in = 0.40;
+ pub const in_far = 0.60;
+ pub const settle = 0.20;
pub const out = 0.30;
};
- /// A source line opening into its instructions, and closing.
- pub const unfold = 0.40;
- /// A wedge drawing from a thing to its enlargement.
- pub const wedge = 0.30;
+ /// `project`: on a run's mark, a bracket takes its row, then the line
+ /// draws to the part of the drawing the bytes are; that part reacts
+ /// only when it arrives. Out with the advance.
+ pub const project = struct {
+ pub const bracket = 0.10;
+ pub const draw = 0.30;
+ pub const out = 0.30;
+ };
+ /// `establish`, for a lens: its elements rise from their rows this far apart.
+ pub const establish_rise = 0.10;
+ /// `relayout`: a change of split.
+ pub const relayout = 0.80;
/// A caption leaves, then nothing, then the next arrives rising this
/// many units; never typed out, never crossfaded. The stage stays
/// still `caption_lead` after it (`caption_lead_first` after a scene's
@@ -846,7 +888,7 @@ test "every mark stands off the page, and letters read on it" {
}
}
// The strokes that carry meaning on their own.
- for ([_]Role{ .current, .write, .read, .pointer, .allocated }) |r|
+ for ([_]Role{ .current, .write, .read, .link, .allocated }) |r|
try expect(contrast(mark(r).solid, color.page) >= 6.5);
try expect(contrast(color.text.ink, mark(.write).solid) >= 6.5);
}
@@ -857,29 +899,28 @@ test "no two roles are drawn the same way" {
test "mono advances are whole units" {
const m = size.mono;
- for ([_]u16{ m.context, m.small, m.data, m.value, m.flight, m.hero }) |s| try expect(s % 5 == 0);
+ for ([_]u16{ m.context, m.small, m.data, m.value, m.flight, m.hero }) |sz| try expect(sz % 5 == 0);
try expect(monoAdvance(m.context) == 12 and m.context >= size.min_read);
try expect(monoAdvance(m.data) == 18);
- try expect(hexWidth(16, m.data) == 315);
- try expect(hexWidth(12, m.small) == 196);
- // A byte's two digits fit its cell; a register's sixteen fit a word's footprint.
- try expect(2 * monoAdvance(m.data) <= metric.byte.side - 8);
- try expect(hexWidth(16, m.data) <= 8 * metric.byte.pitch - 2 - 24);
+ // A byte's two digits fit its 24 units, on a pitch of 30.
+ try expect(2 * monoAdvance(m.context) == 24 and metric.bytes.pitch == 30);
try expect(m.data >= size.min_read and size.sans.label >= size.min_read and size.sans.micro >= size.min_any);
}
-test "layouts fill the stage" {
+test "the splits fill the stage, panels 12 apart" {
try expect(colX(11) + canvas.column == canvas.width - canvas.margin_x);
try expect(span(12) == canvas.stage.w);
try expect(layout.program.w == 880 and layout.state.x == 976);
- // The state column: 468, 228 and 108, twelve apart.
- try expect(layout.registers.h == 468 and layout.stack.h == 228 and layout.backtrace.h == 108);
- try expect(layout.backtrace.y + layout.backtrace.h <= canvas.stage.y + canvas.stage.h);
- for ([_]layout.Split{ layout.split.none, layout.split.beside, layout.split.subject }) |split| {
- try expect(split.disasm.y + split.disasm.h <= canvas.stage.y + canvas.stage.h);
- try expect(split.source.y >= split.lens.y + split.lens.h);
- }
- try expect(layout.split.beside.source.h == 228 and layout.split.beside.disasm.h == 276);
+ 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.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 == 248 and sp.subject.source.y == 308 and sp.subject.disasm.y == 592 and sp.subject.disasm.y + sp.subject.disasm.h == bottom);
+ try expect(sp.subject.stack.y == 760 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) == 11 and layout.rowsIn(sp.subject.stack.h) == 4);
}
test "easing runs from 0 to 1 without turning back" {
@@ -901,7 +942,7 @@ test "easing runs from 0 to 1 without turning back" {
test "durations are whole frames" {
const t = time;
- for ([_]f32{ t.snap, t.quick, t.step, t.step_per_row, t.step_max, t.move, t.travel, t.layout, t.camera, t.camera_far, t.fire, t.cascade, t.read_value, t.read_more, t.rest, t.strike.arm, t.strike.in, t.strike.pulse, t.strike.hold, t.strike.cool, t.strike.out, t.read.out, t.current_jump, t.flight.lift, t.flight.near, t.flight.second, t.veil, t.unfold, t.wedge, t.caption_in, t.caption_out, t.caption_gap, t.walk, t.run, t.sprint, t.phrase_rest, t.before_cut }) |d| {
+ for ([_]f32{ t.snap, t.quick, t.step, t.step_per_row, t.step_max, t.move, t.travel, t.layout, t.camera, t.camera_far, t.fire, t.cascade, t.read_value, t.read_more, t.rest, t.strike.arm, t.strike.in, t.strike.pulse, t.strike.hold, t.strike.cool, t.strike.out, t.read.out, t.current_jump, t.flight.lift, t.flight.near, t.flight.second, t.veil, t.link.after, t.link.pin_out, t.link.in, t.link.in_far, t.link.settle, t.link.out, t.project.bracket, t.project.draw, t.project.out, t.establish_rise, t.relayout, t.caption_in, t.caption_out, t.caption_gap, t.walk, t.run, t.sprint, t.phrase_rest, t.before_cut }) |d| {
const frames = d * t.fps;
try expect(@abs(frames - @round(frames)) < 1e-3);
}