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

#include <rect.h>

+ Inheritance diagram for clan::Rect:

Public Member Functions

 Rect ()
 
 Rect (const Sizex< int > &s)
 
 Rect (int new_left, int new_top, int new_right, int new_bottom)
 
 Rect (const Pointx< int > &p, const Sizex< int > &size)
 
 Rect (const Rectx< int > &rect)
 
 Rect (const Rectx< float > &rect)
 
 Rect (const Rectx< double > &rect)
 
 Rect (int new_left, int new_top, const Sizex< int > &size)
 
Construction
bool operator== (const Rectx< int > &r) const
 Rect == Rect operator. More...
 
bool operator!= (const Rectx< int > &r) const
 Rect != Rect operator. More...
 
Operations
Rectx< int > & set_top_left (const Vec2< int > &p)
 Sets the top-left point of the rectangle. More...
 
Rectx< int > & set_width (intwidth)
 Sets the width of the rectangle. More...
 
Rectx< int > & set_height (intheight)
 Sets the height of the rectangle. More...
 
Rectx< int > & shrink (const int &left, const int &top, const int &right, const int &bottom)
 Shrink the rectangle. More...
 
Rectx< int > & shrink (const int &left_right, const int &top_bottom)
 Shrink the rectangle. More...
 
Rectx< int > & shrink (const int &shrink)
 Shrink the rectangle. More...
 
Rectx< int > & expand (const int &left, const int &top, const int &right, const int &bottom)
 Expand the rectangle. More...
 
Rectx< int > & expand (const int &left_and_right, const int &top_and_bottom)
 Expand the rectangle. More...
 
Rectx< int > & expand (const int &expand)
 Expand the rectangle. More...
 
Rectx< int > & translate (const Vec2< int > &p)
 Translate the rect. More...
 
Rectx< int > & translate (const Sizex< int > &p)
 Translate the rect. More...
 
Rectx< int > & translate (const Rectx< int > &p)
 Translate the rect by another rect (only uses the left and top coords). More...
 
Rectx< int > & translate (intx, inty)
 Translate the rect. More...
 
Rectx< int > & set_size (const Sizex< int > &size)
 Sets the size of the rectangle, maintaining top/left position. More...
 
Rectx< int > & overlap (const Rectx< int > &rect)
 Calculates the intersection of two rectangles. More...
 
Rectx< int > & bounding_rect (const Rectx< int > &rect)
 Calculates the bounding rectangle of the rectangles. More...
 
Rectx< int > & normalize ()
 Normalize rectangle. More...
 
Rectx< int > & apply_alignment (Origin origin, intx, inty)
 Applies an origin and offset pair to this rectangle. More...
 
Rectx< int > & clip (const Rectx< int > &cr)
 Clip according to the specified clip rectangle. More...
 

Attributes

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

Detailed Description

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

Member Function Documentation

Rectx<int >& clan::Rectx< int >::apply_alignment ( Origin  origin,
int  x,
int  y 
)
inlineinherited

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 clan::Vec2< Type >::calc_origin(), clan::Vec2< Type >::x, and clan::Vec2< Type >::y.

Rectx<int >& clan::Rectx< int >::bounding_rect ( const Rectx< int > &  rect)
inlineinherited

Calculates the bounding rectangle of the rectangles.

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

Returns
reference to this object

References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::max(), clan::min(), clan::Rectx< Type >::right, and clan::Rectx< Type >::top.

Rectx<int >& clan::Rectx< int >::clip ( const Rectx< int > &  cr)
inlineinherited

Clip according to the specified clip rectangle.

Returns
reference to this object

References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::max(), clan::min(), clan::Rectx< Type >::right, and clan::Rectx< Type >::top.

bool clan::Rectx< int >::contains ( const Vec2< int > &  p) const
inlineinherited

Returns true if the rectangle contains the point.

References clan::Vec2< Type >::x, and clan::Vec2< Type >::y.

Rectx<int >& clan::Rectx< int >::expand ( const int &  left,
const int &  top,
const int &  right,
const int &  bottom 
)
inlineinherited

Expand the rectangle.

Returns
reference to this object
Rectx<int >& clan::Rectx< int >::expand ( const int &  left_and_right,
const int &  top_and_bottom 
)
inlineinherited

Expand the rectangle.

Returns
reference to this object
Rectx<int >& clan::Rectx< int >::expand ( const int &  expand)
inlineinherited

Expand the rectangle.

Returns
reference to this object
Pointx<int > clan::Rectx< int >::get_bottom_left ( ) const
inlineinherited

Returns the bottom-left point outside the rectangle.

Pointx<int > clan::Rectx< int >::get_bottom_right ( ) const
inlineinherited

Returns the bottom-right point outside the rectangle.

Pointx<int > clan::Rectx< int >::get_center ( ) const
inlineinherited

Returns the center point of the rectangle.

int clan::Rectx< int >::get_height ( ) const
inlineinherited

Returns the height of the rectangle.

Rectx<int > clan::Rectx< int >::get_rot_bounds ( const Vec2< int > &  hotspot,
const Angle angle 
) const
inherited

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

Parameters
hotspotPoint to rotate around.
angleAngle to rotate.
Rectx<int > clan::Rectx< int >::get_rot_bounds ( Origin  origin,
int  x,
int  y,
const Angle angle 
) const
inherited

Returns another 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
Sizex<int > clan::Rectx< int >::get_size ( ) const
inlineinherited

Returns the size of the rectangle.

Pointx<int > clan::Rectx< int >::get_top_left ( ) const
inlineinherited

Returns the top-left point inside the rectangle.

Pointx<int > clan::Rectx< int >::get_top_right ( ) const
inlineinherited

Returns the top-right point outside the rectangle.

int clan::Rectx< int >::get_width ( ) const
inlineinherited

Returns the width of the rectangle.

bool clan::Rectx< int >::is_inside ( const Rectx< int > &  r) const
inlineinherited

Returns true if rectangle passed is inside this rectangle.

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

bool clan::Rectx< int >::is_overlapped ( const Rectx< int > &  r) const
inlineinherited

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

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

Rectx<int >& clan::Rectx< int >::normalize ( )
inlineinherited

Normalize rectangle.

Sets the width to 0 if found a negative width Sets the height to 0 if found a negative height

Returns
reference to this object
bool clan::Rectx< int >::operator!= ( const Rectx< int > &  r) const
inlineinherited
bool clan::Rectx< int >::operator== ( const Rectx< int > &  r) const
inlineinherited
Rectx<int >& clan::Rectx< int >::overlap ( const Rectx< int > &  rect)
inlineinherited

Calculates the intersection of two rectangles.

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

Returns
reference to this object

References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::max(), clan::min(), clan::Rectx< Type >::right, and clan::Rectx< Type >::top.

Rectx<int >& clan::Rectx< int >::set_height ( int  height)
inlineinherited

Sets the height of the rectangle.

Returns
reference to this object
Rectx<int >& clan::Rectx< int >::set_size ( const Sizex< int > &  size)
inlineinherited

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

Returns
reference to this object

References clan::Sizex< Type >::height, and clan::Sizex< Type >::width.

Rectx<int >& clan::Rectx< int >::set_top_left ( const Vec2< int > &  p)
inlineinherited

Sets the top-left point of the rectangle.

Returns
reference to this object

References clan::Vec2< Type >::x, and clan::Vec2< Type >::y.

Rectx<int >& clan::Rectx< int >::set_width ( int  width)
inlineinherited

Sets the width of the rectangle.

Returns
reference to this object
Rectx<int >& clan::Rectx< int >::shrink ( const int &  left,
const int &  top,
const int &  right,
const int &  bottom 
)
inlineinherited

Shrink the rectangle.

Returns
reference to this object
Rectx<int >& clan::Rectx< int >::shrink ( const int &  left_right,
const int &  top_bottom 
)
inlineinherited

Shrink the rectangle.

Returns
reference to this object
Rectx<int >& clan::Rectx< int >::shrink ( const int &  shrink)
inlineinherited

Shrink the rectangle.

Returns
reference to this object
Rectx<int >& clan::Rectx< int >::translate ( const Vec2< int > &  p)
inlineinherited

Translate the rect.

Returns
reference to this object

References clan::Vec2< Type >::x, and clan::Vec2< Type >::y.

Rectx<int >& clan::Rectx< int >::translate ( const Sizex< int > &  p)
inlineinherited

Translate the rect.

Returns
reference to this object

References clan::Sizex< Type >::height, and clan::Sizex< Type >::width.

Rectx<int >& clan::Rectx< int >::translate ( const Rectx< int > &  p)
inlineinherited

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

Returns
reference to this object

References clan::Rectx< Type >::left, and clan::Rectx< Type >::top.

Rectx<int >& clan::Rectx< int >::translate ( int  x,
int  y 
)
inlineinherited

Translate the rect.

Returns
reference to this object

Member Data Documentation

int clan::Rectx< int >::bottom
inherited

Y2-coordinate (point outside the rectange)

int clan::Rectx< int >::left
inherited

X1-coordinate (left point inside the rectangle)

int clan::Rectx< int >::right
inherited

X2-coordinate (point outside the rectangle)

int clan::Rectx< int >::top
inherited

Y1-coordinate (top point inside the rectangle)


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