scatter

fun ShapeProvider.scatter(placementRadius: Double, objectRadius: Double = placementRadius, distanceToEdge: Double = 0.0, tries: Int = 30, obstacles: List<Pair<Double, List<Vector2>>> = emptyList(), random: Random = Random.Default): List<Vector2>(source)

Returns a list of 2D points contained in the ShapeProvider. The algorithm iterates a maximum of tries times trying to find points that maintain the separation to each other specified via placementRadius while keeping a distanceToEdge distance to the contour of the shape.

It is possible to include obstacles to avoid. The optional list of obstacles contains pairs, each pair has a radius and a list of 2D locations. objectRadius defines a margin to keep around the obstacles.