Skip to content

Commit

Permalink
Fixed case of R == G, following original conversion formula (bevyengi…
Browse files Browse the repository at this point in the history
…ne#4383)

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

# Objective
Fixes bevyengine#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 <[email protected]>
  • Loading branch information
2 people authored and ItsDoot committed Feb 1, 2023
1 parent 1a30cd1 commit 52e8d20
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_render/src/color/colorspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 52e8d20

Please sign in to comment.