|
constexpr | Rect () noexcept |
| Default constructor. More...
|
|
constexpr Vector< T, 2 > | getPosition () const noexcept |
| Get the position of the rectangle. More...
|
|
constexpr Vector< T, 2 > | getSize () const noexcept |
| Get the size of the rectangle. More...
|
|
constexpr bool | isEmpty () const noexcept |
| Check if the rectangle is empty. More...
|
|
constexpr Vector< T, 2 > | getCenter () const noexcept |
| Get the center of the rectangle. More...
|
|
constexpr bool | contains (Vector< T, 2 > point) const noexcept |
| Check if a point is inside the rectangle. More...
|
|
constexpr bool | contains (const Rect &other) const noexcept |
| Check if a rectangle is totally inside the rectangle. More...
|
|
constexpr bool | intersects (const Rect &other) const noexcept |
| Check if two rectangles interset. More...
|
|
constexpr bool | intersects (const Rect &other, Rect &result) const noexcept |
| Check if two rectangles interset and get the intersetion rectangle. More...
|
|
constexpr Rect | getIntersection (const Rect &other) const noexcept |
| Compute the intersection of two rectangles. More...
|
|
constexpr T | getIntersectionVolume (const Rect &other) const noexcept |
| Get the volume of the intersection. More...
|
|
constexpr T | getIntersectionExtentLength (const Rect &other) const noexcept |
| Get the extent length of the intersection. More...
|
|
constexpr void | extend (const T(&point)[2]) noexcept |
| Extend the rectangle with a point (as array) More...
|
|
constexpr void | extend (Vector< T, 2 > point) noexcept |
| Extend the rectangle with a point. More...
|
|
constexpr void | extend (const Rect &other) noexcept |
| Extend the rectangle with a rectangle. More...
|
|
constexpr Rect | getExtended (const Rect &other) const noexcept |
| Get the rectangle extended by another rectangle. More...
|
|
constexpr T | getVolume () const noexcept |
| Get the volume of the rectangle. More...
|
|
constexpr T | getExtentLength () const noexcept |
| Get the extent length of the rectangle. More...
|
|
constexpr T | getMinimumEdge () const noexcept |
| Get the minimum edge of the rectangle. More...
|
|
constexpr Rect | grow (T value) const noexcept |
| Grow the rectangle. More...
|
|
constexpr Rect | shrink (T value) const noexcept |
| Shrink the rectangle. More...
|
|
constexpr void | normalize () noexcept |
| Ensures that min coordinates are less than max coordinates. More...
|
|
constexpr Vector< T, 2 > | getPositionFromAnchor (Anchor anchor) const noexcept |
| Get a position from the rectangle and an anchor. More...
|
|
constexpr Vector< T, 2 > | getTopLeft () const noexcept |
| Get the top left corner. More...
|
|
constexpr Vector< T, 2 > | getTopRight () const noexcept |
| Get the top right corner. More...
|
|
constexpr Vector< T, 2 > | getBottomLeft () const noexcept |
| Get the bottom left corner. More...
|
|
constexpr Vector< T, 2 > | getBottomRight () const noexcept |
| Get the bottom right corner. More...
|
|
constexpr T | getWidth () const noexcept |
| Get the width of the rectangle. More...
|
|
constexpr T | getHeight () const noexcept |
| Get the height of the rectangle. More...
|
|
|
static constexpr Rect< T > | fromMinMax (Vector< T, 2 > min, Vector< T, 2 > max) noexcept |
| Create a rectangle from a min point and a max point. More...
|
|
static constexpr Rect< T > | fromPositionSize (Vector< T, 2 > position, Vector< T, 2 > size) noexcept |
| Create a rectangle from a position (top-left) and a size. More...
|
|
static constexpr Rect< T > | fromSize (Vector< T, 2 > size) noexcept |
| Create a rectangle from a size. More...
|
|
static constexpr Rect< T > | fromCenterSize (Vector< T, 2 > center, Vector< T, 2 > size) noexcept |
| Create a rectangle from a center and a size. More...
|
|
static constexpr Rect< T > | empty () noexcept |
| Create an empty rectangle. More...
|
|
template<typename T>
struct gf::Rect< T >
Utility class for manipulating 2D axis aligned rectangles.
A rectangle is defined by its top-left corner (called min
) and its bottom-right corner (called ‘max’).
gf::Rect uses the usual rules for its boundaries:
- The left and top edges are included in the rectangle's area
- The right and bottom edges are excluded from the rectangle's area
gf::Rect is a template and may be used with any numeric type, but for simplicity, some common typedef are defined:
So that you don't have to care about the template syntax.
Usage example:
static constexpr Rect< int > fromSize(Vector< int, 2 > size) noexcept
Create a rectangle from a size.
Definition: Rect.h:114
static constexpr Rect< int > fromPositionSize(Vector< int, 2 > position, Vector< int, 2 > size) noexcept
Create a rectangle from a position (top-left) and a size.
Definition: Rect.h:102
constexpr bool contains(Vector< T, 2 > point) const noexcept
Check if a point is inside the rectangle.
Definition: Rect.h:182
constexpr bool intersects(const Rect &other) const noexcept
Check if two rectangles interset.
Definition: Rect.h:202
- See also
- gf::Circ