Polygon.fromPath constructor
Constructs the polygon from the given contour of a Path
(the first by default).
A polygon only has straight edges, so the curves of the path are
approximated. The contour is sampled every sampling along its length,
and the samples that are not needed to stay within about half of the
sampling of the contour are left out. Higher values give fewer vertices
and a looser fit, while straight stretches and the corners between them
are exact whatever the sampling is. The given tolerance decides
what samples to discard: by default, its value is half the sampling.
See PathMetricExtension.walkContour for the details of the sampling
and tolerance parameters.
Implementation
factory Polygon.fromPath(
Path path, {
int contour = 0,
double sampling = 1.0,
double? tolerance,
}) {
return Polygon(path.walkContourAt(contour, sampling, tolerance).vertices);
}