Skip to content

Add Okhwba color space#24950

Open
tmstorey wants to merge 1 commit into
bevyengine:mainfrom
tmstorey:okhwba
Open

Add Okhwba color space#24950
tmstorey wants to merge 1 commit into
bevyengine:mainfrom
tmstorey:okhwba

Conversation

@tmstorey

@tmstorey tmstorey commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Objective

Bevy has multiple Ok color spaces and the HWB color space, but not the Okhwb color space. This would be good for consistency, and also useful for supporting triangular color pickers, such as an Ok color space version of the HWB picker in my other PR: #24917.

Solution

  • Adds Okhwba color space struct, with new, hwb, with_whiteness and with_blackness methods.
  • Derives Debug, Clone, Copy, PartialEq, Reflect, and serialization.
  • Implements StandardColor, Default, Mix, Gray, Alpha, Hue, ColorToComponents and various From impls.
  • Adds Color::Okhwba(Okhwba) enum variant, and Color::okhwba() and Color::okhwb() constructors.
  • Updates conversion diagram MMD and SVG.

Testing

  • Tests mostly copied from Okhsva.
  • Tests using gen_tests and TEST_COLORS not yet implemented.
  • All current tests pass.

Showcase

New conversion diagram:

model_graph

@kfc35 kfc35 added C-Feature A new feature, making something new possible D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward A-Color Color spaces and color math labels Jul 12, 2026

@kfc35 kfc35 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you planning to do the gen_tests changes in this PR as well? the description mentions it but it’s not clear whether this PR is waiting for that

Beyond that, this PR looks mostly good except for the one thing re: testing okhsva <-> okhwba conversion I mentioned

use crate::testing::assert_approx_eq;

#[test]
fn test_from_oklaba() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this being copied from okhsva as is, I would think there needs to be a thorough test like this one that ensures the conversion between okhwba and okhsva is as expected, since that’s the new logic implemented in this module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Color Color spaces and color math C-Feature A new feature, making something new possible D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants