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) {}
92 template<typename OtherType, typename std::enable_if_t<std::is_integral<Type>::value && !std::is_integral<OtherType>::value,
int> = 0>
95 template<typename OtherType, typename std::enable_if_t<!std::is_integral<Type>::value || std::is_integral<OtherType>::value,
int> = 0>
186 return ((
left <=
r.left)
253 Rectx<Type> &
shrink(
const Type &new_left,
const Type &new_top,
const Type &new_right,
const Type &new_bottom)
280 Rectx<Type> &
expand(
const Type &expand_left,
const Type &expand_top,
const Type &expand_right,
const Type &expand_bottom)
282 left -= expand_left;
top -= expand_top;
right += expand_right;
bottom += expand_bottom;
291 left -= left_and_right;
292 right += left_and_right;
293 top -= top_and_bottom;
450 Rect(
int new_left,
int new_top,
int new_right,
int new_bottom) :
Rectx<int>(new_left, new_top, new_right, new_bottom) {}
465 Rectf(
float new_left,
float new_top,
float new_right,
float new_bottom) :
Rectx<float>(new_left, new_top, new_right, new_bottom) {}
481 Rectd(
double new_left,
double new_top,
double new_right,
double new_bottom) :
Rectx<double>(new_left, new_top, new_right, new_bottom) {}
491 return Rect(
x,
y,
x + width,
y + height);
496 return Rectf(
x,
y,
x + width,
y + height);
501 return Rectd(
x,
y,
x + width,
y + height);
Angle class.
Definition angle.h:60
2D (x,y) point structure.
Definition point.h:52
2D (left,top,right,bottom) rectangle structure - Integer
Definition rect.h:446
Rect(const Rectx< int > &rect)
Definition rect.h:452
Rect(const Rectx< float > &rect)
Definition rect.h:453
Rect()
Definition rect.h:448
Rect(int new_left, int new_top, const Sizex< int > &size)
Definition rect.h:455
Rect(int new_left, int new_top, int new_right, int new_bottom)
Definition rect.h:450
Rect(const Sizex< int > &s)
Definition rect.h:449
Rect(const Rectx< double > &rect)
Definition rect.h:454
Rect(const Pointx< int > &p, const Sizex< int > &size)
Definition rect.h:451
2D (left,top,right,bottom) rectangle structure - Double
Definition rect.h:475
Rectd(const Sizex< float > &s)
Definition rect.h:479
Rectd(const Rectx< double > &rect)
Definition rect.h:485
Rectd()
Definition rect.h:477
Rectd(double new_left, double new_top, const Sizex< double > &size)
Definition rect.h:486
Rectd(const Rectx< float > &rect)
Definition rect.h:484
Rectd(const Sizex< double > &s)
Definition rect.h:480
Rectd(double new_left, double new_top, double new_right, double new_bottom)
Definition rect.h:481
Rectd(const Pointx< double > &p, const Sizex< double > &size)
Definition rect.h:482
Rectd(const Rectx< int > &rect)
Definition rect.h:483
Rectd(const Sizex< int > &s)
Definition rect.h:478
2D (left,top,right,bottom) rectangle structure - Float
Definition rect.h:460
Rectf(const Sizex< int > &s)
Definition rect.h:463
Rectf(const Sizex< float > &s)
Definition rect.h:464
Rectf(const Rectx< int > &rect)
Definition rect.h:467
Rectf(float new_left, float new_top, const Sizex< float > &size)
Definition rect.h:470
Rectf()
Definition rect.h:462
Rectf(const Rectx< float > &rect)
Definition rect.h:468
Rectf(const Pointx< float > &p, const Sizex< float > &size)
Definition rect.h:466
Rectf(float new_left, float new_top, float new_right, float new_bottom)
Definition rect.h:465
Rectf(const Rectx< double > &rect)
Definition rect.h:469
Rectx< Type > & expand(const Type &expand)
Expand the rectangle.
Definition rect.h:301
Type right
X2-coordinate (point outside the rectangle)
Definition rect.h:132
bool operator!=(const Rectx< Type > &r) const
Rect != Rect operator.
Definition rect.h:105
Rectx< Type > & normalize()
Normalize rectangle.
Definition rect.h:399
Rectx< Type > & shrink(const Type &left_right, const Type &top_bottom)
Shrink the rectangle.
Definition rect.h:262
Rectx< Type > & shrink(const Type &shrink)
Shrink the rectangle.
Definition rect.h:271
Type get_height() const
Returns the height of the rectangle.
Definition rect.h:141
Rectx< Type > & clip(const Rectx< Type > &cr)
Clip according to the specified clip rectangle.
Definition rect.h:432
Sizex< Type > get_size() const
Returns the size of the rectangle.
Definition rect.h:144
Rectx(const Rectx< OtherType > ©)
Definition rect.h:93
Pointx< Type > get_bottom_right() const
Returns the bottom-right point outside the rectangle.
Definition rect.h:166
Rectx< Type > & translate(Type x, Type y)
Translate the rect.
Definition rect.h:340
bool contains(const Vec2< Type > &p) const
Returns true if the rectangle contains the point.
Definition rect.h:147
Rectx< Type > & overlap(const Rectx< Type > &rect)
Calculates the intersection of two rectangles.
Definition rect.h:361
Rectx< Type > & set_size(const Sizex< Type > &size)
Sets the size of the rectangle, maintaining top/left position.
Definition rect.h:349
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:280
Pointx< Type > get_top_right() const
Returns the top-right point outside the rectangle.
Definition rect.h:160
Rectx(const Pointx< Type > &p, const Sizex< Type > &size)
Constructs an rectangle.
Definition rect.h:76
static Rectx< Type > ltrb(Type left, Type top, Type right, Type bottom)
Definition rect.h:123
bool operator==(const Rectx< Type > &r) const
Rect == Rect operator.
Definition rect.h:99
Type bottom
Y2-coordinate (point outside the rectange)
Definition rect.h:135
Rectx< Type > & apply_alignment(Origin origin, Type x, Type y)
Applies an origin and offset pair to this rectangle.
Definition rect.h:416
Rectx< Type > & set_width(Type width)
Sets the width of the rectangle.
Definition rect.h:235
static Rectx< Type > xywh(Type x, Type y, Type width, Type height)
Definition rect.h:122
Rectx< Type > & expand(const Type &left_and_right, const Type &top_and_bottom)
Expand the rectangle.
Definition rect.h:289
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 Sizex< Type > &p)
Translate the rect.
Definition rect.h:322
Pointx< Type > get_bottom_left() const
Returns the bottom-left point outside the rectangle.
Definition rect.h:172
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:253
Type top
Y1-coordinate (top point inside the rectangle)
Definition rect.h:129
Rectx< Type > operator*(const Type &s) const
Rect * operator.
Definition rect.h:117
Rectx(Type new_left, Type new_top, const Sizex< Type > &size)
Constructs an rectangle.
Definition rect.h:84
bool is_overlapped(const Rectx< Type > &r) const
Returns true if rectangle passed is overlapping or inside this rectangle.
Definition rect.h:178
Rectx< Type > & translate(const Vec2< Type > &p)
Translate the rect.
Definition rect.h:313
Rectx(const Sizex< Type > &s)
Constructs an rectangle.
Definition rect.h:61
bool is_inside(const Rectx< Type > &r) const
Returns true if rectangle passed is inside this rectangle.
Definition rect.h:184
Type left
X1-coordinate (left point inside the rectangle)
Definition rect.h:126
Rectx()
Constructs an rectangle.
Definition rect.h:56
Type get_width() const
Returns the width of the rectangle.
Definition rect.h:138
Rectx(const Rectx< Type > &rect)=default
Constructs an rectangle.
Rectx< Type > & bounding_rect(const Rectx< Type > &rect)
Calculates the bounding rectangle of the rectangles.
Definition rect.h:382
Rectx< Type > & translate(const Rectx< Type > &p)
Translate the rect by another rect (only uses the left and top coords).
Definition rect.h:331
Rectx< Type > & set_top_left(const Vec2< Type > &p)
Sets the top-left point of the rectangle.
Definition rect.h:215
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.
Rectx(Type new_left, Type new_top, Type new_right, Type new_bottom)
Constructs an rectangle.
Definition rect.h:69
Rectx< Type > & operator*=(const Type &s)
Rect *= operator.
Definition rect.h:111
Pointx< Type > get_top_left() const
Returns the top-left point inside the rectangle.
Definition rect.h:154
Pointx< Type > get_center() const
Returns the center point of the rectangle.
Definition rect.h:207
Rectx< Type > & set_height(Type height)
Sets the height of the rectangle.
Definition rect.h:244
Rectx< Type > & set_bottom_right(const Vec2< Type > &p)
Sets the bottom-right point of the rectangle.
Definition rect.h:225
2D (width,height) size structure.
Definition size.h:55
Type height
Size height.
Definition size.h:82
Type width
Size width.
Definition size.h:79
2D vector
Definition vec2.h:76
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.
Type y
Definition vec2.h:81
Type x
Definition vec2.h:80
Rect RectPS(int x, int y, int width, int height)
Definition rect.h:489
Origin
Alignment origins.
Definition origin.h:39
Rectf RectfPS(float x, float y, float width, float height)
Definition rect.h:494
Rectd RectdPS(double x, double y, double width, double height)
Definition rect.h:499
@ max
Definition graphic_context.h:208
@ min
Definition graphic_context.h:207
@ angle
value is a color
Definition style_value_type.h:44