How to draw an arc with rounded edges in Android?

Viewed 98

I tried to implement a simple pie chart and was faced with the following problem - I need to make the edges of the sector rounded as it's shown in the image

enter image description here

Searched for some examples, found that it's possible to achieve by setting a cap. But as I can see, it's possible to set the cap only for stroke style, while I use the fill. can someone help me to solve the problem? here's the way how my view looks like:

enter image description here

Here's the code:

@Composable
fun PieChart(modifier: Modifier, progress: Double) {
    Canvas(modifier = Modifier.then(modifier)) {
        drawCircle(
            color = Color.White,
            radius = 130F,
            center = Offset(150F, 150F)
        )
        drawArc(
            brush = Brush.horizontalGradient(SecondaryGradient),
            startAngle = -90F,
            sweepAngle = (360 * progress / 100).toFloat(),
            useCenter = true,
            size = Size(300F, 300F),
        )
    }
}

Thanks in advance for any help!

0 Answers
Related