From 80e96166303b054d4b3c0d512631ad9b76a2286a Mon Sep 17 00:00:00 2001 From: Francesco Giordana Date: Thu, 31 Mar 2022 12:16:53 -0700 Subject: [PATCH] Fixed case of R == G, following original conversion formula https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB --- crates/bevy_render/src/color/colorspace.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_render/src/color/colorspace.rs b/crates/bevy_render/src/color/colorspace.rs index 43d3f7986f3c8..3e726315d5d40 100644 --- a/crates/bevy_render/src/color/colorspace.rs +++ b/crates/bevy_render/src/color/colorspace.rs @@ -72,9 +72,9 @@ impl HslRepresentation { let lightness = (x_max + x_min) / 2.0; let hue = if chroma == 0.0 { 0.0 - } else if red > green && red > blue { + } else if red == x_max { 60.0 * (green - blue) / chroma - } else if green > red && green > blue { + } else if green == x_max { 60.0 * (2.0 + (blue - red) / chroma) } else { 60.0 * (4.0 + (red - green) / chroma)