Generic axis-aligned rectangle defined by a position and size.
More...
#include <flint/math/types.h>
|
| | Rect (Vec2< T > position, Vec2< T > size) |
| | Construct a Rect from explicit position and size.
|
| |
| | Rect (T x, T y, T w, T h) |
| |
| std::optional< Rect< T > > | findIntersection (const Rect< T > &other) const |
| | Compute the intersection with another rectangle.
|
| |
| bool | contains (const Vec2< T > &point) const |
| | Test whether point lies inside the rectangle (half-open interval).
|
| |
| auto | toNative () const |
| | Convert to the corresponding SDL rectangle type.
|
| |
| std::optional< Rect > | getGlobalBounds () const |
| | Return this rect as an optional, or nullopt if it has zero/negative area.
|
| |
|
| static auto | fromNative (const SDL_Rect &rect) |
| | Construct a Rect from an SDL_Rect.
|
| |
template<typename T>
struct Flint::Rect< T >
Generic axis-aligned rectangle defined by a position and size.
- Template Parameters
-
| T | Element type (typically int or float). |
Definition at line 87 of file types.h.
◆ Rect() [1/2]
Construct a Rect from explicit position and size.
- Parameters
-
| position | Top-left corner. |
| size | Dimensions (width, height). |
Definition at line 107 of file types.h.
◆ Rect() [2/2]
◆ contains()
Test whether point lies inside the rectangle (half-open interval).
- Parameters
-
- Returns
- true if the point is inside [position, position+size).
Definition at line 146 of file types.h.
◆ findIntersection()
Compute the intersection with another rectangle.
- Parameters
-
| other | Rectangle to intersect with. |
- Returns
- The overlapping region, or std::nullopt if the rectangles do not overlap.
Definition at line 125 of file types.h.
◆ fromNative()
template<typename T >
| static auto Flint::Rect< T >::fromNative |
( |
const SDL_Rect< T > & | rect | ) |
|
|
inlinestatic |
Construct a Rect from an SDL_Rect.
- Parameters
-
| rect | Source SDL rectangle. |
Definition at line 170 of file types.h.
◆ getGlobalBounds()
Return this rect as an optional, or nullopt if it has zero/negative area.
- Returns
- This rect wrapped in std::optional, or std::nullopt if degenerate.
Definition at line 189 of file types.h.
◆ toNative()
Convert to the corresponding SDL rectangle type.
Returns SDL_Rect for int instantiations and SDL_FRect for float.
Definition at line 156 of file types.h.
◆ position
Top-left corner of the rectangle.
Definition at line 90 of file types.h.
◆ size
Width (x) and height (y) of the rectangle.
Definition at line 91 of file types.h.
The documentation for this struct was generated from the following file: