Added Color Lerp Function
@@ -335,5 +335,14 @@ namespace bs
*hue -= 1.0f;
}
+
+ Color Color::lerp(float t, const Color& a, const Color& b)
+ {
+ t = Math::clamp01(t);
+ return Color(a.r + (b.r - a.r) * t,
+ a.g + (b.g - a.g) * t,
+ a.b + (b.b - a.b) * t,
+ a.a + (b.a - a.a) * t);
+ }
@@ -254,6 +254,12 @@ namespace bs
*/
void getHSB(float* hue, float* saturation, float* brightness) const;
+ /**
+ * Linearly interpolates between the two colors using @p t. t should be in [0, 1] range, where t = 0 corresponds
+ * to the left color, while t = 1 corresponds to the right color.
+ */
+ static Color lerp(float t, const Color& a, const Color& b);
float r, g, b, a;
};