Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
Flint::Rect< T > Struct Template Reference

Generic axis-aligned rectangle defined by a position and size. More...

#include <flint/math/types.h>

+ Collaboration diagram for Flint::Rect< T >:

Public Member Functions

 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 Public Member Functions

static auto fromNative (const SDL_Rect &rect)
 Construct a Rect from an SDL_Rect.
 

Public Attributes

union { 
 
   struct { 
 
      Vec2< T >   position 
 
      Vec2< T >   size 
 
   }  
 
   struct { 
 
      T   x 
 
      T   y 
 
      T   w 
 
      T   h 
 
   }  
 
};  
 

Detailed Description

template<typename T>
struct Flint::Rect< T >

Generic axis-aligned rectangle defined by a position and size.

Template Parameters
TElement type (typically int or float).

Definition at line 87 of file types.h.


The documentation for this struct was generated from the following file: