From bc5146142769f36a8c6ef7a420b99a3abab8b3cc Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 3 Jul 2021 15:02:51 +0100 Subject: [PATCH] Make sure the hue returned by Color.RgbToHsv is positive. --- OpenRA.Game/Primitives/Color.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OpenRA.Game/Primitives/Color.cs b/OpenRA.Game/Primitives/Color.cs index 2e3a30dc47..a8ebec609d 100644 --- a/OpenRA.Game/Primitives/Color.cs +++ b/OpenRA.Game/Primitives/Color.cs @@ -151,6 +151,11 @@ namespace OpenRA.Primitives hue = (r - g) / (6 * delta) + 2 / 3f; var h = hue - (int)hue; + + // Wrap negative values into [0-1) + if (h < 0) + h += 1; + var s = delta / rgbMax; return (h, s, v); }