nomlib
Loading...
Searching...
No Matches
nom::Rect< T > Struct Template Reference

Rectangle shape container. More...

#include <Rect.hpp>

Public Member Functions

 Rect (void)
 Default constructor; initialize values to Rect<T>::null.
 ~Rect (void)
 Destructor.
 Rect (T left, T top, T right, T bottom)
 Construct a Rectangle from coordinates.
 Rect (const Point2< T > &pos, const Size2< T > &size)
 Construct an object from a Point2 and Size2 container types.
template<typename U>
 Rect (const Rect< U > &copy)
 Copy constructor.
bool contains (T x, T y) const
bool contains (const Point2< T > &pos) const
bool intersects (const Rect< T > &rectangle) const
 Checks to see if our rectangle overlaps with another.
const Object serialize (void) const
 Save an object to a nom::Value object.
const Point2i position (void) const
const Size2i size (void) const
const T & left () const
const T & top () const
const T & right () const
const T & bottom () const
template<typename U>
void set_position (const Point2< U > &pos)
template<typename U>
void set_size (const Size2< U > &dims)

Public Attributes

x
 Left coordinate of the rectangle (X coordinate of Rectangle).
y
 Top coordinate of the rectangle (Y coordinate of Rectangle).
w
 Width of the rectangle (right side of Rectangle).
h
 Height of the rectangle (bottom side of Rectangle).

Static Public Attributes

static const Rect null
 Null value.
static const Rect zero
 Zeroed values.

Detailed Description

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

Rectangle shape container.

Remarks
This class originated from the sf::Rect class of the SFML library.

Definition at line 46 of file Rect.hpp.

Constructor & Destructor Documentation

◆ Rect() [1/4]

template<typename T>
nom::Rect< T >::Rect ( void )
inline

Default constructor; initialize values to Rect<T>::null.

Definition at line 49 of file Rect.hpp.

◆ ~Rect()

template<typename T>
nom::Rect< T >::~Rect ( void )
inline

Destructor.

Definition at line 59 of file Rect.hpp.

◆ Rect() [2/4]

template<typename T>
nom::Rect< T >::Rect ( T left,
T top,
T right,
T bottom )
inline

Construct a Rectangle from coordinates.

Definition at line 65 of file Rect.hpp.

◆ Rect() [3/4]

template<typename T>
nom::Rect< T >::Rect ( const Point2< T > & pos,
const Size2< T > & size )
inline

Construct an object from a Point2 and Size2 container types.

Definition at line 75 of file Rect.hpp.

◆ Rect() [4/4]

template<typename T>
template<typename U>
nom::Rect< T >::Rect ( const Rect< U > & copy)
inlineexplicit

Copy constructor.

Remarks
The explicit keyword here will result in compile-time errors in any instance that it finds incompatible casting occurring, such as if you try to down-cast a Rect<int> to a Rect<float>.

Definition at line 90 of file Rect.hpp.

Member Function Documentation

◆ bottom()

template<typename T>
const T & nom::Rect< T >::bottom ( ) const
inline

Definition at line 188 of file Rect.hpp.

◆ contains() [1/2]

template<typename T>
bool nom::Rect< T >::contains ( const Point2< T > & pos) const
inline

Check to see if an input Point2 container are within the bounds of this object (think: colliding)

Definition at line 111 of file Rect.hpp.

◆ contains() [2/2]

template<typename T>
bool nom::Rect< T >::contains ( T x,
T y ) const
inline

Check to see if input coordinates X and Y are within the bounds of this object (think: colliding)

Definition at line 101 of file Rect.hpp.

◆ intersects()

template<typename T>
bool nom::Rect< T >::intersects ( const Rect< T > & rectangle) const
inline

Checks to see if our rectangle overlaps with another.

Definition at line 117 of file Rect.hpp.

◆ left()

template<typename T>
const T & nom::Rect< T >::left ( ) const
inline

Definition at line 173 of file Rect.hpp.

◆ position()

template<typename T>
const Point2i nom::Rect< T >::position ( void ) const
inline
Returns
The positioning coordinates of the rectangle.

Definition at line 162 of file Rect.hpp.

◆ right()

template<typename T>
const T & nom::Rect< T >::right ( ) const
inline

Definition at line 183 of file Rect.hpp.

◆ serialize()

template<typename T>
const Object nom::Rect< T >::serialize ( void ) const
inline

Save an object to a nom::Value object.

Todo

Return an Array instead of object?

Rename member key 'width' to 'w'

Rename member key 'h' to 'h'

Definition at line 149 of file Rect.hpp.

◆ set_position()

template<typename T>
template<typename U>
void nom::Rect< T >::set_position ( const Point2< U > & pos)
inline

Definition at line 194 of file Rect.hpp.

◆ set_size()

template<typename T>
template<typename U>
void nom::Rect< T >::set_size ( const Size2< U > & dims)
inline

Definition at line 201 of file Rect.hpp.

◆ size()

template<typename T>
const Size2i nom::Rect< T >::size ( void ) const
inline
Returns
The width and height dimensions of the rectangle.

Definition at line 168 of file Rect.hpp.

◆ top()

template<typename T>
const T & nom::Rect< T >::top ( ) const
inline

Definition at line 178 of file Rect.hpp.

Member Data Documentation

◆ h

template<typename T>
T nom::Rect< T >::h

Height of the rectangle (bottom side of Rectangle).

Definition at line 225 of file Rect.hpp.

◆ null

template<typename T>
const Rect nom::Rect< T >::null
static

Null value.

Remarks
Null value implementation depends on signed (negative) numbers.

Definition at line 210 of file Rect.hpp.

◆ w

template<typename T>
T nom::Rect< T >::w

Width of the rectangle (right side of Rectangle).

Definition at line 222 of file Rect.hpp.

◆ x

template<typename T>
T nom::Rect< T >::x

Left coordinate of the rectangle (X coordinate of Rectangle).

Definition at line 216 of file Rect.hpp.

◆ y

template<typename T>
T nom::Rect< T >::y

Top coordinate of the rectangle (Y coordinate of Rectangle).

Definition at line 219 of file Rect.hpp.

◆ zero

template<typename T>
const Rect nom::Rect< T >::zero
static

Zeroed values.

Definition at line 213 of file Rect.hpp.


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