-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
LinSrgba, Srgba and Hsla color types #1870
Conversation
I made this PR, because I really want to animate colors and to make easier to test out this approach (which, I think is the best), so nothing is set stone. I think roiling with our own type is simpler because we can implement any conversions or traits we want; If you notice I aligned the colors to 16 bytes so they can be ready to use with simd instructions (SSE2), thats because I assumed everything have a alpha, and that is not something I saw in any other crate; Plus I'm thinking in using the |
Sound good to me, I would just like to avoid a breaking change in colors in 0.6 and in 0.7. But even that is not a blocker, we offer no guarantee on that... Breaking twice before 0.6 should be ok. @kabergstrom when do you feel |
I think it's getting there, I added HSV/HSI/HSL, ICtCp and CIELuv this weekend. Did some more work on the docs. What would you like to see in the library? |
I'm blocked by some animator system stuff before I can do some more testing about colors. Do way I think adding using kolor won't break anything, will just add more color types; |
return self; | ||
} | ||
|
||
if self <= 0.0031308 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For floating-point equality checks, should we be using some sort of epsilon
or a different crate like float-cmp
?
#4648 contains further design direction on color. It's probably going to be easier to start from scratch, but I'll leave that decisison to you. |
Superseded by #12013 |
The bevy 0.5 made colors operations undefined, this directly affects our ability to animate any color property.
There is a ongoing discussion here about this.
So this PR does the following:
LinSrgba
,Srgba
,Hsla
color types.Using colors as types allows for predictable behaviour, easer readability, compile time optimizations:
When conversions from SRGB to HSL and back to SRGB are done often, cache the HSL;
type Color = LinSrgba
By default the renderer should operate in the linear color space so we define the
Color
type to be in this same space, to avoid any unnecessary conversions;LinSrgba
andSrgba
,I just used a python script to convert the color constants between each space;