Created
September 21, 2021 15:05
-
-
Save titoaesj/44d3343afce22e27676511dc2790bf7c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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