How to pick the Color code from a position in Android Linear Gradient?

29 Views Asked by At

I am drawing a rectangle with a linear gradient as background color on a Compose Canvas using, drawRect(brush = Brush.horizontalGradient(),topLeft = ,size = ) and it looks like below, Screenshot of gradient

I want to pick the color code from this gradient for an X-coordinate value on the gradient. How can I do that? For example, from the above screenshot the color at position x = 0 should give me color code of Green.

0

There are 0 best solutions below