How to draw point set on `Canvas`? `drawPoints` do...
# compose-desktop
g
How to draw point set on
Canvas
?
drawPoints
doesn't work
i
Try this:
Copy code
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
This almost works. I need to draw exactly 1px point
As far as I understand
drawPoints
is not for this purpose