How to add gradient for drawArc composable?... Cu...
# compose
s
How to add gradient for drawArc composable?... Currently code works fine without brush argument.
t
You need to create a Brush with a sweepGradient:
Copy code
val gradientBrush = Brush.sweepGradient(listOf(lightColor, darkColor))
🙌 1
Pass that into drawArc
Copy code
drawArc(
        brush = gradientBrush,
        startAngle = ...,
        sweepAngle = ...,
        useCenter = ...,
        style = ...
    )
If you want more than 2 colors, you will have to use the overload that takes in
colorStops
Copy code
val gradientBrush = Brush.sweepGradient(
    0.0f to Color...,
    0.3f to Color....,
    1.0f to Color....,
    center = Offset(0.0f, 100.0f)
)
1
s
Works perfect 👍 , Thanks buddy
👍🏼 1