containsRect method

bool containsRect(
  1. GRect rect
)

Determines whether the rect object is contained within this object. A Rectangle is said to contain another if the second Rectangle falls entirely within the boundaries of the first.

Implementation

bool containsRect(GRect rect) {
  if (rect.width <= 0 || rect.height <= 0) {
    return rect.x > x &&
        rect.y > y &&
        rect.right < right &&
        rect.bottom < bottom;
  } else {
    return rect.x >= x &&
        rect.y >= y &&
        rect.right <= right &&
        rect.bottom <= bottom;
  }
}