summaryrefslogtreecommitdiff
path: root/anim/src/cursor.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/cursor.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/cursor.zig')
-rw-r--r--anim/src/cursor.zig32
1 files changed, 31 insertions, 1 deletions
diff --git a/anim/src/cursor.zig b/anim/src/cursor.zig
index 5cb625a..e9aab67 100644
--- a/anim/src/cursor.zig
+++ b/anim/src/cursor.zig
@@ -32,6 +32,14 @@ pub fn glide(t: f32) f32 {
return theme.ease(.glide, t);
}
+/// `glide` for a scroll of `px` pixels over `seconds`, at least a pixel a
+/// frame from rest: a glide's first frames are each under a pixel, and rows
+/// drawn on whole pixels would step one and stand still a frame.
+pub fn glidePixels(t: f32, seconds: f32, px: f32) f32 {
+ if (px < 1) return glide(t);
+ return @min(@max(glide(t), t * seconds * 60 / px), 1);
+}
+
/// For things that answer the program (the mark, cards, tags, an arrow
/// growing): off promptly, a long settle.
pub fn standard(t: f32) f32 {
@@ -292,6 +300,9 @@ pub const Cursor = struct {
sprint_veil: anim.Value,
/// Steps taken.
count: anim.Value,
+ /// The `aim` relation's knob (design/README.md, "4. Ties"): 0 off (the
+ /// default), 1 standing (in and out over 18 f), 2 for the step.
+ aim_knob: anim.Value,
/// The same values a little behind (`time.minimap_lag`, then a frame
/// later each, `time.minimap_fade` of them): what the minimap draws
/// from, secondary action that never starts on a primary onset's frame
@@ -321,6 +332,7 @@ pub const Cursor = struct {
.veil = s.value(0),
.sprint_veil = s.value(0),
.count = s.value(0),
+ .aim_knob = s.value(0),
.lags = undefined,
.first = start,
.last = start,
@@ -762,6 +774,20 @@ pub const Cursor = struct {
}
};
+ /// The `aim` relation's knob from here on (design/README.md, "4. Ties":
+ /// off unless the author turns it on, for a scene or a beat): `.standing`
+ /// draws the aims of the words on screen, coming and going over 18 f;
+ /// `.step` those of the words a walked step writes or reads.
+ pub fn aim(c: Cursor, s: *anim.Frame, knob: enum { off, step, standing }) void {
+ // Over what follows: the timeline's cursor stays where it was.
+ const start = s.cursor;
+ defer s.cursor = start;
+ switch (knob) {
+ .off, .standing => s.play(.{c.aim_knob.to(if (knob == .off) 0 else 1)}, .{ .seconds = 18.0 / 60.0, .ease = anim.ease.linear }),
+ .step => s.play(.{c.aim_knob.to(2)}, .{ .seconds = 0 }),
+ }
+ }
+
/// There at once, with nothing struck: a cut.
pub fn jump(c: Cursor, s: *anim.Frame, to: u64) void {
const Jump = struct {
@@ -797,6 +823,7 @@ pub const Cursor = struct {
.crossings = c.levels.crossings,
.annotation = c.levels.annotation,
.way = .{ c.first, c.last },
+ .aim = placed.value(c.aim_knob),
};
var plan: [Plan.values]f32 = undefined;
for (&plan, c.plan) |*is, v| is.* = placed.value(v);
@@ -869,6 +896,8 @@ pub const Now = struct {
annotation: @FieldType(Levels, "annotation") = .tied,
/// The scene's way through the recording: its first moment and its last.
way: [2]u64 = .{ 0, 0 },
+ /// The `aim` knob: 0 off, up to 1 standing (coming or going), 2 for the step.
+ aim: f32 = 0,
/// The program's state as shown.
pub fn moment(n: Now) Recording.Moment {
@@ -1069,7 +1098,8 @@ pub const Now = struct {
if (n.resting()) return .ember;
if (since_strike < 0) {
var armed = was;
- if (since_strike >= -s.arm) armed.arm = std.math.clamp((since_strike + s.arm) / time.stagger, 0, 1);
+ // In over 4 f (the catalogue's 2 f left a frame of a few pixels: a pop).
+ if (since_strike >= -s.arm) armed.arm = std.math.clamp((since_strike + s.arm) / (2 * time.stagger), 0, 1);
return armed;
}
const in = std.math.clamp(since_strike / s.in, 0, 1);