Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting Okhsva color where the value is 0.0 to Srgba results in all components being NaN. #330

Closed
akhudek opened this issue May 17, 2023 · 2 comments · Fixed by #332
Closed
Labels
defect Something that isn't as or doesn't work as intended

Comments

@akhudek
Copy link

akhudek commented May 17, 2023

When converting from Okhsva to Srgba using the clamped into_color with a color that has zero value, you get NaN for the Srgb components. I would expect this to return black. If the Okhsva value is even slightly non-zero it works as expected.

How To Reproduce

use palette::{IntoColor, Okhsva, Srgba};
let mut c: Okhsva = Srgba::new(255u8, 0, 0, 255).into_format().into_color();
c.value = 0.0;
let c2: Srgba<f32> = c.into_color();
println!("c2 {:?}", c3);

Expected Outcome

c2 should represent black.

Actual Outcome

All components of c2 are NaN.

Additional Details

Using palette 0.7.1;

@akhudek akhudek added the defect Something that isn't as or doesn't work as intended label May 17, 2023
@Ogeon
Copy link
Owner

Ogeon commented May 18, 2023

Sounds like a divide by 0 somewhere. Thanks for reporting!

@Ogeon
Copy link
Owner

Ogeon commented May 21, 2023

The fix has been released in 0.7.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Something that isn't as or doesn't work as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants