35 #include "../api_core.h"
51 template<
typename Type>
52 class CL_API_CORE Rectx
60 Rectx() { left = right = top = bottom = 0; }
73 Rectx(Type new_left, Type new_top, Type new_right, Type new_bottom)
74 { left = new_left; top = new_top; right = new_right; bottom = new_bottom; }
81 { left = p.
x; top = p.
y; right = left + size.
width; bottom = top + size.
height; }
89 { left = new_left; top = new_top; right = left + size.
width; bottom = top + size.
height; }
108 {
return (left == r.
left && top == r.
top && right == r.
right && bottom == r.
bottom); }
112 {
return (left != r.
left || top != r.
top || right != r.
right || bottom != r.
bottom); }
142 return (p.
x >= left && p.
x < right)
143 && (p.
y >= top && p.
y < bottom);
179 return ((left <= r.
left)
181 && (right >= r.
right)
202 return Pointx<Type>( (left + right)/2, ( top + bottom)/2 );
224 right = left + width;
233 bottom = top + height;
242 this->left += left; this->top += top; this->right -= right; this->bottom -= bottom;
251 this->left += left_right; this->top += top_bottom; this->right -= left_right; this->bottom -= top_bottom;
260 this->left += shrink; this->top += shrink; this->right -= shrink; this->bottom -= shrink;
269 this->left -= left; this->top -= top; this->right += right; this->bottom += bottom;
278 this->left -= left_and_right;
279 this->right += left_and_right;
280 this->top -= top_and_bottom;
281 this->bottom += top_and_bottom;
290 this->left -= expand;
291 this->right += expand;
293 this->bottom += expand;
302 left += p.
x; top += p.
y; right += p.
x; bottom += p.
y;
329 left += x; top += y; right += x; bottom += y;
338 right = left + size.
width;
339 bottom = top + size.
height;
425 top =
min(top, bottom);
426 left =
min(left, right);
434 { left = (int) (floor(rect.
left + 0.5f)); top = (int) (floor(rect.
top + 0.5f)); right = (int) (floor(rect.
right + 0.5f)); bottom = (int) (floor(rect.
bottom+0.5f)); }
438 { left = (int) (floor(rect.
left + 0.5)); top = (int) (floor(rect.
top + 0.5)); right = (int) (floor(rect.
right + 0.5)); bottom = (int) (floor(rect.
bottom + 0.5)); }
440 template<
typename Type>
442 { left = (Type) rect.
left; top = (Type) rect.
top; right = (Type) rect.
right; bottom = (Type) rect.
bottom; }
444 template<
typename Type>
446 { left = (Type) rect.
left; top = (Type) rect.
top; right = (Type) rect.
right; bottom = (Type) rect.
bottom; }
448 template<
typename Type>
450 { left = (Type) rect.
left; top = (Type) rect.
top; right = (Type) rect.
right; bottom = (Type) rect.
bottom; }
458 Rect(
int new_left,
int new_top,
int new_right,
int new_bottom) :
Rectx<int>(new_left, new_top, new_right, new_bottom) {}
473 Rectf(
float new_left,
float new_top,
float new_right,
float new_bottom) :
Rectx<float>(new_left, new_top, new_right, new_bottom) {}
489 Rectd(
double new_left,
double new_top,
double new_right,
double new_bottom) :
Rectx<double>(new_left, new_top, new_right, new_bottom) {}
499 return Rect(x, y, x+width, y+height);
504 return Rectf(x, y, x+width, y+height);
509 return Rectd(x, y, x+width, y+height);
Rectf(const Sizex< int > &s)
Definition: rect.h:471
Rectx(const Sizex< Type > &s)
Constructs an rectangle.
Definition: rect.h:65
Rect RectPS(int x, int y, int width, int height)
Definition: rect.h:497
bool operator!=(const Rectx< Type > &r) const
Rect != Rect operator.
Definition: rect.h:111
Rectx< Type > & shrink(const Type &left_right, const Type &top_bottom)
Shrink the rectangle.
Definition: rect.h:249
Rectx< Type > & shrink(const Type &shrink)
Shrink the rectangle.
Definition: rect.h:258
2D (left,top,right,bottom) rectangle structure - Double
Definition: rect.h:482
Rectx< Type > & translate(const Rectx< Type > &p)
Translate the rect by another rect (only uses the left and top coords).
Definition: rect.h:318
Type width
Size width.
Definition: size.h:83
Angle class.
Definition: angle.h:63
bool is_overlapped(const Rectx< Type > &r) const
Returns true if rectangle passed is overlapping or inside this rectangle.
Definition: rect.h:171
Rectd(const Rectx< int > &rect)
Definition: rect.h:491
Rectx< Type > & translate(const Vec2< Type > &p)
Translate the rect.
Definition: rect.h:300
Rectx< Type > & overlap(const Rectx< Type > &rect)
Calculates the intersection of two rectangles.
Definition: rect.h:348
Rectx()
Constructs an rectangle.
Definition: rect.h:60
Rectd(const Sizex< float > &s)
Definition: rect.h:487
Rect(int new_left, int new_top, const Sizex< int > &size)
Definition: rect.h:463
bool contains(const Vec2< Type > &p) const
Returns true if the rectangle contains the point.
Definition: rect.h:140
Rect()
Definition: rect.h:456
Rectx< Type > & clip(const Rectx< Type > &cr)
Clip according to the specified clip rectangle.
Definition: rect.h:419
Pointx< Type > get_center() const
Returns the center point of the rectangle.
Definition: rect.h:200
Origin
Alignment origins.
Definition: origin.h:41
Pointx< Type > get_top_right() const
Returns the top-right point outside the rectangle.
Definition: rect.h:153
Rectx(Type new_left, Type new_top, const Sizex< Type > &size)
Constructs an rectangle.
Definition: rect.h:88
Rectx< Type > & set_top_left(const Vec2< Type > &p)
Sets the top-left point of the rectangle.
Definition: rect.h:212
Type height
Size height.
Definition: size.h:86
Rectd(const Pointx< double > &p, const Sizex< double > &size)
Definition: rect.h:490
Rectf(const Rectx< int > &rect)
Definition: rect.h:475
Rect(const Sizex< int > &s)
Definition: rect.h:457
A min(A a, B b)
Definition: cl_math.h:51
Rect(const Rectx< double > &rect)
Definition: rect.h:462
Rectx< Type > & expand(const Type &expand)
Expand the rectangle.
Definition: rect.h:288
Type top
Y1-coordinate (top point inside the rectangle)
Definition: rect.h:122
Rect(int new_left, int new_top, int new_right, int new_bottom)
Definition: rect.h:458
Rectd(double new_left, double new_top, const Sizex< double > &size)
Definition: rect.h:494
Rectd()
Definition: rect.h:485
Rectx(Type new_left, Type new_top, Type new_right, Type new_bottom)
Constructs an rectangle.
Definition: rect.h:73
static Pointx< Type > calc_origin(Origin origin, const Sizex< Type > &size)
Returns the anchor point for the origin within the dimensions of the size structure.
Rectx< Type > & shrink(const Type &left, const Type &top, const Type &right, const Type &bottom)
Shrink the rectangle.
Definition: rect.h:240
2D (left,top,right,bottom) rectangle structure - Integer
Definition: rect.h:453
Type x
Definition: vec2.h:82
bool is_inside(const Rectx< Type > &r) const
Returns true if rectangle passed is inside this rectangle.
Definition: rect.h:177
Rectf()
Definition: rect.h:470
Rectx< Type > & translate(const Sizex< Type > &p)
Translate the rect.
Definition: rect.h:309
Rectx< Type > & set_height(Type height)
Sets the height of the rectangle.
Definition: rect.h:231
Type get_width() const
Returns the width of the rectangle.
Definition: rect.h:131
Rectf RectfPS(float x, float y, float width, float height)
Definition: rect.h:502
Sizex< Type > get_size() const
Returns the size of the rectangle.
Definition: rect.h:137
Rectx< Type > & expand(const Type &left_and_right, const Type &top_and_bottom)
Expand the rectangle.
Definition: rect.h:276
2D (left,top,right,bottom) rectangle structure - Float
Definition: rect.h:467
Rectf(const Sizex< float > &s)
Definition: rect.h:472
Rectx< Type > & expand(const Type &left, const Type &top, const Type &right, const Type &bottom)
Expand the rectangle.
Definition: rect.h:267
Rect(const Rectx< float > &rect)
Definition: rect.h:461
Rectx< Type > & apply_alignment(Origin origin, Type x, Type y)
Applies an origin and offset pair to this rectangle.
Definition: rect.h:403
Rectd(const Rectx< float > &rect)
Definition: rect.h:492
Rectx< Type > & set_size(const Sizex< Type > &size)
Sets the size of the rectangle, maintaining top/left position.
Definition: rect.h:336
Rect(const Pointx< int > &p, const Sizex< int > &size)
Definition: rect.h:459
A max(A a, B b)
Definition: cl_math.h:52
Rect(const Rectx< int > &rect)
Definition: rect.h:460
2D vector
Definition: line.h:49
Rectf(const Rectx< float > &rect)
Definition: rect.h:476
2D (left,top,right,bottom) rectangle structure.
Definition: line.h:46
Rectx< Type > & bounding_rect(const Rectx< Type > &rect)
Calculates the bounding rectangle of the rectangles.
Definition: rect.h:369
Type left
X1-coordinate (left point inside the rectangle)
Definition: rect.h:119
Type right
X2-coordinate (point outside the rectangle)
Definition: rect.h:125
bool operator==(const Rectx< Type > &r) const
Rect == Rect operator.
Definition: rect.h:107
Rectd RectdPS(double x, double y, double width, double height)
Definition: rect.h:507
Rectx< Type > & normalize()
Normalize rectangle.
Definition: rect.h:386
Rectx< Type > & translate(Type x, Type y)
Translate the rect.
Definition: rect.h:327
Rectf(float new_left, float new_top, const Sizex< float > &size)
Definition: rect.h:478
Rectf(const Pointx< float > &p, const Sizex< float > &size)
Definition: rect.h:474
2D (x,y) point structure.
Definition: point.h:53
Rectd(const Sizex< double > &s)
Definition: rect.h:488
Rectf(const Rectx< double > &rect)
Definition: rect.h:477
Pointx< Type > get_bottom_right() const
Returns the bottom-right point outside the rectangle.
Definition: rect.h:159
Rectf(float new_left, float new_top, float new_right, float new_bottom)
Definition: rect.h:473
Rectd(double new_left, double new_top, double new_right, double new_bottom)
Definition: rect.h:489
Rectx(const Pointx< Type > &p, const Sizex< Type > &size)
Constructs an rectangle.
Definition: rect.h:80
Pointx< Type > get_top_left() const
Returns the top-left point inside the rectangle.
Definition: rect.h:147
Rectx< Type > & set_width(Type width)
Sets the width of the rectangle.
Definition: rect.h:222
Rectd(const Sizex< int > &s)
Definition: rect.h:486
Type bottom
Y2-coordinate (point outside the rectange)
Definition: rect.h:128
Pointx< Type > get_bottom_left() const
Returns the bottom-left point outside the rectangle.
Definition: rect.h:165
2D (width,height) size structure.
Definition: size.h:55
Type get_height() const
Returns the height of the rectangle.
Definition: rect.h:134
Type y
Definition: vec2.h:83
Rectd(const Rectx< double > &rect)
Definition: rect.h:493