2D (left,top,right,bottom) rectangle structure. More...
#include <rect.h>
Public Member Functions | |
Rectx () | |
Constructs an rectangle. | |
Rectx (const Pointx< Type > &p, const Sizex< Type > &size) | |
Constructs an rectangle. | |
Rectx (const Rectx< double > &rect) | |
Constructs an rectangle. | |
Rectx (const Rectx< double > &rect) | |
Rectx (const Rectx< float > &rect) | |
Constructs an rectangle. | |
Rectx (const Rectx< float > &rect) | |
Rectx (const Rectx< int > &rect) | |
Constructs an rectangle. | |
Rectx (const Sizex< Type > &s) | |
Constructs an rectangle. | |
Rectx (Type new_left, Type new_top, const Sizex< Type > &size) | |
Constructs an rectangle. | |
Rectx (Type new_left, Type new_top, Type new_right, Type new_bottom) | |
Constructs an rectangle. | |
Rectx< Type > & | apply_alignment (Origin origin, Type x, Type y) |
Applies an origin and offset pair to this rectangle. | |
Rectx< Type > & | bounding_rect (const Rectx< Type > &rect) |
Calculates the bounding rectangle of the rectangles. | |
Rectx< Type > & | clip (const Rectx< Type > &cr) |
Clip according to the specified clip rectangle. | |
bool | contains (const Vec2< Type > &p) const |
Returns true if the rectangle contains the point. | |
Rectx< Type > & | expand (const Type &expand) |
Expand the rectangle. | |
Rectx< Type > & | expand (const Type &expand_left, const Type &expand_top, const Type &expand_right, const Type &expand_bottom) |
Expand the rectangle. | |
Rectx< Type > & | expand (const Type &left_and_right, const Type &top_and_bottom) |
Expand the rectangle. | |
Pointx< Type > | get_bottom_left () const |
Returns the bottom-left point outside the rectangle. | |
Pointx< Type > | get_bottom_right () const |
Returns the bottom-right point outside the rectangle. | |
Pointx< Type > | get_center () const |
Returns the center point of the rectangle. | |
Type | get_height () const |
Returns the height of the rectangle. | |
Rectx< Type > | get_rot_bounds (const Vec2< Type > &hotspot, const Angle &angle) const |
Returns another Rectx<Type> containing a rotated version of this one. | |
Rectx< Type > | get_rot_bounds (Origin origin, Type x, Type y, const Angle &angle) const |
Returns another Rectx<Type> containing a rotated version of this one. | |
Sizex< Type > | get_size () const |
Returns the size of the rectangle. | |
Pointx< Type > | get_top_left () const |
Returns the top-left point inside the rectangle. | |
Pointx< Type > | get_top_right () const |
Returns the top-right point outside the rectangle. | |
Type | get_width () const |
Returns the width of the rectangle. | |
bool | is_inside (const Rectx< Type > &r) const |
Returns true if rectangle passed is inside this rectangle. | |
bool | is_overlapped (const Rectx< Type > &r) const |
Returns true if rectangle passed is overlapping or inside this rectangle. | |
Rectx< Type > & | normalize () |
Normalize rectangle. | |
bool | operator!= (const Rectx< Type > &r) const |
Rect != Rect operator. | |
Rectx< Type > | operator* (const Type &s) const |
Rect * operator. | |
Rectx< Type > & | operator*= (const Type &s) |
Rect *= operator. | |
bool | operator== (const Rectx< Type > &r) const |
Rect == Rect operator. | |
Rectx< Type > & | overlap (const Rectx< Type > &rect) |
Calculates the intersection of two rectangles. | |
Rectx< Type > & | set_bottom_right (const Vec2< Type > &p) |
Sets the bottom-right point of the rectangle. | |
Rectx< Type > & | set_height (Type height) |
Sets the height of the rectangle. | |
Rectx< Type > & | set_size (const Sizex< Type > &size) |
Sets the size of the rectangle, maintaining top/left position. | |
Rectx< Type > & | set_top_left (const Vec2< Type > &p) |
Sets the top-left point of the rectangle. | |
Rectx< Type > & | set_width (Type width) |
Sets the width of the rectangle. | |
Rectx< Type > & | shrink (const Type &left_right, const Type &top_bottom) |
Shrink the rectangle. | |
Rectx< Type > & | shrink (const Type &new_left, const Type &new_top, const Type &new_right, const Type &new_bottom) |
Shrink the rectangle. | |
Rectx< Type > & | shrink (const Type &shrink) |
Shrink the rectangle. | |
Rectx< Type > & | translate (const Rectx< Type > &p) |
Translate the rect by another rect (only uses the left and top coords). | |
Rectx< Type > & | translate (const Sizex< Type > &p) |
Translate the rect. | |
Rectx< Type > & | translate (const Vec2< Type > &p) |
Translate the rect. | |
Rectx< Type > & | translate (Type x, Type y) |
Translate the rect. | |
Static Public Member Functions | |
static Rectx< Type > | ltrb (Type left, Type top, Type right, Type bottom) |
static Rectx< Type > | xywh (Type x, Type y, Type width, Type height) |
Public Attributes | |
Type | bottom |
Y2-coordinate (point outside the rectange) | |
Type | left |
X1-coordinate (left point inside the rectangle) | |
Type | right |
X2-coordinate (point outside the rectangle) | |
Type | top |
Y1-coordinate (top point inside the rectangle) | |
2D (left,top,right,bottom) rectangle structure.
These line templates are defined for: int (Rect), float (Rectf), double (Rectd)
|
inline |
Constructs an rectangle.
Initialised to zero
|
inline |
Constructs an rectangle.
s | = Size |
|
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. |
|
inline |
Constructs an rectangle.
p | = Initial top-left position of rectangle. |
size | Initial size of rectangle. |
|
inline |
Constructs an rectangle.
new_left | Initial left position of rectangle. |
new_top | Initial top position of rectangle. |
size | Initial size of rectangle. |
|
inline |
|
inline |
|
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 |
References clan::Rectx< Type >::bottom, clan::Vec2< Type >::calc_origin(), clan::Rectx< Type >::get_size(), clan::Rectx< Type >::left, clan::Rectx< Type >::right, clan::Rectx< Type >::top, clan::Vec2< Type >::x, clan::x, clan::Vec2< Type >::y, and clan::y.
|
inline |
Calculates the bounding rectangle of the rectangles.
Rect values become: min left, min top, max right, max bottom.
References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::max, clan::min, clan::Rectx< Type >::right, and clan::Rectx< Type >::top.
|
inline |
Clip according to the specified clip rectangle.
References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::max, clan::min, clan::Rectx< Type >::right, and clan::Rectx< Type >::top.
|
inline |
Returns true if the rectangle contains the point.
References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::p, clan::Rectx< Type >::right, and clan::Rectx< Type >::top.
|
inline |
Expand the rectangle.
References clan::Rectx< Type >::bottom, clan::Rectx< Type >::expand(), clan::Rectx< Type >::left, clan::Rectx< Type >::right, and clan::Rectx< Type >::top.
|
inline |
Expand the rectangle.
References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::Rectx< Type >::right, and clan::Rectx< Type >::top.
Referenced by clan::Rectx< Type >::expand().
|
inline |
Expand the rectangle.
References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::Rectx< Type >::right, and clan::Rectx< Type >::top.
|
inline |
Returns the bottom-left point outside the rectangle.
References clan::Rectx< Type >::bottom, and clan::Rectx< Type >::left.
|
inline |
Returns the bottom-right point outside the rectangle.
References clan::Rectx< Type >::bottom, and clan::Rectx< Type >::right.
|
inline |
Returns the center point of the rectangle.
References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::Rectx< Type >::right, and clan::Rectx< Type >::top.
|
inline |
Returns the height of the rectangle.
References clan::Rectx< Type >::bottom, and clan::Rectx< Type >::top.
Rectx< Type > clan::Rectx< Type >::get_rot_bounds | ( | const Vec2< Type > & | hotspot, |
const Angle & | angle | ||
) | const |
Rectx< Type > clan::Rectx< Type >::get_rot_bounds | ( | Origin | origin, |
Type | x, | ||
Type | y, | ||
const Angle & | angle | ||
) | const |
Returns another 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 |
|
inline |
Returns the size of the rectangle.
References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::Rectx< Type >::right, and clan::Rectx< Type >::top.
Referenced by clan::Rectx< Type >::apply_alignment().
|
inline |
Returns the top-left point inside the rectangle.
References clan::Rectx< Type >::left, and clan::Rectx< Type >::top.
|
inline |
Returns the top-right point outside the rectangle.
References clan::Rectx< Type >::right, and clan::Rectx< Type >::top.
|
inline |
Returns the width of the rectangle.
References clan::Rectx< Type >::left, and clan::Rectx< Type >::right.
|
inline |
Returns true if rectangle passed is inside this rectangle.
References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::r, clan::Rectx< Type >::right, and clan::Rectx< Type >::top.
|
inline |
Returns true if rectangle passed is overlapping or inside this rectangle.
References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::r, clan::Rectx< Type >::right, and clan::Rectx< Type >::top.
|
inlinestatic |
|
inline |
Normalize rectangle.
Sets the width to 0 if found a negative width Sets the height to 0 if found a negative height
References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::Rectx< Type >::right, and clan::Rectx< Type >::top.
|
inline |
|
inline |
Rect * operator.
References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::Rectx< Type >::right, clan::s, and clan::Rectx< Type >::top.
|
inline |
Rect *= operator.
References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::Rectx< Type >::right, clan::s, and clan::Rectx< Type >::top.
|
inline |
|
inline |
Calculates the intersection of two rectangles.
Rect values become: max left, max top, min right, min bottom.
References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::max, clan::min, clan::Rectx< Type >::right, and clan::Rectx< Type >::top.
|
inline |
Sets the bottom-right point of the rectangle.
References clan::Rectx< Type >::bottom, clan::p, and clan::Rectx< Type >::right.
|
inline |
Sets the height of the rectangle.
References clan::Rectx< Type >::bottom, and clan::Rectx< Type >::top.
|
inline |
Sets the size of the rectangle, maintaining top/left position.
References clan::Rectx< Type >::bottom, clan::Sizex< Type >::height, clan::Rectx< Type >::left, clan::Rectx< Type >::right, clan::Rectx< Type >::top, and clan::Sizex< Type >::width.
|
inline |
Sets the top-left point of the rectangle.
References clan::Rectx< Type >::left, clan::p, and clan::Rectx< Type >::top.
|
inline |
Sets the width of the rectangle.
References clan::Rectx< Type >::left, and clan::Rectx< Type >::right.
|
inline |
Shrink the rectangle.
References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::Rectx< Type >::right, and clan::Rectx< Type >::top.
|
inline |
Shrink the rectangle.
References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::Rectx< Type >::right, and clan::Rectx< Type >::top.
Referenced by clan::Rectx< Type >::shrink().
|
inline |
Shrink the rectangle.
References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::Rectx< Type >::right, clan::Rectx< Type >::shrink(), and clan::Rectx< Type >::top.
|
inline |
Translate the rect by another rect (only uses the left and top coords).
References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::p, clan::Rectx< Type >::right, and clan::Rectx< Type >::top.
|
inline |
Translate the rect.
References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::p, clan::Rectx< Type >::right, and clan::Rectx< Type >::top.
|
inline |
Translate the rect.
References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::p, clan::Rectx< Type >::right, and clan::Rectx< Type >::top.
|
inline |
Translate the rect.
References clan::Rectx< Type >::bottom, clan::Rectx< Type >::left, clan::Rectx< Type >::right, clan::Rectx< Type >::top, clan::x, and clan::y.
|
inlinestatic |
Type clan::Rectx< Type >::bottom |
Y2-coordinate (point outside the rectange)
Referenced by clan::Rectx< Type >::apply_alignment(), clan::Rectx< Type >::bounding_rect(), clan::Rectx< Type >::clip(), clan::Rectx< Type >::contains(), clan::Rectx< Type >::expand(), clan::Rectx< Type >::get_bottom_left(), clan::Rectx< Type >::get_bottom_right(), clan::Rectx< Type >::get_center(), clan::Rectx< Type >::get_height(), clan::Rectx< Type >::get_size(), clan::Rectx< Type >::is_inside(), clan::Rectx< Type >::is_overlapped(), clan::Rectx< Type >::ltrb(), clan::Rectx< Type >::normalize(), clan::Rectx< Type >::operator!=(), clan::Rectx< Type >::operator*(), clan::Rectx< Type >::operator*=(), clan::Rectx< Type >::operator==(), clan::Rectx< Type >::overlap(), clan::Rectx< Type >::set_bottom_right(), clan::Rectx< Type >::set_height(), clan::Rectx< Type >::set_size(), clan::Rectx< Type >::shrink(), and clan::Rectx< Type >::translate().
Type clan::Rectx< Type >::left |
X1-coordinate (left point inside the rectangle)
Referenced by clan::Rectx< Type >::apply_alignment(), clan::Rectx< Type >::bounding_rect(), clan::Rectx< Type >::clip(), clan::Rectx< Type >::contains(), clan::Rectx< Type >::expand(), clan::Rectx< Type >::get_bottom_left(), clan::Rectx< Type >::get_center(), clan::Rectx< Type >::get_size(), clan::Rectx< Type >::get_top_left(), clan::Rectx< Type >::get_width(), clan::Rectx< Type >::is_inside(), clan::Rectx< Type >::is_overlapped(), clan::Rectx< Type >::ltrb(), clan::Rectx< Type >::normalize(), clan::Rectx< Type >::operator!=(), clan::Rectx< Type >::operator*(), clan::Rectx< Type >::operator*=(), clan::Rectx< Type >::operator==(), clan::Rectx< Type >::overlap(), clan::Rectx< Type >::set_size(), clan::Rectx< Type >::set_top_left(), clan::Rectx< Type >::set_width(), clan::Rectx< Type >::shrink(), and clan::Rectx< Type >::translate().
Type clan::Rectx< Type >::right |
X2-coordinate (point outside the rectangle)
Referenced by clan::Rectx< Type >::apply_alignment(), clan::Rectx< Type >::bounding_rect(), clan::Rectx< Type >::clip(), clan::Rectx< Type >::contains(), clan::Rectx< Type >::expand(), clan::Rectx< Type >::get_bottom_right(), clan::Rectx< Type >::get_center(), clan::Rectx< Type >::get_size(), clan::Rectx< Type >::get_top_right(), clan::Rectx< Type >::get_width(), clan::Rectx< Type >::is_inside(), clan::Rectx< Type >::is_overlapped(), clan::Rectx< Type >::ltrb(), clan::Rectx< Type >::normalize(), clan::Rectx< Type >::operator!=(), clan::Rectx< Type >::operator*(), clan::Rectx< Type >::operator*=(), clan::Rectx< Type >::operator==(), clan::Rectx< Type >::overlap(), clan::Rectx< Type >::set_bottom_right(), clan::Rectx< Type >::set_size(), clan::Rectx< Type >::set_width(), clan::Rectx< Type >::shrink(), and clan::Rectx< Type >::translate().
Type clan::Rectx< Type >::top |
Y1-coordinate (top point inside the rectangle)
Referenced by clan::Rectx< Type >::apply_alignment(), clan::Rectx< Type >::bounding_rect(), clan::Rectx< Type >::clip(), clan::Rectx< Type >::contains(), clan::Rectx< Type >::expand(), clan::Rectx< Type >::get_center(), clan::Rectx< Type >::get_height(), clan::Rectx< Type >::get_size(), clan::Rectx< Type >::get_top_left(), clan::Rectx< Type >::get_top_right(), clan::Rectx< Type >::is_inside(), clan::Rectx< Type >::is_overlapped(), clan::Rectx< Type >::ltrb(), clan::Rectx< Type >::normalize(), clan::Rectx< Type >::operator!=(), clan::Rectx< Type >::operator*(), clan::Rectx< Type >::operator*=(), clan::Rectx< Type >::operator==(), clan::Rectx< Type >::overlap(), clan::Rectx< Type >::set_height(), clan::Rectx< Type >::set_size(), clan::Rectx< Type >::set_top_left(), clan::Rectx< Type >::shrink(), and clan::Rectx< Type >::translate().