|
SDL3pp
A slim C++ wrapper for SDL3
|
A rectangle, with the origin at the upper left (using integers). More...
Public Member Functions | |
| constexpr | Rect (const RectRaw &r={}) noexcept |
| Wraps Rect. | |
| constexpr | Rect (int x, int y, int w, int h) noexcept |
| Constructs from its fields. | |
| constexpr | Rect (const PointRaw &corner, const PointRaw &size) |
| Construct from offset and size. | |
| bool | operator== (const RectRaw &other) const |
| Compares with the underlying type. | |
| bool | operator== (const Rect &other) const |
| Compares with the underlying type. | |
| operator bool () const | |
| constexpr int | GetX () const noexcept |
| Get left x coordinate. | |
| constexpr Rect & | SetX (int newX) noexcept |
| Set the left x coordinate. | |
| constexpr int | GetY () const noexcept |
| Get top y coordinate. | |
| constexpr Rect & | SetY (int newY) noexcept |
| Set the top y coordinate. | |
| constexpr int | GetW () const noexcept |
| Get width of the rect. | |
| constexpr Rect & | SetW (int newW) noexcept |
| Set the width of the rect. | |
| constexpr int | GetH () const noexcept |
| Get height of the rect. | |
| constexpr Rect & | SetH (int newH) noexcept |
| Set the height of the rect. | |
| constexpr int | GetX2 () const |
| Get X coordinate of the rect second corner. | |
| constexpr Rect & | SetX2 (int x2) |
| Set X coordinate of the rect second corner. | |
| constexpr int | GetY2 () const |
| Get Y coordinate of the rect second corner. | |
| constexpr Rect & | SetY2 (int y2) |
| Set Y coordinate of the rect second corner. | |
| constexpr Point | GetTopLeft () const |
| Get top left corner of the rect. | |
| constexpr Point | GetTopRight () const |
| Get top right corner of the rect. | |
| constexpr Point | GetBottomLeft () const |
| Get bottom left corner of the rect. | |
| constexpr Point | GetBottomRight () const |
| Get bottom right corner of the rect. | |
| constexpr Point | GetSize () const |
| Get size of the rect. | |
| constexpr Point | GetCentroid () const |
| Get centroid of the rect. | |
| bool | GetLineIntersection (PointRaw *p1, PointRaw *p2) const |
| Calculate the intersection of a rectangle and line segment. | |
| bool | GetLineIntersection (int *X1, int *Y1, int *X2, int *Y2) const |
| Calculate the intersection of a rectangle and line segment. | |
| operator SDL_FRect () const | |
| Convert an SDL_Rect to SDL_FRect. | |
| constexpr | operator FRect () const |
| bool | Empty () const |
| Determine whether a rectangle has no area. | |
| bool | Equal (const RectRaw &other) const |
| Determine whether two rectangles are equal. | |
| bool | Contains (const PointRaw &p) const |
| Check whether the rect contains given point. | |
| bool | Contains (const RectRaw &other) const |
| Check whether the rect contains given point. | |
| bool | HasIntersection (const RectRaw &other) const |
| Determine whether two rectangles intersect. | |
| Rect | GetIntersection (const RectRaw &other) const |
| Calculate the intersection of two rectangles. | |
| constexpr Rect | GetUnion (const RectRaw &other) const |
| Calculate the union of two rectangles. | |
| constexpr Rect | GetExtension (unsigned int amount) const |
| Get a rect extended by specified amount of pixels. | |
| constexpr Rect | GetExtension (unsigned int hAmount, unsigned int vAmount) const |
| Get a rect extended by specified amount of pixels. | |
| constexpr Rect & | Extend (unsigned int amount) |
| Extend a rect by specified amount of pixels. | |
| constexpr Rect & | Extend (unsigned int hAmount, unsigned int vAmount) |
| Extend a rect by specified amount of pixels. | |
| constexpr Rect | operator+ (const Point &offset) const |
| Get rectangle moved by a given offset. | |
| constexpr Rect | operator- (const Point &offset) const |
| Get rectangle moved by an opposite of given offset. | |
| constexpr Rect & | operator+= (const Point &offset) |
| Move by then given offset. | |
| constexpr Rect & | operator-= (const Point &offset) |
| Move by an opposite of the given offset. | |
Static Public Member Functions | |
| static Rect | GetEnclosingPoints (SpanRef< const PointRaw > points, OptionalRef< const RectRaw > clip=std::nullopt) |
| Calculate a minimal rectangle enclosing a set of points. | |
| static constexpr Rect | FromCenter (int cx, int cy, int w, int h) |
| Construct the rect from given center coordinates, width and height. | |
| static constexpr Rect | FromCenter (Point center, Point size) |
| Construct the rect from given center coordinates and size. | |
| static constexpr Rect | FromCorners (int x1, int y1, int x2, int y2) |
| Construct the rect from given corners coordinates. | |
| static constexpr Rect | FromCorners (Point p1, Point p2) |
| Construct the rect from given centers coordinates. | |
A rectangle, with the origin at the upper left (using integers).
|
inlineconstexprnoexcept |
Wraps Rect.
| r | the value to be wrapped |
|
inlineconstexprnoexcept |
Constructs from its fields.
| x | the left x. |
| y | the top y. |
| w | the width. |
| h | the height. |
Construct from offset and size.
| corner | the top-left corner |
| size | the size |
|
inline |
Check whether the rect contains given point.
| p | Point to check |
|
inline |
Check whether the rect contains given point.
| other | Point to check |
|
inlineconstexpr |
Extend a rect by specified amount of pixels.
| [in] | amount | Number of pixels to extend by |
|
inlineconstexpr |
Extend a rect by specified amount of pixels.
| [in] | hAmount | Number of pixels to extend by in horizontal direction |
| [in] | vAmount | Number of pixels to extend by in vertical direction |
|
inlinestaticconstexpr |
Construct the rect from given center coordinates, width and height.
| [in] | cx | X coordinate of the rectangle center |
| [in] | cy | Y coordinate of the rectangle center |
| [in] | w | Width of the rectangle |
| [in] | h | Height of the rectangle |
Construct the rect from given center coordinates and size.
| [in] | center | Coordinates of the rectangle center |
| [in] | size | Dimensions of the rectangle |
|
inlinestaticconstexpr |
Construct the rect from given corners coordinates.
| [in] | x1 | X coordinate of the top left rectangle corner |
| [in] | y1 | Y coordinate of the top left rectangle corner |
| [in] | x2 | X coordinate of the bottom right rectangle corner |
| [in] | y2 | Y coordinate of the bottom right rectangle corner |
Construct the rect from given centers coordinates.
| [in] | p1 | Coordinates of the top left rectangle corner |
| [in] | p2 | Coordinates of the bottom right rectangle corner |
|
inlineconstexpr |
Get bottom left corner of the rect.
|
inlineconstexpr |
Get bottom right corner of the rect.
|
inlineconstexpr |
Get centroid of the rect.
|
inlineconstexpr |
Get a rect extended by specified amount of pixels.
| [in] | amount | Number of pixels to extend by |
|
inlineconstexpr |
Get a rect extended by specified amount of pixels.
| [in] | hAmount | Number of pixels to extend by in horizontal direction |
| [in] | vAmount | Number of pixels to extend by in vertical direction |
|
inlineconstexprnoexcept |
Get height of the rect.
Calculate the intersection of a rectangle and line segment.
| [in,out] | p1 | Starting coordinates of the line |
| [in,out] | p2 | Ending coordinates of the line |
This function is used to clip a line segment to a rectangle. A line segment contained entirely within the rectangle or that does not intersect will remain unchanged. A line segment that crosses the rectangle at either or both ends will be clipped to the boundary of the rectangle and the new coordinates saved in p1 and/or p2 as necessary.
|
inlineconstexpr |
Get size of the rect.
|
inlineconstexpr |
Get top left corner of the rect.
|
inlineconstexpr |
Get top right corner of the rect.
|
inlineconstexprnoexcept |
Get width of the rect.
|
inlineconstexprnoexcept |
Get left x coordinate.
|
inlineconstexpr |
Get X coordinate of the rect second corner.
|
inlineconstexprnoexcept |
Get top y coordinate.
|
inlineconstexpr |
Get Y coordinate of the rect second corner.
|
inlineexplicit |
|
constexpr |
Get rectangle moved by a given offset.
| [in] | offset | Point specifying an offset |
Get rectangle moved by an opposite of given offset.
| [in] | offset | Point specifying an offset |
Move by an opposite of the given offset.
| [in] | offset | Point specifying an offset |
|
inlineconstexprnoexcept |
Set the height of the rect.
| newH | the new height. |
|
inlineconstexprnoexcept |
Set the width of the rect.
| newW | the new width. |
|
inlineconstexprnoexcept |
Set the left x coordinate.
| newX | the new left x. |
|
inlineconstexpr |
Set X coordinate of the rect second corner.
| [in] | x2 | New X coordinate value |
This modifies rectangle width internally
|
inlineconstexprnoexcept |
Set the top y coordinate.
| newY | the new top y. |
|
inlineconstexpr |
Set Y coordinate of the rect second corner.
| [in] | y2 | New Y coordinate value |
This modifies rectangle height internally