diff --git a/Engine.Core/Primitives/ColorHSV.cs b/Engine.Core/Primitives/ColorHSV.cs index 1772e64..22af2a0 100644 --- a/Engine.Core/Primitives/ColorHSV.cs +++ b/Engine.Core/Primitives/ColorHSV.cs @@ -87,7 +87,14 @@ public readonly struct ColorHSV(float hue, float saturation, float value) /// The ending (t = 1). /// The interpolation parameter. /// The interpolated . - public static ColorHSV Lerp(ColorHSV from, ColorHSV to, float t) => from + FromTo(from, to) * t; + public static ColorHSV Lerp(ColorHSV from, ColorHSV to, float t) + { + float hueDiff = to.Hue - from.Hue; + float saturationDiff = to.Saturation - from.Saturation; + float valueDiff = to.Value - from.Value; + + return from + new ColorHSV(hueDiff * t, saturationDiff * t, valueDiff * t); + } /// /// Checks if two s are approximately equal within a specified epsilon range. diff --git a/Engine.Core/Primitives/ColorRGB.cs b/Engine.Core/Primitives/ColorRGB.cs index 1171a17..67c0d99 100644 --- a/Engine.Core/Primitives/ColorRGB.cs +++ b/Engine.Core/Primitives/ColorRGB.cs @@ -87,7 +87,14 @@ public readonly struct ColorRGB(byte r, byte g, byte b) /// The ending (t = 1). /// The interpolation parameter. /// The interpolated . - public static ColorRGB Lerp(ColorRGB from, ColorRGB to, float t) => from + FromTo(from, to) * t; + public static ColorRGB Lerp(ColorRGB from, ColorRGB to, float t) + { + int redDiff = to.R - from.R; + int greenDiff = to.G - from.G; + int blueDiff = to.B - from.B; + + return from + new ColorRGB((byte)(redDiff * t), (byte)(greenDiff * t), (byte)(blueDiff * t)); + } /// /// Determines whether the specified object is equal to the current . diff --git a/Engine.Core/Primitives/ColorRGBA.cs b/Engine.Core/Primitives/ColorRGBA.cs index 2e7deb5..ea512a4 100644 --- a/Engine.Core/Primitives/ColorRGBA.cs +++ b/Engine.Core/Primitives/ColorRGBA.cs @@ -116,7 +116,15 @@ public readonly struct ColorRGBA(byte r, byte g, byte b, byte a = 255) /// The ending (t = 1). /// The interpolation parameter. /// The interpolated . - public static ColorRGBA Lerp(ColorRGBA from, ColorRGBA to, float t) => from + FromTo(from, to) * t; + public static ColorRGBA Lerp(ColorRGBA from, ColorRGBA to, float t) + { + int redDiff = to.R - from.R; + int greenDiff = to.G - from.G; + int blueDiff = to.B - from.B; + int alphaDiff = to.A - from.A; + + return from + new ColorRGBA((byte)(redDiff * t), (byte)(greenDiff * t), (byte)(blueDiff * t), (byte)(alphaDiff * t)); + } /// /// Determines whether the specified object is equal to the current .