4#include <SDL3/SDL_rect.h>
5#include "SDL3pp_error.h"
6#include "SDL3pp_optionalRef.h"
7#include "SDL3pp_spanRef.h"
8#include "SDL3pp_stdinc.h"
48 return lhs.x == rhs.x && lhs.y == rhs.y;
54 return lhs.x == rhs.x && lhs.y == rhs.y;
60 return SDL_RectsEqual(&lhs, &rhs);
66 return SDL_RectsEqualFloat(&lhs, &rhs);
72 if (lhs.x != rhs.x)
return lhs.x <=> rhs.x;
73 return lhs.y <=> rhs.y;
79 if (lhs.x != rhs.x)
return lhs.x <=> rhs.x;
80 return lhs.y <=> rhs.y;
114 constexpr Point(
int x,
int y) noexcept
125 : SDL_Point{int(p.x), int(p.y)}
134 constexpr explicit operator bool() const noexcept
144 constexpr int GetX() const noexcept {
return x; }
163 constexpr int GetY() const noexcept {
return y; }
217 return Point(x + other.x, y + other.y);
230 return Point(x - other.x, y - other.y);
244 return Point(x / value, y / value);
269 return Point(x / other.x, y / other.y);
284 return Point(x % value, y % value);
299 return Point(x % other.x, y % other.y);
314 return Point(x * value, y * value);
341 return Point(x * other.x, y * other.y);
512 constexpr operator FPoint()
const;
543 constexpr FPoint(
float x,
float y) noexcept
553 constexpr explicit operator bool() const noexcept
563 constexpr float GetX() const noexcept {
return x; }
582 constexpr float GetY() const noexcept {
return y; }
636 return FPoint(x + other.x, y + other.y);
649 return FPoint(x - other.x, y - other.y);
663 return FPoint(x / value, y / value);
677 return FPoint(x / other.x, y / other.y);
692 return FPoint(x * value, y * value);
707 return FPoint(x * other.x, y * other.y);
878 constexpr Rect(
int x,
int y,
int w,
int h) noexcept
890 :
Rect{corner.x, corner.y, size.x, size.y}
900 return *
this == (
const RectRaw&)(other);
904 explicit operator bool()
const {
return !
Empty(); }
911 constexpr int GetX() const noexcept {
return x; }
930 constexpr int GetY() const noexcept {
return y; }
949 constexpr int GetW() const noexcept {
return w; }
968 constexpr int GetH() const noexcept {
return h; }
1015 return Rect(cx - w / 2, cy - h / 2, w, h);
1027 return Rect(center - size / 2, size);
1041 return Rect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
1062 constexpr int GetX2()
const {
return x + w - 1; }
1086 constexpr int GetY2()
const {
return y + h - 1; }
1171 p1 ? &p1->y :
nullptr,
1172 p2 ? &p2->x :
nullptr,
1173 p2 ? &p2->y :
nullptr);
1207 operator SDL_FRect()
const;
1210 constexpr operator FRect()
const;
1344 r.
Extend(hAmount, vAmount);
1369 constexpr Rect&
Extend(
unsigned int hAmount,
unsigned int vAmount)
1388 return Rect(x + offset.x, y + offset.y, w, h);
1401 return Rect(x - offset.x, y - offset.y, w, h);
1476 constexpr FRect(
float x,
float y,
float w,
float h) noexcept
1485 :
FRect{corner.x, corner.y, size.x, size.y}
1490 operator bool()
const {
return !
Empty(); }
1497 constexpr float GetX() const noexcept {
return x; }
1516 constexpr float GetY() const noexcept {
return y; }
1535 constexpr float GetW() const noexcept {
return w; }
1554 constexpr float GetH() const noexcept {
return h; }
1602 return FRect(cx - w / 2, cy - h / 2, w, h);
1614 return FRect(center - size / 2, size);
1628 return FRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
1649 constexpr float GetX2()
const {
return x + w - 1; }
1673 constexpr float GetY2()
const {
return y + h - 1; }
1780 p1 ? &p1->y :
nullptr,
1781 p2 ? &p2->x :
nullptr,
1782 p2 ? &p2->y :
nullptr);
1866 return SDL_PointInRectFloat(&p,
this);
1955 r.
Extend(hAmount, vAmount);
1999 return FRect(x + offset.x, y + offset.y, w, h);
2012 return FRect(x - offset.x, y - offset.y, w, h);
2059 SDL_RectToFRect(&rect, &frect);
2088 return SDL_PointInRect(&p, &r);
2139 return SDL_RectsEqual(&a, &b);
2164 return SDL_HasRectIntersection(&A, &B);
2190 if (
Rect result; SDL_GetRectIntersection(&A, &B, &result))
return result;
2243 if (
Rect result; SDL_GetRectEnclosingPoints(
2282 return SDL_GetRectAndLineIntersection(&rect, X1, Y1, X2, Y2);
2313 return SDL_PointInRectFloat(&p, &r);
2370 const float epsilon)
2372 return SDL_RectsEqualEpsilon(&a, &b, epsilon);
2376 const float epsilon)
const
2408 return SDL_RectsEqualFloat(&a, &b);
2433 return SDL_HasRectIntersectionFloat(&A, &B);
2459 if (
FRect r; SDL_GetRectIntersectionFloat(&A, &B, &r))
return r;
2484 CheckError(SDL_GetRectUnionFloat(&A, &B, &r));
2513 if (
FRect result; SDL_GetRectEnclosingPointsFloat(
2553 return SDL_GetRectAndLineIntersectionFloat(&rect, X1, Y1, X2, Y2);
2566constexpr Point::operator
FPoint()
const {
return {float(x), float(y)}; }
2570 return FPoint(*
this) / value;
2574 return FPoint(*
this) * value;
2586 if (x < rect.x) x = rect.x;
2588 if (y < rect.y) y = rect.y;
2603 x = rect.x + rect.w - 1 - (rect.x - x + rect.w - 1) % rect.w;
2604 else if (x >= rect.x + rect.w)
2605 x = rect.x + (x - rect.x - rect.w) % rect.w;
2608 y = rect.y + rect.h - 1 - (rect.y - y + rect.h - 1) % rect.h;
2609 else if (y >= rect.y + rect.h)
2610 y = rect.y + (y - rect.y - rect.h) % rect.h;
2624 if (x < rect.x) x = rect.x;
2626 if (y < rect.y) y = rect.y;
2641 x = rect.x + rect.w - 1 -
SDL::fmod(rect.x - x + rect.w - 1, rect.w);
2642 else if (x >= rect.x + rect.w)
2643 x = rect.x +
SDL::fmod(x - rect.x - rect.w, rect.w);
2646 y = rect.y + rect.h - 1 -
SDL::fmod(rect.y - y + rect.h - 1, rect.h);
2647 else if (y >= rect.y + rect.h)
2648 y = rect.y +
SDL::fmod(y - rect.y - rect.h, rect.h);
2655 return {float(x), float(y), float(w), float(h)};
Optional-like shim for references.
Definition SDL3pp_optionalRef.h:20
span-like for empty-derived structs
Definition SDL3pp_spanRef.h:24
constexpr T * data() const
Retrieves contained data.
Definition SDL3pp_spanRef.h:75
constexpr size_t size() const
Retrieves contained size.
Definition SDL3pp_spanRef.h:69
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition SDL3pp_error.h:199
constexpr bool operator==(ColorRaw lhs, ColorRaw rhs) noexcept
Comparison operator for Color.
Definition SDL3pp_pixels.h:2103
constexpr auto operator<=>(ColorRaw lhs, ColorRaw rhs) noexcept
Spaceship operator for Color.
Definition SDL3pp_pixels.h:2115
FRect RectToFRect(const RectRaw &rect)
Convert an Rect to FRect.
Definition SDL3pp_rect.h:2056
bool Equal(const RectRaw &other) const
Determine whether two rectangles are equal.
Definition SDL3pp_rect.h:2142
Rect GetRectIntersection(const RectRaw &A, const RectRaw &B)
Calculate the intersection of two rectangles.
Definition SDL3pp_rect.h:2188
bool HasIntersection(const RectRaw &other) const
Determine whether two rectangles intersect.
Definition SDL3pp_rect.h:2167
constexpr FRect GetRectUnionFloat(const FRectRaw &A, const FRectRaw &B)
Calculate the union of two rectangles with float precision.
Definition SDL3pp_rect.h:2481
bool HasRectIntersection(const RectRaw &A, const RectRaw &B)
Determine whether two rectangles intersect.
Definition SDL3pp_rect.h:2162
bool InRect(const RectRaw &r) const
Determine whether a point resides inside a rectangle.
Definition SDL3pp_rect.h:2091
SDL_Rect RectRaw
Alias to raw representation for Rect.
Definition SDL3pp_rect.h:34
bool EqualEpsilon(const FRectRaw &other, const float epsilon) const
Determine whether two floating point rectangles are equal, within some given epsilon.
Definition SDL3pp_rect.h:2375
static FRect GetEnclosingPoints(SpanRef< const FPointRaw > points, OptionalRef< const FRectRaw > clip=std::nullopt)
Calculate a minimal rectangle enclosing a set of points with float precision.
Definition SDL3pp_rect.h:2520
bool Equal(const FRectRaw &other) const
Determine whether two floating point rectangles are equal, within a default epsilon.
Definition SDL3pp_rect.h:2411
bool RectsEqual(const RectRaw &a, const RectRaw &b)
Determine whether two rectangles are equal.
Definition SDL3pp_rect.h:2137
bool GetLineIntersection(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:2556
Rect GetRectEnclosingPoints(SpanRef< const PointRaw > points, OptionalRef< const RectRaw > clip=std::nullopt)
Calculate a minimal rectangle enclosing a set of points.
Definition SDL3pp_rect.h:2239
SDL_FRect FRectRaw
Alias to raw representation for FRect.
Definition SDL3pp_rect.h:40
Rect GetIntersection(const RectRaw &other) const
Calculate the intersection of two rectangles.
Definition SDL3pp_rect.h:2194
bool GetRectAndLineIntersectionFloat(const FRectRaw &rect, float *X1, float *Y1, float *X2, float *Y2)
Calculate the intersection of a rectangle and line segment with float precision.
Definition SDL3pp_rect.h:2547
bool HasRectIntersectionFloat(const FRectRaw &A, const FRectRaw &B)
Determine whether two rectangles intersect with float precision.
Definition SDL3pp_rect.h:2431
FRect GetRectIntersectionFloat(const FRectRaw &A, const FRectRaw &B)
Calculate the intersection of two rectangles with float precision.
Definition SDL3pp_rect.h:2457
bool PointInRect(const PointRaw &p, const RectRaw &r)
Determine whether a point resides inside a rectangle.
Definition SDL3pp_rect.h:2086
bool RectEmptyFloat(const FRectRaw &r)
Determine whether a floating point rectangle takes no space.
Definition SDL3pp_rect.h:2339
bool InRect(const FRectRaw &r) const
Determine whether a point resides inside a floating point rectangle.
Definition SDL3pp_rect.h:2316
bool RectEmpty(const RectRaw &r)
Determine whether a rectangle has no area.
Definition SDL3pp_rect.h:2114
SDL_FPoint FPointRaw
Alias to raw representation for FPoint.
Definition SDL3pp_rect.h:28
constexpr Rect GetUnion(const RectRaw &other) const
Calculate the union of two rectangles.
Definition SDL3pp_rect.h:2218
static Rect GetEnclosingPoints(SpanRef< const PointRaw > points, OptionalRef< const RectRaw > clip=std::nullopt)
Calculate a minimal rectangle enclosing a set of points.
Definition SDL3pp_rect.h:2250
bool HasIntersection(const FRectRaw &other) const
Determine whether two rectangles intersect with float precision.
Definition SDL3pp_rect.h:2436
bool RectsEqualEpsilon(const FRectRaw &a, const FRectRaw &b, const float epsilon)
Determine whether two floating point rectangles are equal, within some given epsilon.
Definition SDL3pp_rect.h:2368
bool Empty() const
Determine whether a rectangle has no area.
Definition SDL3pp_rect.h:2341
constexpr Rect GetRectUnion(const RectRaw &A, const RectRaw &B)
Calculate the union of two rectangles.
Definition SDL3pp_rect.h:2211
bool RectsEqualFloat(const FRectRaw &a, const FRectRaw &b)
Determine whether two floating point rectangles are equal, within a default epsilon.
Definition SDL3pp_rect.h:2406
FRect GetIntersection(const FRectRaw &other) const
Calculate the intersection of two rectangles with float precision.
Definition SDL3pp_rect.h:2463
bool GetRectAndLineIntersection(const RectRaw &rect, int *X1, int *Y1, int *X2, int *Y2)
Calculate the intersection of a rectangle and line segment.
Definition SDL3pp_rect.h:2276
constexpr FRect GetUnion(const FRectRaw &other) const
Calculate the union of two rectangles with float precision.
Definition SDL3pp_rect.h:2488
bool PointInRectFloat(const FPointRaw &p, const FRectRaw &r)
Determine whether a point resides inside a floating point rectangle.
Definition SDL3pp_rect.h:2311
bool Empty() const
Determine whether a rectangle has no area.
Definition SDL3pp_rect.h:2116
FRect GetRectEnclosingPointsFloat(SpanRef< const FPointRaw > points, OptionalRef< const FRectRaw > clip=std::nullopt)
Calculate a minimal rectangle enclosing a set of points with float precision.
Definition SDL3pp_rect.h:2509
SDL_Point PointRaw
Alias to raw representation for Point.
Definition SDL3pp_rect.h:22
double fmod(double x, double y)
Return the floating-point remainder of x / y.
Definition SDL3pp_stdinc.h:5201
Main include header for the SDL3pp library.
Sint32 narrowS32(T value)
Narrows to Sint32.
Definition SDL3pp_stdinc.h:6257
The structure that defines a point (using floating point values).
Definition SDL3pp_rect.h:526
constexpr float GetY() const noexcept
Get the y coordinate.
Definition SDL3pp_rect.h:582
constexpr FPoint operator/(const FPoint &other) const
Get point's memberwise division by another point.
Definition SDL3pp_rect.h:675
constexpr FPoint & Wrap(const FRect &rect)
Wrap point coordinates within a specified rect.
Definition SDL3pp_rect.h:2638
constexpr FPoint operator-() const
Get point's memberwise negation.
Definition SDL3pp_rect.h:624
constexpr FPoint & operator/=(const FPoint &other)
Memberwise divide by another point.
Definition SDL3pp_rect.h:763
constexpr float GetX() const noexcept
Get the x coordinate.
Definition SDL3pp_rect.h:563
constexpr FPoint operator/(float value) const
Get point's memberwise division by an float.
Definition SDL3pp_rect.h:661
constexpr FPoint operator-(const FPoint &other) const
Get point's memberwise subtraction with another point.
Definition SDL3pp_rect.h:647
constexpr FPoint operator*(float value) const
Get point's memberwise multiplication by an float.
Definition SDL3pp_rect.h:690
constexpr FPoint(float x, float y) noexcept
Constructs from its fields.
Definition SDL3pp_rect.h:543
constexpr FPoint & operator/=(float value)
Memberwise divide by an float.
Definition SDL3pp_rect.h:748
constexpr FPoint & SetX(float newX) noexcept
Set the x coordinate.
Definition SDL3pp_rect.h:571
constexpr FPoint GetClamped(const FRect &rect) const
Get a point with coordinates modified so it fits into a given rect.
Definition SDL3pp_rect.h:2615
constexpr FPoint & operator*=(const FPoint &other)
Memberwise multiply by another point.
Definition SDL3pp_rect.h:793
constexpr FPoint & SetY(float newY) noexcept
Set the y coordinate.
Definition SDL3pp_rect.h:590
constexpr FPoint GetWrapped(const FRect &rect) const
Get a point wrapped within a specified rect.
Definition SDL3pp_rect.h:2631
constexpr FPoint operator+(const FPoint &other) const
Get point's memberwise addition with another point.
Definition SDL3pp_rect.h:634
constexpr FPoint & Clamp(const FRect &rect)
Clamp point coordinates to make it fit into a given rect.
Definition SDL3pp_rect.h:2622
constexpr FPoint & operator*=(float value)
Memberwise multiply by an float.
Definition SDL3pp_rect.h:778
constexpr FPoint(const FPointRaw &p={}) noexcept
Wraps FPoint.
Definition SDL3pp_rect.h:532
constexpr FPoint & operator-=(const FPoint &other)
Memberwise subtract another point.
Definition SDL3pp_rect.h:733
constexpr FPoint operator*(const FPoint &other) const
Get point's memberwise multiplication by another point.
Definition SDL3pp_rect.h:705
constexpr FPoint & operator+=(const FPoint &other)
Memberwise add another point.
Definition SDL3pp_rect.h:718
A rectangle stored using floating point values.
Definition SDL3pp_rect.h:1457
constexpr FRect & Extend(float hAmount, float vAmount)
Extend a rect by specified amount of pixels.
Definition SDL3pp_rect.h:1980
constexpr FRect operator+(const FPoint &offset) const
Get rectangle moved by a given offset.
Definition SDL3pp_rect.h:1997
constexpr FRect & SetX(float newX) noexcept
Set the left x coordinate.
Definition SDL3pp_rect.h:1505
static constexpr FRect FromCorners(FPoint p1, FPoint p2)
Construct the rect from given centers coordinates.
Definition SDL3pp_rect.h:1638
constexpr FRect(float x, float y, float w, float h) noexcept
Constructs from its fields.
Definition SDL3pp_rect.h:1476
constexpr float GetH() const noexcept
Get height of the rect.
Definition SDL3pp_rect.h:1554
constexpr float GetY() const noexcept
Get top y coordinate.
Definition SDL3pp_rect.h:1516
constexpr FPoint GetTopRight() const
Get top right corner of the rect.
Definition SDL3pp_rect.h:1705
constexpr FRect operator-(const FPoint &offset) const
Get rectangle moved by an opposite of given offset.
Definition SDL3pp_rect.h:2010
bool Contains(const FPointRaw &p) const
Check whether the rect contains given point.
Definition SDL3pp_rect.h:1864
constexpr FRect & operator+=(const FPoint &offset)
Move by then given offset.
Definition SDL3pp_rect.h:2023
constexpr float GetX() const noexcept
Get left x coordinate.
Definition SDL3pp_rect.h:1497
static constexpr FRect FromCenter(FPoint center, FPoint size)
Construct the rect from given center coordinates and size.
Definition SDL3pp_rect.h:1612
bool Contains(const FRectRaw &other) const
Check whether the rect contains given point.
Definition SDL3pp_rect.h:1877
constexpr FRect & operator-=(const FPoint &offset)
Move by an opposite of the given offset.
Definition SDL3pp_rect.h:2038
constexpr FPoint GetBottomRight() const
Get bottom right corner of the rect.
Definition SDL3pp_rect.h:1721
constexpr FPoint GetBottomLeft() const
Get bottom left corner of the rect.
Definition SDL3pp_rect.h:1713
constexpr FRect(const FPointRaw &corner, const FPointRaw &size)
Constructs from top-left corner plus size.
Definition SDL3pp_rect.h:1484
constexpr float GetX2() const
Get X coordinate of the rect second corner.
Definition SDL3pp_rect.h:1649
constexpr FRect GetExtension(unsigned int amount) const
Get a rect extended by specified amount of pixels.
Definition SDL3pp_rect.h:1934
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:1600
constexpr float GetY2() const
Get Y coordinate of the rect second corner.
Definition SDL3pp_rect.h:1673
constexpr FRect & SetH(float newH) noexcept
Set the height of the rect.
Definition SDL3pp_rect.h:1562
constexpr FRect & SetY2(float y2)
Set Y coordinate of the rect second corner.
Definition SDL3pp_rect.h:1685
constexpr float GetW() const noexcept
Get width of the rect.
Definition SDL3pp_rect.h:1535
constexpr FRect & SetX2(float x2)
Set X coordinate of the rect second corner.
Definition SDL3pp_rect.h:1661
static constexpr FRect FromCorners(float x1, float y1, float x2, float y2)
Construct the rect from given corners coordinates.
Definition SDL3pp_rect.h:1626
constexpr FRect & Extend(float amount)
Extend a rect by specified amount of pixels.
Definition SDL3pp_rect.h:1967
constexpr FRect & SetY(float newY) noexcept
Set the top y coordinate.
Definition SDL3pp_rect.h:1524
constexpr FRect & SetW(float newW) noexcept
Set the width of the rect.
Definition SDL3pp_rect.h:1543
constexpr FRect GetExtension(float hAmount, float vAmount) const
Get a rect extended by specified amount of pixels.
Definition SDL3pp_rect.h:1952
constexpr FPoint GetCentroid() const
Get centroid of the rect.
Definition SDL3pp_rect.h:1737
bool GetLineIntersection(FPoint *p1, FPoint *p2) const
Determine whether a floating point rectangle takes no space.
Definition SDL3pp_rect.h:1777
constexpr FPoint GetTopLeft() const
Get top left corner of the rect.
Definition SDL3pp_rect.h:1697
constexpr FRect(const FRectRaw &r={}) noexcept
Wraps FRect.
Definition SDL3pp_rect.h:1463
constexpr FPoint GetSize() const
Get size of the rect.
Definition SDL3pp_rect.h:1729
The structure that defines a point (using integers).
Definition SDL3pp_rect.h:97
constexpr Point & operator/=(int value)
Memberwise divide by an integer.
Definition SDL3pp_rect.h:382
constexpr Point & operator%=(const Point &other)
Memberwise remainder from division by another point.
Definition SDL3pp_rect.h:428
constexpr Point(const PointRaw &p={}) noexcept
Wraps Point.
Definition SDL3pp_rect.h:103
constexpr Point operator/(int value) const
Get point's memberwise division by an integer.
Definition SDL3pp_rect.h:242
constexpr Point GetClamped(const Rect &rect) const
Get a point with coordinates modified so it fits into a given rect.
Definition SDL3pp_rect.h:2577
constexpr Point operator-(const Point &other) const
Get point's memberwise subtraction with another point.
Definition SDL3pp_rect.h:228
constexpr Point(int x, int y) noexcept
Constructs from its fields.
Definition SDL3pp_rect.h:114
constexpr Point operator+(const Point &other) const
Get point's memberwise addition with another point.
Definition SDL3pp_rect.h:215
constexpr Point & Clamp(const Rect &rect)
Clamp point coordinates to make it fit into a given rect.
Definition SDL3pp_rect.h:2584
constexpr Point operator*(const Point &other) const
Get point's memberwise multiplication by another point.
Definition SDL3pp_rect.h:339
constexpr Point & SetX(int newX) noexcept
Set the x coordinate.
Definition SDL3pp_rect.h:152
constexpr Point operator%(int value) const
Get point's memberwise remainder from division by an integer.
Definition SDL3pp_rect.h:282
constexpr Point & SetY(int newY) noexcept
Set the y coordinate.
Definition SDL3pp_rect.h:171
constexpr Point & operator*=(const Point &other)
Memberwise multiply by another point.
Definition SDL3pp_rect.h:458
constexpr Point & operator-=(const Point &other)
Memberwise subtract another point.
Definition SDL3pp_rect.h:367
constexpr Point operator*(int value) const
Get point's memberwise multiplication by an integer.
Definition SDL3pp_rect.h:312
constexpr int GetY() const noexcept
Get y coordinate.
Definition SDL3pp_rect.h:163
constexpr Point & operator/=(const Point &other)
Memberwise divide by another point.
Definition SDL3pp_rect.h:397
constexpr Point operator%(const Point &other) const
Get point's memberwise remainder from division by another point.
Definition SDL3pp_rect.h:297
constexpr int GetX() const noexcept
Get x coordinate.
Definition SDL3pp_rect.h:144
constexpr Point GetWrapped(const Rect &rect) const
Get a point wrapped within a specified rect.
Definition SDL3pp_rect.h:2593
constexpr Point & Wrap(const Rect &rect)
Wrap point coordinates within a specified rect.
Definition SDL3pp_rect.h:2600
constexpr Point & operator%=(int value)
Memberwise remainder from division by an integer.
Definition SDL3pp_rect.h:412
constexpr Point operator/(const Point &other) const
Get point's memberwise division by another point.
Definition SDL3pp_rect.h:267
constexpr Point & operator+=(const Point &other)
Memberwise add another point.
Definition SDL3pp_rect.h:352
constexpr Point operator-() const
Get point's memberwise negation.
Definition SDL3pp_rect.h:205
constexpr Point(const FPointRaw &p)
Wraps Point.
Definition SDL3pp_rect.h:124
constexpr Point & operator*=(int value)
Memberwise multiply by an integer.
Definition SDL3pp_rect.h:443
A rectangle, with the origin at the upper left (using integers).
Definition SDL3pp_rect.h:859
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:1013
bool Contains(const RectRaw &other) const
Check whether the rect contains given point.
Definition SDL3pp_rect.h:1269
constexpr Rect(const PointRaw &corner, const PointRaw &size)
Construct from offset and size.
Definition SDL3pp_rect.h:889
constexpr Rect & operator-=(const Point &offset)
Move by an opposite of the given offset.
Definition SDL3pp_rect.h:1427
bool GetLineIntersection(PointRaw *p1, PointRaw *p2) const
Calculate the intersection of a rectangle and line segment.
Definition SDL3pp_rect.h:1168
bool operator==(const RectRaw &other) const
Compares with the underlying type.
Definition SDL3pp_rect.h:895
constexpr Rect GetExtension(unsigned int hAmount, unsigned int vAmount) const
Get a rect extended by specified amount of pixels.
Definition SDL3pp_rect.h:1341
constexpr Point GetTopLeft() const
Get top left corner of the rect.
Definition SDL3pp_rect.h:1110
constexpr Rect & Extend(unsigned int hAmount, unsigned int vAmount)
Extend a rect by specified amount of pixels.
Definition SDL3pp_rect.h:1369
constexpr int GetY() const noexcept
Get top y coordinate.
Definition SDL3pp_rect.h:930
constexpr int GetH() const noexcept
Get height of the rect.
Definition SDL3pp_rect.h:968
constexpr Rect operator+(const Point &offset) const
Get rectangle moved by a given offset.
Definition SDL3pp_rect.h:1386
constexpr Rect & operator+=(const Point &offset)
Move by then given offset.
Definition SDL3pp_rect.h:1412
constexpr Rect(const RectRaw &r={}) noexcept
Wraps Rect.
Definition SDL3pp_rect.h:865
constexpr Rect GetExtension(unsigned int amount) const
Get a rect extended by specified amount of pixels.
Definition SDL3pp_rect.h:1323
constexpr Rect & SetY(int newY) noexcept
Set the top y coordinate.
Definition SDL3pp_rect.h:938
constexpr Rect & SetW(int newW) noexcept
Set the width of the rect.
Definition SDL3pp_rect.h:957
constexpr Rect & Extend(unsigned int amount)
Extend a rect by specified amount of pixels.
Definition SDL3pp_rect.h:1356
constexpr Point GetCentroid() const
Get centroid of the rect.
Definition SDL3pp_rect.h:1150
constexpr Point GetBottomLeft() const
Get bottom left corner of the rect.
Definition SDL3pp_rect.h:1126
constexpr Rect & SetX2(int x2)
Set X coordinate of the rect second corner.
Definition SDL3pp_rect.h:1074
static constexpr Rect FromCorners(Point p1, Point p2)
Construct the rect from given centers coordinates.
Definition SDL3pp_rect.h:1051
bool Contains(const PointRaw &p) const
Check whether the rect contains given point.
Definition SDL3pp_rect.h:1259
bool operator==(const Rect &other) const
Compares with the underlying type.
Definition SDL3pp_rect.h:898
static constexpr Rect FromCorners(int x1, int y1, int x2, int y2)
Construct the rect from given corners coordinates.
Definition SDL3pp_rect.h:1039
constexpr Rect(int x, int y, int w, int h) noexcept
Constructs from its fields.
Definition SDL3pp_rect.h:878
constexpr Point GetSize() const
Get size of the rect.
Definition SDL3pp_rect.h:1142
constexpr Rect operator-(const Point &offset) const
Get rectangle moved by an opposite of given offset.
Definition SDL3pp_rect.h:1399
constexpr Point GetBottomRight() const
Get bottom right corner of the rect.
Definition SDL3pp_rect.h:1134
constexpr int GetY2() const
Get Y coordinate of the rect second corner.
Definition SDL3pp_rect.h:1086
static constexpr Rect FromCenter(Point center, Point size)
Construct the rect from given center coordinates and size.
Definition SDL3pp_rect.h:1025
constexpr Rect & SetH(int newH) noexcept
Set the height of the rect.
Definition SDL3pp_rect.h:976
constexpr int GetW() const noexcept
Get width of the rect.
Definition SDL3pp_rect.h:949
constexpr Rect & SetX(int newX) noexcept
Set the left x coordinate.
Definition SDL3pp_rect.h:919
constexpr Rect & SetY2(int y2)
Set Y coordinate of the rect second corner.
Definition SDL3pp_rect.h:1098
constexpr int GetX() const noexcept
Get left x coordinate.
Definition SDL3pp_rect.h:911
constexpr Point GetTopRight() const
Get top right corner of the rect.
Definition SDL3pp_rect.h:1118
constexpr int GetX2() const
Get X coordinate of the rect second corner.
Definition SDL3pp_rect.h:1062