AuthoredPathOutline.fromNormalized constructor
AuthoredPathOutline.fromNormalized(
- DiagramRect bounds,
- Iterable<
DiagramPoint> normalizedPoints, { - List<
double> widths = const [], - double strokeWidth = 0,
- InkPreset preset = InkPreset.pen,
Implementation
factory AuthoredPathOutline.fromNormalized(
DiagramRect bounds,
Iterable<DiagramPoint> normalizedPoints, {
List<double> widths = const [],
double strokeWidth = 0,
InkPreset preset = InkPreset.pen,
}) {
final points = normalizedPoints.toList(growable: false);
if (points.length < 2 ||
points.any(
(point) =>
!point.x.isFinite ||
!point.y.isFinite ||
point.x < 0 ||
point.x > 1 ||
point.y < 0 ||
point.y > 1,
)) {
throw StateError(
'Authored path points must contain at least two finite unit points.',
);
}
final resolved = [
for (final point in points)
DiagramPoint(
bounds.left + bounds.width * point.x,
bounds.top + bounds.height * point.y,
),
];
final hull = DiagramInkOutline.resolve(
resolved,
widths,
strokeWidth,
preset: preset,
);
final extent = hull.isEmpty
? bounds
: DiagramRect.fromPoints([...bounds.corners, ...hull]);
return AuthoredPathOutline(extent, resolved, inkHull: hull);
}