2D rectangle defined by position and size. More...
#include <rect.h>
Public Member Functions | |
| Rect ()=default | |
| Default constructor. Creates an empty rectangle at origin. | |
| Rect (const Point< T, 2 > &pos, const Size2DTemplate< T > &size) | |
| Constructs a rectangle from position and size. | |
| Rect (T x, T y, T width, T height) | |
| Constructs a rectangle from individual components. | |
| T | x () const |
| Returns the X coordinate of the left edge. | |
| T | y () const |
| Returns the Y coordinate of the top edge. | |
| T | width () const |
| Returns the width. | |
| T | height () const |
| Returns the height. | |
| void | setX (T val) |
| Sets the X coordinate. | |
| void | setY (T val) |
| Sets the Y coordinate. | |
| void | setWidth (T val) |
| Sets the width. | |
| void | setHeight (T val) |
| Sets the height. | |
| Point< T, 2 > | topLeft () const |
| Returns the top-left position. | |
| Point< T, 2 > | topRight () const |
| Returns the top-right position. | |
| Point< T, 2 > | bottomLeft () const |
| Returns the bottom-left position. | |
| Point< T, 2 > | bottomRight () const |
| Returns the bottom-right position. | |
| Point< T, 2 > | center () const |
| Returns the center point. | |
| const Point< T, 2 > & | pos () const |
| Returns the position (top-left). | |
| const Size2DTemplate< T > & | size () const |
| Returns the size. | |
| void | setPos (const Point< T, 2 > &p) |
| Sets the position. | |
| void | setSize (const Size2DTemplate< T > &s) |
| Sets the size. | |
| bool | isValid () const |
| Returns true if both width and height are greater than zero. | |
| bool | isEmpty () const |
| Returns true if width or height is zero or negative. | |
| bool | contains (const Point< T, 2 > &p) const |
| Returns true if the given point is inside this rectangle. | |
| bool | contains (const Rect &r) const |
| Returns true if the given rectangle is entirely inside this rectangle. | |
| bool | intersects (const Rect &r) const |
| Returns true if the given rectangle overlaps this rectangle. | |
| Rect | intersected (const Rect &r) const |
| Returns the intersection of this rectangle with another. | |
| Rect | united (const Rect &r) const |
| Returns the smallest rectangle containing both this and another. | |
| Rect | adjusted (T dx1, T dy1, T dx2, T dy2) const |
| Returns a rectangle adjusted by the given deltas. | |
| Rect | translated (T dx, T dy) const |
| Returns a rectangle translated by dx, dy. | |
| bool | operator== (const Rect &other) const |
| Equality operator. | |
| bool | operator!= (const Rect &other) const |
| Inequality operator. | |
2D rectangle defined by position and size.
A simple value type combining a Point<T,2> origin (top-left corner) with a Size2DTemplate<T> extent. Provides intersection, union,
| T | The component type (e.g. int, float, double). |