summaryrefslogtreecommitdiff
path: root/src/animation.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/animation.zig')
-rw-r--r--src/animation.zig16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/animation.zig b/src/animation.zig
index 547b9201..a4887148 100644
--- a/src/animation.zig
+++ b/src/animation.zig
@@ -1226,22 +1226,14 @@ pub fn Immediate(comptime Value: type) type {
};
}
-pub fn interpolateRgb(from: [3]u8, to: [3]u8, step: u16, steps: u16) [3]u8 {
- if (step == 0) return from;
- if (step >= steps) return to;
- var out: [3]u8 = undefined;
- for (&out, from, to) |*dst, a, b| {
- const numerator = @as(u32, a) * (steps - step) + @as(u32, b) * step;
- dst.* = @intCast((numerator + steps / 2) / steps);
- }
- return out;
-}
-
+/// A Fade's value for its tests: a colour stepped channel by channel.
const TestColor = struct {
rgb: [3]u8,
pub fn interpolate(from: TestColor, to: TestColor, step: u16, steps: u16) TestColor {
- return .{ .rgb = interpolateRgb(from.rgb, to.rgb, step, steps) };
+ var out = from;
+ for (&out.rgb, to.rgb) |*c, b| c.* = @intCast((@as(u32, c.*) * (steps - step) + @as(u32, b) * step + steps / 2) / steps);
+ return out;
}
};