summaryrefslogtreecommitdiff
path: root/anim/src/cursor.zig
diff options
context:
space:
mode:
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);