From 816d6e18460e4192a0cde6dac55058a2f5cf6a18 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Tue, 31 Mar 2026 23:11:42 +0300 Subject: [PATCH] fix: color lerping not working properly --- Engine.Core/Primitives/ColorRGB.cs | 6 +++++- Engine.Core/Primitives/ColorRGBA.cs | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Engine.Core/Primitives/ColorRGB.cs b/Engine.Core/Primitives/ColorRGB.cs index cd93a23..afcc5e7 100644 --- a/Engine.Core/Primitives/ColorRGB.cs +++ b/Engine.Core/Primitives/ColorRGB.cs @@ -95,7 +95,11 @@ public readonly struct ColorRGB(byte r, byte g, byte b) : IEquatable int greenDiff = to.G - from.G; int blueDiff = to.B - from.B; - return new((byte)(from.R - redDiff * t), (byte)(from.G - greenDiff * t), (byte)(from.B - blueDiff * t)); + return new( + (byte)(from.R + redDiff * t), + (byte)(from.G + greenDiff * t), + (byte)(from.B + blueDiff * t) + ); } /// diff --git a/Engine.Core/Primitives/ColorRGBA.cs b/Engine.Core/Primitives/ColorRGBA.cs index c8be913..ce14ac8 100644 --- a/Engine.Core/Primitives/ColorRGBA.cs +++ b/Engine.Core/Primitives/ColorRGBA.cs @@ -1,4 +1,5 @@ using System; +using Engine.Core.Debug; namespace Engine.Core; @@ -125,7 +126,12 @@ public readonly struct ColorRGBA(byte r, byte g, byte b, byte a = 255) : IEquata int blueDiff = to.B - from.B; int alphaDiff = to.A - from.A; - return new((byte)(from.R - redDiff * t), (byte)(from.G - greenDiff * t), (byte)(from.B - blueDiff * t), (byte)(from.A - alphaDiff * t)); + return new( + (byte)(from.R + redDiff * t), + (byte)(from.G + greenDiff * t), + (byte)(from.B + blueDiff * t), + (byte)(from.A + alphaDiff * t) + ); } ///