Rectangle template. More...
#include <rect.h>
Public Member Functions | |
rect () | |
Default constructor creating empty rectangle at (0,0) More... | |
rect (T x, T y, T x2, T y2) | |
Constructor with two corners. More... | |
rect (const position2d< T > &upperLeft, const position2d< T > &lowerRight) | |
Constructor with two corners. More... | |
template<class U > | |
rect (const position2d< T > &pos, const dimension2d< U > &size) | |
Constructor with upper left corner and dimension. More... | |
void | addInternalPoint (const position2d< T > &p) |
Adds a point to the rectangle. More... | |
void | addInternalPoint (T x, T y) |
Adds a point to the bounding rectangle. More... | |
void | clipAgainst (const rect< T > &other) |
Clips this rectangle with another one. More... | |
bool | constrainTo (const rect< T > &other) |
Moves this rectangle to fit inside another one. More... | |
T | getArea () const |
Returns size of rectangle. More... | |
position2d< T > | getCenter () const |
Get the center of the rectangle. More... | |
T | getHeight () const |
Get height of rectangle. More... | |
dimension2d< T > | getSize () const |
Get the dimensions of the rectangle. More... | |
T | getWidth () const |
Get width of rectangle. More... | |
bool | isPointInside (const position2d< T > &pos) const |
Returns if a 2d point is within this rectangle. More... | |
bool | isRectCollided (const rect< T > &other) const |
Check if the rectangle collides with another rectangle. More... | |
bool | isValid () const |
Returns if the rect is valid to draw. More... | |
bool | operator!= (const rect< T > &other) const |
inequality operator More... | |
rect< T > | operator+ (const position2d< T > &pos) const |
move right by given numbers More... | |
rect< T > & | operator+= (const position2d< T > &pos) |
move right by given numbers More... | |
rect< T > | operator- (const position2d< T > &pos) const |
move left by given numbers More... | |
rect< T > & | operator-= (const position2d< T > &pos) |
move left by given numbers More... | |
bool | operator< (const rect< T > &other) const |
compares size of rectangles More... | |
bool | operator== (const rect< T > &other) const |
equality operator More... | |
void | repair () |
If the lower right corner of the rect is smaller then the upper left, the points are swapped. More... | |
Public Attributes | |
position2d< T > | LowerRightCorner |
Lower right corner. More... | |
position2d< T > | UpperLeftCorner |
Upper left corner. More... | |
Rectangle template.
Mostly used by 2D GUI elements and for 2D drawing methods. It has 2 positions instead of position and dimension and a fast method for collision detection with other rectangles and points.
Coordinates are (0,0) for top-left corner, and increasing to the right and to the bottom.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Adds a point to the rectangle.
Causes the rectangle to grow bigger if point is outside of the box
p | Point to add to the box. |
Definition at line 241 of file rect.h.
Referenced by irr::core::rect< f32 >::addInternalPoint().
|
inline |
|
inline |
Clips this rectangle with another one.
other | Rectangle to clip with |
Definition at line 126 of file rect.h.
Referenced by irr::gui::IGUIElement::recalculateAbsolutePosition().
|
inline |
|
inline |
Returns size of rectangle.
Definition at line 97 of file rect.h.
Referenced by irr::core::rect< f32 >::operator<().
|
inline |
|
inline |
Get height of rectangle.
Definition at line 190 of file rect.h.
Referenced by irr::core::CMatrix4< T >::buildNDCToDCMatrix(), irr::core::rect< f32 >::constrainTo(), irr::core::rect< f32 >::getArea(), irr::core::rect< f32 >::getSize(), and irr::gui::IGUIElement::recalculateAbsolutePosition().
|
inline |
Get the dimensions of the rectangle.
Definition at line 231 of file rect.h.
Referenced by irr::gui::IGUIElement::setRelativePosition(), and irr::gui::IGUIElement::setRelativePositionProportional().
|
inline |
Get width of rectangle.
Definition at line 184 of file rect.h.
Referenced by irr::core::CMatrix4< T >::buildNDCToDCMatrix(), irr::core::rect< f32 >::constrainTo(), irr::core::rect< f32 >::getArea(), irr::core::rect< f32 >::getSize(), and irr::gui::IGUIElement::recalculateAbsolutePosition().
|
inline |
Returns if a 2d point is within this rectangle.
pos | Position to test if it lies within this rectangle. |
Definition at line 105 of file rect.h.
Referenced by irr::gui::IGUIElement::isPointInside().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
If the lower right corner of the rect is smaller then the upper left, the points are swapped.
Definition at line 196 of file rect.h.
Referenced by irr::gui::IGUIElement::recalculateAbsolutePosition().
position2d<T> irr::core::rect< T >::LowerRightCorner |
Lower right corner.
Definition at line 267 of file rect.h.
Referenced by irr::core::rect< f32 >::addInternalPoint(), irr::core::CMatrix4< T >::buildNDCToDCMatrix(), irr::core::rect< f32 >::clipAgainst(), irr::core::rect< f32 >::constrainTo(), irr::core::rect< f32 >::getCenter(), irr::core::rect< f32 >::getHeight(), irr::core::rect< f32 >::getWidth(), irr::core::rect< f32 >::isPointInside(), irr::core::rect< f32 >::isRectCollided(), irr::core::rect< f32 >::isValid(), irr::core::rect< f32 >::operator!=(), irr::core::rect< f32 >::operator+=(), irr::core::rect< f32 >::operator-=(), irr::core::rect< f32 >::operator==(), irr::gui::IGUIElement::recalculateAbsolutePosition(), irr::core::rect< f32 >::repair(), irr::gui::IGUIElement::setAlignment(), irr::gui::IGUIElement::setRelativePosition(), and irr::gui::IGUIElement::setRelativePositionProportional().
position2d<T> irr::core::rect< T >::UpperLeftCorner |
Upper left corner.
Definition at line 265 of file rect.h.
Referenced by irr::core::rect< f32 >::addInternalPoint(), irr::core::CMatrix4< T >::buildNDCToDCMatrix(), irr::core::rect< f32 >::clipAgainst(), irr::core::rect< f32 >::constrainTo(), irr::core::rect< f32 >::getCenter(), irr::core::rect< f32 >::getHeight(), irr::core::rect< f32 >::getWidth(), irr::core::rect< f32 >::isPointInside(), irr::core::rect< f32 >::isRectCollided(), irr::core::rect< f32 >::isValid(), irr::core::rect< f32 >::operator!=(), irr::core::rect< f32 >::operator+=(), irr::core::rect< f32 >::operator-=(), irr::core::rect< f32 >::operator==(), irr::gui::IGUIElement::recalculateAbsolutePosition(), irr::core::rect< f32 >::repair(), irr::gui::IGUIElement::setAlignment(), irr::gui::IGUIElement::setRelativePosition(), and irr::gui::IGUIElement::setRelativePositionProportional().