RoundedPolygon.fromFeatures constructor
RoundedPolygon.fromFeatures(})
Implementation
factory RoundedPolygon.fromFeatures(
List<Feature> features, {
double centerX = double.nan,
double centerY = double.nan,
}) {
if (features.length < 2) {
throw ArgumentError('Polygons must have at least 2 features.');
}
if (centerX.isNaN || centerY.isNaN) {
final vertices = <double>[];
for (final feature in features) {
for (final cubic in feature.cubics) {
vertices
..add(cubic.anchor0X)
..add(cubic.anchor0Y);
}
}
final center = calculateCenter(vertices);
final cX = centerX.isNaN ? center.x : centerX;
final cY = centerY.isNaN ? center.y : centerY;
return RoundedPolygon._(features, Point(cX, cY));
}
return RoundedPolygon._(features, Point(centerX, centerY));
}