boundingBox property

  1. @override
Rectangle get boundingBox
override

The smallest axis-aligned rectangle that completely encloses the shape.

Implementation

@override
Rectangle get boundingBox {
  final minX = math.min(p1.x, math.min(p2.x, p3.x)).toDouble();
  final maxX = math.max(p1.x, math.max(p2.x, p3.x)).toDouble();
  final minY = math.min(p1.y, math.min(p2.y, p3.y)).toDouble();
  final maxY = math.max(p1.y, math.max(p2.y, p3.y)).toDouble();

  return Rectangle(
    width: maxX - minX,
    height: maxY - minY,
    center: Point(x: (minX + maxX) / 2, y: (minY + maxY) / 2)
  );
}