lerp
Linear interpolocation of colors component wise
Parameters
Source
Implementation
pub fn lerp(self: Color, other: Color, t: f32) Color {
if (t <= 0) return self;
if (t >= 1) return other;
const r: f32 = std.math.lerp(@as(f32, self.r) / 255, @as(f32, other.r) / 255, t);
const g: f32 = std.math.lerp(@as(f32, self.g) / 255, @as(f32, other.g) / 255, t);
const b: f32 = std.math.lerp(@as(f32, self.b) / 255, @as(f32, other.b) / 255, t);
const a: f32 = std.math.lerp(@as(f32, self.a) / 255, @as(f32, other.a) / 255, t);
return Color{
.r = @trunc(r * 255.99),
.g = @trunc(g * 255.99),
.b = @trunc(b * 255.99),
.a = @trunc(a * 255.99),
};
}