Skip to content

Instantly share code, notes, and snippets.

@rubenquadros
Created August 25, 2021 19:17
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 rubenquadros/80937b97b8436eac07a7bb8b96e92b25 to your computer and use it in GitHub Desktop.
Save rubenquadros/80937b97b8436eac07a7bb8b96e92b25 to your computer and use it in GitHub Desktop.
Custom path for the shape
fun drawArcPath(size: Size): Path {
return Path().apply {
reset()
// go from (0,0) to (width, 0)
lineTo(size.width, 0f)
// go from (width, 0) to (width, height)
lineTo(size.width, size.height)
// Draw an arch from (width, height) to (0, height)
// starting from 0 degree to 180 degree
arcTo(
rect =
Rect(
Offset(0f, 0f),
Size(size.width, size.height)
),
startAngleDegrees = 0f,
sweepAngleDegrees = 180f,
forceMoveTo = false
)
// go from (0, height) to (0, 0)
lineTo(0f, 0f)
close()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment