Skip to content

Instantly share code, notes, and snippets.

@titoaesj
Created September 21, 2021 15:05
Show Gist options
  • Save titoaesj/44d3343afce22e27676511dc2790bf7c to your computer and use it in GitHub Desktop.
Save titoaesj/44d3343afce22e27676511dc2790bf7c to your computer and use it in GitHub Desktop.
class CustomArcShape : Shape {
override fun createOutline(
size: Size,
layoutDirection: LayoutDirection,
density: Density
): Outline {
return Outline.Generic(
path = drawArcPath(size = size)
)
}
private fun drawArcPath(size: Size): Path {
return Path().apply {
reset()
lineTo(size.width, 0f)
lineTo(size.width, size.height)
lineTo(0f, size.height)
lineTo(0f, 0f)
// 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
// )
close()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment