diff options
Diffstat (limited to 'anim/src/theme.zig')
| -rw-r--r-- | anim/src/theme.zig | 59 |
1 files changed, 33 insertions, 26 deletions
diff --git a/anim/src/theme.zig b/anim/src/theme.zig index ac01bd7..a96d79c 100644 --- a/anim/src/theme.zig +++ b/anim/src/theme.zig @@ -69,11 +69,14 @@ pub const layout = struct { pub const program = cols(0, 6, 0, canvas.stage.h); pub const state = cols(6, 6, 0, canvas.stage.h); - /// 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. + /// Where every panel is in one split. The band is the lens, two + /// panels: `band`, its drawing, over the program column, and `view`, + /// the pane the drawing is a view of (a dump, the backtrace), over the + /// state column. They and `backtrace` have no height where the split + /// has none. pub const Split = struct { band: Rect, + view: Rect, source: Rect, disasm: Rect, registers: Rect, @@ -88,22 +91,23 @@ pub const layout = struct { 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 }; + 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 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); + /// 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); + /// 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); - 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 }; + fn shared(drawing_h: f32, view_h: f32, source_rows: f32, disasm_rows: f32, slots: f32, dump_rows: u32) 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 }; } }; @@ -770,10 +774,12 @@ pub const time = struct { pub const project = struct { pub const bracket = 0.10; pub const draw = 0.30; + /// Over 600 units: a frame's way back to its call's node. + pub const far = 0.50; pub const out = 0.30; }; - /// `establish`, for a lens: its elements rise from their rows this far apart. - pub const establish_rise = 0.10; + /// `establish`, for a lens: its elements come in from this far into the opening. + pub const establish_rise = 0.50; /// `relayout`: a change of split. pub const relayout = 0.80; /// A caption leaves, then nothing, then the next arrives rising this @@ -824,10 +830,9 @@ pub const time = struct { /// A change of pace is never a switch: each step of it is this much /// of the one before. pub const ramp = 0.6; - /// Stillness at a scene's opening, for the picture to be read: - /// `establish` and `establish_per_panel` for each panel. + /// A scene's opening: its first caption this long after the panels + /// begin to come in (and after a lens has risen from its bytes). pub const establish = 1.00; - pub const establish_per_panel = 0.50; /// Stillness after the stage is rearranged, and on the last picture. pub const settle = 0.80; pub const before_cut = 2.00; @@ -916,11 +921,13 @@ test "the splits fill the stage, panels 12 apart" { // 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.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 == 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); + 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); + // 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); } test "easing runs from 0 to 1 without turning back" { |
