Fixed case of R == G, following original conversion formula (#4383)

https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB

# Objective
Fixes #4382

## Solution

- Describe the solution used to achieve the objective above.
Fixed conversion formula to account for red and green component being max and equal
---

## Changelog
Fixed RGB -> HSL colorspace conversion

## Migration Guide


Co-authored-by: Francesco Giordana <fgiordana@netflix.com>
This commit is contained in:
Francesco Giordana 2022-04-04 18:59:00 +00:00
parent 28d0a40028
commit dbd5e7ab6b

View File

@ -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)