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"
47 constexpr Point(
const SDL_Point& p = {})
66 constexpr explicit Point(
const SDL_FPoint& p)
67 : SDL_Point{int(p.x), int(p.y)}
76 return x == other.x && y == other.y;
91 constexpr explicit operator bool()
const {
return x != 0 && y != 0; }
99 constexpr int GetX()
const {
return x; }
119 constexpr int GetY()
const {
return y; }
173 return Point(x + other.x, y + other.y);
186 return Point(x - other.x, y - other.y);
200 return Point(x / value, y / value);
225 return Point(x / other.x, y / other.y);
240 return Point(x % value, y % value);
255 return Point(x % other.x, y % other.y);
270 return Point(x * value, y * value);
297 return Point(x * other.x, y * other.y);
468 constexpr operator FPoint()
const;
485 constexpr FPoint(
const SDL_FPoint& p = {})
506 return x == other.x && y == other.y;
522 constexpr explicit operator bool()
const {
return x != 0 && y != 0; }
529 constexpr float GetX()
const {
return x; }
548 constexpr float GetY()
const {
return y; }
602 return FPoint(x + other.x, y + other.y);
615 return FPoint(x - other.x, y - other.y);
629 return FPoint(x / value, y / value);
643 return FPoint(x / other.x, y / other.y);
658 return FPoint(x * value, y * value);
673 return FPoint(x * other.x, y * other.y);
823 constexpr Rect(
const SDL_Rect& r = {})
836 constexpr Rect(
int x,
int y,
int w,
int h)
837 : SDL_Rect({x, y, w, h})
847 constexpr Rect(
const SDL_Point& corner,
const SDL_Point& size)
848 :
Rect{corner.x, corner.y, size.x, size.y}
868 constexpr operator bool()
const {
return !
Empty(); }
876 constexpr int GetX()
const {
return x; }
896 constexpr int GetY()
const {
return y; }
916 constexpr int GetW()
const {
return w; }
936 constexpr int GetH()
const {
return h; }
971 if (SDL_GetRectEnclosingPoints(
972 points.data(), points.size(), clip, &result)) {
989 return Rect(cx - w / 2, cy - h / 2, w, h);
1001 return Rect(center - size / 2, size);
1015 return Rect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
1036 constexpr int GetX2()
const {
return x + w - 1; }
1060 constexpr int GetY2()
const {
return y + h - 1; }
1145 return SDL_GetRectAndLineIntersection(
this, X1, Y1, X2, Y2);
1167 p1 ? &p1->y :
nullptr,
1168 p2 ? &p2->x :
nullptr,
1169 p2 ? &p2->y :
nullptr);
1182 constexpr operator FRect()
const;
1187 constexpr operator SDL_FRect()
const {
return operator SDL_FRect(); }
1206 constexpr bool Empty()
const {
return SDL_RectEmpty(
this); }
1228 return SDL_RectsEqual(
this, &other);
1241 return SDL_PointInRect(&p,
this);
1271 return SDL_HasRectIntersection(
this, &other);
1289 if (
Rect result; SDL_GetRectIntersection(
this, &other, &result)) {
1292 return std::nullopt;
1307 CheckError(SDL_GetRectUnion(
this, &other, &result));
1340 r.
Extend(hAmount, vAmount);
1365 constexpr Rect&
Extend(
unsigned int hAmount,
unsigned int vAmount)
1384 return Rect(x + offset.x, y + offset.y, w, h);
1397 return Rect(x - offset.x, y - offset.y, w, h);
1445 constexpr FRect(
const SDL_FRect& r = {})
1458 constexpr FRect(
float x,
float y,
float w,
float h)
1459 : SDL_FRect{x, y, w, h}
1464 constexpr FRect(
const SDL_FPoint& corner,
const SDL_FPoint& size)
1465 :
FRect{corner.x, corner.y, size.x, size.y}
1485 constexpr operator bool()
const {
return !
Empty(); }
1493 constexpr float GetX()
const {
return x; }
1513 constexpr float GetY()
const {
return y; }
1533 constexpr float GetW()
const {
return w; }
1553 constexpr float GetH()
const {
return h; }
1588 if (
FRect result; SDL_GetRectEnclosingPointsFloat(
1589 points.data(), points.size(), clip, &result)) {
1606 return FRect(cx - w / 2, cy - h / 2, w, h);
1618 return FRect(center - size / 2, size);
1632 return FRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
1653 constexpr float GetX2()
const {
return x + w - 1; }
1677 constexpr float GetY2()
const {
return y + h - 1; }
1763 return SDL_GetRectAndLineIntersectionFloat(
this, X1, Y1, X2, Y2);
1785 p1 ? &p1->y :
nullptr,
1786 p2 ? &p2->x :
nullptr,
1787 p2 ? &p2->y :
nullptr);
1807 constexpr bool Empty()
const {
return SDL_RectEmptyFloat(
this); }
1835 return SDL_RectsEqualEpsilon(
this, &other, epsilon);
1858 return SDL_RectsEqualFloat(
this, &other);
1871 return SDL_PointInRectFloat(&p,
this);
1901 return SDL_HasRectIntersectionFloat(
this, &other);
1919 if (
FRect result; SDL_GetRectIntersectionFloat(
this, &other, &result)) {
1937 CheckError(SDL_GetRectUnionFloat(
this, &other, &result));
1970 r.
Extend(hAmount, vAmount);
2014 return FRect(x + offset.x, y + offset.y, w, h);
2027 return FRect(x - offset.x, y - offset.y, w, h);
2074constexpr Point::operator
FPoint()
const {
return {float(x), float(y)}; }
2078 return FPoint(*
this) / value;
2082 return FPoint(*
this) * value;
2094 if (x < rect.x) x = rect.x;
2096 if (y < rect.y) y = rect.y;
2111 x = rect.x + rect.w - 1 - (rect.x - x + rect.w - 1) % rect.w;
2112 else if (x >= rect.x + rect.w)
2113 x = rect.x + (x - rect.x - rect.w) % rect.w;
2116 y = rect.y + rect.h - 1 - (rect.y - y + rect.h - 1) % rect.h;
2117 else if (y >= rect.y + rect.h)
2118 y = rect.y + (y - rect.y - rect.h) % rect.h;
2132 if (x < rect.x) x = rect.x;
2134 if (y < rect.y) y = rect.y;
2149 x = rect.x + rect.w - 1 -
fmod(rect.x - x + rect.w - 1, rect.w);
2150 else if (x >= rect.x + rect.w)
2151 x = rect.x +
fmod(x - rect.x - rect.w, rect.w);
2154 y = rect.y + rect.h - 1 -
fmod(rect.y - y + rect.h - 1, rect.h);
2155 else if (y >= rect.y + rect.h)
2156 y = rect.y +
fmod(y - rect.y - rect.h, rect.h);
2163 return {float(x), float(y), float(w), float(h)};
2166#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:2061
constexpr bool IsInRect(const FRect &r) const
Determine whether a point resides inside a floating point rectangle.
Definition SDL3pp_rect.h:2066
double fmod(double x, double y)
Return the floating-point remainder of x / y
Definition SDL3pp_stdinc.h:4579
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:479
constexpr FPoint operator/(const FPoint &other) const
Get point's memberwise division by another point.
Definition SDL3pp_rect.h:641
constexpr FPoint(float x, float y)
Constructs from its fields.
Definition SDL3pp_rect.h:496
constexpr FPoint & Wrap(const FRect &rect)
Wrap point coordinates within a specified rect.
Definition SDL3pp_rect.h:2146
constexpr float GetX() const
Get the x coordinate.
Definition SDL3pp_rect.h:529
constexpr float GetY() const
Get the y coordinate.
Definition SDL3pp_rect.h:548
constexpr FPoint operator-() const
Get point's memberwise negation.
Definition SDL3pp_rect.h:590
constexpr FPoint & operator/=(const FPoint &other)
Memberwise divide by another point.
Definition SDL3pp_rect.h:729
constexpr FPoint(const SDL_FPoint &p={})
Wraps FPoint.
Definition SDL3pp_rect.h:485
constexpr FPoint operator/(float value) const
Get point's memberwise division by an float.
Definition SDL3pp_rect.h:627
constexpr FPoint operator-(const FPoint &other) const
Get point's memberwise subtraction with another point.
Definition SDL3pp_rect.h:613
constexpr FPoint operator*(float value) const
Get point's memberwise multiplication by an float.
Definition SDL3pp_rect.h:656
constexpr FPoint & operator/=(float value)
Memberwise divide by an float.
Definition SDL3pp_rect.h:714
constexpr FPoint & SetX(float newX)
Set the x coordinate.
Definition SDL3pp_rect.h:537
constexpr FPoint GetClamped(const FRect &rect) const
Get a point with coordinates modified so it fits into a given rect.
Definition SDL3pp_rect.h:2123
constexpr bool operator==(const SDL_FPoint &p) const
Compares with the underlying type.
Definition SDL3pp_rect.h:512
constexpr FPoint & operator*=(const FPoint &other)
Memberwise multiply by another point.
Definition SDL3pp_rect.h:759
constexpr FPoint GetWrapped(const FRect &rect) const
Get a point wrapped within a specified rect.
Definition SDL3pp_rect.h:2139
constexpr FPoint operator+(const FPoint &other) const
Get point's memberwise addition with another point.
Definition SDL3pp_rect.h:600
constexpr FPoint & SetY(float newY)
Set the y coordinate.
Definition SDL3pp_rect.h:556
constexpr FPoint & Clamp(const FRect &rect)
Clamp point coordinates to make it fit into a given rect.
Definition SDL3pp_rect.h:2130
constexpr FPoint & operator*=(float value)
Memberwise multiply by an float.
Definition SDL3pp_rect.h:744
constexpr FPoint & operator-=(const FPoint &other)
Memberwise subtract another point.
Definition SDL3pp_rect.h:699
constexpr bool operator==(const FPoint &other) const
Default comparison operator.
Definition SDL3pp_rect.h:504
constexpr FPoint operator*(const FPoint &other) const
Get point's memberwise multiplication by another point.
Definition SDL3pp_rect.h:671
constexpr FPoint & operator+=(const FPoint &other)
Memberwise add another point.
Definition SDL3pp_rect.h:684
A rectangle, with the origin at the upper left (using floats).
Definition SDL3pp_rect.h:1439
constexpr float GetH() const
Get height of the rect.
Definition SDL3pp_rect.h:1553
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:1833
FRect GetIntersection(const FRect &other) const
Calculate the intersection of two rectangles with float precision.
Definition SDL3pp_rect.h:1917
bool HasIntersection(const FRect &other) const
Determine whether two rectangles intersect.
Definition SDL3pp_rect.h:1899
constexpr bool Equal(const FRect &other) const
Determine whether two rectangles are equal.
Definition SDL3pp_rect.h:1856
constexpr FRect & Extend(float hAmount, float vAmount)
Extend a rect by specified amount of pixels.
Definition SDL3pp_rect.h:1995
static constexpr FRect FromCenter(const FPoint ¢er, const FPoint &size)
Construct the rect from given center coordinates and size.
Definition SDL3pp_rect.h:1616
constexpr FRect & SetH(float newH)
Set the height of the rect.
Definition SDL3pp_rect.h:1561
constexpr FRect & SetW(float newW)
Set the width of the rect.
Definition SDL3pp_rect.h:1541
constexpr bool Contains(const FPoint &p) const
Check whether the rect contains given point.
Definition SDL3pp_rect.h:1869
constexpr float GetY() const
Get top y coordinate.
Definition SDL3pp_rect.h:1513
constexpr FRect operator+(const FPoint &offset) const
Get rectangle moved by a given offset.
Definition SDL3pp_rect.h:2012
constexpr bool operator==(const FRect &other) const
Definition SDL3pp_rect.h:1472
constexpr FPoint GetTopRight() const
Get top right corner of the rect.
Definition SDL3pp_rect.h:1709
constexpr FRect operator-(const FPoint &offset) const
Get rectangle moved by an opposite of given offset.
Definition SDL3pp_rect.h:2025
constexpr float GetW() const
Get width of the rect.
Definition SDL3pp_rect.h:1533
constexpr FRect & operator+=(const FPoint &offset)
Move by then given offset.
Definition SDL3pp_rect.h:2038
bool IntersectLine(FPoint *p1, FPoint *p2) const
Calculate the intersection of a rectangle and line segment.
Definition SDL3pp_rect.h:1782
constexpr bool operator==(const SDL_FRect &r) const
Compares with the underlying type.
Definition SDL3pp_rect.h:1477
constexpr FRect & operator-=(const FPoint &offset)
Move by an opposite of the given offset.
Definition SDL3pp_rect.h:2053
constexpr FPoint GetBottomRight() const
Get bottom right corner of the rect.
Definition SDL3pp_rect.h:1725
constexpr FPoint GetBottomLeft() const
Get bottom left corner of the rect.
Definition SDL3pp_rect.h:1717
constexpr bool Empty() const
Determine whether a rectangle has no area.
Definition SDL3pp_rect.h:1807
constexpr float GetX2() const
Get X coordinate of the rect second corner.
Definition SDL3pp_rect.h:1653
constexpr FRect GetExtension(unsigned int amount) const
Get a rect extended by specified amount of pixels.
Definition SDL3pp_rect.h:1949
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:1604
constexpr float GetY2() const
Get Y coordinate of the rect second corner.
Definition SDL3pp_rect.h:1677
constexpr FRect & SetY2(float y2)
Set Y coordinate of the rect second corner.
Definition SDL3pp_rect.h:1689
constexpr FRect & SetY(float newY)
Set the top y coordinate.
Definition SDL3pp_rect.h:1521
constexpr FRect(const SDL_FRect &r={})
Wraps FRect.
Definition SDL3pp_rect.h:1445
constexpr FRect & SetX2(float x2)
Set X coordinate of the rect second corner.
Definition SDL3pp_rect.h:1665
static constexpr FRect FromCorners(float x1, float y1, float x2, float y2)
Construct the rect from given corners coordinates.
Definition SDL3pp_rect.h:1630
constexpr FRect(const SDL_FPoint &corner, const SDL_FPoint &size)
Constructs from top-left corner plus size.
Definition SDL3pp_rect.h:1464
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:1761
constexpr FRect & SetX(float newX)
Set the left x coordinate.
Definition SDL3pp_rect.h:1501
constexpr FRect & Extend(float amount)
Extend a rect by specified amount of pixels.
Definition SDL3pp_rect.h:1982
static constexpr FRect FromCorners(const FPoint &p1, const FPoint &p2)
Construct the rect from given centers coordinates.
Definition SDL3pp_rect.h:1642
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:1584
FRect GetUnion(const FRect &other) const
Calculate the union of two rectangles with float precision.
Definition SDL3pp_rect.h:1934
constexpr FRect GetExtension(float hAmount, float vAmount) const
Get a rect extended by specified amount of pixels.
Definition SDL3pp_rect.h:1967
constexpr FPoint GetCentroid() const
Get centroid of the rect.
Definition SDL3pp_rect.h:1741
constexpr FRect(float x, float y, float w, float h)
Constructs from its fields.
Definition SDL3pp_rect.h:1458
constexpr FPoint GetTopLeft() const
Get top left corner of the rect.
Definition SDL3pp_rect.h:1701
constexpr FPoint GetSize() const
Get size of the rect.
Definition SDL3pp_rect.h:1733
constexpr bool Contains(const FRect &other) const
Check whether the rect contains given point.
Definition SDL3pp_rect.h:1882
constexpr float GetX() const
Get left x coordinate.
Definition SDL3pp_rect.h:1493
The structure that defines a point (using integers)
Definition SDL3pp_rect.h:41
constexpr Point & operator/=(int value)
Memberwise divide by an integer.
Definition SDL3pp_rect.h:338
constexpr Point & operator%=(const Point &other)
Memberwise remainder from division by another point.
Definition SDL3pp_rect.h:384
constexpr Point operator/(int value) const
Get point's memberwise division by an integer.
Definition SDL3pp_rect.h:198
constexpr Point GetClamped(const Rect &rect) const
Get a point with coordinates modified so it fits into a given rect.
Definition SDL3pp_rect.h:2085
constexpr Point operator-(const Point &other) const
Get point's memberwise subtraction with another point.
Definition SDL3pp_rect.h:184
constexpr int GetX() const
Get x coordinate.
Definition SDL3pp_rect.h:99
constexpr Point operator+(const Point &other) const
Get point's memberwise addition with another point.
Definition SDL3pp_rect.h:171
constexpr Point & Clamp(const Rect &rect)
Clamp point coordinates to make it fit into a given rect.
Definition SDL3pp_rect.h:2092
constexpr Point operator*(const Point &other) const
Get point's memberwise multiplication by another point.
Definition SDL3pp_rect.h:295
constexpr Point operator%(int value) const
Get point's memberwise remainder from division by an integer.
Definition SDL3pp_rect.h:238
constexpr Point & operator*=(const Point &other)
Memberwise multiply by another point.
Definition SDL3pp_rect.h:414
constexpr Point & SetX(int newX)
Set the x coordinate.
Definition SDL3pp_rect.h:107
constexpr bool operator==(const SDL_Point &p) const
Compares with the underlying type.
Definition SDL3pp_rect.h:82
constexpr Point & operator-=(const Point &other)
Memberwise subtract another point.
Definition SDL3pp_rect.h:323
constexpr Point(const SDL_Point &p={})
Wraps Point.
Definition SDL3pp_rect.h:47
constexpr Point(const SDL_FPoint &p)
Explicit conversion from FPoint.
Definition SDL3pp_rect.h:66
constexpr Point operator*(int value) const
Get point's memberwise multiplication by an integer.
Definition SDL3pp_rect.h:268
constexpr Point & operator/=(const Point &other)
Memberwise divide by another point.
Definition SDL3pp_rect.h:353
constexpr bool operator==(const Point &other) const
Default comparison operator.
Definition SDL3pp_rect.h:74
constexpr Point operator%(const Point &other) const
Get point's memberwise remainder from division by another point.
Definition SDL3pp_rect.h:253
constexpr Point GetWrapped(const Rect &rect) const
Get a point wrapped within a specified rect.
Definition SDL3pp_rect.h:2101
constexpr Point(int x, int y)
Constructs from its fields.
Definition SDL3pp_rect.h:58
constexpr Point & Wrap(const Rect &rect)
Wrap point coordinates within a specified rect.
Definition SDL3pp_rect.h:2108
constexpr int GetY() const
Get y coordinate.
Definition SDL3pp_rect.h:119
constexpr Point & SetY(int newY)
Set the y.
Definition SDL3pp_rect.h:127
constexpr Point & operator%=(int value)
Memberwise remainder from division by an integer.
Definition SDL3pp_rect.h:368
constexpr Point operator/(const Point &other) const
Get point's memberwise division by another point.
Definition SDL3pp_rect.h:223
constexpr Point & operator+=(const Point &other)
Memberwise add another point.
Definition SDL3pp_rect.h:308
constexpr Point operator-() const
Get point's memberwise negation.
Definition SDL3pp_rect.h:161
constexpr Point & operator*=(int value)
Memberwise multiply by an integer.
Definition SDL3pp_rect.h:399
A rectangle, with the origin at the upper left (using integers).
Definition SDL3pp_rect.h:817
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:987
constexpr bool Equal(const Rect &other) const
Determine whether two rectangles are equal.
Definition SDL3pp_rect.h:1226
constexpr int GetX() const
Get left x coordinate.
Definition SDL3pp_rect.h:876
constexpr Rect & operator-=(const Point &offset)
Move by an opposite of the given offset.
Definition SDL3pp_rect.h:1423
constexpr int GetW() const
Get width of the rect.
Definition SDL3pp_rect.h:916
static constexpr Rect FromCenter(const Point ¢er, const Point &size)
Construct the rect from given center coordinates and size.
Definition SDL3pp_rect.h:999
constexpr Rect GetExtension(unsigned int hAmount, unsigned int vAmount) const
Get a rect extended by specified amount of pixels.
Definition SDL3pp_rect.h:1337
constexpr Rect(int x, int y, int w, int h)
Constructs from its fields.
Definition SDL3pp_rect.h:836
constexpr Rect(const SDL_Rect &r={})
Wraps Rect.
Definition SDL3pp_rect.h:823
constexpr Rect & SetY(int newY)
Set the top y coordinate.
Definition SDL3pp_rect.h:904
constexpr Point GetTopLeft() const
Get top left corner of the rect.
Definition SDL3pp_rect.h:1084
constexpr bool Contains(const Point &p) const
Check whether the rect contains given point.
Definition SDL3pp_rect.h:1239
constexpr std::optional< Rect > GetIntersection(const Rect &other) const
Calculate the intersection of two rectangles.
Definition SDL3pp_rect.h:1287
constexpr Rect & Extend(unsigned int hAmount, unsigned int vAmount)
Extend a rect by specified amount of pixels.
Definition SDL3pp_rect.h:1365
constexpr bool operator==(const SDL_Rect &r) const
Compares with the underlying type.
Definition SDL3pp_rect.h:860
constexpr Rect operator+(const Point &offset) const
Get rectangle moved by a given offset.
Definition SDL3pp_rect.h:1382
bool IntersectLine(Point *p1, Point *p2) const
Calculate the intersection of a rectangle and line segment.
Definition SDL3pp_rect.h:1164
constexpr bool Empty() const
Determine whether a rectangle has no area.
Definition SDL3pp_rect.h:1206
constexpr Rect & operator+=(const Point &offset)
Move by then given offset.
Definition SDL3pp_rect.h:1408
constexpr bool operator==(const Rect &other) const
Definition SDL3pp_rect.h:855
constexpr Rect(const SDL_Point &corner, const SDL_Point &size)
Construct from offset and size.
Definition SDL3pp_rect.h:847
constexpr Rect GetExtension(unsigned int amount) const
Get a rect extended by specified amount of pixels.
Definition SDL3pp_rect.h:1319
constexpr Rect & Extend(unsigned int amount)
Extend a rect by specified amount of pixels.
Definition SDL3pp_rect.h:1352
constexpr Rect GetUnion(const Rect &other) const
Calculate the union of two rectangles.
Definition SDL3pp_rect.h:1304
constexpr Rect & SetW(int newW)
Set the width of the rect.
Definition SDL3pp_rect.h:924
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:966
constexpr Point GetCentroid() const
Get centroid of the rect.
Definition SDL3pp_rect.h:1124
constexpr Point GetBottomLeft() const
Get bottom left corner of the rect.
Definition SDL3pp_rect.h:1100
constexpr int GetH() const
Get height of the rect.
Definition SDL3pp_rect.h:936
constexpr Rect & SetX2(int x2)
Set X coordinate of the rect second corner.
Definition SDL3pp_rect.h:1048
constexpr Rect & SetH(int newH)
Set the height of the rect.
Definition SDL3pp_rect.h:944
static constexpr Rect FromCorners(int x1, int y1, int x2, int y2)
Construct the rect from given corners coordinates.
Definition SDL3pp_rect.h:1013
constexpr Point GetSize() const
Get size of the rect.
Definition SDL3pp_rect.h:1116
constexpr Rect operator-(const Point &offset) const
Get rectangle moved by an opposite of given offset.
Definition SDL3pp_rect.h:1395
constexpr Point GetBottomRight() const
Get bottom right corner of the rect.
Definition SDL3pp_rect.h:1108
constexpr int GetY2() const
Get Y coordinate of the rect second corner.
Definition SDL3pp_rect.h:1060
static constexpr Rect FromCorners(const Point &p1, const Point &p2)
Construct the rect from given centers coordinates.
Definition SDL3pp_rect.h:1025
bool HasIntersection(const Rect &other) const
Determine whether two rectangles intersect.
Definition SDL3pp_rect.h:1269
constexpr int GetY() const
Get top y coordinate.
Definition SDL3pp_rect.h:896
constexpr Rect & SetX(int newX)
Set the left x coordinate.
Definition SDL3pp_rect.h:884
constexpr bool Contains(const Rect &other) const
Check whether the rect contains given point.
Definition SDL3pp_rect.h:1252
constexpr Rect & SetY2(int y2)
Set Y coordinate of the rect second corner.
Definition SDL3pp_rect.h:1072
bool IntersectLine(int *X1, int *Y1, int *X2, int *Y2) const
Calculate the intersection of a rectangle and line segment.
Definition SDL3pp_rect.h:1143
constexpr Point GetTopRight() const
Get top right corner of the rect.
Definition SDL3pp_rect.h:1092
constexpr int GetX2() const
Get X coordinate of the rect second corner.
Definition SDL3pp_rect.h:1036