addPoint method

dynamic addPoint(
  1. num? x,
  2. num? y
)

Add the point to the bounding box. The x1/y1/x2/y2 coordinates of the bounding box will now encompass the given point. @param {number} x - The X coordinate of the point. @param {number} y - The Y coordinate of the point.

Implementation

addPoint(num? x, num? y) {
  if (x is num) {
    if ( this.x1 == null || this.x2 == null ) {
      this.x1 = x;
      this.x2 = x;
    }
    if (x < this.x1!) {
      this.x1 = x;
    }
    if (x > this.x2!) {
      this.x2 = x;
    }
  }
  if (y is num) {
    if ( this.y1 == null || this.y2 == null ) {
      this.y1 = y;
      this.y2 = y;
    }
    if (y < this.y1!) {
      this.y1 = y;
    }
    if (y > this.y2!) {
      this.y2 = y;
    }
  }
}