Skip to content

Added StableInterpolate implementations for linear colors. #18601

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

Merged
merged 4 commits into from
May 6, 2025

Conversation

mintlu8
Copy link
Contributor

@mintlu8 mintlu8 commented Mar 29, 2025

Objective

Colors currently do not implement StableInterpolate, which makes them ineligible for functions like smooth_nudge and make some generic APIs awkward.

Solution

Implemented StableInterpolate for linear color types that should be uncontroversial. Non-linear types like Hsl are not implemented in this PR.

Testing

Added a test that checks implementations are correct.

@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible X-Uncontroversial This work is generally agreed upon 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 29, 2025
@alice-i-cecile alice-i-cecile added this to the 0.17 milestone Mar 29, 2025
Copy link
Contributor

@greeble-dev greeble-dev left a comment

Choose a reason for hiding this comment

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

Could consider reusing impl_componentwise_vector_space? b8d7c35

#[test]
pub fn test_color_stable_interpolate() {
let b = Srgba::BLACK;
let w = Srgba::WHITE;
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 Is Srgba actually a linear space?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could be wrong but I think the point of color spaces is to use them in a linear space.

Copy link
Contributor

@IQuick143 IQuick143 left a comment

Choose a reason for hiding this comment

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

Seems good, although I'm not personally certain about the impls other than LinearRgba.

@JaySpruce JaySpruce 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 S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Mar 29, 2025
@NthTensor
Copy link
Contributor

This isn't the place to get into it I guess, but I'm increasingly of the feeling that the color types shouldn't implement VectorSpace and if you want to do color math, use to_vec4 and from_vec4.

That said, all of the colors can still actually implement StableInterpolate I think. So I guess this is fine. I'm working on something that will make some more significant changes here.

@alice-i-cecile alice-i-cecile added this pull request to the merge queue May 5, 2025
Merged via the queue into bevyengine:main with commit 8184591 May 6, 2025
34 checks passed
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.

6 participants