clan::Quadx< Type > Class Template Reference

2D quad structure. More...

#include <quad.h>

Public Member Functions

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

Public Attributes

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

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

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

Constructs a quad.

Referenced by clan::Quadx< int >::operator+(), and clan::Quadx< int >::operator-().

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.
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
template<typename Type>
clan::Quadx< Type >::Quadx ( const Quadx< Type > &  quad)
inline

Constructs a quad.

Parameters
quad= Quad used to initialize this quad.

Member Function Documentation

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
template<typename Type>
Vec2<Type> clan::Quadx< Type >::center ( ) const

Returns the center point of the quad.

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

Returns the bounding box of the quad as a Rect.

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

Returns the height of the quad.

Referenced by clan::Quadx< int >::get_size().

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

Returns the size of the rectangle.

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

Returns the width of the quad.

Referenced by clan::Quadx< int >::get_size().

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

Check if a point is inside or outside the quad.

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

Quad != Quad operator.

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

Quad + Quad operator.

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

Quad + Point operator.

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

Quad += Quad operator.

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

Quad += Point operator.

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

Quad - Quad operator.

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

Quad - Point operator.

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

Quad -= Quad operator.

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

Quad -= Point operator.

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

Quad == Quad operator.

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
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
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

Member Data Documentation


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