ClanLib  2.3.7
List of all members
CL_Rectx< Type > Class Template Reference

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

#include <line.h>

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

Public Member Functions

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

Attributes

Type left
 X1-coordinate. More...
 
Type top
 Y1-coordinate. More...
 
Type right
 X2-coordinate. More...
 
Type bottom
 Y2-coordinate. More...
 
Type get_width () const
 Returns the width of the rectangle. More...
 
Type get_height () const
 Returns the height of the rectangle. More...
 
CL_Sizex< Type > get_size () const
 Returns the size of the rectangle. More...
 
bool contains (const CL_Vec2< Type > &p) const
 Returns true if the rectangle contains the point. More...
 
CL_Pointx< Type > get_top_left () const
 Returns the top-left point of the rectangle. More...
 
CL_Pointx< Type > get_top_right () const
 Returns the top-right point of the rectangle. More...
 
CL_Pointx< Type > get_bottom_right () const
 Returns the bottom-right point of the rectangle. More...
 
CL_Pointx< Type > get_bottom_left () const
 Returns the bottom-left point of the rectangle. More...
 
bool is_overlapped (const CL_Rectx< Type > &r) const
 Returns true if rectangle passed is overlapping or inside this rectangle. More...
 
bool is_inside (const CL_Rectx< Type > &r) const
 Returns true if rectangle passed is inside this rectangle. More...
 
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. More...
 
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. More...
 
CL_Pointx< Type > get_center () const
 Returns the center point of the rectangle. More...
 

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_leftInitial left position of rectangle.
new_topInitial top position of rectangle.
new_rightInitial right position of rectangle.
new_bottomInitial 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.
sizeInitial 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_leftInitial left position of rectangle.
new_topInitial top position of rectangle.
sizeInitial 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
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>
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
hotspotPoint to rotate around.
angleAngle 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
originDetermines the hotspot point within the rectangle
xOffsets applied negatively to the hotspot point
yOffsets applied negatively to the hotspot point
angleAngle
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 &  left_right,
const Type &  top_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 >::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 files: