clan::Quadx< Type > Class Template Reference

2D quad structure. More...

#include <quad.h>

Public Member Functions

 Quadx ()
 Constructs a quad.
 
 Quadx (const Quadx< Type > &quad)
 Constructs a quad.
 
 Quadx (const Rectx< Type > &rect)
 Constructs a quad.
 
 Quadx (const Vec2< Type > &new_p, const Vec2< Type > &new_q, const Vec2< Type > &new_r, const Vec2< Type > &new_s)
 Constructs a quad.
 
Quadx< Type > & apply_alignment (Origin origin, Type x, Type y)
 Applies an origin and offset pair to this rectangle.
 
Vec2< Type > center () const
 Returns the center point of the quad.
 
Rect get_bounds () const
 Returns the bounding box of the quad as a Rect.
 
Type get_height () const
 Returns the height of the quad.
 
Sizex< Type > get_size () const
 Returns the size of the rectangle.
 
Type get_width () const
 Returns the width of the quad.
 
bool is_inside (const Vec2< Type > &point) const
 Check if a point is inside or outside the quad.
 
bool operator!= (const Quadx< Type > &quad) const
 Quad != Quad operator.
 
Quadx< Type > operator+ (const Quadx< Type > &quad) const
 Quad + Quad operator.
 
Quadx< Type > operator+ (const Vec2< Type > &point) const
 Quad + Point operator.
 
Quadx< Type > & operator+= (const Quadx< Type > &quad)
 Quad += Quad operator.
 
Quadx< Type > & operator+= (const Vec2< Type > &point)
 Quad += Point operator.
 
Quadx< Type > operator- (const Quadx< Type > &quad) const
 Quad - Quad operator.
 
Quadx< Type > operator- (const Vec2< Type > &point) const
 Quad - Point operator.
 
Quadx< Type > & operator-= (const Quadx< Type > &quad)
 Quad -= Quad operator.
 
Quadx< Type > & operator-= (const Vec2< Type > &point)
 Quad -= Point operator.
 
bool operator== (const Quadx< Type > &quad) const
 Quad == Quad operator.
 
Quadx< Type > & rotate (const Vec2< Type > &hotspot, const Angle &angle)
 Rotates the Quad.
 
Quadx< Type > & scale (const Vec2< Type > &hotspot, float sx, float sy)
 Scale the Quad.
 
Quadx< Type > & scale (float sx, float sy)
 Scale the Quad.
 

Public Attributes

Vec2< Type > p
 First Point.
 
Vec2< Type > q
 Second Point.
 
Vec2< Type > r
 Third Point.
 
Vec2< Type > s
 Fourth Point.
 

Detailed Description

template<typename Type>
class clan::Quadx< Type >

2D quad structure.

These quads templates are defined for: int (Quad), float (Quadf), double (Quadd)

Constructor & Destructor Documentation

◆ Quadx() [1/4]

template<typename Type>
clan::Quadx< Type >::Quadx ( )
inline

◆ Quadx() [2/4]

template<typename Type>
clan::Quadx< Type >::Quadx ( const Vec2< Type > & new_p,
const Vec2< Type > & new_q,
const Vec2< Type > & new_r,
const Vec2< Type > & new_s )
inline

Constructs a quad.

Parameters
new_p= coord for first point of quad.
new_q= coord for second point of quad.
new_r= coord for third point of quad.
new_s= coord for forth point of quad.

References p, q, r, and s.

◆ Quadx() [3/4]

template<typename Type>
clan::Quadx< Type >::Quadx ( const Rectx< Type > & rect)
inline

Constructs a quad.

Parameters
rectRectangle used to initialize the quad.

The corners of the rect are mapped to the quad member variables as follows:

  • Top-left: p
  • Top-right: q
  • Bottom-right: r
  • Bottom-left: s

References clan::left, p, q, r, clan::right, and s.

◆ Quadx() [4/4]

template<typename Type>
clan::Quadx< Type >::Quadx ( const Quadx< Type > & quad)
inline

Constructs a quad.

Parameters
quad= Quad used to initialize this quad.

References Quadx(), p, q, r, and s.

Member Function Documentation

◆ apply_alignment()

template<typename Type>
Quadx< Type > & clan::Quadx< Type >::apply_alignment ( Origin origin,
Type x,
Type y )

Applies an origin and offset pair to this rectangle.

Parameters
originThe new origin to adjust to from default upper-left position
x,yOffsets applied negatively to each corner of the rectangle
Returns
reference to this object

References Quadx(), clan::x, and clan::y.

◆ center()

template<typename Type>
Vec2< Type > clan::Quadx< Type >::center ( ) const

Returns the center point of the quad.

◆ get_bounds()

template<typename Type>
Rect clan::Quadx< Type >::get_bounds ( ) const

Returns the bounding box of the quad as a Rect.

◆ get_height()

template<typename Type>
Type clan::Quadx< Type >::get_height ( ) const

Returns the height of the quad.

Referenced by get_size().

◆ get_size()

template<typename Type>
Sizex< Type > clan::Quadx< Type >::get_size ( ) const
inline

Returns the size of the rectangle.

References get_height(), and get_width().

◆ get_width()

template<typename Type>
Type clan::Quadx< Type >::get_width ( ) const

Returns the width of the quad.

Referenced by get_size().

◆ is_inside()

template<typename Type>
bool clan::Quadx< Type >::is_inside ( const Vec2< Type > & point) const

Check if a point is inside or outside the quad.

References clan::point.

◆ operator!=()

template<typename Type>
bool clan::Quadx< Type >::operator!= ( const Quadx< Type > & quad) const
inline

Quad != Quad operator.

References Quadx(), p, q, r, and s.

◆ operator+() [1/2]

template<typename Type>
Quadx< Type > clan::Quadx< Type >::operator+ ( const Quadx< Type > & quad) const
inline

Quad + Quad operator.

References Quadx(), p, q, r, and s.

◆ operator+() [2/2]

template<typename Type>
Quadx< Type > clan::Quadx< Type >::operator+ ( const Vec2< Type > & point) const
inline

Quad + Point operator.

References Quadx(), p, clan::point, q, r, and s.

◆ operator+=() [1/2]

template<typename Type>
Quadx< Type > & clan::Quadx< Type >::operator+= ( const Quadx< Type > & quad)
inline

Quad += Quad operator.

References Quadx(), p, q, r, and s.

◆ operator+=() [2/2]

template<typename Type>
Quadx< Type > & clan::Quadx< Type >::operator+= ( const Vec2< Type > & point)
inline

Quad += Point operator.

References Quadx(), p, clan::point, q, r, and s.

◆ operator-() [1/2]

template<typename Type>
Quadx< Type > clan::Quadx< Type >::operator- ( const Quadx< Type > & quad) const
inline

Quad - Quad operator.

References Quadx(), p, q, r, and s.

◆ operator-() [2/2]

template<typename Type>
Quadx< Type > clan::Quadx< Type >::operator- ( const Vec2< Type > & point) const
inline

Quad - Point operator.

References Quadx(), p, clan::point, q, r, and s.

◆ operator-=() [1/2]

template<typename Type>
Quadx< Type > & clan::Quadx< Type >::operator-= ( const Quadx< Type > & quad)
inline

Quad -= Quad operator.

References Quadx(), p, q, r, and s.

◆ operator-=() [2/2]

template<typename Type>
Quadx< Type > & clan::Quadx< Type >::operator-= ( const Vec2< Type > & point)
inline

Quad -= Point operator.

References Quadx(), p, clan::point, q, r, and s.

◆ operator==()

template<typename Type>
bool clan::Quadx< Type >::operator== ( const Quadx< Type > & quad) const
inline

Quad == Quad operator.

References Quadx(), p, q, r, and s.

◆ rotate()

template<typename Type>
Quadx< Type > & clan::Quadx< Type >::rotate ( const Vec2< Type > & hotspot,
const Angle & angle )

Rotates the Quad.

Parameters
hotspotPoint to rotate around.
angleAngle to rotate in degrees.
Returns
reference to this object

References Quadx(), and clan::angle.

◆ scale() [1/2]

template<typename Type>
Quadx< Type > & clan::Quadx< Type >::scale ( const Vec2< Type > & hotspot,
float sx,
float sy )

Scale the Quad.

Parameters
sx= Scale value in x-axis
sy= Scale value in y-axis
hotspot= Point to scale around.
Returns
reference to this object

References Quadx().

◆ scale() [2/2]

template<typename Type>
Quadx< Type > & clan::Quadx< Type >::scale ( float sx,
float sy )

Scale the Quad.

Parameters
sx= Scale value in x-axis
sy= Scale value in y-axis
Returns
reference to this object

References Quadx().

Member Data Documentation

◆ p

◆ q

◆ r

◆ s


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