PolygonComponent.fromPath constructor
PolygonComponent.fromPath(})
With this constructor you create a PolygonComponent from the given
contour (the first by default) of a Path.
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
PolygonComponent.fromPath(
Path path, {
int contour = 0,
double sampling = 1.0,
double? tolerance,
Vector2? position,
Vector2? scale,
double? angle,
Anchor? anchor,
int? priority,
Paint? paint,
List<Paint>? paintLayers,
bool? shrinkToBounds,
bool isSolid = false,
ComponentKey? key,
List<Component>? children,
}) : this(
path.walkContourAt(contour, sampling, tolerance).vertices,
position: position,
angle: angle,
anchor: anchor,
scale: scale,
priority: priority,
paint: paint,
paintLayers: paintLayers,
shrinkToBounds: shrinkToBounds ?? true,
isSolid: isSolid,
key: key,
children: children,
);