Add Okhsla and Okhsva to bevy_color#24137
Open
beicause wants to merge 12 commits into
Open
Conversation
6c8ca57 to
d812c36
Compare
d812c36 to
27efc4b
Compare
a913df2 to
d6d3385
Compare
dadf965 to
9f36128
Compare
…ting (#4) The pre-compute results for testing is from `node colorconversion.js` with increased Halley steps: [colorconversion.js.zip](https://github.com/user-attachments/files/27423193/colorconversion.js.zip) Use `libm`'s `cbrtf` implemention to fix windows testing
beicause
commented
May 6, 2026
Comment on lines
+516
to
+523
| // Note: This is copied from `libm` to fix precision issue on Windows CI testing. | ||
|
|
||
| const B1: u32 = 709958130; /* B1 = (127-127.0/3-0.03306235651)*2**23 */ | ||
| const B2: u32 = 642849266; /* B2 = (127-127.0/3-24/3-0.03306235651)*2**23 */ | ||
| /// Cube root (f32) | ||
| /// | ||
| /// Computes the cube root of the argument. | ||
| pub(crate) fn libm_cbrtf(x: f32) -> f32 { |
Member
Author
There was a problem hiding this comment.
I had to use libm's cbrtf for oklab, okhsl and okhsv, otherwise the error is too large on Windows and the tests would fail. See also beicause#4
viridia
approved these changes
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Fixes #17650. May help with #24118.
Solution
Implement okhsl and okhsv according to ok_color.h and add them to
bevy_color.For tests, the okhsl and okhsv values of test colors are pre-computed via colorconversion.js.zip
TODO:
libmisn't enabled by usinglibm_cbrtfTesting
cargo test -p bevy_color