#include <libwoopsigfx/include/rect.h>
List of all members.
Public Member Functions |
| Rect () |
| Rect (s16 x, s16 y, s32 width, s32 height) |
| Rect (const Rect &rect) |
s16 | getX () const |
s16 | getY () const |
s32 | getWidth () const |
s32 | getHeight () const |
void | setX (s16 x) |
void | setY (s16 y) |
void | setWidth (s32 width) |
void | setHeight (s32 height) |
void | setX2 (s16 x2) |
void | setY2 (s16 y2) |
s16 | getX2 () const |
s16 | getY2 () const |
bool | hasDimensions () const |
void | getIntersect (const Rect &rect, Rect &dest) const |
void | getAddition (const Rect &rect, Rect &dest) const |
void | clipToIntersect (const Rect &rect) |
void | expandToInclude (const Rect &rect) |
bool | intersects (const Rect &rect) const |
bool | contains (s16 x, s16 y) const |
void | copyTo (Rect &dest) const |
bool | splitIntersection (const Rect &rect, Rect &intersection, WoopsiArray< Rect > *remainderRects) const |
Rect | operator& (const Rect &rect) |
Rect | operator+ (const Rect &rect) |
bool | operator== (const Rect &rect) |
bool | operator!= (const Rect &rect) |
Static Public Member Functions |
static Rect | fromCoordinates (s16 x1, s16 y1, s16 x2, s16 y2) |
Public Attributes |
s16 | x |
s16 | y |
s32 | width |
s32 | height |
Detailed Description
Class describing a rectangle.
Constructor & Destructor Documentation
Rect::Rect |
( |
s16 |
x, |
|
|
s16 |
y, |
|
|
s32 |
width, |
|
|
s32 |
height |
|
) |
| |
Constructor.
- Parameters:
-
x | The x co-ordinate of the rect. |
y | The y co-ordinate of the rect. |
width | The width of the rect. |
height | The height of the rect. |
Rect::Rect |
( |
const Rect & |
rect | ) |
|
Copy constructor.
- Parameters:
-
Member Function Documentation
void Rect::clipToIntersect |
( |
const Rect & |
rect | ) |
|
Clips this rect to the region that intersects the supplied rect.
bool Rect::contains |
( |
s16 |
x, |
|
|
s16 |
y |
|
) |
| const |
Check if the rect contains the supplied point.
- Parameters:
-
x | X co-ord of the point. |
y | Y co-ord of the point. |
- Returns:
- True if the rect contains the point; false if not.
void Rect::copyTo |
( |
Rect & |
dest | ) |
const |
Copy the properties of this rect to the destination rect.
- Parameters:
-
dest | Destination rect to copy to. |
void Rect::expandToInclude |
( |
const Rect & |
rect | ) |
|
Expands this rect so that it includes the area described by the supplied rect.
static Rect WoopsiGfx::Rect::fromCoordinates |
( |
s16 |
x1, |
|
|
s16 |
y1, |
|
|
s16 |
x2, |
|
|
s16 |
y2 |
|
) |
| [static] |
Create a rect object from the supplied co-ordinates.
- Parameters:
-
x1 | The x co-ordinate of the rect's top-left corner. |
y1 | The y co-ordinate of the rect's top-left corner. |
x2 | The x co-ordinate of the rect's bottom-right corner. |
y2 | The y co-ordinate of the rect's bottom-right corner. |
- Returns:
- A new rect.
void Rect::getAddition |
( |
const Rect & |
rect, |
|
|
Rect & |
dest |
|
) |
| const |
Populates dest with a rectangle representating the smallest rectangle that contains this rectangle and rect.
- Parameters:
-
rect | The rectangle to add to this. |
dest | The destination rectangle. |
s32 WoopsiGfx::Rect::getHeight |
( |
| ) |
const [inline] |
Get the rect's height.
- Returns:
- The rect's height.
void Rect::getIntersect |
( |
const Rect & |
rect, |
|
|
Rect & |
dest |
|
) |
| const |
Populates dest with a rectangle representating the intersection of this rectangle and rect.
- Parameters:
-
rect | The rectangle to intersect with this. |
dest | The destination rectangle. |
s32 WoopsiGfx::Rect::getWidth |
( |
| ) |
const [inline] |
Get the rect's width.
- Returns:
- The rect's width.
s16 WoopsiGfx::Rect::getX |
( |
| ) |
const [inline] |
Get the rect's x co-ordinate.
- Returns:
- The rect's x co-ordinate.
s16 WoopsiGfx::Rect::getX2 |
( |
| ) |
const [inline] |
Get the x co-ordinate of the rect's bottom-right corner.
- Returns:
- The x co-ordinate of the rect's bottom-right corner.
s16 WoopsiGfx::Rect::getY |
( |
| ) |
const [inline] |
Get the rect's y co-ordinate.
- Returns:
- The rect's y co-ordinate.
s16 WoopsiGfx::Rect::getY2 |
( |
| ) |
const [inline] |
Get the y co-ordinate of the rect's bottom-right corner.
- Returns:
- The y co-ordinate of the rect's bottom-right corner.
bool Rect::hasDimensions |
( |
| ) |
const |
Determines if the rectangle has two dimensions; in other words, does it have both height and width? Negative width or height is considered not to be valid.
- Returns:
- True if the rect has height and width; false if not.
bool Rect::intersects |
( |
const Rect & |
rect | ) |
const |
Check if the supplied rect intersects this.
- Parameters:
-
rect | Rect to check for intersection with this. |
- Returns:
- True if the rect intersects this; false if not.
bool Rect::operator!= |
( |
const Rect & |
rect | ) |
|
Overloaded != operator. Checks if the dimensions of the supplied rect are not the same as this rect.
- Parameters:
-
rect | The rect to compare with this. |
- Returns:
- True if the dimensions are not equal; false if they are.
Rect Rect::operator& |
( |
const Rect & |
rect | ) |
|
Overloaded & operator. Returns the intersect of this rectangle and the rectangle passed as the "rect" argument".
- Parameters:
-
rect | The rectangle to intersect with this. |
- Returns:
- The intersect of this rect with the argument.
Rect Rect::operator+ |
( |
const Rect & |
rect | ) |
|
Overloaded + operator. Returns the smallest rectangle that can contain this rectangle and the rectangle passed as the "rect" argument.
- Parameters:
-
rect | The rectangle to add to this. |
- Returns:
- The smallest rect that contains this and the argument.
bool Rect::operator== |
( |
const Rect & |
rect | ) |
|
Overloaded == operator. Checks if the dimensions of the supplied rect are the same as this rect.
- Parameters:
-
rect | The rect to compare with this. |
- Returns:
- True if the dimensions are equal; false if not.
void WoopsiGfx::Rect::setHeight |
( |
s32 |
height | ) |
[inline] |
Set the rect's height.
- Parameters:
-
void WoopsiGfx::Rect::setWidth |
( |
s32 |
width | ) |
[inline] |
Set the rect's width.
- Parameters:
-
void WoopsiGfx::Rect::setX |
( |
s16 |
x | ) |
[inline] |
Set the rect's x co-ordinate.
- Parameters:
-
void Rect::setX2 |
( |
s16 |
x2 | ) |
|
Set the x co-ordinate of the rect's bottom-right corner. If x2 is less than the rect's current x co-ordinate the method automatically adjusts the co-ords so that the rect's width is never negative. Changing this property will change the width of the rect.
- Parameters:
-
x2 | The x co-ordinate of the rect's bottom-right corner. |
void WoopsiGfx::Rect::setY |
( |
s16 |
y | ) |
[inline] |
Set the rect's y co-ordinate.
- Parameters:
-
void Rect::setY2 |
( |
s16 |
y2 | ) |
|
Set the y co-ordinate of the rect's bottom-right corner. If y2 is less than the rect's current y co-ordinate the method automatically adjusts the co-ords so that the rect's height is never negative. Changing this property will change the height of the rect.
- Parameters:
-
y2 | The y co-ordinate of the rect's bottom-right corner. |
bool Rect::splitIntersection |
( |
const Rect & |
rect, |
|
|
Rect & |
intersection, |
|
|
WoopsiArray< Rect > * |
remainderRects |
|
) |
| const |
Determines if the supplied rect intersects this and, if so, divides the supplied rect into the intersected region (stored in "intersection") and the rectangular regions that do not intersect (stored in "remainderRects").
- Parameters:
-
rect | Rectangle to check for intersection. |
intersection | Will contain the dimensions of the intersect once the function ends. |
remainderRects | Will contain the list of non-intersecting regions of rect. |
- Returns:
- True if there is an intersection; false if not.
Member Data Documentation
X co-ordinate of the rectangle.
Y co-ordinate of the rectangle.
The documentation for this class was generated from the following files:
- libwoopsigfx/include/rect.h
- libwoopsigfx/src/rect.cpp