49 template<
typename Type>
69 Rectx(Type new_left, Type new_top, Type new_right, Type new_bottom)
85 :
left(new_left),
top(new_top),
right(new_left + size.width),
bottom(new_top + size.height) {}
190 return ((
left <=
r.left)
257 Rectx<Type> &
shrink(
const Type &new_left,
const Type &new_top,
const Type &new_right,
const Type &new_bottom)
284 Rectx<Type> &
expand(
const Type &expand_left,
const Type &expand_top,
const Type &expand_right,
const Type &expand_bottom)
286 left -= expand_left;
top -= expand_top;
right += expand_right;
bottom += expand_bottom;
295 left -= left_and_right;
296 right += left_and_right;
297 top -= top_and_bottom;
368 result.left =
max(
left, rect.left);
369 result.right =
min(
right, rect.right);
370 result.top =
max(
top, rect.top);
371 result.bottom =
min(
bottom, rect.bottom);
372 if (result.right < result.left)
373 result.left = result.right;
374 if (result.bottom < result.top)
375 result.top = result.bottom;
389 result.left =
min(
left, rect.left);
390 result.right =
max(
right, rect.right);
391 result.top =
min(
top, rect.top);
392 result.bottom =
max(
bottom, rect.bottom);
450 :
left(static_cast<int> (floor(rect.
left + 0.5
f))),
451 top(static_cast<int> (floor(rect.top + 0.5
f))),
452 right(static_cast<int> (floor(rect.
right + 0.5
f))),
453 bottom(static_cast<int> (floor(rect.bottom + 0.5
f)))
459 :
left(static_cast<int> (floor(rect.
left + 0.5))),
460 top(static_cast<int> (floor(rect.top + 0.5))),
461 right(static_cast<int> (floor(rect.
right + 0.5))),
462 bottom(static_cast<int> (floor(rect.bottom + 0.5)))
466 template<
typename Type>
468 :
left(static_cast<Type> (rect.
left)), top(static_cast<Type> (rect.top)),
469 right(static_cast<Type> (rect.
right)), bottom(static_cast<Type> (rect.bottom))
473 template<
typename Type>
475 :
left(static_cast<Type> (rect.
left)), top(static_cast<Type> (rect.top)),
476 right(static_cast<Type> (rect.
right)), bottom(static_cast<Type> (rect.bottom))
480 template<
typename Type>
482 :
left(static_cast<Type> (rect.
left)), top(static_cast<Type> (rect.top)),
483 right(static_cast<Type> (rect.
right)), bottom(static_cast<Type> (rect.bottom))
493 Rect(
int new_left,
int new_top,
int new_right,
int new_bottom) :
Rectx<int>(new_left, new_top, new_right, new_bottom) {}
508 Rectf(
float new_left,
float new_top,
float new_right,
float new_bottom) :
Rectx<float>(new_left, new_top, new_right, new_bottom) {}
524 Rectd(
double new_left,
double new_top,
double new_right,
double new_bottom) :
Rectx<double>(new_left, new_top, new_right, new_bottom) {}
534 return Rect(
x,
y,
x + width,
y + height);
539 return Rectf(
x,
y,
x + width,
y + height);
544 return Rectd(
x,
y,
x + width,
y + height);
Rectx(const Pointx< Type > &p, const Sizex< Type > &size)
Constructs an rectangle.
Definition: rect.h:76
bool is_overlapped(const Rectx< Type > &r) const
Returns true if rectangle passed is overlapping or inside this rectangle.
Definition: rect.h:182
Rect RectPS(int x, int y, int width, int height)
Definition: rect.h:532
Rectf(const Rectx< int > &rect)
Definition: rect.h:510
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.
2D (left,top,right,bottom) rectangle structure - Double
Definition: rect.h:517
Pointx< Type > get_center() const
Returns the center point of the rectangle.
Definition: rect.h:211
Rectd(const Rectx< float > &rect)
Definition: rect.h:527
Angle class.
Definition: angle.h:59
Type top
Y1-coordinate (top point inside the rectangle)
Definition: rect.h:133
Sizex< Type > get_size() const
Returns the size of the rectangle.
Definition: rect.h:148
Rect(int new_left, int new_top, int new_right, int new_bottom)
Definition: rect.h:493
Type get_height() const
Returns the height of the rectangle.
Definition: rect.h:145
Rectd(double new_left, double new_top, const Sizex< double > &size)
Definition: rect.h:529
Rect(const Rectx< double > &rect)
Definition: rect.h:497
Rectd(const Sizex< float > &s)
Definition: rect.h:522
Rectx< Type > & expand(const Type &expand)
Expand the rectangle.
Definition: rect.h:305
Rectx< Type > & translate(const Sizex< Type > &p)
Translate the rect.
Definition: rect.h:326
Rectx< Type > & overlap(const Rectx< Type > &rect)
Calculates the intersection of two rectangles.
Definition: rect.h:365
Pointx< Type > get_top_right() const
Returns the top-right point outside the rectangle.
Definition: rect.h:164
Origin
Alignment origins.
Definition: origin.h:38
Rectf(const Rectx< double > &rect)
Definition: rect.h:512
Rectx(Type new_left, Type new_top, Type new_right, Type new_bottom)
Constructs an rectangle.
Definition: rect.h:69
Rectf(const Sizex< float > &s)
Definition: rect.h:507
Rectx< Type > & set_bottom_right(const Vec2< Type > &p)
Sets the bottom-right point of the rectangle.
Definition: rect.h:229
Rectx< Type > operator*(const Type &s) const
Rect * operator.
Definition: rect.h:121
Rect(const Sizex< int > &s)
Definition: rect.h:492
Rectf()
Definition: rect.h:505
Rectx< Type > & expand(const Type &left_and_right, const Type &top_and_bottom)
Expand the rectangle.
Definition: rect.h:293
Rectx< Type > & set_width(Type width)
Sets the width of the rectangle.
Definition: rect.h:239
Rectx(Type new_left, Type new_top, const Sizex< Type > &size)
Constructs an rectangle.
Definition: rect.h:84
Pointx< Type > get_top_left() const
Returns the top-left point inside the rectangle.
Definition: rect.h:158
Type right
X2-coordinate (point outside the rectangle)
Definition: rect.h:136
Pointx< Type > get_bottom_right() const
Returns the bottom-right point outside the rectangle.
Definition: rect.h:170
bool operator!=(const Rectx< Type > &r) const
Rect != Rect operator.
Definition: rect.h:109
Rectf(float new_left, float new_top, float new_right, float new_bottom)
Definition: rect.h:508
Rectx< Type > & normalize()
Normalize rectangle.
Definition: rect.h:403
Type get_width() const
Returns the width of the rectangle.
Definition: rect.h:142
Rect(const Pointx< int > &p, const Sizex< int > &size)
Definition: rect.h:494
Rectx< Type > & shrink(const Type &shrink)
Shrink the rectangle.
Definition: rect.h:275
2D (left,top,right,bottom) rectangle structure - Integer
Definition: rect.h:488
static Rectx< Type > ltrb(Type left, Type top, Type right, Type bottom)
Definition: rect.h:127
Rectd(const Sizex< int > &s)
Definition: rect.h:521
Rect(const Rectx< int > &rect)
Definition: rect.h:495
Type bottom
Y2-coordinate (point outside the rectange)
Definition: rect.h:139
Rectx< Type > & set_size(const Sizex< Type > &size)
Sets the size of the rectangle, maintaining top/left position.
Definition: rect.h:353
Rectf RectfPS(float x, float y, float width, float height)
Definition: rect.h:537
2D (left,top,right,bottom) rectangle structure - Float
Definition: rect.h:502
Rectd(const Sizex< double > &s)
Definition: rect.h:523
Rectx< Type > & set_height(Type height)
Sets the height of the rectangle.
Definition: rect.h:248
Rect(const Rectx< float > &rect)
Definition: rect.h:496
Rectd(const Pointx< double > &p, const Sizex< double > &size)
Definition: rect.h:525
Rectx< Type > & expand(const Type &expand_left, const Type &expand_top, const Type &expand_right, const Type &expand_bottom)
Expand the rectangle.
Definition: rect.h:284
2D vector
Definition: line.h:46
static Rectx< Type > xywh(Type x, Type y, Type width, Type height)
Definition: rect.h:126
Rectf(float new_left, float new_top, const Sizex< float > &size)
Definition: rect.h:513
Type y
Definition: vec2.h:81
Rectf(const Sizex< int > &s)
Definition: rect.h:506
Rectf(const Pointx< float > &p, const Sizex< float > &size)
Definition: rect.h:509
Rectx< Type > & shrink(const Type &left_right, const Type &top_bottom)
Shrink the rectangle.
Definition: rect.h:266
Rectx< Type > & apply_alignment(Origin origin, Type x, Type y)
Applies an origin and offset pair to this rectangle.
Definition: rect.h:420
Rectx< Type > & set_top_left(const Vec2< Type > &p)
Sets the top-left point of the rectangle.
Definition: rect.h:219
Rectx< Type > & translate(const Vec2< Type > &p)
Translate the rect.
Definition: rect.h:317
Rectd RectdPS(double x, double y, double width, double height)
Definition: rect.h:542
Rectx< Type > & operator*=(const Type &s)
Rect *= operator.
Definition: rect.h:115
Rectx< Type > & shrink(const Type &new_left, const Type &new_top, const Type &new_right, const Type &new_bottom)
Shrink the rectangle.
Definition: rect.h:257
Type x
Definition: vec2.h:80
Type height
Size height.
Definition: size.h:77
Type left
X1-coordinate (left point inside the rectangle)
Definition: rect.h:130
Rectx(const Sizex< Type > &s)
Constructs an rectangle.
Definition: rect.h:61
Rectx< Type > & clip(const Rectx< Type > &cr)
Clip according to the specified clip rectangle.
Definition: rect.h:436
Rectx< Type > & bounding_rect(const Rectx< Type > &rect)
Calculates the bounding rectangle of the rectangles.
Definition: rect.h:386
2D (x,y) point structure.
Definition: point.h:51
Rectd()
Definition: rect.h:520
Pointx< Type > get_bottom_left() const
Returns the bottom-left point outside the rectangle.
Definition: rect.h:176
Rect(int new_left, int new_top, const Sizex< int > &size)
Definition: rect.h:498
Rectx< Type > & translate(Type x, Type y)
Translate the rect.
Definition: rect.h:344
Rectd(const Rectx< double > &rect)
Definition: rect.h:528
Rectd(const Rectx< int > &rect)
Definition: rect.h:526
Rectf(const Rectx< float > &rect)
Definition: rect.h:511
bool is_inside(const Rectx< Type > &r) const
Returns true if rectangle passed is inside this rectangle.
Definition: rect.h:188
Rect()
Definition: rect.h:491
Rectx()
Constructs an rectangle.
Definition: rect.h:56
bool operator==(const Rectx< Type > &r) const
Rect == Rect operator.
Definition: rect.h:103
2D (width,height) size structure.
Definition: size.h:54
bool contains(const Vec2< Type > &p) const
Returns true if the rectangle contains the point.
Definition: rect.h:151
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 > & translate(const Rectx< Type > &p)
Translate the rect by another rect (only uses the left and top coords).
Definition: rect.h:335
Type width
Size width.
Definition: size.h:74
Rectd(double new_left, double new_top, double new_right, double new_bottom)
Definition: rect.h:524