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

[f32; 4] conversions missing from bevy_color #13224

Closed
tychedelia opened this issue May 4, 2024 · 3 comments · Fixed by #13276
Closed

[f32; 4] conversions missing from bevy_color #13224

tychedelia opened this issue May 4, 2024 · 3 comments · Fixed by #13276
Labels
A-Color Color spaces and color math C-Usability A simple quality-of-life change that makes Bevy easier to use D-Trivial Nice and easy! A great choice to get started with Bevy X-Uncontroversial This work is generally agreed upon
Milestone

Comments

@tychedelia
Copy link
Contributor

What problem does this solve or what need does it fill?

Previously, we supported lots of operations back and forth from [f32; 4] that are currently missing with the exception of to_f32_array on LinearRgba. Non-engine code sometimes needs to access these for other color spaces. The last one I ran into I believe was using Lcha with lyon for Nannou. Other libraries like egui also sometimes supply or expect these in their raw form.

See the old docs

What solution would you like?

A trait or method impls to support -> [f32; 4] as well as From<[f32; 4]>.

@tychedelia tychedelia added C-Enhancement A new feature S-Needs-Triage This issue needs to be labelled labels May 4, 2024
@alice-i-cecile alice-i-cecile added D-Trivial Nice and easy! A great choice to get started with Bevy C-Usability A simple quality-of-life change that makes Bevy easier to use X-Uncontroversial This work is generally agreed upon A-Color Color spaces and color math and removed C-Enhancement A new feature S-Needs-Triage This issue needs to be labelled labels May 4, 2024
@alice-i-cecile alice-i-cecile added this to the 0.14 milestone May 4, 2024
@alice-i-cecile
Copy link
Member

These should probably be methods rather than a trait as the semantic meaning is different for each color space.

@BD103
Copy link
Member

BD103 commented May 5, 2024

It may also be handy to implement conversion from a [f32; 3] as well, where the alpha channel defaults to 1.0.

@moonlightaria
Copy link
Contributor

i'll start on this and see how far i can go

github-merge-queue bot pushed a commit that referenced this issue May 9, 2024
# Objective
fixes #13224
adds conversions for Vec3 and Vec4 since these appear so often

## Solution
added Covert trait (couldn't think of good name) for [f32; 4], [f32, 3],
Vec4, and Vec3 along with the symmetric implementation

## Changelog
added conversions between arrays and vector to colors and vice versa

#migration
LinearRgba appears to have already had implicit conversions for [f32;4]
and Vec4
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-Usability A simple quality-of-life change that makes Bevy easier to use D-Trivial Nice and easy! A great choice to get started with Bevy X-Uncontroversial This work is generally agreed upon
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants