bevy
bevy copied to clipboard
Added a Grey trait, and implementations on baked-in colors. Fixes #13206
Added a Grey trait to allow colors to create a generic "grey" color.
This currently assumes the color spaces follow the same gradient, which I'm pretty sure isn't true, but it should make a "grey-ish" color relative to the provided intensity.
Objective
- Implements #13206
Solution
- A small
Grey
trait was added and implemented for the common color kinds.
Testing
- Currently untested, unit tests exposed the non-linear relation between colors. I am debating adding an example to show this, as I have no idea what color space represents what relation of grey, and I figure others may be similarly confused.
Changelog
- The
Grey
trait was added, and the correspondinggrey
BREAKING CHANGES
The const qualifier for LinearRGBA::gray was removed (the symbol still exists via a trait, it's just not const anymore)
Some colors have const fn gray()
already. The old method should probably be removed if this trait is kept, though currently trait methods are non-const
.
Probably a good idea to include a little generic test.
I added a test to verify all the different colors implement white and black as gray(1)
and gray(0)
respectively.
I'm very tempted to add a trait for approximate equality on colors now, but for now this works. It's not approximate, so it may be error prone, but it seems to work for now...
@Earthmark could you resolve the merge conflicts? I'll merge this in as soon as you do.
Will do. I'll get the conflicts resolved later today, and verify this is in prelude.
I forgot about this for a few days, but now it's here!
Thanks!