summaryrefslogtreecommitdiff
path: root/anim/src/source.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-11 23:46:02 -0300
committerGabriel Schneider <[email protected]>2026-11-12 01:40:04 -0300
commit60e07feef401d9044db3a1c925cb9d1f6d20dac9 (patch)
tree98957ba8425193f686c8e8692cd10a10f27dbf4b /anim/src/source.zig
parent9c0696447dbc5cf37e56aee562c7ebba4f4d4e6b (diff)
downloadcomputeranim-60e07feef401d9044db3a1c925cb9d1f6d20dac9.tar.gz
computeranim-60e07feef401d9044db3a1c925cb9d1f6d20dac9.zip
canim: relations as one data-oriented subsystem; aim; the ASan pair; the introduction's chapters
From the user. Relations between panes are one subsystem: per-frame tables of places and values in struct-of-arrays, owned by the frame; the kinds one table of data; a resolver of pure passes (join, filter, priority, cut) unit-tested on hand-written tables. Ported kinds draw byte-identical frames; a synthetic map of 4000 places and 6000 values resolves in 0.56 ms against the old table's 5.7. aim, a word holding a code address tied to its row, is the first new kind, off unless a scene turns it on. The ASan pair: one overflow built plain and with ASan, recorded by instruction; the frame as bytes eight a row; the plain run goes on alone in the column, its return address aimed at main's row until the letters reach it; the fault at ret. The introduction's three chapters are built and tested, not yet exported. Annotations, rows and scrolls that changed in one frame now fade; captions stand twelve seconds at most. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
Diffstat (limited to 'anim/src/source.zig')
-rw-r--r--anim/src/source.zig16
1 files changed, 12 insertions, 4 deletions
diff --git a/anim/src/source.zig b/anim/src/source.zig
index ab49bc0..aedbb3e 100644
--- a/anim/src/source.zig
+++ b/anim/src/source.zig
@@ -34,6 +34,8 @@ pub const Source = struct {
descent: bool = false,
/// Which box of its stage it is in: on the map the source may go on in `source_more`.
part: @import("stage.zig").Part = .source,
+ /// Words after the file's name in its tag (a `pair`'s shared source: `both builds`).
+ tag: []const u8 = "",
pub fn draw(p: *const Source, f: *sk.Frame, placed: anim.Placed) void {
const box = p.stage.box(placed, p.part);
@@ -56,7 +58,13 @@ pub const Source = struct {
// The window: where the line it is on has it, and (as the mark
// moves on) gliding to where the next one does. It never cuts.
const going = now.advancing();
- const windows = [2]f32{ @as(f32, @floatFromInt(rec.shownFirst(span_fit, at[0]))) + skip, @as(f32, @floatFromInt(rec.shownFirst(span_fit, at[1]))) + skip };
+ var windows = [2]f32{ @as(f32, @floatFromInt(rec.shownFirst(span_fit, at[0]))) + skip, @as(f32, @floatFromInt(rec.shownFirst(span_fit, at[1]))) + skip };
+ // The panel growing or shrinking at rest (a column's change): its window glides
+ // from the one its old height has to its new one's, never a jump.
+ if (now.resting()) if (p.stage.resizing(placed, p.part)) |r| {
+ const ends = [2]f32{ @floatFromInt(rec.shownFirst(@intCast(theme.layout.rowsIn(r.from) + tail), at[1])), @floatFromInt(rec.shownFirst(@intCast(theme.layout.rowsIn(r.to) + tail), at[1])) };
+ windows = @splat(std.math.lerp(ends[0], ends[1], r.p) + skip);
+ };
// Another file: the panel fades through (12 f out, 12 f in), its tag
// naming the file it comes to. Farther than its own height in one
// file (another function far off): its strip shows where it goes
@@ -80,7 +88,7 @@ pub const Source = struct {
const side: usize = if (jump) |j| @intFromBool(j.travel >= 0.5) else if (turn) @intFromBool(going >= 0.5) else if (far) @intFromBool(if (ui.mapping) going > 0 else going >= 0.75) else @intFromBool(going >= 0.5);
const file = rec.sources[at[side].src];
const text = prepared(file.text, file.path) orelse return;
- const first = if (jump) |j| (if (ui.mapping) std.math.lerp(windows[0], windows[1], cursors.glide(j.travel)) else windows[side]) else if (turn or far) windows[side] else std.math.lerp(windows[0], windows[1], cursors.glide(going));
+ const first = if (jump) |j| (if (ui.mapping) std.math.lerp(windows[0], windows[1], cursors.glide(j.travel)) else windows[side]) else if (turn or far) windows[side] else std.math.lerp(windows[0], windows[1], cursors.glidePixels(going, now.plan.travel, @abs(windows[1] - windows[0]) * m.row * u.at.scale));
const fade: f32 = if (jump) |j| (if (ui.mapping) 1 else 1 - theme.ease(.glide, j.grow)) else if (turn) @abs(2 * going - 1) else if (far and !ui.mapping) (if (going < 0.5) 1 else @abs(4 * going - 3)) else 1;
const lit = u.faded(fade);
const from: u32 = @intFromFloat(@floor(first));
@@ -99,7 +107,7 @@ pub const Source = struct {
for (now.marks, at, &notes, lines_notes) |mk, a, *note, lines_note| note.* = if (p.descent and !a.here and a.line != 0) u.print("{s} waits at line {d} \u{00b7} the pc is in {s}", .{ context.frameName(u, rec, rec.register(lastShown(rec, mk), "rip")), a.line, whereIs(u, rec, mk) }) else lines_note;
const swap = !std.mem.eql(u8, notes[0], notes[1]) and now.walking();
const titles = [2][]const u8{ rec.sources[at[0].src].name(), rec.sources[at[1].src].name() };
- const title = if (p.part == .source_more) u.print("{s}, continued", .{file.name()}) else file.name();
+ const title = if (p.part == .source_more) u.print("{s}, continued", .{file.name()}) else if (p.tag.len > 0) u.print("{s} \u{00b7} {s}", .{ file.name(), p.tag }) else file.name();
const body = u.panel(box.w, box.h, if (turn) "" else title, .{ .focus = p.focus, .note = if (swap) "" else notes[side] });
// Its tag's file and note change with the fade through it; a note otherwise over the 12 f before the advance.
if (turn) for (titles, [2]f32{ 1 - 2 * going, 2 * going - 1 }) |t, shows| u.faded(shows).tagTitle(t, p.focus);
@@ -162,7 +170,7 @@ pub const Source = struct {
if (waits) {
// The number ringed: a 2-unit primary frame where the plaque would be, no wash.
u.faded(shows).frame(.{ .x = theme.stroke.rule + 1, .y = mark_y + 1, .w = theme.metric.plaque.line + widen - 2, .h = m.row - 2 }, theme.color.text.primary, theme.stroke.rule);
- if (!ui.mapping) ties.thread_waits = true;
+ if (!ui.mapping) ties.of(u.f).thread_waits = true;
} else if (shows > 0) u.faded(shows).current(.{ .x = theme.stroke.rule, .y = mark_y, .w = box.w - 2 * theme.stroke.rule, .h = m.row }, theme.metric.plaque.line + widen, now.fires(.source));
if (shows >= 1 and mark_y >= body.y and mark_y + m.row <= box.h) ties.anchor(u, .source, .{ .x = 0, .y = mark_y, .w = box.w, .h = m.row });