diff options
Diffstat (limited to 'anim/src/cursor.zig')
| -rw-r--r-- | anim/src/cursor.zig | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/anim/src/cursor.zig b/anim/src/cursor.zig index f196fab..6a02948 100644 --- a/anim/src/cursor.zig +++ b/anim/src/cursor.zig @@ -596,12 +596,17 @@ pub const Now = struct { if (since_strike >= -s.arm) armed.arm = std.math.clamp((since_strike + s.arm) / time.stagger, 0, 1); return armed; } + const cooled = (n.time - n.plan.advance) / s.cool; + const in = std.math.clamp(since_strike / s.in, 0, 1); return .{ .level = 1, - .solid = 1 - glide(std.math.clamp((n.time - n.plan.advance) / s.cool, 0, 1)), - .in = std.math.clamp(since_strike / s.in, 0, 1), + .solid = 1 - glide(std.math.clamp(cooled, 0, 1)), + .in = in, .from = if (was.level >= 1) .ember else .nothing, .out = if (since_strike < s.pulse) theme.pulse(since_strike / s.pulse) else 0, + // The turned corner: the old one goes as the paper comes in over + // it; the new one comes in over the cool's last 6 f. + .corner = @max(std.math.clamp((cooled - 1) * s.cool / s.corner + 1, 0, 1), if (was.level >= 1) 1 - in else 0), }; } @@ -683,8 +688,12 @@ test "a write is armed, strikes, holds, cools with the advance, and leaves after // Held solid until the mark leaves, then cooled, halfway at the middle. h = instant(0.89, plan).heat(0, null, 0.59); try expect(h.solid == 1 and h.in == 1 and h.out == 0); + try expect(h.corner == 0); h = instant(0.90 + s.cool / 2.0, plan).heat(0, null, 0.8); try std.testing.expectApproxEqAbs(@as(f32, 0.5), h.solid, 1e-3); + // The turned corner: none until the cool's last 6 f, then in. + try expect(h.corner == 0); + try std.testing.expectApproxEqAbs(@as(f32, 0.5), instant(0.90 + s.cool - s.corner / 2.0, plan).heat(0, null, 1).corner, 1e-3); // At rest, and for the steps after: the ember; then it goes. const rest = instant(std.math.inf(f32), plan); try expectEqual(ui.Heat.ember, rest.heat(0, null, std.math.inf(f32))); |
