boundingBox方法

Rectangle<num> boundingBox(
  1. Rectangle<num> other
)

返回一个包含thisother的新矩形。

实现

Rectangle<num> boundingBox(Rectangle<num> other) {
  var right = max(this.left + this.width, other.left + other.width);
  var bottom = max(this.top + this.height, other.top + other.height);

  var left = min(this.left, other.left);
  var top = min(this.top, other.top);

  return new Rectangle<num>(left, top, right - left, bottom - top);
}