Member-only story
Draw an Oval With Canvas In Jetpack Compose.
1 min readMay 3, 2024
In this article we will see how to draw an oval with Canvas in Jetpack Compose.
I have already written few articles on canvas.
To draw an oval , you need two things ,
Canvas
Composable functiondrawOval()
function
@Composable
fun DrawOval() {
Canvas(modifier = Modifier.fillMaxSize()) {
val width = size.width
val height = size.height
drawOval(
color = Color.Red,
topLeft = Offset(width / 2, height / 2),
style = Stroke(width = 10f),
size = Size(300f,500f)
)
}
}
As you can see above , we called Canvas
Composable function and provide the full size to the screen.
And also given the color , topLeft(position to draw oval) , stroke and size of the oval.
That’s all for today’s my friends , Hope you enjoyed and learnt something new from this article.