shapeBoundingBox property

  1. @override
PRectangle get shapeBoundingBox
override

Implementation

@override
PRectangle get shapeBoundingBox {
  List<Point> ps = [];

  var pathPoints2 = pathPoints;
  final length = pathPoints2.length;

  for (var i = 0; i < length; ++i) {
    var e = pathPoints2[i];

    if (e is num) {
      var x1 = e;
      var y1 = pathPoints2[++i] as num;

      ps.add(Point(x1, y1));
    } else if (e is Point) {
      ps.add(e);
    } else if (e is List<num>) {
      var cubic = e.toList(growable: false);
      assert(cubic.length == 6);

      ps.add(Point(cubic[0], cubic[1]));
      ps.add(Point(cubic[2], cubic[3]));
      ps.add(Point(cubic[4], cubic[5]));
    }
  }

  var boundingBox =
      ps.boundingBox ?? (throw StateError("Empty `pathPoints`"));
  return boundingBox;
}