How to construct a Path for a polygon from a list of point?
Copy code
val path = Path().apply {
moveTo(polygon[0].x, polygon[0].y)
polygon.drop(1).forEach { point -> lineTo(point.x, point.y) }
close()
}
I have this, but it feels very overcomplicated for what it is, I'd expect a constructor that takes a list of points.
r
romainguy
05/17/2024, 2:45 PM
It's not complicated? And the way to do it.
m
Marcin Wisniowski
05/17/2024, 2:51 PM
If that's the intended way, then all good then! I had a feeling it's not the optimal way since it looks like I'm mutating the object for every point separately instead of adding them all at once.