Draw an Oval With Canvas In Jetpack Compose.

Jayant Kumar🇮🇳
1 min readMay 3, 2024
Photo by Andy White on Unsplash

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 function
  • drawOval() 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.

--

--

Jayant Kumar🇮🇳

Hello , My name is Jayant, I am a tech youtuber and software Engineer from India 🇮🇳