#include <csrect.h>
Inheritance diagram for csRect:

Public Methods | |
| csRect () | |
| Create a empty rectangle. | |
| csRect (int ixmin, int iymin, int ixmax, int iymax) | |
| Create a new rectangle. | |
| csRect (const csRect ©) | |
| Copy constructor. | |
| virtual | ~csRect () |
| Destructor. | |
| void | Intersect (int ixmin, int iymin, int ixmax, int iymax) |
| Intersect with another rectangle. | |
| void | Intersect (const csRect &other) |
| Intersect with another rectangle. | |
| bool | Intersects (const csRect &target) const |
| Return true if rectangle intersects with target. | |
| void | Union (int ixmin, int iymin, int ixmax, int iymax) |
| Add a rectangle: find minimal rectangle that embeds both given rectangles. | |
| void | Union (const csRect &other) |
| Add a rectangle: find minimal rectangle that embeds both given rectangles. | |
| void | Exclude (int ixmin, int iymin, int ixmax, int iymax) |
| Subtract rectangle: find the minimal rectangle which embeds all parts of this rectangle which are not covered by given rectangle. More... | |
| void | Exclude (const csRect &other) |
| Same but works on a csRect argument. | |
| void | Subtract (const csRect &rect) |
| Alternative subtraction: find maximal area of this rectangle that is not covered by argument. | |
| bool | IsEmpty () const |
| Return true if rectangle is empty. | |
| void | MakeEmpty () |
| Make rectangle empty. | |
| void | Set (int ixmin, int iymin, int ixmax, int iymax) |
| Set rectangle to given ixmin,iymin,ixmax,iymax position. | |
| void | Set (const csRect &target) |
| Copy rectangle. | |
| void | SetPos (int x, int y) |
| Set rectangle xmin,ymin position. | |
| void | SetSize (int w, int h) |
| Set rectangle size. | |
| void | Move (int dX, int dY) |
| Move rectangle by deltaX, deltaY. | |
| int | Width () const |
| Return the width of rectangle. | |
| int | Height () const |
| Return the height of rectangle. | |
| bool | Contains (int x, int y) const |
| Return true if a point lies within rectangle bounds. | |
| bool | ContainsRel (int x, int y) const |
| Return true if a relative point lies within rectangle bounds. | |
| bool | Equal (int ixmin, int iymin, int ixmax, int iymax) const |
| Return true if rectangle is the same. | |
| bool | Equal (csRect &other) const |
| Same but compare with another csRect. | |
| void | Normalize () |
| Normalize a rectangle such that xmin <= xmax and ymin <= ymax. | |
| int | Area () const |
| Return area of this rectangle. | |
| void | AddAdjanced (const csRect &rect) |
| Add an adjanced rectangle if resulting rectangle will have larger area. | |
| bool | operator!= (const csRect &rect) const |
| Test inequality of two rectangles. | |
| void | Extend (int x, int y) |
| Extend rectangle so that it will include given point. | |
| void | Join (const csRect &rect) |
| Joins two rects by their minimum and maximum bounds. | |
| void | Outset (int n) |
| Expands the whole rect by n units. | |
| void | Inset (int n) |
| Contracts the whole rect by n units. | |
Public Attributes | |
| int | xmin |
| Rectangle bounds. | |
| int | ymin |
| Rectangle bounds. | |
| int | xmax |
| Rectangle bounds. | |
| int | ymax |
| Rectangle bounds. | |
This class is somewhat similar to Box, but uses integer coordinates.
Example of a rectangle (xmin = 0, ymin = 0, xmax = 3, ymax = 2):
0 1 2 3 4 ...
| | | | | |
0 --@@@@@--+--+--
@//|//|//@ | |
1 --@--+--+--@--+--+--
@//|//|//@ | |
2 --@@@@@--+--+--
| | | | | |
3 --+--+--+--+--+--+--
| | | | | |
*...--+--+--+--+--+--+--
Vertical line 'X=3' and horizontal line 'Y=2' does NOT belong to the rectangle.
|
|
Subtract rectangle: find the minimal rectangle which embeds all parts of this rectangle which are not covered by given rectangle. If rectangle is fully covered by argument, it becomes empty. |