Skip to content

Instantly share code, notes, and snippets.

@shoaibmushtaq25
Created August 17, 2023 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shoaibmushtaq25/2ed071e6b69fb3a7a2dfd209a03c1656 to your computer and use it in GitHub Desktop.
Save shoaibmushtaq25/2ed071e6b69fb3a7a2dfd209a03c1656 to your computer and use it in GitHub Desktop.
private fun DrawScope.drawCircularProgressIndicator(
startAngle: Float,
sweep: Float,
color: Color,
stroke: Stroke
) {
// To draw this circle we need a rect with edges that line up with the midpoint of the stroke.
// To do this we need to remove half the stroke width from the total diameter for both sides.
val diameterOffset = stroke.width / 2
val arcDimen = size.width - 2 * diameterOffset
drawArc(
color = color,
startAngle = startAngle,
sweepAngle = sweep,
useCenter = false,
topLeft = Offset(diameterOffset, diameterOffset),
size = Size(arcDimen, arcDimen),
style = stroke
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment