boundingBox property

Rect get boundingBox

Get the bounding box of the lasso

Implementation

Rect get boundingBox {
  if (points.isEmpty) return Rect.zero;

  double minX = points.first.dx;
  double maxX = points.first.dx;
  double minY = points.first.dy;
  double maxY = points.first.dy;

  for (final point in points) {
    if (point.dx < minX) minX = point.dx;
    if (point.dx > maxX) maxX = point.dx;
    if (point.dy < minY) minY = point.dy;
    if (point.dy > maxY) maxY = point.dy;
  }

  return Rect.fromLTRB(minX, minY, maxX, maxY);
}