csRect Class Reference
[Geometry utilities]
Rectangle class: simple class for manipulating 2D rectangles.
More...
#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. | |
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 (const 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 equality of two rectangles. | |
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. | |
bool | ClipLineGeneral (int &x1, int &y1, int &x2, int &y2) |
This function is the same as ClipLine() except that it doesn't check for two trivial cases (horizontal and vertical lines). | |
bool | ClipLine (int &x1, int &y1, int &x2, int &y2) |
Clip a line to make it fit to this rectangle. | |
bool | ClipLineSafe (int &x1, int &y1, int &x2, int &y2) |
Clip a line to make it fit to this rectangle. | |
Public Attributes | |
int | xmin |
Rectangle bounds. | |
int | ymin |
Rectangle bounds. | |
int | xmax |
Rectangle bounds. | |
int | ymax |
Rectangle bounds. |
Detailed Description
Rectangle class: simple class for manipulating 2D rectangles.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.
Definition at line 51 of file csrect.h.
Constructor & Destructor Documentation
|
Create a empty rectangle.
|
|
Create a new rectangle.
|
|
Copy constructor.
|
|
Destructor.
|
Member Function Documentation
|
Add an adjanced rectangle if resulting rectangle will have larger area.
|
|
Return area of this rectangle.
|
|
Clip a line to make it fit to this rectangle. This algorithm is inclusive (the clipped line will touch the borders). If this function returns false the line is fully outside the rectangle. Note: this function is only guaranteed to work correctly if the lines are not longer than an integer that fits in 16 bits. |
|
This function is the same as ClipLine() except that it doesn't check for two trivial cases (horizontal and vertical lines). It also doesn't check if the line is fully outside the box. Note: this function is only guaranteed to work correctly if the lines are not longer than an integer that fits in 16 bits. |
|
Clip a line to make it fit to this rectangle. This algorithm is inclusive (the clipped line will touch the borders). If this function returns false the line is fully outside the rectangle. Note: this function is guaranteed to work correctly even if the integer coordinates of the line are very big. |
|
Return true if a point lies within rectangle bounds.
|
|
Return true if a relative point lies within rectangle bounds.
Definition at line 154 of file csrect.h. References Height(). |
|
Same but compare with another csRect.
|
|
Return true if rectangle is the same.
Definition at line 158 of file csrect.h. References xmax, xmin, ymax, and ymin. Referenced by Equal(), operator!=(), and operator==(). |
|
Same but works on a csRect argument.
|
|
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. Referenced by Exclude(). |
|
Extend rectangle so that it will include given point.
|
|
Return the height of rectangle.
Definition at line 147 of file csrect.h. Referenced by Area(), csComponent::Clear(), csComponent::ClearZbuffer(), and ContainsRel(). |
|
Contracts the whole rect by n units.
|
|
Intersect with another rectangle.
Definition at line 73 of file csrect.h. References Intersect(), xmax, xmin, ymax, and ymin. |
|
Intersect with another rectangle.
Referenced by Intersect(). |
|
Return true if rectangle intersects with target.
|
|
Return true if rectangle is empty.
Definition at line 110 of file csrect.h. References xmax, xmin, ymax, and ymin. Referenced by Area(). |
|
Joins two rects by their minimum and maximum bounds.
|
|
Make rectangle empty.
Definition at line 114 of file csrect.h. Referenced by csComponent::SetClipRect(). |
|
Move rectangle by deltaX, deltaY.
|
|
Normalize a rectangle such that xmin <= xmax and ymin <= ymax.
|
|
Test inequality of two rectangles.
Definition at line 191 of file csrect.h. References Equal(). |
|
Test equality of two rectangles.
Definition at line 185 of file csrect.h. References Equal(). |
|
Expands the whole rect by n units.
|
|
Copy rectangle.
|
|
Set rectangle to given ixmin,iymin,ixmax,iymax position.
Definition at line 118 of file csrect.h. References xmax, xmin, ymax, and ymin. Referenced by csComponent::SetClipRect(), and csGridView::SetViewArea(). |
|
Set rectangle xmin,ymin position.
|
|
Set rectangle size.
|
|
Alternative subtraction: find maximal area of this rectangle that is not covered by argument.
|
|
Add a rectangle: find minimal rectangle that embeds both given rectangles.
|
|
Add a rectangle: find minimal rectangle that embeds both given rectangles.
Referenced by Union(). |
|
Return the width of rectangle.
Definition at line 144 of file csrect.h. Referenced by Area(), csComponent::Clear(), and csComponent::ClearZbuffer(). |
Member Data Documentation
|
Rectangle bounds.
Definition at line 55 of file csrect.h. Referenced by Equal(), Exclude(), Extend(), Intersect(), IsEmpty(), MakeEmpty(), Move(), Normalize(), csApp::pplSetClipRect(), Set(), csComponent::SetPos(), csComponent::SetRect(), SetSize(), csGridView::SetViewArea(), Union(), and Width(). |
|
Rectangle bounds.
Definition at line 55 of file csrect.h. Referenced by Contains(), Equal(), Exclude(), Extend(), Intersect(), IsEmpty(), MakeEmpty(), Move(), Normalize(), csApp::pplSetClipRect(), Set(), csComponent::SetPos(), SetPos(), csComponent::SetRect(), csComponent::SetSize(), SetSize(), csGridView::SetViewArea(), Union(), and Width(). |
|
Rectangle bounds.
Definition at line 55 of file csrect.h. Referenced by Contains(), Equal(), Exclude(), Extend(), Height(), Intersect(), IsEmpty(), Move(), Normalize(), csApp::pplSetClipRect(), Set(), csComponent::SetPos(), csComponent::SetRect(), SetSize(), csGridView::SetViewArea(), and Union(). |
|
Rectangle bounds.
Definition at line 55 of file csrect.h. Referenced by Contains(), Equal(), Exclude(), Extend(), Height(), Intersect(), IsEmpty(), Move(), Normalize(), csApp::pplSetClipRect(), Set(), csComponent::SetPos(), SetPos(), csComponent::SetRect(), csComponent::SetSize(), SetSize(), csGridView::SetViewArea(), and Union(). |
The documentation for this class was generated from the following file:
- csgeom/csrect.h
Generated for Crystal Space by doxygen 1.2.18