Rectangle subject to the query. "Is *this* rectangle above the other?"
Rectangle used as reference.
Comparing two rectangles laid out in a column.
const rect1 = Rectangle(0, 0, 10, 10); const rect2 = Rectangle(0, 20, 10, 10); assert(rect1.isAbove(rect2)); assert(rect2.isBelow(rect1)); assert(!rect1.isBelow(rect2)); assert(!rect2.isAbove(rect1)); assert(!rect1.isToLeft(rect2)); assert(!rect2.isToLeft(rect1)); assert(!rect1.isToRight(rect2)); assert(!rect2.isToRight(rect1));
Comparing two rectangles laid out in a row.
const rect1 = Rectangle( 0, 0, 10, 10); const rect2 = Rectangle(20, 0, 10, 10); assert(rect1.isToLeft(rect2)); assert(rect2.isToRight(rect1)); assert(!rect1.isToRight(rect2)); assert(!rect2.isToLeft(rect1)); assert(!rect1.isAbove(rect2)); assert(!rect2.isAbove(rect1)); assert(!rect1.isBelow(rect2)); assert(!rect2.isBelow(rect1));
Check if a rectangle is located above (isAbove), below (isBelow), to the left (isToLeft) or to the right (isToRight) of another rectangle.
The four functions wrap isBeyond which accepts a Side argument to specify direction at runtime.