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

Add Saturation trait to bevy_color #18202

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

boondocklabs
Copy link

Objective

  • Allow for convenient access and mutation of color saturation providing following the Hue, Luminance traits.

  • with_saturation() builder method

  • saturation() to get the saturation of a Color

  • set_saturation() to set the saturation of a mutable Color

Solution

  • Defined Saturation trait in color_ops.rs
  • Implemented Saturation on Hsla and Hsva
  • Implemented Saturation on Color which proxies to other color space impls.
  • In the case of colorspaces which don't have native saturation components
    the color is converted to 'Hsla` internally

Testing

  • Empirically tested

Showcase

fn next_golden(&mut self) -> Color {
    self.current
        .rotate_hue((1.0 / GOLDEN_RATIO) * 360.0)
        .with_saturation(self.rand_saturation())
        .with_luminance(self.rand_luminance())
        .into()
}

commit 0318021
Author: boondockenergy <[email protected]>
Date:   Sat Mar 8 12:39:07 2025 -0800

    Implement Saturation on Color

commit 789bfcd
Author: boondockenergy <[email protected]>
Date:   Sat Mar 8 11:56:33 2025 -0800

    Add Saturation trait to color_ops, implement on Hsla and Hsva
@IQuick143 IQuick143 added C-Feature A new feature, making something new possible D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward A-Color Color spaces and color math labels Mar 8, 2025
@alice-i-cecile alice-i-cecile added M-Needs-Release-Note Work that should be called out in the blog due to impact X-Uncontroversial This work is generally agreed upon labels Mar 8, 2025
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed M-Needs-Release-Note Work that should be called out in the blog due to impact S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Mar 8, 2025
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-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Uncontroversial This work is generally agreed upon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants