MutableRectangle.fromPoints factory constructor

MutableRectangle.fromPoints(Point<T> a, Point<T> b)

Create a mutable rectangle spanned by the points a and b;

The rectangle contains the points with x-coordinate between a.x and b.x, and with y-coordinate between a.y and b.y, both inclusive.

If the distance between a.x and b.x is not representable (which can happen if one or both is a double), the actual right edge might be slightly off from max(a.x, b.x). Similar for the y-coordinates and the bottom edge.

Source

factory MutableRectangle.fromPoints(Point<T> a, Point<T> b) {
  T left = min(a.x, b.x);
  T width = max(a.x, b.x) - left;
  T top = min(a.y, b.y);
  T height = max(a.y, b.y) - top;
  return new MutableRectangle<T>(left, top, width, height);
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-math/MutableRectangle/MutableRectangle.fromPoints.html