PRectangle.fromCoordinates constructor

PRectangle.fromCoordinates(
  1. num x1,
  2. num y1,
  3. num x2,
  4. num y2,
)

Implementation

factory PRectangle.fromCoordinates(num x1, num y1, num x2, num y2) {
  if (x2 < x1) {
    var tmp = x1;
    x1 = x2;
    x2 = tmp;
  }

  if (y2 < y1) {
    var tmp = y1;
    y1 = y2;
    y2 = tmp;
  }

  return PRectangle(x1, y1, x2 - x1, y2 - y1);
}