2D (left,top,right,bottom) rectangle structure. More...
#include <rect.h>
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. |
2D (left,top,right,bottom) rectangle structure.
These line templates are defined for: int (CL_Rect), float (CL_Rectf), double (CL_Rectd)
Constructs an rectangle.
Initialised to zero
Constructs an rectangle.
s | = Size |
CL_Rectx< Type >::CL_Rectx | ( | Type | new_left, | |
Type | new_top, | |||
Type | new_right, | |||
Type | new_bottom | |||
) | [inline] |
Constructs an rectangle.
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. |
CL_Rectx< Type >::CL_Rectx | ( | const CL_Pointx< Type > & | p, | |
const CL_Sizex< Type > & | size | |||
) | [inline] |
Constructs an rectangle.
p | = Initial top-left position of rectangle. | |
size | Initial size of rectangle. |
CL_Rectx< Type >::CL_Rectx | ( | Type | new_left, | |
Type | new_top, | |||
const CL_Sizex< Type > & | size | |||
) | [inline] |
Constructs an rectangle.
new_left | Initial left position of rectangle. | |
new_top | Initial top position of rectangle. | |
size | Initial size of rectangle. |
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.
origin | The new origin to adjust to from default upper-left position | |
x,y | Offsets applied negatively to each corner of the rectangle |
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.
CL_Rectx<Type>& CL_Rectx< Type >::clip | ( | const CL_Rectx< Type > & | cr | ) | [inline] |
Clip according to the specified clip rectangle.
bool CL_Rectx< Type >::contains | ( | const CL_Vec2< Type > & | p | ) | const [inline] |
Returns true if the rectangle contains the point.
CL_Rectx<Type>& CL_Rectx< Type >::expand | ( | const Type & | left, | |
const Type & | top, | |||
const Type & | right, | |||
const Type & | bottom | |||
) | [inline] |
Expand the rectangle.
CL_Rectx<Type>& CL_Rectx< Type >::expand | ( | const Type & | left_and_right, | |
const Type & | top_and_bottom | |||
) | [inline] |
Expand the rectangle.
Expand the rectangle.
Returns the bottom-left point of the rectangle.
Returns the bottom-right point of the rectangle.
Returns the center point of the rectangle.
Type CL_Rectx< Type >::get_height | ( | ) | const [inline] |
Returns the height of the rectangle.
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.
hotspot | Point to rotate around. | |
angle | Angle to rotate. |
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.
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 |
Returns the size of the rectangle.
Returns the top-left point of the rectangle.
Returns the top-right point of the rectangle.
Type CL_Rectx< Type >::get_width | ( | ) | const [inline] |
Returns the width of the rectangle.
bool CL_Rectx< Type >::is_inside | ( | const CL_Rectx< Type > & | r | ) | const [inline] |
Returns true if rectangle passed is inside this rectangle.
bool CL_Rectx< Type >::is_overlapped | ( | const CL_Rectx< Type > & | r | ) | const [inline] |
Returns true if rectangle passed is overlapping or inside this rectangle.
Normalize rectangle. Ensures that left is less than right and top is less than bottom.
bool CL_Rectx< Type >::operator!= | ( | const CL_Rectx< Type > & | r | ) | const [inline] |
Rect != Rect operator.
bool CL_Rectx< Type >::operator== | ( | const CL_Rectx< Type > & | r | ) | const [inline] |
Rect == Rect operator.
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.
CL_Rectx<Type>& CL_Rectx< Type >::set_bottom_left | ( | const CL_Vec2< Type > & | p | ) | [inline] |
Sets the bottom-left point of the rectangle.
CL_Rectx<Type>& CL_Rectx< Type >::set_bottom_right | ( | const CL_Vec2< Type > & | p | ) | [inline] |
Sets the bottom-right point of the rectangle.
Sets the height of the rectangle.
CL_Rectx<Type>& CL_Rectx< Type >::set_size | ( | const CL_Sizex< Type > & | size | ) | [inline] |
Sets the size of the rectangle, maintaining top/left position.
CL_Rectx<Type>& CL_Rectx< Type >::set_top_left | ( | const CL_Vec2< Type > & | p | ) | [inline] |
Sets the top-left point of the rectangle.
CL_Rectx<Type>& CL_Rectx< Type >::set_top_right | ( | const CL_Vec2< Type > & | p | ) | [inline] |
Sets the top-right point of the rectangle.
Sets the width of the rectangle.
CL_Rectx<Type>& CL_Rectx< Type >::shrink | ( | const Type & | left, | |
const Type & | top, | |||
const Type & | right, | |||
const Type & | bottom | |||
) | [inline] |
Shrink the rectangle.
Shrink the rectangle.
CL_Rectx<Type>& CL_Rectx< Type >::shrink | ( | const Type & | left_right, | |
const Type & | top_bottom | |||
) | [inline] |
Shrink the rectangle.
CL_Rectx<Type>& CL_Rectx< Type >::translate | ( | const CL_Vec2< Type > & | p | ) | [inline] |
Translate the rect.
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).
Translate the rect.
Y2-coordinate.
Referenced by CL_Rectx< int >::bounding_rect(), CL_Quadx< int >::CL_Quadx(), CL_Rectx< Type >::CL_Rectx(), CL_Rectx< int >::CL_Rectx(), CL_Rectx< int >::clip(), CL_Rectx< int >::is_inside(), CL_Rectx< int >::is_overlapped(), CL_Rectx< int >::operator!=(), CL_Rectx< int >::operator==(), and CL_Rectx< int >::overlap().
X1-coordinate.
Referenced by CL_Rectx< int >::bounding_rect(), CL_Quadx< int >::CL_Quadx(), CL_Rectx< Type >::CL_Rectx(), CL_Rectx< int >::CL_Rectx(), CL_Rectx< int >::clip(), CL_Rectx< int >::is_inside(), CL_Rectx< int >::is_overlapped(), CL_Rectx< int >::operator!=(), CL_Rectx< int >::operator==(), CL_Rectx< int >::overlap(), and CL_Rectx< int >::translate().
X2-coordinate.
Referenced by CL_Rectx< int >::bounding_rect(), CL_Quadx< int >::CL_Quadx(), CL_Rectx< Type >::CL_Rectx(), CL_Rectx< int >::CL_Rectx(), CL_Rectx< int >::clip(), CL_Rectx< int >::is_inside(), CL_Rectx< int >::is_overlapped(), CL_Rectx< int >::operator!=(), CL_Rectx< int >::operator==(), and CL_Rectx< int >::overlap().
Y1-coordinate.
Referenced by CL_Rectx< int >::bounding_rect(), CL_Quadx< int >::CL_Quadx(), CL_Rectx< Type >::CL_Rectx(), CL_Rectx< int >::CL_Rectx(), CL_Rectx< int >::clip(), CL_Rectx< int >::is_inside(), CL_Rectx< int >::is_overlapped(), CL_Rectx< int >::operator!=(), CL_Rectx< int >::operator==(), CL_Rectx< int >::overlap(), and CL_Rectx< int >::translate().