fitted method

UDocShape fitted(
  1. Rect target
)

Scales the shape so its bounds become target.

Implementation

UDocShape fitted(Rect target) {
  final Rect from = bounds;
  final double sx = from.width.abs() < 1e-6 ? 1 : target.width / from.width;
  final double sy = from.height.abs() < 1e-6 ? 1 : target.height / from.height;
  return copyWith(points: points.map((Offset point) => Offset(target.left + (point.dx - from.left) * sx, target.top + (point.dy - from.top) * sy)).toList());
}