CL_Rectx< Type > Class Template Reference
[clanCore Math]

2D (left,top,right,bottom) rectangle structure. More...

#include <rect.h>

Inheritance diagram for CL_Rectx< Type >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

Construction

 CL_Rectx ()
 Constructs an rectangle.
 CL_Rectx (const CL_Sizex< Type > &s)
 Constructs an rectangle.
 CL_Rectx (Type new_left, Type new_top, Type new_right, Type new_bottom)
 Constructs an rectangle.
 CL_Rectx (const CL_Pointx< Type > &p, const CL_Sizex< Type > &size)
 Constructs an rectangle.
 CL_Rectx (Type new_left, Type new_top, const CL_Sizex< Type > &size)
 Constructs an rectangle.
 CL_Rectx (const CL_Rectx< int > &rect)
 Constructs an rectangle.
 CL_Rectx (const CL_Rectx< float > &rect)
 Constructs an rectangle.
 CL_Rectx (const CL_Rectx< double > &rect)
 Constructs an rectangle.
bool operator== (const CL_Rectx< Type > &r) const
 Rect == Rect operator.
bool operator!= (const CL_Rectx< Type > &r) const
 Rect != Rect operator.
Operations

CL_Rectx< Type > & set_top_left (const CL_Vec2< Type > &p)
 Sets the top-left point of the rectangle.
CL_Rectx< Type > & set_top_right (const CL_Vec2< Type > &p)
 Sets the top-right point of the rectangle.
CL_Rectx< Type > & set_bottom_right (const CL_Vec2< Type > &p)
 Sets the bottom-right point of the rectangle.
CL_Rectx< Type > & set_bottom_left (const CL_Vec2< Type > &p)
 Sets the bottom-left point of the rectangle.
CL_Rectx< Type > & set_width (Type width)
 Sets the width of the rectangle.
CL_Rectx< Type > & set_height (Type height)
 Sets the height of the rectangle.
CL_Rectx< Type > & shrink (const Type &left, const Type &top, const Type &right, const Type &bottom)
 Shrink the rectangle.
CL_Rectx< Type > & shrink (const Type &left_right, const Type &top_bottom)
 Shrink the rectangle.
CL_Rectx< Type > & shrink (const Type &shrink)
 Shrink the rectangle.
CL_Rectx< Type > & expand (const Type &left, const Type &top, const Type &right, const Type &bottom)
 Expand the rectangle.
CL_Rectx< Type > & expand (const Type &left_and_right, const Type &top_and_bottom)
 Expand the rectangle.
CL_Rectx< Type > & expand (const Type &expand)
 Expand the rectangle.
CL_Rectx< Type > & translate (const CL_Vec2< Type > &p)
 Translate the rect.
CL_Rectx< Type > & translate (const CL_Rectx< Type > &p)
 Translate the rect by another rect (only uses the left and top coords).
CL_Rectx< Type > & translate (Type x, Type y)
 Translate the rect.
CL_Rectx< Type > & set_size (const CL_Sizex< Type > &size)
 Sets the size of the rectangle, maintaining top/left position.
CL_Rectx< Type > & overlap (const CL_Rectx< Type > &rect)
 Calculates the intersection of two rectangles.
CL_Rectx< Type > & bounding_rect (const CL_Rectx< Type > &rect)
 Calculates the bounding rectangle of the rectangles.
CL_Rectx< Type > & normalize ()
 Normalize rectangle. Ensures that left is less than right and top is less than bottom.
CL_Rectx< Type > & apply_alignment (CL_Origin origin, Type x, Type y)
 Applies an origin and offset pair to this rectangle.
CL_Rectx< Type > & clip (const CL_Rectx< Type > &cr)
 Clip according to the specified clip rectangle.

Attributes



Type left
 X1-coordinate.
Type top
 Y1-coordinate.
Type right
 X2-coordinate.
Type bottom
 Y2-coordinate.
Type get_width () const
 Returns the width of the rectangle.
Type get_height () const
 Returns the height of the rectangle.
CL_Sizex< Type > get_size () const
 Returns the size of the rectangle.
bool contains (const CL_Vec2< Type > &p) const
 Returns true if the rectangle contains the point.
CL_Pointx< Type > get_top_left () const
 Returns the top-left point of the rectangle.
CL_Pointx< Type > get_top_right () const
 Returns the top-right point of the rectangle.
CL_Pointx< Type > get_bottom_right () const
 Returns the bottom-right point of the rectangle.
CL_Pointx< Type > get_bottom_left () const
 Returns the bottom-left point of the rectangle.
bool is_overlapped (const CL_Rectx< Type > &r) const
 Returns true if rectangle passed is overlapping or inside this rectangle.
bool is_inside (const CL_Rectx< Type > &r) const
 Returns true if rectangle passed is inside this rectangle.
CL_Rectx< Type > get_rot_bounds (const CL_Vec2< Type > &hotspot, const CL_Angle &angle) const
 Returns another CL_Rectx<Type> containing a rotated version of this one.
CL_Rectx< Type > get_rot_bounds (CL_Origin origin, Type x, Type y, const CL_Angle &angle) const
 Returns another CL_Rectx<Type> containing a rotated version of this one.
CL_Pointx< Type > get_center () const
 Returns the center point of the rectangle.

Detailed Description

template<typename Type>
class CL_Rectx< Type >

2D (left,top,right,bottom) rectangle structure.

These line templates are defined for: int (CL_Rect), float (CL_Rectf), double (CL_Rectd)


Constructor & Destructor Documentation

template<typename Type>
CL_Rectx< Type >::CL_Rectx (  )  [inline]

Constructs an rectangle.

Initialised to zero

template<typename Type>
CL_Rectx< Type >::CL_Rectx ( const CL_Sizex< Type > &  s  )  [inline]

Constructs an rectangle.

Parameters:
s = Size
template<typename Type>
CL_Rectx< Type >::CL_Rectx ( Type  new_left,
Type  new_top,
Type  new_right,
Type  new_bottom 
) [inline]

Constructs an rectangle.

Parameters:
new_left Initial left position of rectangle.
new_top Initial top position of rectangle.
new_right Initial right position of rectangle.
new_bottom Initial bottom position of rectangle.
template<typename Type>
CL_Rectx< Type >::CL_Rectx ( const CL_Pointx< Type > &  p,
const CL_Sizex< Type > &  size 
) [inline]

Constructs an rectangle.

Parameters:
p = Initial top-left position of rectangle.
size Initial size of rectangle.
template<typename Type>
CL_Rectx< Type >::CL_Rectx ( Type  new_left,
Type  new_top,
const CL_Sizex< Type > &  size 
) [inline]

Constructs an rectangle.

Parameters:
new_left Initial left position of rectangle.
new_top Initial top position of rectangle.
size Initial size of rectangle.

Member Function Documentation

template<typename Type>
CL_Rectx<Type>& CL_Rectx< Type >::apply_alignment ( CL_Origin  origin,
Type  x,
Type  y 
) [inline]

Applies an origin and offset pair to this rectangle.

Parameters:
origin The new origin to adjust to from default upper-left position
x,y Offsets applied negatively to each corner of the rectangle
Returns:
reference to this object
template<typename Type>
CL_Rectx<Type>& CL_Rectx< Type >::bounding_rect ( const CL_Rectx< Type > &  rect  )  [inline]

Calculates the bounding rectangle of the rectangles.

Rect values become: min left, min top, max right, max bottom.

Returns:
reference to this object
template<typename Type>
CL_Rectx<Type>& CL_Rectx< Type >::clip ( const CL_Rectx< Type > &  cr  )  [inline]

Clip according to the specified clip rectangle.

Returns:
reference to this object
template<typename Type>
bool CL_Rectx< Type >::contains ( const CL_Vec2< Type > &  p  )  const [inline]

Returns true if the rectangle contains the point.

template<typename Type>
CL_Rectx<Type>& CL_Rectx< Type >::expand ( const Type &  left,
const Type &  top,
const Type &  right,
const Type &  bottom 
) [inline]

Expand the rectangle.

Returns:
reference to this object
template<typename Type>
CL_Rectx<Type>& CL_Rectx< Type >::expand ( const Type &  left_and_right,
const Type &  top_and_bottom 
) [inline]

Expand the rectangle.

Returns:
reference to this object
template<typename Type>
CL_Rectx<Type>& CL_Rectx< Type >::expand ( const Type &  expand  )  [inline]

Expand the rectangle.

Returns:
reference to this object
template<typename Type>
CL_Pointx<Type> CL_Rectx< Type >::get_bottom_left (  )  const [inline]

Returns the bottom-left point of the rectangle.

template<typename Type>
CL_Pointx<Type> CL_Rectx< Type >::get_bottom_right (  )  const [inline]

Returns the bottom-right point of the rectangle.

template<typename Type>
CL_Pointx<Type> CL_Rectx< Type >::get_center (  )  const [inline]

Returns the center point of the rectangle.

template<typename Type>
Type CL_Rectx< Type >::get_height (  )  const [inline]

Returns the height of the rectangle.

template<typename Type>
CL_Rectx<Type> CL_Rectx< Type >::get_rot_bounds ( const CL_Vec2< Type > &  hotspot,
const CL_Angle angle 
) const

Returns another CL_Rectx<Type> containing a rotated version of this one.

Parameters:
hotspot Point to rotate around.
angle Angle to rotate.
template<typename Type>
CL_Rectx<Type> CL_Rectx< Type >::get_rot_bounds ( CL_Origin  origin,
Type  x,
Type  y,
const CL_Angle angle 
) const

Returns another CL_Rectx<Type> containing a rotated version of this one.

Parameters:
origin Determines the hotspot point within the rectangle
x Offsets applied negatively to the hotspot point
y Offsets applied negatively to the hotspot point
angle Angle
template<typename Type>
CL_Sizex<Type> CL_Rectx< Type >::get_size (  )  const [inline]

Returns the size of the rectangle.

template<typename Type>
CL_Pointx<Type> CL_Rectx< Type >::get_top_left (  )  const [inline]

Returns the top-left point of the rectangle.

template<typename Type>
CL_Pointx<Type> CL_Rectx< Type >::get_top_right (  )  const [inline]

Returns the top-right point of the rectangle.

template<typename Type>
Type CL_Rectx< Type >::get_width (  )  const [inline]

Returns the width of the rectangle.

template<typename Type>
bool CL_Rectx< Type >::is_inside ( const CL_Rectx< Type > &  r  )  const [inline]

Returns true if rectangle passed is inside this rectangle.

template<typename Type>
bool CL_Rectx< Type >::is_overlapped ( const CL_Rectx< Type > &  r  )  const [inline]

Returns true if rectangle passed is overlapping or inside this rectangle.

template<typename Type>
CL_Rectx<Type>& CL_Rectx< Type >::normalize (  )  [inline]

Normalize rectangle. Ensures that left is less than right and top is less than bottom.

Returns:
reference to this object
template<typename Type>
bool CL_Rectx< Type >::operator!= ( const CL_Rectx< Type > &  r  )  const [inline]

Rect != Rect operator.

template<typename Type>
bool CL_Rectx< Type >::operator== ( const CL_Rectx< Type > &  r  )  const [inline]

Rect == Rect operator.

template<typename Type>
CL_Rectx<Type>& CL_Rectx< Type >::overlap ( const CL_Rectx< Type > &  rect  )  [inline]

Calculates the intersection of two rectangles.

Rect values become: max left, max top, min right, min bottom.

Returns:
reference to this object
template<typename Type>
CL_Rectx<Type>& CL_Rectx< Type >::set_bottom_left ( const CL_Vec2< Type > &  p  )  [inline]

Sets the bottom-left point of the rectangle.

Returns:
reference to this object
template<typename Type>
CL_Rectx<Type>& CL_Rectx< Type >::set_bottom_right ( const CL_Vec2< Type > &  p  )  [inline]

Sets the bottom-right point of the rectangle.

Returns:
reference to this object
template<typename Type>
CL_Rectx<Type>& CL_Rectx< Type >::set_height ( Type  height  )  [inline]

Sets the height of the rectangle.

Returns:
reference to this object
template<typename Type>
CL_Rectx<Type>& CL_Rectx< Type >::set_size ( const CL_Sizex< Type > &  size  )  [inline]

Sets the size of the rectangle, maintaining top/left position.

Returns:
reference to this object
template<typename Type>
CL_Rectx<Type>& CL_Rectx< Type >::set_top_left ( const CL_Vec2< Type > &  p  )  [inline]

Sets the top-left point of the rectangle.

Returns:
reference to this object
template<typename Type>
CL_Rectx<Type>& CL_Rectx< Type >::set_top_right ( const CL_Vec2< Type > &  p  )  [inline]

Sets the top-right point of the rectangle.

Returns:
reference to this object
template<typename Type>
CL_Rectx<Type>& CL_Rectx< Type >::set_width ( Type  width  )  [inline]

Sets the width of the rectangle.

Returns:
reference to this object
template<typename Type>
CL_Rectx<Type>& CL_Rectx< Type >::shrink ( const Type &  left,
const Type &  top,
const Type &  right,
const Type &  bottom 
) [inline]

Shrink the rectangle.

Returns:
reference to this object
template<typename Type>
CL_Rectx<Type>& CL_Rectx< Type >::shrink ( const Type &  shrink  )  [inline]

Shrink the rectangle.

Returns:
reference to this object
template<typename Type>
CL_Rectx<Type>& CL_Rectx< Type >::shrink ( const Type &  left_right,
const Type &  top_bottom 
) [inline]

Shrink the rectangle.

Returns:
reference to this object
template<typename Type>
CL_Rectx<Type>& CL_Rectx< Type >::translate ( const CL_Vec2< Type > &  p  )  [inline]

Translate the rect.

Returns:
reference to this object
template<typename Type>
CL_Rectx<Type>& CL_Rectx< Type >::translate ( const CL_Rectx< Type > &  p  )  [inline]

Translate the rect by another rect (only uses the left and top coords).

Returns:
reference to this object
template<typename Type>
CL_Rectx<Type>& CL_Rectx< Type >::translate ( Type  x,
Type  y 
) [inline]

Translate the rect.

Returns:
reference to this object

Member Data Documentation

template<typename Type>
Type CL_Rectx< Type >::bottom
template<typename Type>
Type CL_Rectx< Type >::left
template<typename Type>
Type CL_Rectx< Type >::right
template<typename Type>
Type CL_Rectx< Type >::top

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