Saga3D API Documentation
1.0-RC4
|
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 glm::vec2 &upperLeft, const glm::vec2 &lowerRight) | |
Constructor with two corners. More... | |
template<class U > | |
rect (const glm::vec2 &pos, const glm::vec2 &size) | |
Constructor with upper left corner and dimension. More... | |
template<class U > | |
rect (const glm::vec2 &size) | |
Constructor with upper left at 0,0 and lower right using dimension. More... | |
rect< T > | operator+ (const glm::vec2 &pos) const |
move right by given numbers More... | |
rect< T > & | operator+= (const glm::vec2 &pos) |
move right by given numbers More... | |
rect< T > | operator- (const glm::vec2 &pos) const |
move left by given numbers More... | |
rect< T > & | operator-= (const glm::vec2 &pos) |
move left by given numbers More... | |
bool | operator== (const rect< T > &other) const |
equality operator More... | |
bool | operator!= (const rect< T > &other) const |
inequality operator More... | |
bool | operator< (const rect< T > &other) const |
compares size of rectangles More... | |
T | getArea () const |
Returns size of rectangle. More... | |
bool | isPointInside (const glm::vec2 &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... | |
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 | getWidth () const |
Get width of rectangle. More... | |
T | getHeight () const |
Get height of rectangle. More... | |
void | repair () |
If the lower right corner of the rect is smaller then the upper left, the points are swapped. More... | |
bool | isValid () const |
Returns if the rect is valid to draw. More... | |
glm::vec2 | getCenter () const |
Get the center of the rectangle. More... | |
glm::vec2 | getSize () const |
Get the dimensions of the rectangle. More... | |
void | addInternalPoint (const glm::vec2 &p) |
Adds a point to the rectangle. More... | |
void | addInternalPoint (T x, T y) |
Adds a point to the bounding rectangle. More... | |
Public Attributes | |
glm::vec2 | UpperLeftCorner |
Upper left corner. More... | |
glm::vec2 | LowerRightCorner |
Lower right 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 |
|
inlineexplicit |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
glm::vec2 saga::core::rect< T >::LowerRightCorner |
glm::vec2 saga::core::rect< T >::UpperLeftCorner |