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.
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,Hslacolor 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 = LinSrgbaBy default the renderer should operate in the linear color space so we define the
Colortype to be in this same space, to avoid any unnecessary conversions;LinSrgbaandSrgba,I just used a python script to convert the color constants between each space;