Member-only story

Draw Points With Canvas In Jetpack Compose.

Jayant Kumar🇮🇳
2 min readMay 3, 2024

--

Photo by Katie McNabb on Unsplash

In this article we will see how to draw points with Canvas in Jetpack Compose.

I have already written few articles on canvas.

To draw points, you need two things ,

  • Canvas Composable function
  • drawPoints() function
@Composable
fun DrawPoints() {

Canvas(
modifier = Modifier
.padding(30.dp)
.fillMaxWidth()
.height(300.dp)
) {
val width = size.width
val height = size.height
drawPoints(
points = listOf(
Offset(width / 2, 0f),
Offset(width / 2, height / 2),
Offset(width / 2, height)
),
pointMode = PointMode.Points,
color = Color.Red,
strokeWidth = 50f,
cap = StrokeCap.Round
)
}
}

As you can see above , we called Canvas Composable function and also provide width and height.

First it will take list of point’s positions in points parameter . Also provided the color and…

--

--

Jayant Kumar🇮🇳
Jayant Kumar🇮🇳

Written by Jayant Kumar🇮🇳

Hello My name is Jayant Kumar, I am a software Engineer , specialist in Mobile Development (Android , IOS , Flutter , React Native and Ionic) from India 🇮🇳

No responses yet