You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#[cfg(test)]
mod test {
use bevy::prelude::*;
const EPSILON: f32 = 0.0001;
fn are_equal(a: &[f32; 4], b: &[f32; 4]) -> bool {
for i in 0..4 {
if (a[i] - b[i]).abs() > EPSILON {
return false;
}
}
true
}
#[test]
fn test_hsl() {
for r in 0..255 {
for g in 0..255 {
for b in 0..255 {
let c_rgba = Color::rgba(r as f32 / 255.0, g as f32 / 255.0, b as f32 / 255.0, 1.0);
let c_hsla = c_rgba.as_hsla();
if !are_equal(&(c_rgba.as_rgba_f32()), &(c_hsla.as_rgba_f32())) {
panic!("colors are different: {:?}, {:?}\n{:?}, {:?}", c_rgba, c_hsla, c_rgba.as_rgba_f32(), c_hsla.as_rgba_f32());
}
}
}
}
}
}
What you expected to happen
The test should be successful. There is an error in the conversion formula when the R and G components are the same
…ne#4383)
https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB
# Objective
Fixesbevyengine#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]>
ItsDoot
pushed a commit
to ItsDoot/bevy
that referenced
this issue
Feb 1, 2023
…ne#4383)
https://en.wikipedia.org/wiki/HSL_and_HSV#From_RGB
# Objective
Fixesbevyengine#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]>
Bevy version
commit 5e6400a
Operating system & version
macOS 12.2.1 on MBP 2021, Apple M1 Max
What you did
What you expected to happen
The test should be successful. There is an error in the conversion formula when the R and G components are the same
What actually happened
thread 'scene::test::test_hsl' panicked at 'colors are different: Rgba { red: 0.003921569, green: 0.003921569, blue: 0.0, alpha: 1.0 }, Hsla { hue: 240.0, saturation: 1.0, lightness: 0.0019607844, alpha: 1.0 }
[0.003921569, 0.003921569, 0.0, 1.0], [2.3283064e-10, 2.3283064e-10, 0.0039215684, 1.0]'
Additional information
There is an error in the conversion formula, it should actually be:
The text was updated successfully, but these errors were encountered: