diff options
Diffstat (limited to 'anim/src/words.zig')
| -rw-r--r-- | anim/src/words.zig | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/anim/src/words.zig b/anim/src/words.zig index 5601156..bec5116 100644 --- a/anim/src/words.zig +++ b/anim/src/words.zig @@ -7,6 +7,7 @@ const sk = @import("sketch"); const anim = @import("anim"); const ui = @import("ui.zig"); const Cursor = @import("cursor.zig").Cursor; +const cursors = @import("cursor.zig"); const theme = ui.theme; const Rect = ui.Rect; const t = theme.color.text; @@ -33,11 +34,30 @@ pub const Clock = struct { u.fill(.{ .x = -c.width, .y = 0, .w = c.width + stage.x - 8, .h = c.height }, theme.color.page); u.fill(.{ .x = stage.x + stage.w + 8, .y = 0, .w = c.width, .h = c.height }, theme.color.page); u.fill(.{ .x = stage.x, .y = c.clock_y - 1, .w = stage.w, .h = theme.stroke.rule }, theme.color.rule); - u.fill(.{ .x = stage.x, .y = c.clock_y - 2, .w = stage.w * now.place, .h = 4 }, theme.mark(.current).solid); + // Time itself: still while a step plays at a walk or a run; once its + // mark has landed, the step's piece fades in (12 f, 8 at a run) and + // the count changes as it starts. At a sprint it grows with the recording. + const gold = theme.mark(.current).solid; + const at_stop = struct { + fn of(n: cursors.Now, m: u64) f32 { + return std.math.clamp(@as(f32, @floatFromInt(m -| n.way[0])) / @as(f32, @floatFromInt(@max(n.way[1] -| n.way[0], 1))), 0, 1); + } + }.of; + var counted = now.marked(); + if (now.plan.gait == .sprint or now.resting()) { + u.fill(.{ .x = stage.x, .y = c.clock_y - 2, .w = stage.w * now.place, .h = 4 }, gold); + } else { + const landed = now.plan.advance + now.plan.travel; + const fade = std.math.clamp((now.time - landed) / @as(f32, if (now.plan.gait == .run) theme.time.run_ease else theme.time.quick), 0, 1); + const from = at_stop(now, now.stops[1]); + const to = at_stop(now, now.stops[0]); + u.fill(.{ .x = stage.x, .y = c.clock_y - 2, .w = stage.w * from, .h = 4 }, gold); + if (fade > 0) u.fill(.{ .x = stage.x + stage.w * from, .y = c.clock_y - 2, .w = stage.w * (to - from), .h = 4 }, ui.mix(theme.color.page, gold, fade)); + counted = if (now.time >= landed) now.stops[0] else now.stops[1]; + } const size = theme.size.mono.context; const base = c.clock_y + 28; - // The count is where the current mark is: it changes as the mark moves on. - const count = u.print("moment {d} of {d}", .{ now.marked() -| now.way[0], now.way[1] -| now.way[0] }); + const count = u.print("moment {d} of {d}", .{ counted -| now.way[0], now.way[1] -| now.way[0] }); const count_x = stage.x + stage.w - u.width(.mono, size, count); u.text(.mono, size, count_x, base, count, t.faint); // Secondary action: the pace, said quietly. It only fades. |
