Class for manipulating 2D axis aligned rectangles. More...
#include <Rect.h>
Public Member Functions | |
Rect () | |
Default constructor. More... | |
Rect (T rectLeft, T rectTop, T rectWidth, T rectHeight) | |
Construct the rectangle from its coordinates. More... | |
Rect (const Vector2< T > &position, const Vector2< T > &size) | |
Construct the rectangle from position and size. More... | |
template<typename U > | |
Rect (const Rect< U > &rectangle) | |
Construct the rectangle from another type of rectangle. More... | |
bool | contains (T x, T y) const |
Check if a point is inside the rectangle's area. More... | |
bool | contains (const Vector2< T > &point) const |
Check if a point is inside the rectangle's area. More... | |
bool | intersects (const Rect< T > &other) const |
Check the intersection between two rectangles. More... | |
bool | intersects (const Rect< T > &rectangle, Rect< T > &intersection) const |
Check the intersection between two rectangles. More... | |
Vector2< T > | getPosition () const |
Get the position of the rectangle's top-left corner. More... | |
Vector2< T > | getSize () const |
Get the size of the rectangle. More... | |
Public Attributes | |
T | left |
Left coordinate of the rectangle. More... | |
T | top |
Top coordinate of the rectangle. More... | |
T | width |
Width of the rectangle. More... | |
T | height |
Height of the rectangle. More... | |
Related Functions | |
(Note that these are not member functions.) | |
template<typename T > | |
bool | operator== (const Rect< T > &left, const Rect< T > &right) |
Overload of binary operator ==. More... | |
template<typename T > | |
bool | operator!= (const Rect< T > &left, const Rect< T > &right) |
Overload of binary operator !=. More... | |
Class for manipulating 2D axis aligned rectangles.
ime::Rect< T >::Rect | ( | ) |
Default constructor.
Creates an empty rectangle (it is equivalent to calling Rect(0, 0, 0, 0))
ime::Rect< T >::Rect | ( | T | rectLeft, |
T | rectTop, | ||
T | rectWidth, | ||
T | rectHeight | ||
) |
Construct the rectangle from its coordinates.
rectLeft | Left coordinate of the rectangle |
rectTop | Top coordinate of the rectangle |
rectWidth | Width of the rectangle |
rectHeight | Height of the rectangle |
ime::Rect< T >::Rect | ( | const Vector2< T > & | position, |
const Vector2< T > & | size | ||
) |
Construct the rectangle from position and size.
position | Position of the top-left corner of the rectangle |
size | Size of the rectangle |
|
explicit |
Construct the rectangle from another type of rectangle.
rectangle | Rectangle to convert |
This constructor doesn't replace the copy constructor, it's called only when U != T. A call to this constructor will fail to compile if U is not convertible to T
Check if a point is inside the rectangle's area.
point | Point to test |
This check is non-inclusive. If the point lies on the edge of the rectangle, this function will return false.
bool ime::Rect< T >::contains | ( | T | x, |
T | y | ||
) | const |
Check if a point is inside the rectangle's area.
x | X coordinate of the point to test |
y | Y coordinate of the point to test |
This check is non-inclusive. If the point lies on the edge of the rectangle, this function will return false.
Check the intersection between two rectangles.
other | Rectangle to test |
bool ime::Rect< T >::intersects | ( | const Rect< T > & | rectangle, |
Rect< T > & | intersection | ||
) | const |
Check the intersection between two rectangles.
rectangle | Rectangle to test |
intersection | Rectangle to be filled with the intersection |
This overload returns the overlapped rectangle in the intersection parameter
Overload of binary operator !=.
left | Left operand (a rectangle) |
right | Right operand (a rectangle) |
This operator compares strict difference between two rectangles Create most common types
Overload of binary operator ==.
left | Left operand (a rectangle) |
right | Right operand (a rectangle) |
This operator compares strict equality between two rectangles
T ime::Rect< T >::height |
T ime::Rect< T >::left |
T ime::Rect< T >::top |
T ime::Rect< T >::width |