How can I get a Color that is x% on the way betwee...
# compose
m
How can I get a Color that is x% on the way between Color A and Color B? I want the same behavior as
animateColorAsState()
except there is no animation, I just want a fixed value that would be there, say, 50% through the animation.
same name as every the linear interpolator function on every other compose type
m
Just as I finished implementing my own 😄 I looked for "lerp" on the Color class, didn't know it would just be a global function, thanks!
z
If you’re using your own, make sure to use the oklab color space
a
Any reason why the default srgb shouldn't be used? Might as well change defaults then.
r
sRGB doesn't interpolate colors very well, notably losing luminance
Linear sRGB is an improvement but still shows luminance/hue skews that OkLab improves upon
It's not perfect either but much much better
Compose's lerp () will use OkLab
Here's a good example:
Image from iOS.jpg
mind blown 3
a
Oh that's very interesting. Thanks!
121 Views