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

bevy_color::Color convenience methods #12171

Merged

Conversation

alice-i-cecile
Copy link
Member

Objective

As suggested in #12163 by @cart, we should add convenience constructors to bevy_color::Color to match the existing API (easing migration pain) and generally improve ergonomics.

Solution

  • Add const fn Color::rgba(red, green, blue, alpha) and friends, which directly construct the appropriate variant.
  • Add const fn Color::rgb(red, green, blue) and friends, which impute and alpha value of 1.0.
  • Add const BLACK, WHITE, NONE to Color. These are stored in LinearRgba to reduce pointless conversion costs and inaccuracy.
  • Changed the default Color from Srgba::WHITE to the new linear equivalent for the same reason.

@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen C-Usability A simple quality-of-life change that makes Bevy easier to use labels Feb 27, 2024
@alice-i-cecile alice-i-cecile added this to the 0.14 milestone Feb 27, 2024
Copy link
Contributor

@pablo-lua pablo-lua left a comment

Choose a reason for hiding this comment

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

Nice little const methods, for sure will make the migration easier

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Feb 28, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Feb 28, 2024
@alice-i-cecile
Copy link
Member Author

Thanks for the quick reviews! Now I can go rebase #12163 on this and use it :D

Merged via the queue into bevyengine:main with commit 9ae5ba2 Feb 28, 2024
29 checks passed
@BD103 BD103 added the A-Color Color spaces and color math label May 3, 2024
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 A-Rendering Drawing game state to the screen C-Usability A simple quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants