#include <Rectangle.h>
Public Member Functions | |
Rectangle () | |
Rectangle (float width, float height) | |
Rectangle (float x, float y, float width, float height) | |
Rectangle (const Rectangle ©) | |
~Rectangle () | |
bool | isEmpty () const |
void | set (float x, float y, float width, float height) |
void | set (const Rectangle &r) |
void | setPosition (float x, float y) |
float | left () const |
float | top () const |
float | right () const |
float | bottom () const |
bool | contains (float x, float y) const |
bool | contains (float x, float y, float width, float height) const |
bool | contains (const Rectangle &r) const |
bool | intersects (float x, float y, float width, float height) const |
bool | intersects (const Rectangle &r) const |
void | inflate (float horizontalAmount, float verticalAmount) |
Rectangle & | operator= (const Rectangle &r) |
bool | operator== (const Rectangle &r) const |
bool | operator!= (const Rectangle &r) const |
Static Public Member Functions | |
static const Rectangle & | empty () |
static bool | intersect (const Rectangle &r1, const Rectangle &r2, Rectangle *dst) |
static void | combine (const Rectangle &r1, const Rectangle &r2, Rectangle *dst) |
Public Attributes | |
float | x |
float | y |
float | width |
float | height |
Defines a rectangle.
Constructs a new rectangle initialized to all zeros.
gameplay::Rectangle::Rectangle | ( | float | width, |
float | height | ||
) |
Constructs a new rectangle with the x = 0, y = 0 and the specified width and height.
width | The width of the rectangle. |
height | The height of the rectangle. |
gameplay::Rectangle::Rectangle | ( | float | x, |
float | y, | ||
float | width, | ||
float | height | ||
) |
Constructs a new rectangle with the specified x, y, width and height.
x | The x-coordinate of the rectangle. |
y | The y-coordinate of the rectangle. |
width | The width of the rectangle. |
height | The height of the rectangle. |
gameplay::Rectangle::Rectangle | ( | const Rectangle & | copy | ) |
Constructs a new rectangle that is a copy of the specified rectangle.
copy | The rectangle to copy. |
Destructor.
float gameplay::Rectangle::bottom | ( | ) | const |
Returns the y-coordinate of the bottom of the rectangle.
static void gameplay::Rectangle::combine | ( | const Rectangle & | r1, |
const Rectangle & | r2, | ||
Rectangle * | dst | ||
) | [static] |
Returns a new rectangle that exactly contains two other rectangles.
r1 | The first rectangle to contain. |
r2 | The second rectangle to contain. |
dst | A rectangle to store the union of the two rectangle parameters. |
bool gameplay::Rectangle::contains | ( | float | x, |
float | y | ||
) | const |
Determines whether this rectangle contains a specified point.
x | The x-coordinate of the point. |
y | The y-coordinate of the point. |
bool gameplay::Rectangle::contains | ( | float | x, |
float | y, | ||
float | width, | ||
float | height | ||
) | const |
Determines whether this rectangle contains a specified rectangle.
x | The x-coordinate of the rectangle. |
y | The y-coordinate of the rectangle. |
width | The width of the rectangle. |
height | The height of the rectangle. |
bool gameplay::Rectangle::contains | ( | const Rectangle & | r | ) | const |
Determines whether this rectangle contains a specified rectangle.
r | The rectangle. |
static const Rectangle& gameplay::Rectangle::empty | ( | ) | [static] |
Returns a rectangle with all of its values set to zero.
void gameplay::Rectangle::inflate | ( | float | horizontalAmount, |
float | verticalAmount | ||
) |
Pushes the edges of the Rectangle out by the horizontal and vertical values specified.
Each corner of the Rectangle is pushed away from the center of the rectangle by the specified amounts. This results in the width and height of the Rectangle increasing by twice the values provided.
horizontalAmount | The value to push the sides out by. |
verticalAmount | The value to push the top and bottom out by. |
static bool gameplay::Rectangle::intersect | ( | const Rectangle & | r1, |
const Rectangle & | r2, | ||
Rectangle * | dst | ||
) | [static] |
Computes the intersection of two rectangles and returns the result.
r1 | The first rectangle. |
r2 | The second rectangle. |
dst | Populated with the resulting intersection, or Rectangle.empty if they do not intersect. |
bool gameplay::Rectangle::intersects | ( | float | x, |
float | y, | ||
float | width, | ||
float | height | ||
) | const |
Determines whether a specified rectangle intersects with this rectangle. Rectangles intersect if there is a common point that is contained in both rectangles.
x | The x-coordinate of the rectangle. |
y | The y-coordinate of the rectangle. |
width | The width of the rectangle. |
height | The height of the rectangle. |
bool gameplay::Rectangle::intersects | ( | const Rectangle & | r | ) | const |
Determines whether a specified rectangle intersects with this rectangle.
r | The rectangle. |
bool gameplay::Rectangle::isEmpty | ( | ) | const |
Gets a value that indicates whether the rectangle is empty.
float gameplay::Rectangle::left | ( | ) | const |
Returns the x-coordinate of the left side of the rectangle.
bool gameplay::Rectangle::operator!= | ( | const Rectangle & | r | ) | const |
operator !=
bool gameplay::Rectangle::operator== | ( | const Rectangle & | r | ) | const |
operator ==
float gameplay::Rectangle::right | ( | ) | const |
Returns the x-coordinate of the right side of the rectangle.
void gameplay::Rectangle::set | ( | float | x, |
float | y, | ||
float | width, | ||
float | height | ||
) |
Sets the values of this rectangle to the specified values.
x | The x-coordinate of the rectangle. |
y | The y-coordinate of the rectangle. |
width | The width of the rectangle. |
height | The height of the rectangle. |
void gameplay::Rectangle::set | ( | const Rectangle & | r | ) |
Sets the values of this rectangle to those in the specified rectangle.
r | The rectangle to copy. |
void gameplay::Rectangle::setPosition | ( | float | x, |
float | y | ||
) |
Sets the x-coordinate and y-coordinate values of this rectangle to the specified values.
x | The x-coordinate of the rectangle. |
y | The y-coordinate of the rectangle. |
float gameplay::Rectangle::top | ( | ) | const |
Returns the y-coordinate of the top of the rectangle.
Specifies the height of the rectangle.
Specifies the width of the rectangle.
float gameplay::Rectangle::x |
Specifies the x-coordinate of the rectangle.
float gameplay::Rectangle::y |
Specifies the y-coordinate of the rectangle.