ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
asw::Quad< T > Class Template Reference

A 2D rectangle in space. More...

#include <geometry.h>

Public Member Functions

 Quad ()
 Default constructor for the Quad class.
 
 Quad (const Vec2< T > &position, const Vec2< T > &size)
 Constructor for the Quad class.
 
 Quad (T x, T y, T width, T height)
 Constructor for the Quad class.
 
void setPosition (T x, T y)
 Set the position of the rectangle.
 
void setSize (T width, T height)
 Set the size of the rectangle.
 
Vec2< T > getCenter () const
 Get center of the rectangle.
 
bool contains (const Vec2< T > &point) const
 Check if a point is inside the rectangle.
 
bool contains (T x, T y) const
 Check if coordinates are inside the rectangle.
 
bool collides (const Quad &other) const
 Check if a rectangle is inside the rectangle.
 
bool collidesBottom (const Quad &other) const
 
bool collidesTop (const Quad &other) const
 
bool collidesLeft (const Quad &other) const
 
bool collidesRight (const Quad &other) const
 
Quad operator+ (const Quad< T > &quad) const
 Add a vector to the rectangle.
 
Quad operator- (const Quad< T > &quad) const
 Subtract a vector from the rectangle.
 
Quad operator* (const T scalar) const
 Multiply the rectangle by a scalar.
 
Quad operator/ (const T scalar) const
 Divide the rectangle by a scalar.
 

Public Attributes

Vec2< T > position
 The position of the rectangle.
 
Vec2< T > size
 The size of the rectangle.
 

Detailed Description

template<typename T>
class asw::Quad< T >

A 2D rectangle in space.

This class represents a 2D rectangle in space. It is used to represent areas, sizes, and positions.

Definition at line 370 of file geometry.h.

Constructor & Destructor Documentation

◆ Quad() [1/3]

template<typename T >
asw::Quad< T >::Quad ( )
inline

Default constructor for the Quad class.

Definition at line 374 of file geometry.h.

◆ Quad() [2/3]

template<typename T >
asw::Quad< T >::Quad ( const Vec2< T > & position,
const Vec2< T > & size )
inline

Constructor for the Quad class.

Parameters
positionThe position of the rectangle.
sizeThe size of the rectangle.

Definition at line 381 of file geometry.h.

◆ Quad() [3/3]

template<typename T >
asw::Quad< T >::Quad ( T x,
T y,
T width,
T height )
inline

Constructor for the Quad class.

Parameters
xThe x position of the rectangle.
yThe y position of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.

Definition at line 391 of file geometry.h.

Member Function Documentation

◆ collides()

template<typename T >
bool asw::Quad< T >::collides ( const Quad< T > & other) const
inline

Check if a rectangle is inside the rectangle.

Parameters
otherThe rectangle to check.
Returns
bool True if the rectangle is inside the rectangle.

Definition at line 441 of file geometry.h.

◆ collidesBottom()

template<typename T >
bool asw::Quad< T >::collidesBottom ( const Quad< T > & other) const
inline

Definition at line 452 of file geometry.h.

◆ collidesLeft()

template<typename T >
bool asw::Quad< T >::collidesLeft ( const Quad< T > & other) const
inline

Definition at line 462 of file geometry.h.

◆ collidesRight()

template<typename T >
bool asw::Quad< T >::collidesRight ( const Quad< T > & other) const
inline

Definition at line 467 of file geometry.h.

◆ collidesTop()

template<typename T >
bool asw::Quad< T >::collidesTop ( const Quad< T > & other) const
inline

Definition at line 457 of file geometry.h.

◆ contains() [1/2]

template<typename T >
bool asw::Quad< T >::contains ( const Vec2< T > & point) const
inline

Check if a point is inside the rectangle.

Parameters
pointThe point to check.
Returns
bool True if the point is inside the rectangle.

Definition at line 421 of file geometry.h.

◆ contains() [2/2]

template<typename T >
bool asw::Quad< T >::contains ( T x,
T y ) const
inline

Check if coordinates are inside the rectangle.

Parameters
pointThe point to check.
Returns
bool True if the point is inside the rectangle.

Definition at line 431 of file geometry.h.

◆ getCenter()

template<typename T >
Vec2< T > asw::Quad< T >::getCenter ( ) const
inline

Get center of the rectangle.

Returns
Vec2 The center of the rectangle.

Definition at line 411 of file geometry.h.

◆ operator*()

template<typename T >
Quad asw::Quad< T >::operator* ( const T scalar) const
inline

Multiply the rectangle by a scalar.

Parameters
scalarThe scalar to multiply by.
Returns
Quad The rectangle multiplied by the scalar.

Definition at line 495 of file geometry.h.

◆ operator+()

template<typename T >
Quad asw::Quad< T >::operator+ ( const Quad< T > & quad) const
inline

Add a vector to the rectangle.

Parameters
vecThe vector to add.
Returns
Quad The rectangle with the vector added.

Definition at line 477 of file geometry.h.

◆ operator-()

template<typename T >
Quad asw::Quad< T >::operator- ( const Quad< T > & quad) const
inline

Subtract a vector from the rectangle.

Parameters
vecThe vector to subtract.
Returns
Quad The rectangle with the vector subtracted.

Definition at line 486 of file geometry.h.

◆ operator/()

template<typename T >
Quad asw::Quad< T >::operator/ ( const T scalar) const
inline

Divide the rectangle by a scalar.

Parameters
scalarThe scalar to divide by.
Returns
Quad The rectangle divided by the scalar.

Definition at line 504 of file geometry.h.

◆ setPosition()

template<typename T >
void asw::Quad< T >::setPosition ( T x,
T y )
inline

Set the position of the rectangle.

Parameters
xThe x position of the rectangle.
yThe y position of the rectangle.

Definition at line 398 of file geometry.h.

◆ setSize()

template<typename T >
void asw::Quad< T >::setSize ( T width,
T height )
inline

Set the size of the rectangle.

Parameters
widthThe width of the rectangle.
heightThe height of the rectangle.

Definition at line 405 of file geometry.h.

Member Data Documentation

◆ position

template<typename T >
Vec2<T> asw::Quad< T >::position

The position of the rectangle.

Definition at line 509 of file geometry.h.

◆ size

template<typename T >
Vec2<T> asw::Quad< T >::size

The size of the rectangle.

Definition at line 512 of file geometry.h.


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