randomPoint method
Returns a random point within the shape if within
is true (default) and
otherwise a point along the edges of the shape.
Do note that within
=true also includes the edges.
If isClosed is false, the within
value does not make a difference.
Implementation
@override
Vector2 randomPoint({Random? random, bool within = true}) {
final randomGenerator = random ?? randomFallback;
if (within) {
return Vector2(
left + randomGenerator.nextDouble() * width,
top + randomGenerator.nextDouble() * height,
);
} else {
return Polygon.randomPointAlongEdges(vertices, random: randomGenerator);
}
}