Public Member Functions

CL_Rect Class Reference
[clanCore Math]

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

#include <rect.h>

Inheritance diagram for CL_Rect:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 CL_Rect ()
 CL_Rect (int new_left, int new_top, const CL_Sizex< int > &size)
 CL_Rect (const CL_Rectx< double > &rect)
 CL_Rect (const CL_Rectx< float > &rect)
 CL_Rect (const CL_Rectx< int > &rect)
 CL_Rect (const CL_Pointx< int > &p, const CL_Sizex< int > &size)
 CL_Rect (int new_left, int new_top, int new_right, int new_bottom)
 CL_Rect (const CL_Sizex< int > &s)
Construction

bool operator== (const CL_Rectx< int > &r) const
 Rect == Rect operator.
bool operator!= (const CL_Rectx< int > &r) const
 Rect != Rect operator.
Operations

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

Attributes



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

Detailed Description

2D (left,top,right,bottom) rectangle structure - Integer


Constructor & Destructor Documentation

CL_Rect::CL_Rect (  )  [inline]
CL_Rect::CL_Rect ( const CL_Sizex< int > &  s  )  [inline]
CL_Rect::CL_Rect ( int  new_left,
int  new_top,
int  new_right,
int  new_bottom 
) [inline]
CL_Rect::CL_Rect ( const CL_Pointx< int > &  p,
const CL_Sizex< int > &  size 
) [inline]
CL_Rect::CL_Rect ( const CL_Rectx< int > &  rect  )  [inline]
CL_Rect::CL_Rect ( const CL_Rectx< float > &  rect  )  [inline]
CL_Rect::CL_Rect ( const CL_Rectx< double > &  rect  )  [inline]
CL_Rect::CL_Rect ( int  new_left,
int  new_top,
const CL_Sizex< int > &  size 
) [inline]

Member Function Documentation

CL_Rectx<int >& CL_Rectx< int >::apply_alignment ( CL_Origin  origin,
int  x,
int  y 
) [inline, inherited]

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

References CL_Vec2< Type >::x, and CL_Vec2< Type >::y.

CL_Rectx<int >& CL_Rectx< int >::bounding_rect ( const CL_Rectx< int > &  rect  )  [inline, inherited]

Calculates the bounding rectangle of the rectangles.

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

Returns:
reference to this object

References CL_Rectx< Type >::bottom, cl_max(), cl_min(), CL_Rectx< Type >::left, CL_Rectx< Type >::right, and CL_Rectx< Type >::top.

CL_Rectx<int >& CL_Rectx< int >::clip ( const CL_Rectx< int > &  cr  )  [inline, inherited]

Clip according to the specified clip rectangle.

Returns:
reference to this object

References CL_Rectx< Type >::bottom, cl_max(), cl_min(), CL_Rectx< Type >::left, CL_Rectx< Type >::right, and CL_Rectx< Type >::top.

bool CL_Rectx< int >::contains ( const CL_Vec2< int > &  p  )  const [inline, inherited]

Returns true if the rectangle contains the point.

References CL_Vec2< Type >::x, and CL_Vec2< Type >::y.

CL_Rectx<int >& CL_Rectx< int >::expand ( const int &  left,
const int &  top,
const int &  right,
const int &  bottom 
) [inline, inherited]

Expand the rectangle.

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

Expand the rectangle.

Returns:
reference to this object
CL_Rectx<int >& CL_Rectx< int >::expand ( const int &  expand  )  [inline, inherited]

Expand the rectangle.

Returns:
reference to this object
CL_Pointx<int > CL_Rectx< int >::get_bottom_left (  )  const [inline, inherited]

Returns the bottom-left point of the rectangle.

CL_Pointx<int > CL_Rectx< int >::get_bottom_right (  )  const [inline, inherited]

Returns the bottom-right point of the rectangle.

CL_Pointx<int > CL_Rectx< int >::get_center (  )  const [inline, inherited]

Returns the center point of the rectangle.

int CL_Rectx< int >::get_height (  )  const [inline, inherited]

Returns the height of the rectangle.

CL_Rectx<int > CL_Rectx< int >::get_rot_bounds ( const CL_Vec2< int > &  hotspot,
const CL_Angle angle 
) const [inherited]

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

Parameters:
hotspot Point to rotate around.
angle Angle to rotate.
CL_Rectx<int > CL_Rectx< int >::get_rot_bounds ( CL_Origin  origin,
int  x,
int  y,
const CL_Angle angle 
) const [inherited]

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
CL_Sizex<int > CL_Rectx< int >::get_size (  )  const [inline, inherited]

Returns the size of the rectangle.

CL_Pointx<int > CL_Rectx< int >::get_top_left (  )  const [inline, inherited]

Returns the top-left point of the rectangle.

CL_Pointx<int > CL_Rectx< int >::get_top_right (  )  const [inline, inherited]

Returns the top-right point of the rectangle.

int CL_Rectx< int >::get_width (  )  const [inline, inherited]

Returns the width of the rectangle.

bool CL_Rectx< int >::is_inside ( const CL_Rectx< int > &  r  )  const [inline, inherited]

Returns true if rectangle passed is inside this rectangle.

References CL_Rectx< Type >::bottom, CL_Rectx< Type >::left, CL_Rectx< Type >::right, and CL_Rectx< Type >::top.

bool CL_Rectx< int >::is_overlapped ( const CL_Rectx< int > &  r  )  const [inline, inherited]

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

References CL_Rectx< Type >::bottom, CL_Rectx< Type >::left, CL_Rectx< Type >::right, and CL_Rectx< Type >::top.

CL_Rectx<int >& CL_Rectx< int >::normalize (  )  [inline, inherited]

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

Returns:
reference to this object
bool CL_Rectx< int >::operator!= ( const CL_Rectx< int > &  r  )  const [inline, inherited]
bool CL_Rectx< int >::operator== ( const CL_Rectx< int > &  r  )  const [inline, inherited]
CL_Rectx<int >& CL_Rectx< int >::overlap ( const CL_Rectx< int > &  rect  )  [inline, inherited]

Calculates the intersection of two rectangles.

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

Returns:
reference to this object

References CL_Rectx< Type >::bottom, cl_max(), cl_min(), CL_Rectx< Type >::left, CL_Rectx< Type >::right, and CL_Rectx< Type >::top.

CL_Rectx<int >& CL_Rectx< int >::set_bottom_left ( const CL_Vec2< int > &  p  )  [inline, inherited]

Sets the bottom-left point of the rectangle.

Returns:
reference to this object

References CL_Vec2< Type >::x, and CL_Vec2< Type >::y.

CL_Rectx<int >& CL_Rectx< int >::set_bottom_right ( const CL_Vec2< int > &  p  )  [inline, inherited]

Sets the bottom-right point of the rectangle.

Returns:
reference to this object

References CL_Vec2< Type >::x, and CL_Vec2< Type >::y.

CL_Rectx<int >& CL_Rectx< int >::set_height ( int  height  )  [inline, inherited]

Sets the height of the rectangle.

Returns:
reference to this object
CL_Rectx<int >& CL_Rectx< int >::set_size ( const CL_Sizex< int > &  size  )  [inline, inherited]

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

Returns:
reference to this object

References CL_Sizex< Type >::height, and CL_Sizex< Type >::width.

CL_Rectx<int >& CL_Rectx< int >::set_top_left ( const CL_Vec2< int > &  p  )  [inline, inherited]

Sets the top-left point of the rectangle.

Returns:
reference to this object

References CL_Vec2< Type >::x, and CL_Vec2< Type >::y.

CL_Rectx<int >& CL_Rectx< int >::set_top_right ( const CL_Vec2< int > &  p  )  [inline, inherited]

Sets the top-right point of the rectangle.

Returns:
reference to this object

References CL_Vec2< Type >::x, and CL_Vec2< Type >::y.

CL_Rectx<int >& CL_Rectx< int >::set_width ( int  width  )  [inline, inherited]

Sets the width of the rectangle.

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

Shrink the rectangle.

Returns:
reference to this object
CL_Rectx<int >& CL_Rectx< int >::shrink ( const int &  shrink  )  [inline, inherited]

Shrink the rectangle.

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

Shrink the rectangle.

Returns:
reference to this object
CL_Rectx<int >& CL_Rectx< int >::translate ( const CL_Vec2< int > &  p  )  [inline, inherited]

Translate the rect.

Returns:
reference to this object

References CL_Vec2< Type >::x, and CL_Vec2< Type >::y.

CL_Rectx<int >& CL_Rectx< int >::translate ( const CL_Rectx< int > &  p  )  [inline, inherited]

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

Returns:
reference to this object

References CL_Rectx< Type >::left, and CL_Rectx< Type >::top.

CL_Rectx<int >& CL_Rectx< int >::translate ( int  x,
int  y 
) [inline, inherited]

Translate the rect.

Returns:
reference to this object

Member Data Documentation

int CL_Rectx< int >::bottom [inherited]

Y2-coordinate.

int CL_Rectx< int >::left [inherited]

X1-coordinate.

int CL_Rectx< int >::right [inherited]

X2-coordinate.

int CL_Rectx< int >::top [inherited]

Y1-coordinate.


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