Probably a silly question... but is there some way...
# compose
c
Probably a silly question... but is there some way to improve the look of this gradient? color = Brush.horizontalGradient( colors = listOf(Color.Red, Color.White, Color.Blue) ) To me it looks like the middle color in the gradient is showing "less" than the others. Is this just a weird thing about gradients in general, or am I misusing them in compose somehow?
🚔 3
s
Add more steps in the middle: red, white, white, blue. Or, specify color stops with percentage of distribution https://developer.android.com/develop/ui/compose/graphics/draw/brush#color-stops
val colorStops = arrayOf( 0.25f to Color.Red, 0.5f to Color.White, 0.25f to Color.Blue ) IDK 😄
💯 1
r
You're not using them wrong, it's just a perception issue (mostly caused by the fact gradients are interpolated in nonlinear space)
❤️ 1
y
IIRC for animation the color space affects things, and is swappable? but I assume not for gradient?
r
Not for gradients. I tried years ago but it causes many compatibility issues
Animations interpolate in oklab space
Btw I wrote an example of a gradient in a different color space yesterday: https://gist.github.com/romainguy/141e5b04e00f99140f48865546bb0d73
❤️ 2
🏳️‍🌈 3