intersects method

bool intersects(
  1. num x,
  2. num y,
  3. num width,
  4. num height,
)

Returns true this rectangle intersects with x,y , width,height.

Implementation

bool intersects(num x, num y, num width, num height) {
  final mx = this.x;
  final my = this.y;
  final mw = this.width;
  final mh = this.height;
  return width > 0 &&
      height > 0 &&
      mw > 0 &&
      mh > 0 &&
      x < mx + mw &&
      x + width > mx &&
      y < my + mh &&
      y + height > my;
}