|void||clip (const Rect &r)|
|void||clip (int16 maxw, int16 maxh)|
|bool||contains (int16 x, int16 y) const|
|bool||contains (const Point &p) const|
|bool||contains (const Rect &r) const|
|void||debugPrint (int debuglevel=0, const char *caption="Rect:") const|
|bool||equals (const Rect &r) const|
|void||extend (const Rect &r)|
|void||grow (int16 offset)|
|int16||height () const|
|bool||intersects (const Rect &r) const|
|bool||isEmpty () const|
|bool||isValidRect () const|
|void||moveTo (const Point &p)|
|void||moveTo (int16 x, int16 y)|
|bool||operator!= (const Rect &rhs) const|
|bool||operator== (const Rect &rhs) const|
|Rect (int16 w, int16 h)|
|Rect (int16 x1, int16 y1, int16 x2, int16 y2)|
|void||setHeight (int16 aHeight)|
|void||setWidth (int16 aWidth)|
|void||translate (int16 dx, int16 dy)|
|int16||width () const|
|static Rect||center (int16 cx, int16 cy, int16 w, int16 h)|
|The point at the top left of the rectangle (part of the rect). |
|The point at the bottom right of the rectangle (not part of the rect). |
Simple class for handling a rectangular zone.
Note: This implementation is built around the assumption that (top,left) is part of the rectangle, but (bottom,right) is not. This is reflected in various methods, including contains(), intersects() and others.
Another very wide spread approach to rectangle classes treats (bottom,right) also as a part of the rectangle.
Conceptually, both are sound, but the approach we use saves many intermediate computations (like computing the height in our case is done by doing this: height = bottom - top; while in the alternate system, it would be height = bottom - top + 1;
When writing code using our Rect class, always keep this principle in mind!