https://kotlinlang.org logo
Title
g

Grigorii Yurkov

11/06/2020, 1:16 PM
How to draw point set on
Canvas
?
drawPoints
doesn't work
i

Igor Demin

11/06/2020, 2:02 PM
Try this:
import androidx.compose.desktop.Window
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.size
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PointMode
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.unit.dp

fun main() {
    Window {
        Canvas(Modifier.size(200.dp)) {
            drawPoints(
                pointMode = PointMode.Points,
                color = Color.Black,
                strokeWidth = 20f,
                cap = StrokeCap.Round,
                points = listOf(
                    Offset(50f, 50f),
                    Offset(100f, 100f)
                )
            )
        }
    }
}
g

Grigorii Yurkov

11/06/2020, 2:06 PM
This almost works. I need to draw exactly 1px point
As far as I understand
drawPoints
is not for this purpose