6#include <SDL3/SDL_rect.h>
7#include "SDL3pp_error.h"
8#include "SDL3pp_optionalRef.h"
9#include "SDL3pp_spanRef.h"
10#include "SDL3pp_stdinc.h"
52 constexpr Point(
const SDL_Point& p = {})
71 constexpr explicit Point(
const SDL_FPoint& p)
72 : SDL_Point{int(p.x), int(p.y)}
81 return x == other.x && y == other.y;
96 constexpr explicit operator bool()
const {
return x != 0 && y != 0; }
104 constexpr int GetX()
const {
return x; }
124 constexpr int GetY()
const {
return y; }
178 return Point(x + other.x, y + other.y);
191 return Point(x - other.x, y - other.y);
205 return Point(x / value, y / value);
230 return Point(x / other.x, y / other.y);
245 return Point(x % value, y % value);
260 return Point(x % other.x, y % other.y);
275 return Point(x * value, y * value);
302 return Point(x * other.x, y * other.y);
473 constexpr operator FPoint()
const;
493 constexpr FPoint(
const SDL_FPoint& p = {})
514 return x == other.x && y == other.y;
530 constexpr explicit operator bool()
const {
return x != 0 && y != 0; }
537 constexpr float GetX()
const {
return x; }
556 constexpr float GetY()
const {
return y; }
610 return FPoint(x + other.x, y + other.y);
623 return FPoint(x - other.x, y - other.y);
637 return FPoint(x / value, y / value);
651 return FPoint(x / other.x, y / other.y);
666 return FPoint(x * value, y * value);
681 return FPoint(x * other.x, y * other.y);
839 constexpr Rect(
const SDL_Rect& r = {})
852 constexpr Rect(
int x,
int y,
int w,
int h)
853 : SDL_Rect({x, y, w, h})
863 constexpr Rect(
const SDL_Point& corner,
const SDL_Point& size)
864 :
Rect{corner.x, corner.y, size.x, size.y}
884 constexpr operator bool()
const {
return !
Empty(); }
892 constexpr int GetX()
const {
return x; }
912 constexpr int GetY()
const {
return y; }
932 constexpr int GetW()
const {
return w; }
952 constexpr int GetH()
const {
return h; }
987 if (SDL_GetRectEnclosingPoints(
988 points.data(), points.size(), clip, &result)) {
1005 return Rect(cx - w / 2, cy - h / 2, w, h);
1017 return Rect(center - size / 2, size);
1031 return Rect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
1052 constexpr int GetX2()
const {
return x + w - 1; }
1076 constexpr int GetY2()
const {
return y + h - 1; }
1161 return SDL_GetRectAndLineIntersection(
this, X1, Y1, X2, Y2);
1183 p1 ? &p1->y :
nullptr,
1184 p2 ? &p2->x :
nullptr,
1185 p2 ? &p2->y :
nullptr);
1198 constexpr operator FRect()
const;
1203 constexpr operator SDL_FRect()
const
1205 return {float(x), float(y), float(w), float(h)};
1225 constexpr bool Empty()
const {
return SDL_RectEmpty(
this); }
1247 return SDL_RectsEqual(
this, &other);
1260 return SDL_PointInRect(&p,
this);
1290 return SDL_HasRectIntersection(
this, &other);
1308 if (
Rect result; SDL_GetRectIntersection(
this, &other, &result)) {
1311 return std::nullopt;
1326 CheckError(SDL_GetRectUnion(
this, &other, &result));
1359 r.
Extend(hAmount, vAmount);
1384 constexpr Rect&
Extend(
unsigned int hAmount,
unsigned int vAmount)
1403 return Rect(x + offset.x, y + offset.y, w, h);
1416 return Rect(x - offset.x, y - offset.y, w, h);
1475 constexpr FRect(
const SDL_FRect& r = {})
1488 constexpr FRect(
float x,
float y,
float w,
float h)
1489 : SDL_FRect{x, y, w, h}
1494 constexpr FRect(
const SDL_FPoint& corner,
const SDL_FPoint& size)
1495 :
FRect{corner.x, corner.y, size.x, size.y}
1515 constexpr operator bool()
const {
return !
Empty(); }
1523 constexpr float GetX()
const {
return x; }
1543 constexpr float GetY()
const {
return y; }
1563 constexpr float GetW()
const {
return w; }
1583 constexpr float GetH()
const {
return h; }
1618 if (
FRect result; SDL_GetRectEnclosingPointsFloat(
1619 points.data(), points.size(), clip, &result)) {
1636 return FRect(cx - w / 2, cy - h / 2, w, h);
1648 return FRect(center - size / 2, size);
1662 return FRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
1683 constexpr float GetX2()
const {
return x + w - 1; }
1707 constexpr float GetY2()
const {
return y + h - 1; }
1793 return SDL_GetRectAndLineIntersectionFloat(
this, X1, Y1, X2, Y2);
1815 p1 ? &p1->y :
nullptr,
1816 p2 ? &p2->x :
nullptr,
1817 p2 ? &p2->y :
nullptr);
1837 constexpr bool Empty()
const {
return SDL_RectEmptyFloat(
this); }
1865 return SDL_RectsEqualEpsilon(
this, &other, epsilon);
1888 return SDL_RectsEqualFloat(
this, &other);
1901 return SDL_PointInRectFloat(&p,
this);
1931 return SDL_HasRectIntersectionFloat(
this, &other);
1949 if (
FRect result; SDL_GetRectIntersectionFloat(
this, &other, &result)) {
1967 CheckError(SDL_GetRectUnionFloat(
this, &other, &result));
2000 r.
Extend(hAmount, vAmount);
2044 return FRect(x + offset.x, y + offset.y, w, h);
2057 return FRect(x - offset.x, y - offset.y, w, h);
2104constexpr Point::operator
FPoint()
const {
return {float(x), float(y)}; }
2108 return FPoint(*
this) / value;
2112 return FPoint(*
this) * value;
2124 if (x < rect.x) x = rect.x;
2126 if (y < rect.y) y = rect.y;
2141 x = rect.x + rect.w - 1 - (rect.x - x + rect.w - 1) % rect.w;
2142 else if (x >= rect.x + rect.w)
2143 x = rect.x + (x - rect.x - rect.w) % rect.w;
2146 y = rect.y + rect.h - 1 - (rect.y - y + rect.h - 1) % rect.h;
2147 else if (y >= rect.y + rect.h)
2148 y = rect.y + (y - rect.y - rect.h) % rect.h;
2162 if (x < rect.x) x = rect.x;
2164 if (y < rect.y) y = rect.y;
2179 x = rect.x + rect.w - 1 -
fmod(rect.x - x + rect.w - 1, rect.w);
2180 else if (x >= rect.x + rect.w)
2181 x = rect.x +
fmod(x - rect.x - rect.w, rect.w);
2184 y = rect.y + rect.h - 1 -
fmod(rect.y - y + rect.h - 1, rect.h);
2185 else if (y >= rect.y + rect.h)
2186 y = rect.y +
fmod(y - rect.y - rect.h, rect.h);
2193 return {float(x), float(y), float(w), float(h)};
2196#pragma endregion impl
Optional-like shim for references.
Definition SDL3pp_optionalRef.h:20
span-like for empty-derived structs
Definition SDL3pp_spanRef.h:24
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition SDL3pp_error.h:206
constexpr bool IsInRect(const Rect &r) const
Determine whether a point resides inside a rectangle.
Definition SDL3pp_rect.h:2091
constexpr bool IsInRect(const FRect &r) const
Determine whether a point resides inside a floating point rectangle.
Definition SDL3pp_rect.h:2096
double fmod(double x, double y)
Return the floating-point remainder of x / y
Definition SDL3pp_stdinc.h:4585
the main namespace where all SDL3pp public functions and types live
Definition SDL3pp_assert.h:7
The structure that defines a point (using floating point values).
Definition SDL3pp_rect.h:487
constexpr FPoint operator/(const FPoint &other) const
Get point's memberwise division by another point.
Definition SDL3pp_rect.h:649
constexpr FPoint(float x, float y)
Constructs from its fields.
Definition SDL3pp_rect.h:504
constexpr FPoint & Wrap(const FRect &rect)
Wrap point coordinates within a specified rect.
Definition SDL3pp_rect.h:2176
constexpr float GetX() const
Get the x coordinate.
Definition SDL3pp_rect.h:537
constexpr float GetY() const
Get the y coordinate.
Definition SDL3pp_rect.h:556
constexpr FPoint operator-() const
Get point's memberwise negation.
Definition SDL3pp_rect.h:598
constexpr FPoint & operator/=(const FPoint &other)
Memberwise divide by another point.
Definition SDL3pp_rect.h:737
constexpr FPoint(const SDL_FPoint &p={})
Wraps FPoint.
Definition SDL3pp_rect.h:493
constexpr FPoint operator/(float value) const
Get point's memberwise division by an float.
Definition SDL3pp_rect.h:635
constexpr FPoint operator-(const FPoint &other) const
Get point's memberwise subtraction with another point.
Definition SDL3pp_rect.h:621
constexpr FPoint operator*(float value) const
Get point's memberwise multiplication by an float.
Definition SDL3pp_rect.h:664
constexpr FPoint & operator/=(float value)
Memberwise divide by an float.
Definition SDL3pp_rect.h:722
constexpr FPoint & SetX(float newX)
Set the x coordinate.
Definition SDL3pp_rect.h:545
constexpr FPoint GetClamped(const FRect &rect) const
Get a point with coordinates modified so it fits into a given rect.
Definition SDL3pp_rect.h:2153
constexpr bool operator==(const SDL_FPoint &p) const
Compares with the underlying type.
Definition SDL3pp_rect.h:520
constexpr FPoint & operator*=(const FPoint &other)
Memberwise multiply by another point.
Definition SDL3pp_rect.h:767
constexpr FPoint GetWrapped(const FRect &rect) const
Get a point wrapped within a specified rect.
Definition SDL3pp_rect.h:2169
constexpr FPoint operator+(const FPoint &other) const
Get point's memberwise addition with another point.
Definition SDL3pp_rect.h:608
constexpr FPoint & SetY(float newY)
Set the y coordinate.
Definition SDL3pp_rect.h:564
constexpr FPoint & Clamp(const FRect &rect)
Clamp point coordinates to make it fit into a given rect.
Definition SDL3pp_rect.h:2160
constexpr FPoint & operator*=(float value)
Memberwise multiply by an float.
Definition SDL3pp_rect.h:752
constexpr FPoint & operator-=(const FPoint &other)
Memberwise subtract another point.
Definition SDL3pp_rect.h:707
constexpr bool operator==(const FPoint &other) const
Default comparison operator.
Definition SDL3pp_rect.h:512
constexpr FPoint operator*(const FPoint &other) const
Get point's memberwise multiplication by another point.
Definition SDL3pp_rect.h:679
constexpr FPoint & operator+=(const FPoint &other)
Memberwise add another point.
Definition SDL3pp_rect.h:692
A rectangle, with the origin at the upper left (using floating point values).
Definition SDL3pp_rect.h:1469
constexpr float GetH() const
Get height of the rect.
Definition SDL3pp_rect.h:1583
constexpr bool EqualEpsilon(const FRect &other, const float epsilon) const
Determine whether two floating point rectangles are equal, within some given epsilon.
Definition SDL3pp_rect.h:1863
FRect GetIntersection(const FRect &other) const
Calculate the intersection of two rectangles with float precision.
Definition SDL3pp_rect.h:1947
bool HasIntersection(const FRect &other) const
Determine whether two rectangles intersect.
Definition SDL3pp_rect.h:1929
constexpr bool Equal(const FRect &other) const
Determine whether two rectangles are equal.
Definition SDL3pp_rect.h:1886
constexpr FRect & Extend(float hAmount, float vAmount)
Extend a rect by specified amount of pixels.
Definition SDL3pp_rect.h:2025
static constexpr FRect FromCenter(const FPoint ¢er, const FPoint &size)
Construct the rect from given center coordinates and size.
Definition SDL3pp_rect.h:1646
constexpr FRect & SetH(float newH)
Set the height of the rect.
Definition SDL3pp_rect.h:1591
constexpr FRect & SetW(float newW)
Set the width of the rect.
Definition SDL3pp_rect.h:1571
constexpr bool Contains(const FPoint &p) const
Check whether the rect contains given point.
Definition SDL3pp_rect.h:1899
constexpr float GetY() const
Get top y coordinate.
Definition SDL3pp_rect.h:1543
constexpr FRect operator+(const FPoint &offset) const
Get rectangle moved by a given offset.
Definition SDL3pp_rect.h:2042
constexpr bool operator==(const FRect &other) const
Definition SDL3pp_rect.h:1502
constexpr FPoint GetTopRight() const
Get top right corner of the rect.
Definition SDL3pp_rect.h:1739
constexpr FRect operator-(const FPoint &offset) const
Get rectangle moved by an opposite of given offset.
Definition SDL3pp_rect.h:2055
constexpr float GetW() const
Get width of the rect.
Definition SDL3pp_rect.h:1563
constexpr FRect & operator+=(const FPoint &offset)
Move by then given offset.
Definition SDL3pp_rect.h:2068
bool IntersectLine(FPoint *p1, FPoint *p2) const
Calculate the intersection of a rectangle and line segment.
Definition SDL3pp_rect.h:1812
constexpr bool operator==(const SDL_FRect &r) const
Compares with the underlying type.
Definition SDL3pp_rect.h:1507
constexpr FRect & operator-=(const FPoint &offset)
Move by an opposite of the given offset.
Definition SDL3pp_rect.h:2083
constexpr FPoint GetBottomRight() const
Get bottom right corner of the rect.
Definition SDL3pp_rect.h:1755
constexpr FPoint GetBottomLeft() const
Get bottom left corner of the rect.
Definition SDL3pp_rect.h:1747
constexpr bool Empty() const
Determine whether a rectangle has no area.
Definition SDL3pp_rect.h:1837
constexpr float GetX2() const
Get X coordinate of the rect second corner.
Definition SDL3pp_rect.h:1683
constexpr FRect GetExtension(unsigned int amount) const
Get a rect extended by specified amount of pixels.
Definition SDL3pp_rect.h:1979
static constexpr FRect FromCenter(float cx, float cy, float w, float h)
Construct the rect from given center coordinates, width and height.
Definition SDL3pp_rect.h:1634
constexpr float GetY2() const
Get Y coordinate of the rect second corner.
Definition SDL3pp_rect.h:1707
constexpr FRect & SetY2(float y2)
Set Y coordinate of the rect second corner.
Definition SDL3pp_rect.h:1719
constexpr FRect & SetY(float newY)
Set the top y coordinate.
Definition SDL3pp_rect.h:1551
constexpr FRect(const SDL_FRect &r={})
Wraps FRect.
Definition SDL3pp_rect.h:1475
constexpr FRect & SetX2(float x2)
Set X coordinate of the rect second corner.
Definition SDL3pp_rect.h:1695
static constexpr FRect FromCorners(float x1, float y1, float x2, float y2)
Construct the rect from given corners coordinates.
Definition SDL3pp_rect.h:1660
constexpr FRect(const SDL_FPoint &corner, const SDL_FPoint &size)
Constructs from top-left corner plus size.
Definition SDL3pp_rect.h:1494
bool IntersectLine(float *X1, float *Y1, float *X2, float *Y2) const
Calculate the intersection of a rectangle and line segment with float precision.
Definition SDL3pp_rect.h:1791
constexpr FRect & SetX(float newX)
Set the left x coordinate.
Definition SDL3pp_rect.h:1531
constexpr FRect & Extend(float amount)
Extend a rect by specified amount of pixels.
Definition SDL3pp_rect.h:2012
static constexpr FRect FromCorners(const FPoint &p1, const FPoint &p2)
Construct the rect from given centers coordinates.
Definition SDL3pp_rect.h:1672
static FRect GetEnclosingPoints(SpanRef< const SDL_FPoint > points, OptionalRef< const SDL_FRect > clip=std::nullopt)
Calculate a minimal rectangle enclosing a set of points with float precision.
Definition SDL3pp_rect.h:1614
FRect GetUnion(const FRect &other) const
Calculate the union of two rectangles with float precision.
Definition SDL3pp_rect.h:1964
constexpr FRect GetExtension(float hAmount, float vAmount) const
Get a rect extended by specified amount of pixels.
Definition SDL3pp_rect.h:1997
constexpr FPoint GetCentroid() const
Get centroid of the rect.
Definition SDL3pp_rect.h:1771
constexpr FRect(float x, float y, float w, float h)
Constructs from its fields.
Definition SDL3pp_rect.h:1488
constexpr FPoint GetTopLeft() const
Get top left corner of the rect.
Definition SDL3pp_rect.h:1731
constexpr FPoint GetSize() const
Get size of the rect.
Definition SDL3pp_rect.h:1763
constexpr bool Contains(const FRect &other) const
Check whether the rect contains given point.
Definition SDL3pp_rect.h:1912
constexpr float GetX() const
Get left x coordinate.
Definition SDL3pp_rect.h:1523
The structure that defines a point (using integers).
Definition SDL3pp_rect.h:46
constexpr Point & operator/=(int value)
Memberwise divide by an integer.
Definition SDL3pp_rect.h:343
constexpr Point & operator%=(const Point &other)
Memberwise remainder from division by another point.
Definition SDL3pp_rect.h:389
constexpr Point operator/(int value) const
Get point's memberwise division by an integer.
Definition SDL3pp_rect.h:203
constexpr Point GetClamped(const Rect &rect) const
Get a point with coordinates modified so it fits into a given rect.
Definition SDL3pp_rect.h:2115
constexpr Point operator-(const Point &other) const
Get point's memberwise subtraction with another point.
Definition SDL3pp_rect.h:189
constexpr int GetX() const
Get x coordinate.
Definition SDL3pp_rect.h:104
constexpr Point operator+(const Point &other) const
Get point's memberwise addition with another point.
Definition SDL3pp_rect.h:176
constexpr Point & Clamp(const Rect &rect)
Clamp point coordinates to make it fit into a given rect.
Definition SDL3pp_rect.h:2122
constexpr Point operator*(const Point &other) const
Get point's memberwise multiplication by another point.
Definition SDL3pp_rect.h:300
constexpr Point operator%(int value) const
Get point's memberwise remainder from division by an integer.
Definition SDL3pp_rect.h:243
constexpr Point & operator*=(const Point &other)
Memberwise multiply by another point.
Definition SDL3pp_rect.h:419
constexpr Point & SetX(int newX)
Set the x coordinate.
Definition SDL3pp_rect.h:112
constexpr bool operator==(const SDL_Point &p) const
Compares with the underlying type.
Definition SDL3pp_rect.h:87
constexpr Point & operator-=(const Point &other)
Memberwise subtract another point.
Definition SDL3pp_rect.h:328
constexpr Point(const SDL_Point &p={})
Wraps Point.
Definition SDL3pp_rect.h:52
constexpr Point(const SDL_FPoint &p)
Explicit conversion from FPoint.
Definition SDL3pp_rect.h:71
constexpr Point operator*(int value) const
Get point's memberwise multiplication by an integer.
Definition SDL3pp_rect.h:273
constexpr Point & operator/=(const Point &other)
Memberwise divide by another point.
Definition SDL3pp_rect.h:358
constexpr bool operator==(const Point &other) const
Default comparison operator.
Definition SDL3pp_rect.h:79
constexpr Point operator%(const Point &other) const
Get point's memberwise remainder from division by another point.
Definition SDL3pp_rect.h:258
constexpr Point GetWrapped(const Rect &rect) const
Get a point wrapped within a specified rect.
Definition SDL3pp_rect.h:2131
constexpr Point(int x, int y)
Constructs from its fields.
Definition SDL3pp_rect.h:63
constexpr Point & Wrap(const Rect &rect)
Wrap point coordinates within a specified rect.
Definition SDL3pp_rect.h:2138
constexpr int GetY() const
Get y coordinate.
Definition SDL3pp_rect.h:124
constexpr Point & SetY(int newY)
Set the y.
Definition SDL3pp_rect.h:132
constexpr Point & operator%=(int value)
Memberwise remainder from division by an integer.
Definition SDL3pp_rect.h:373
constexpr Point operator/(const Point &other) const
Get point's memberwise division by another point.
Definition SDL3pp_rect.h:228
constexpr Point & operator+=(const Point &other)
Memberwise add another point.
Definition SDL3pp_rect.h:313
constexpr Point operator-() const
Get point's memberwise negation.
Definition SDL3pp_rect.h:166
constexpr Point & operator*=(int value)
Memberwise multiply by an integer.
Definition SDL3pp_rect.h:404
A rectangle, with the origin at the upper left (using integers).
Definition SDL3pp_rect.h:833
static constexpr Rect FromCenter(int cx, int cy, int w, int h)
Construct the rect from given center coordinates, width and height.
Definition SDL3pp_rect.h:1003
constexpr bool Equal(const Rect &other) const
Determine whether two rectangles are equal.
Definition SDL3pp_rect.h:1245
constexpr int GetX() const
Get left x coordinate.
Definition SDL3pp_rect.h:892
constexpr Rect & operator-=(const Point &offset)
Move by an opposite of the given offset.
Definition SDL3pp_rect.h:1442
constexpr int GetW() const
Get width of the rect.
Definition SDL3pp_rect.h:932
static constexpr Rect FromCenter(const Point ¢er, const Point &size)
Construct the rect from given center coordinates and size.
Definition SDL3pp_rect.h:1015
constexpr Rect GetExtension(unsigned int hAmount, unsigned int vAmount) const
Get a rect extended by specified amount of pixels.
Definition SDL3pp_rect.h:1356
constexpr Rect(int x, int y, int w, int h)
Constructs from its fields.
Definition SDL3pp_rect.h:852
constexpr Rect(const SDL_Rect &r={})
Wraps Rect.
Definition SDL3pp_rect.h:839
constexpr Rect & SetY(int newY)
Set the top y coordinate.
Definition SDL3pp_rect.h:920
constexpr Point GetTopLeft() const
Get top left corner of the rect.
Definition SDL3pp_rect.h:1100
constexpr bool Contains(const Point &p) const
Check whether the rect contains given point.
Definition SDL3pp_rect.h:1258
constexpr std::optional< Rect > GetIntersection(const Rect &other) const
Calculate the intersection of two rectangles.
Definition SDL3pp_rect.h:1306
constexpr Rect & Extend(unsigned int hAmount, unsigned int vAmount)
Extend a rect by specified amount of pixels.
Definition SDL3pp_rect.h:1384
constexpr bool operator==(const SDL_Rect &r) const
Compares with the underlying type.
Definition SDL3pp_rect.h:876
constexpr Rect operator+(const Point &offset) const
Get rectangle moved by a given offset.
Definition SDL3pp_rect.h:1401
bool IntersectLine(Point *p1, Point *p2) const
Calculate the intersection of a rectangle and line segment.
Definition SDL3pp_rect.h:1180
constexpr bool Empty() const
Determine whether a rectangle has no area.
Definition SDL3pp_rect.h:1225
constexpr Rect & operator+=(const Point &offset)
Move by then given offset.
Definition SDL3pp_rect.h:1427
constexpr bool operator==(const Rect &other) const
Definition SDL3pp_rect.h:871
constexpr Rect(const SDL_Point &corner, const SDL_Point &size)
Construct from offset and size.
Definition SDL3pp_rect.h:863
constexpr Rect GetExtension(unsigned int amount) const
Get a rect extended by specified amount of pixels.
Definition SDL3pp_rect.h:1338
constexpr Rect & Extend(unsigned int amount)
Extend a rect by specified amount of pixels.
Definition SDL3pp_rect.h:1371
constexpr Rect GetUnion(const Rect &other) const
Calculate the union of two rectangles.
Definition SDL3pp_rect.h:1323
constexpr Rect & SetW(int newW)
Set the width of the rect.
Definition SDL3pp_rect.h:940
static Rect GetEnclosingPoints(SpanRef< const SDL_Point > points, OptionalRef< const SDL_Rect > clip=std::nullopt)
Calculate a minimal rectangle enclosing a set of points.
Definition SDL3pp_rect.h:982
constexpr Point GetCentroid() const
Get centroid of the rect.
Definition SDL3pp_rect.h:1140
constexpr Point GetBottomLeft() const
Get bottom left corner of the rect.
Definition SDL3pp_rect.h:1116
constexpr int GetH() const
Get height of the rect.
Definition SDL3pp_rect.h:952
constexpr Rect & SetX2(int x2)
Set X coordinate of the rect second corner.
Definition SDL3pp_rect.h:1064
constexpr Rect & SetH(int newH)
Set the height of the rect.
Definition SDL3pp_rect.h:960
static constexpr Rect FromCorners(int x1, int y1, int x2, int y2)
Construct the rect from given corners coordinates.
Definition SDL3pp_rect.h:1029
constexpr Point GetSize() const
Get size of the rect.
Definition SDL3pp_rect.h:1132
constexpr Rect operator-(const Point &offset) const
Get rectangle moved by an opposite of given offset.
Definition SDL3pp_rect.h:1414
constexpr Point GetBottomRight() const
Get bottom right corner of the rect.
Definition SDL3pp_rect.h:1124
constexpr int GetY2() const
Get Y coordinate of the rect second corner.
Definition SDL3pp_rect.h:1076
static constexpr Rect FromCorners(const Point &p1, const Point &p2)
Construct the rect from given centers coordinates.
Definition SDL3pp_rect.h:1041
bool HasIntersection(const Rect &other) const
Determine whether two rectangles intersect.
Definition SDL3pp_rect.h:1288
constexpr int GetY() const
Get top y coordinate.
Definition SDL3pp_rect.h:912
constexpr Rect & SetX(int newX)
Set the left x coordinate.
Definition SDL3pp_rect.h:900
constexpr bool Contains(const Rect &other) const
Check whether the rect contains given point.
Definition SDL3pp_rect.h:1271
constexpr Rect & SetY2(int y2)
Set Y coordinate of the rect second corner.
Definition SDL3pp_rect.h:1088
bool IntersectLine(int *X1, int *Y1, int *X2, int *Y2) const
Calculate the intersection of a rectangle and line segment.
Definition SDL3pp_rect.h:1159
constexpr Point GetTopRight() const
Get top right corner of the rect.
Definition SDL3pp_rect.h:1108
constexpr int GetX2() const
Get X coordinate of the rect second corner.
Definition SDL3pp_rect.h:1052