Conversation
| impl From<LinearRgba> for Color { | ||
| fn from(lin: LinearRgba) -> Self { | ||
| let srgb: Srgba = lin.into(); | ||
| srgb.into() | ||
| } | ||
| } | ||
|
|
||
| impl From<Srgba> for Color { | ||
| fn from(srgb: Srgba) -> Self { |
There was a problem hiding this comment.
this was surprising to me! Isn't From<T> the way to handle generally?
There was a problem hiding this comment.
Mmm, probably a more stylistic thing but before we were saying a color is ALWAYS a srgb repr and now it's more just like, this is one way you can construct a color? Since all the specific color spaces impl Into<bevy::Color> we could probably impl From<bevy::Color> for our color and it would probably "just work"
catilac
left a comment
There was a problem hiding this comment.
left question but i think this looks good! I like the interface of tuples to structured color object, and being able to pass a specific color space explicitly
|
|
||
| impl From<Srgba> for Color { | ||
| fn from(srgb: Srgba) -> Self { | ||
| pub fn from_linear(lin: LinearRgba) -> Self { |
There was a problem hiding this comment.
Is the idea we would implement this for every color space?
There was a problem hiding this comment.
This is just a specific helper because some operations like GPU readback return raw bytes in a linear format.
Adds support for "color mode", see p5 and processing.
This is a bit weird and partly legacy cruft. The key contention here is about this question of scaling, i.e. the "max" positional args. It seems, historically, this was used to switch between 8bit and 0-1 normalized color values (despite the fact that everything in Processing is 8-bit internally). However, p5 also demonstrates using it just to set an arbitrary range. I cannot for the life of me understand why / when this latter use case would be helpful, but it exists.
Internally, everything in our core just uses Bevy color which is floats.
Here's basically our current logic as expressed in this PR for a given Python method
foowhich accepts a color:foo(1.0, 1.0, 1.0, 1.0)uses the configuredColorMode, by default sRGB.foo(1.0)orfoo(1.0, 1.0)maps to grayscale and scales usingColorMode.foo(vec4(...))orfoo(vec4(..))same as above but using vec instances.foo(255, 255, 255, 255)(i.e. ints) uses the configuredColorModeand is scaled to a normalized float internally.foo(oklch(...))uses the providedColorinstance and is considered to be fully resolved, i.e. it does not observe the configured color mode.