cpp-sdl2
C++ header-only SDL2 wrapper
|
sdl::Rect, C++ wrapping of SDL_Rect More...
#include <rect.hpp>
Public Member Functions | |
constexpr | Rect () |
Construct a Rect initialized at 0. More... | |
constexpr | Rect (int x, int y, int w, int h) |
Construct a Rect with the given dimensions. More... | |
constexpr | Rect (Vec2i const &corner, Vec2i const &size) |
Construct a Rect with the given dimensions. More... | |
constexpr | Rect (SDL_Rect const &r) |
Copy a Rect. More... | |
Rect (Rect const &) noexcept=default | |
Copy a Rect. More... | |
Rect (Rect &&) noexcept=default | |
Move from a Rect. More... | |
Rect & | operator= (Rect const &) noexcept=default |
Copy assign a Rect. More... | |
Rect & | operator= (Rect &&) noexcept=default |
Move assign a Rect. More... | |
bool | operator== (Rect const &other) const |
Returns true if the two rect are the same. More... | |
constexpr int | x1 () const |
Return the 'min X' position of the Rect. More... | |
constexpr int | x2 () const |
Return the 'max X' position of the Rect. More... | |
constexpr int | y1 () const |
Return the 'min Y' position of the Rect. More... | |
constexpr int | y2 () const |
Return the 'max Y' position of the Rect. More... | |
Vec2i | botleft () const |
Get the bottom left corner position. More... | |
Vec2i | botright () const |
Get the bottom right corner position. More... | |
Vec2i | topleft () const |
Get the top left corner position. More... | |
Vec2i | topright () const |
Get the top right corner position. More... | |
Vec2i | size () const |
Get the size of the Rect. More... | |
Vec2i | center () const |
Get the center of the Rect. More... | |
bool | is_empty () const |
Return true if this Rect is empty. More... | |
bool | contains (int px, int py) const |
Return true if this rect contains the given point. More... | |
bool | contains (Vec2i const &point) const |
Return true if this rect contains the given point. More... | |
bool | intersects (Rect const &r) const |
Return true if this rect intersect another rect. More... | |
bool | intersects (Vec2i const &p1, Vec2i const &p2) const |
Return true if this rect intersect the line. More... | |
Rect | inter (Rect const &r) const |
Return the intersection of the two rects. More... | |
Rect | get_union (Rect const &r) const |
Return the union of the two rects. More... | |
Static Public Member Functions | |
static constexpr Rect | from_center (int cx, int cy, int w, int h) |
Contruct a Rect with dimensions around a center point. More... | |
static constexpr Rect | from_center (Vec2i const ¢er, Vec2i const &size) |
Construct a Rect with dimensions around a center point. More... | |
static constexpr Rect | from_corners (int x1, int y1, int x2, int y2) |
Construct a rect from 2 corner points. More... | |
static constexpr Rect | from_corners (Vec2i const &corner1, Vec2i const &corner2) |
Construct a rect from 2 corner points. More... | |
|
inline |
Construct a Rect initialized at 0.
Definition at line 15 of file rect.hpp.
Referenced by from_corners(), and Rect().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Return true if this rect contains the given point.
point | The X/Y coordinates of the point as a vector 2D |
Definition at line 120 of file rect.hpp.
References contains().
Referenced by contains().
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Construct a rect from 2 corner points.
corner1 | X/Y position of the first corner as a 2D vector |
corner2 | X/Y position of the second corner as a 2D vector |
Definition at line 71 of file rect.hpp.
References operator=(), and Rect().
|
inline |
|
inline |
Copy assign a Rect.
Referenced by from_corners().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Return the 'min X' position of the Rect.
Definition at line 85 of file rect.hpp.
Referenced by botleft(), contains(), intersects(), and topleft().
|
inline |
Return the 'max X' position of the Rect.
Definition at line 87 of file rect.hpp.
Referenced by botright(), intersects(), and topright().
|
inline |
Return the 'min Y' position of the Rect.
Definition at line 89 of file rect.hpp.
Referenced by botleft(), botright(), contains(), and intersects().
|
inline |
Return the 'max Y' position of the Rect.
Definition at line 91 of file rect.hpp.
Referenced by contains(), intersects(), topleft(), and topright().