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);
111 : SDL_Point{int(p.x), int(p.y)}
120 constexpr explicit operator bool()
const {
return *
this !=
PointRaw{}; }
127 constexpr int GetX()
const {
return x; }
146 constexpr int GetY()
const {
return y; }
200 return Point(x + other.x, y + other.y);
213 return Point(x - other.x, y - other.y);
227 return Point(x / value, y / value);
252 return Point(x / other.x, y / other.y);
267 return Point(x % value, y % value);
282 return Point(x % other.x, y % other.y);
297 return Point(x * value, y * value);
324 return Point(x * other.x, y * other.y);
495 constexpr operator FPoint()
const;
536 constexpr explicit operator bool()
const {
return *
this !=
FPointRaw{}; }
543 constexpr float GetX()
const {
return x; }
562 constexpr float GetY()
const {
return y; }
616 return FPoint(x + other.x, y + other.y);
629 return FPoint(x - other.x, y - other.y);
643 return FPoint(x / value, y / value);
657 return FPoint(x / other.x, y / other.y);
672 return FPoint(x * value, y * value);
687 return FPoint(x * other.x, y * other.y);
858 constexpr Rect(
int x,
int y,
int w,
int h)
870 :
Rect{corner.x, corner.y, size.x, size.y}
880 return *
this == (
const RectRaw&)(other);
884 constexpr explicit operator bool()
const {
return !
Empty(); }
891 constexpr int GetX()
const {
return x; }
910 constexpr int GetY()
const {
return y; }
929 constexpr int GetW()
const {
return w; }
948 constexpr int GetH()
const {
return h; }
993 return Rect(cx - w / 2, cy - h / 2, w, h);
1005 return Rect(center - size / 2, size);
1019 return Rect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
1040 constexpr int GetX2()
const {
return x + w - 1; }
1064 constexpr int GetY2()
const {
return y + h - 1; }
1149 p1 ? &p1->y :
nullptr,
1150 p2 ? &p2->x :
nullptr,
1151 p2 ? &p2->y :
nullptr);
1183 constexpr operator SDL_FRect()
const;
1186 constexpr operator FRect()
const;
1205 constexpr bool Empty()
const;
1237 return SDL_PointInRect(&p,
this);
1322 r.
Extend(hAmount, vAmount);
1347 constexpr Rect&
Extend(
unsigned int hAmount,
unsigned int vAmount)
1366 return Rect(x + offset.x, y + offset.y, w, h);
1379 return Rect(x - offset.x, y - offset.y, w, h);
1451 constexpr FRect(
float x,
float y,
float w,
float h)
1460 :
FRect{corner.x, corner.y, size.x, size.y}
1467 return Equal(other);
1473 return *
this == (
const FRectRaw&)(other);
1477 constexpr operator bool()
const {
return !
Empty(); }
1484 constexpr float GetX()
const {
return x; }
1503 constexpr float GetY()
const {
return y; }
1522 constexpr float GetW()
const {
return w; }
1541 constexpr float GetH()
const {
return h; }
1587 return FRect(cx - w / 2, cy - h / 2, w, h);
1599 return FRect(center - size / 2, size);
1613 return FRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
1634 constexpr float GetX2()
const {
return x + w - 1; }
1658 constexpr float GetY2()
const {
return y + h - 1; }
1763 p1 ? &p1->y :
nullptr,
1764 p2 ? &p2->x :
nullptr,
1765 p2 ? &p2->y :
nullptr);
1785 constexpr bool Empty()
const;
1848 return SDL_PointInRectFloat(&p,
this);
1933 r.
Extend(hAmount, vAmount);
1977 return FRect(x + offset.x, y + offset.y, w, h);
1990 return FRect(x - offset.x, y - offset.y, w, h);
2037 SDL_RectToFRect(&rect, &frect);
2041constexpr Rect::operator SDL_FRect()
const {
return RectToFRect(*
this); }
2066 return SDL_PointInRect(&p, &r);
2117 return SDL_RectsEqual(&a, &b);
2142 return SDL_HasRectIntersection(&A, &B);
2166 if (
Rect result; SDL_GetRectIntersection(&A, &B, &result))
return result;
2216 SDL_GetRectEnclosingPoints(points.
data(), points.
size(), clip, &result)) {
2252 return SDL_GetRectAndLineIntersection(&rect, X1, Y1, X2, Y2);
2283 return SDL_PointInRectFloat(&p, &r);
2311 return SDL_RectEmptyFloat(&r);
2343 const float epsilon)
2345 return SDL_RectsEqualEpsilon(&a, &b, epsilon);
2349 const float epsilon)
const
2381 return SDL_RectsEqualFloat(&a, &b);
2404 return SDL_HasRectIntersectionFloat(&A, &B);
2428 if (
FRect r; SDL_GetRectIntersectionFloat(&A, &B, &r))
return r;
2451 CheckError(SDL_GetRectUnionFloat(&A, &B, &r));
2479 if (
FRect result; SDL_GetRectEnclosingPointsFloat(
2480 points.
data(), points.
size(), clip, &result)) {
2517 return SDL_GetRectAndLineIntersectionFloat(&rect, X1, Y1, X2, Y2);
2530constexpr Point::operator
FPoint()
const {
return {float(x), float(y)}; }
2534 return FPoint(*
this) / value;
2538 return FPoint(*
this) * value;
2550 if (x < rect.x) x = rect.x;
2552 if (y < rect.y) y = rect.y;
2567 x = rect.x + rect.w - 1 - (rect.x - x + rect.w - 1) % rect.w;
2568 else if (x >= rect.x + rect.w)
2569 x = rect.x + (x - rect.x - rect.w) % rect.w;
2572 y = rect.y + rect.h - 1 - (rect.y - y + rect.h - 1) % rect.h;
2573 else if (y >= rect.y + rect.h)
2574 y = rect.y + (y - rect.y - rect.h) % rect.h;
2588 if (x < rect.x) x = rect.x;
2590 if (y < rect.y) y = rect.y;
2605 x = rect.x + rect.w - 1 - SDL_fmod(rect.x - x + rect.w - 1, rect.w);
2606 else if (x >= rect.x + rect.w)
2607 x = rect.x + SDL_fmod(x - rect.x - rect.w, rect.w);
2610 y = rect.y + rect.h - 1 - SDL_fmod(rect.y - y + rect.h - 1, rect.h);
2611 else if (y >= rect.y + rect.h)
2612 y = rect.y + SDL_fmod(y - rect.y - rect.h, rect.h);
2619 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:198
constexpr bool operator==(ColorRaw lhs, ColorRaw rhs)
Comparison operator for Color.
Definition: SDL3pp_pixels.h:2148
constexpr bool RectEmptyFloat(const FRectRaw &r)
Determine whether a floating point rectangle can contain any point.
Definition: SDL3pp_rect.h:2309
constexpr FRect GetRectUnionFloat(const FRectRaw &A, const FRectRaw &B)
Calculate the union of two rectangles with float precision.
Definition: SDL3pp_rect.h:2448
constexpr bool InRect(const RectRaw &r) const
Determine whether a point resides inside a rectangle.
Definition: SDL3pp_rect.h:2069
constexpr bool HasRectIntersectionFloat(const FRectRaw &A, const FRectRaw &B)
Determine whether two rectangles intersect with float precision.
Definition: SDL3pp_rect.h:2402
constexpr FRect GetRectIntersectionFloat(const FRectRaw &A, const FRectRaw &B)
Calculate the intersection of two rectangles with float precision.
Definition: SDL3pp_rect.h:2426
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:2520
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:2211
constexpr FRect GetIntersection(const FRectRaw &other) const
Calculate the intersection of two rectangles with float precision.
Definition: SDL3pp_rect.h:2432
constexpr 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:2348
constexpr bool InRect(const FRectRaw &r) const
Determine whether a point resides inside a floating point rectangle.
Definition: SDL3pp_rect.h:2286
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:2511
constexpr bool PointInRectFloat(const FPointRaw &p, const FRectRaw &r)
Determine whether a point resides inside a floating point rectangle.
Definition: SDL3pp_rect.h:2281
constexpr bool Equal(const FRectRaw &other) const
Determine whether two rectangles are equal.
Definition: SDL3pp_rect.h:2384
SDL_FPoint FPointRaw
Alias to raw representation for FPoint.
Definition: SDL3pp_rect.h:28
constexpr bool Empty() const
Determine whether a rectangle has no area.
Definition: SDL3pp_rect.h:2094
constexpr bool Equal(const RectRaw &other) const
Determine whether two rectangles are equal.
Definition: SDL3pp_rect.h:2120
constexpr bool RectsEqual(const RectRaw &a, const RectRaw &b)
Determine whether two rectangles are equal.
Definition: SDL3pp_rect.h:2115
constexpr bool Empty() const
Determine whether a rectangle has no area.
Definition: SDL3pp_rect.h:2314
constexpr bool RectEmpty(const RectRaw &r)
Determine whether a rectangle has no area.
Definition: SDL3pp_rect.h:2092
constexpr Rect GetUnion(const RectRaw &other) const
Calculate the union of two rectangles.
Definition: SDL3pp_rect.h:2192
constexpr bool PointInRect(const PointRaw &p, const RectRaw &r)
Determine whether a point resides inside a rectangle.
Definition: SDL3pp_rect.h:2064
static constexpr 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:2486
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:2222
constexpr Rect GetRectUnion(const RectRaw &A, const RectRaw &B)
Calculate the union of two rectangles.
Definition: SDL3pp_rect.h:2185
constexpr FRect RectToFRect(const RectRaw &rect)
Convert an Rect to FRect.
Definition: SDL3pp_rect.h:2034
constexpr Rect GetRectIntersection(const RectRaw &A, const RectRaw &B)
Calculate the intersection of two rectangles.
Definition: SDL3pp_rect.h:2164
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:2246
constexpr FRect GetUnion(const FRectRaw &other) const
Calculate the union of two rectangles with float precision.
Definition: SDL3pp_rect.h:2455
constexpr bool RectsEqualFloat(const FRectRaw &a, const FRectRaw &b)
Determine whether two floating point rectangles are equal, within a default epsilon.
Definition: SDL3pp_rect.h:2379
constexpr 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:2341
SDL_Rect RectRaw
Alias to raw representation for Rect.
Definition: SDL3pp_rect.h:34
SDL_FRect FRectRaw
Alias to raw representation for FRect.
Definition: SDL3pp_rect.h:40
constexpr bool HasIntersection(const RectRaw &other) const
Determine whether two rectangles intersect.
Definition: SDL3pp_rect.h:2145
constexpr bool HasIntersection(const FRectRaw &other) const
Determine whether two rectangles intersect.
Definition: SDL3pp_rect.h:2407
constexpr Rect GetIntersection(const RectRaw &other) const
Calculate the intersection of two rectangles.
Definition: SDL3pp_rect.h:2170
constexpr 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:2475
SDL_Point PointRaw
Alias to raw representation for Point.
Definition: SDL3pp_rect.h:22
constexpr bool HasRectIntersection(const RectRaw &A, const RectRaw &B)
Determine whether two rectangles intersect.
Definition: SDL3pp_rect.h:2140
Main include header for the SDL3pp library.
The structure that defines a point (using floating point values).
Definition: SDL3pp_rect.h:509
constexpr FPoint operator/(const FPoint &other) const
Get point's memberwise division by another point.
Definition: SDL3pp_rect.h:655
constexpr FPoint(float x, float y)
Constructs from its fields.
Definition: SDL3pp_rect.h:526
constexpr FPoint & Wrap(const FRect &rect)
Wrap point coordinates within a specified rect.
Definition: SDL3pp_rect.h:2602
constexpr float GetX() const
Get the x coordinate.
Definition: SDL3pp_rect.h:543
constexpr float GetY() const
Get the y coordinate.
Definition: SDL3pp_rect.h:562
constexpr FPoint operator-() const
Get point's memberwise negation.
Definition: SDL3pp_rect.h:604
constexpr FPoint & operator/=(const FPoint &other)
Memberwise divide by another point.
Definition: SDL3pp_rect.h:743
constexpr FPoint operator/(float value) const
Get point's memberwise division by an float.
Definition: SDL3pp_rect.h:641
constexpr FPoint(const FPointRaw &p={})
Wraps FPoint.
Definition: SDL3pp_rect.h:515
constexpr FPoint operator-(const FPoint &other) const
Get point's memberwise subtraction with another point.
Definition: SDL3pp_rect.h:627
constexpr FPoint operator*(float value) const
Get point's memberwise multiplication by an float.
Definition: SDL3pp_rect.h:670
constexpr FPoint & operator/=(float value)
Memberwise divide by an float.
Definition: SDL3pp_rect.h:728
constexpr FPoint & SetX(float newX)
Set the x coordinate.
Definition: SDL3pp_rect.h:551
constexpr FPoint GetClamped(const FRect &rect) const
Get a point with coordinates modified so it fits into a given rect.
Definition: SDL3pp_rect.h:2579
constexpr FPoint & operator*=(const FPoint &other)
Memberwise multiply by another point.
Definition: SDL3pp_rect.h:773
constexpr FPoint GetWrapped(const FRect &rect) const
Get a point wrapped within a specified rect.
Definition: SDL3pp_rect.h:2595
constexpr FPoint operator+(const FPoint &other) const
Get point's memberwise addition with another point.
Definition: SDL3pp_rect.h:614
constexpr FPoint & SetY(float newY)
Set the y coordinate.
Definition: SDL3pp_rect.h:570
constexpr FPoint & Clamp(const FRect &rect)
Clamp point coordinates to make it fit into a given rect.
Definition: SDL3pp_rect.h:2586
constexpr FPoint & operator*=(float value)
Memberwise multiply by an float.
Definition: SDL3pp_rect.h:758
constexpr FPoint & operator-=(const FPoint &other)
Memberwise subtract another point.
Definition: SDL3pp_rect.h:713
constexpr FPoint operator*(const FPoint &other) const
Get point's memberwise multiplication by another point.
Definition: SDL3pp_rect.h:685
constexpr FPoint & operator+=(const FPoint &other)
Memberwise add another point.
Definition: SDL3pp_rect.h:698
A rectangle, with the origin at the upper left (using floating point values).
Definition: SDL3pp_rect.h:1432
constexpr bool operator==(const FRectRaw &other) const
Compares with the underlying type.
Definition: SDL3pp_rect.h:1465
constexpr float GetH() const
Get height of the rect.
Definition: SDL3pp_rect.h:1541
constexpr FRect(FPoint corner, FPoint size)
Constructs from top-left corner plus size.
Definition: SDL3pp_rect.h:1459
constexpr FRect & Extend(float hAmount, float vAmount)
Extend a rect by specified amount of pixels.
Definition: SDL3pp_rect.h:1958
constexpr FRect & SetH(float newH)
Set the height of the rect.
Definition: SDL3pp_rect.h:1549
constexpr FRect & SetW(float newW)
Set the width of the rect.
Definition: SDL3pp_rect.h:1530
constexpr float GetY() const
Get top y coordinate.
Definition: SDL3pp_rect.h:1503
constexpr FRect operator+(const FPoint &offset) const
Get rectangle moved by a given offset.
Definition: SDL3pp_rect.h:1975
static constexpr FRect FromCorners(FPoint p1, FPoint p2)
Construct the rect from given centers coordinates.
Definition: SDL3pp_rect.h:1623
constexpr bool operator==(const FRect &other) const
Compares with the underlying type.
Definition: SDL3pp_rect.h:1471
constexpr FPoint GetTopRight() const
Get top right corner of the rect.
Definition: SDL3pp_rect.h:1690
constexpr FRect operator-(const FPoint &offset) const
Get rectangle moved by an opposite of given offset.
Definition: SDL3pp_rect.h:1988
constexpr float GetW() const
Get width of the rect.
Definition: SDL3pp_rect.h:1522
constexpr bool Contains(const FRectRaw &other) const
Check whether the rect contains given point.
Definition: SDL3pp_rect.h:1859
constexpr FRect & operator+=(const FPoint &offset)
Move by then given offset.
Definition: SDL3pp_rect.h:2001
static constexpr FRect FromCenter(FPoint center, FPoint size)
Construct the rect from given center coordinates and size.
Definition: SDL3pp_rect.h:1597
constexpr FRect & operator-=(const FPoint &offset)
Move by an opposite of the given offset.
Definition: SDL3pp_rect.h:2016
constexpr FPoint GetBottomRight() const
Get bottom right corner of the rect.
Definition: SDL3pp_rect.h:1706
constexpr FPoint GetBottomLeft() const
Get bottom left corner of the rect.
Definition: SDL3pp_rect.h:1698
constexpr float GetX2() const
Get X coordinate of the rect second corner.
Definition: SDL3pp_rect.h:1634
constexpr FRect GetExtension(unsigned int amount) const
Get a rect extended by specified amount of pixels.
Definition: SDL3pp_rect.h:1912
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:1585
constexpr float GetY2() const
Get Y coordinate of the rect second corner.
Definition: SDL3pp_rect.h:1658
constexpr FRect & SetY2(float y2)
Set Y coordinate of the rect second corner.
Definition: SDL3pp_rect.h:1670
constexpr FRect(const FRectRaw &r={})
Wraps FRect.
Definition: SDL3pp_rect.h:1438
constexpr FRect & SetY(float newY)
Set the top y coordinate.
Definition: SDL3pp_rect.h:1511
constexpr FRect & SetX2(float x2)
Set X coordinate of the rect second corner.
Definition: SDL3pp_rect.h:1646
static constexpr FRect FromCorners(float x1, float y1, float x2, float y2)
Construct the rect from given corners coordinates.
Definition: SDL3pp_rect.h:1611
constexpr bool Contains(const FPointRaw &p) const
Check whether the rect contains given point.
Definition: SDL3pp_rect.h:1846
constexpr FRect & SetX(float newX)
Set the left x coordinate.
Definition: SDL3pp_rect.h:1492
constexpr FRect & Extend(float amount)
Extend a rect by specified amount of pixels.
Definition: SDL3pp_rect.h:1945
constexpr FRect GetExtension(float hAmount, float vAmount) const
Get a rect extended by specified amount of pixels.
Definition: SDL3pp_rect.h:1930
constexpr FPoint GetCentroid() const
Get centroid of the rect.
Definition: SDL3pp_rect.h:1722
constexpr FRect(float x, float y, float w, float h)
Constructs from its fields.
Definition: SDL3pp_rect.h:1451
bool GetLineIntersection(FPoint *p1, FPoint *p2) const
Calculate the intersection of a rectangle and line segment.
Definition: SDL3pp_rect.h:1760
constexpr FPoint GetTopLeft() const
Get top left corner of the rect.
Definition: SDL3pp_rect.h:1682
constexpr FPoint GetSize() const
Get size of the rect.
Definition: SDL3pp_rect.h:1714
constexpr float GetX() const
Get left x coordinate.
Definition: SDL3pp_rect.h:1484
The structure that defines a point (using integers).
Definition: SDL3pp_rect.h:83
constexpr Point & operator/=(int value)
Memberwise divide by an integer.
Definition: SDL3pp_rect.h:365
constexpr Point & operator%=(const Point &other)
Memberwise remainder from division by another point.
Definition: SDL3pp_rect.h:411
constexpr Point operator/(int value) const
Get point's memberwise division by an integer.
Definition: SDL3pp_rect.h:225
constexpr Point GetClamped(const Rect &rect) const
Get a point with coordinates modified so it fits into a given rect.
Definition: SDL3pp_rect.h:2541
constexpr Point operator-(const Point &other) const
Get point's memberwise subtraction with another point.
Definition: SDL3pp_rect.h:211
constexpr int GetX() const
Get x coordinate.
Definition: SDL3pp_rect.h:127
constexpr Point operator+(const Point &other) const
Get point's memberwise addition with another point.
Definition: SDL3pp_rect.h:198
constexpr Point & Clamp(const Rect &rect)
Clamp point coordinates to make it fit into a given rect.
Definition: SDL3pp_rect.h:2548
constexpr Point operator*(const Point &other) const
Get point's memberwise multiplication by another point.
Definition: SDL3pp_rect.h:322
constexpr Point operator%(int value) const
Get point's memberwise remainder from division by an integer.
Definition: SDL3pp_rect.h:265
constexpr Point & operator*=(const Point &other)
Memberwise multiply by another point.
Definition: SDL3pp_rect.h:441
constexpr Point & SetX(int newX)
Set the x coordinate.
Definition: SDL3pp_rect.h:135
constexpr Point & operator-=(const Point &other)
Memberwise subtract another point.
Definition: SDL3pp_rect.h:350
constexpr Point(const PointRaw &p={})
Wraps Point.
Definition: SDL3pp_rect.h:89
constexpr Point operator*(int value) const
Get point's memberwise multiplication by an integer.
Definition: SDL3pp_rect.h:295
constexpr Point & operator/=(const Point &other)
Memberwise divide by another point.
Definition: SDL3pp_rect.h:380
constexpr Point operator%(const Point &other) const
Get point's memberwise remainder from division by another point.
Definition: SDL3pp_rect.h:280
constexpr Point GetWrapped(const Rect &rect) const
Get a point wrapped within a specified rect.
Definition: SDL3pp_rect.h:2557
constexpr Point(int x, int y)
Constructs from its fields.
Definition: SDL3pp_rect.h:100
constexpr Point & Wrap(const Rect &rect)
Wrap point coordinates within a specified rect.
Definition: SDL3pp_rect.h:2564
constexpr int GetY() const
Get y coordinate.
Definition: SDL3pp_rect.h:146
constexpr Point & SetY(int newY)
Set the y coordinate.
Definition: SDL3pp_rect.h:154
constexpr Point & operator%=(int value)
Memberwise remainder from division by an integer.
Definition: SDL3pp_rect.h:395
constexpr Point operator/(const Point &other) const
Get point's memberwise division by another point.
Definition: SDL3pp_rect.h:250
constexpr Point & operator+=(const Point &other)
Memberwise add another point.
Definition: SDL3pp_rect.h:335
constexpr Point operator-() const
Get point's memberwise negation.
Definition: SDL3pp_rect.h:188
constexpr Point(const FPointRaw &p)
Wraps Point.
Definition: SDL3pp_rect.h:110
constexpr Point & operator*=(int value)
Memberwise multiply by an integer.
Definition: SDL3pp_rect.h:426
A rectangle, with the origin at the upper left (using integers).
Definition: SDL3pp_rect.h:839
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:991
constexpr int GetX() const
Get left x coordinate.
Definition: SDL3pp_rect.h:891
constexpr Rect(const PointRaw &corner, const PointRaw &size)
Construct from offset and size.
Definition: SDL3pp_rect.h:869
constexpr Rect & operator-=(const Point &offset)
Move by an opposite of the given offset.
Definition: SDL3pp_rect.h:1405
constexpr bool Contains(const PointRaw &p) const
Check whether the rect contains given point.
Definition: SDL3pp_rect.h:1235
bool GetLineIntersection(PointRaw *p1, PointRaw *p2) const
Calculate the intersection of a rectangle and line segment.
Definition: SDL3pp_rect.h:1146
constexpr int GetW() const
Get width of the rect.
Definition: SDL3pp_rect.h:929
constexpr Rect GetExtension(unsigned int hAmount, unsigned int vAmount) const
Get a rect extended by specified amount of pixels.
Definition: SDL3pp_rect.h:1319
constexpr Rect(const RectRaw &r={})
Wraps Rect.
Definition: SDL3pp_rect.h:845
constexpr Rect(int x, int y, int w, int h)
Constructs from its fields.
Definition: SDL3pp_rect.h:858
constexpr Rect & SetY(int newY)
Set the top y coordinate.
Definition: SDL3pp_rect.h:918
constexpr Point GetTopLeft() const
Get top left corner of the rect.
Definition: SDL3pp_rect.h:1088
constexpr Rect & Extend(unsigned int hAmount, unsigned int vAmount)
Extend a rect by specified amount of pixels.
Definition: SDL3pp_rect.h:1347
constexpr Rect operator+(const Point &offset) const
Get rectangle moved by a given offset.
Definition: SDL3pp_rect.h:1364
constexpr Rect & operator+=(const Point &offset)
Move by then given offset.
Definition: SDL3pp_rect.h:1390
constexpr bool operator==(const Rect &other) const
Compares with the underlying type.
Definition: SDL3pp_rect.h:878
constexpr Rect GetExtension(unsigned int amount) const
Get a rect extended by specified amount of pixels.
Definition: SDL3pp_rect.h:1301
constexpr Rect & Extend(unsigned int amount)
Extend a rect by specified amount of pixels.
Definition: SDL3pp_rect.h:1334
constexpr Rect & SetW(int newW)
Set the width of the rect.
Definition: SDL3pp_rect.h:937
constexpr Point GetCentroid() const
Get centroid of the rect.
Definition: SDL3pp_rect.h:1128
constexpr Point GetBottomLeft() const
Get bottom left corner of the rect.
Definition: SDL3pp_rect.h:1104
constexpr int GetH() const
Get height of the rect.
Definition: SDL3pp_rect.h:948
constexpr Rect & SetX2(int x2)
Set X coordinate of the rect second corner.
Definition: SDL3pp_rect.h:1052
constexpr Rect & SetH(int newH)
Set the height of the rect.
Definition: SDL3pp_rect.h:956
static constexpr Rect FromCorners(Point p1, Point p2)
Construct the rect from given centers coordinates.
Definition: SDL3pp_rect.h:1029
static constexpr Rect FromCorners(int x1, int y1, int x2, int y2)
Construct the rect from given corners coordinates.
Definition: SDL3pp_rect.h:1017
constexpr Point GetSize() const
Get size of the rect.
Definition: SDL3pp_rect.h:1120
constexpr Rect operator-(const Point &offset) const
Get rectangle moved by an opposite of given offset.
Definition: SDL3pp_rect.h:1377
constexpr Point GetBottomRight() const
Get bottom right corner of the rect.
Definition: SDL3pp_rect.h:1112
constexpr int GetY2() const
Get Y coordinate of the rect second corner.
Definition: SDL3pp_rect.h:1064
static constexpr Rect FromCenter(Point center, Point size)
Construct the rect from given center coordinates and size.
Definition: SDL3pp_rect.h:1003
constexpr bool operator==(const RectRaw &other) const
Compares with the underlying type.
Definition: SDL3pp_rect.h:875
constexpr int GetY() const
Get top y coordinate.
Definition: SDL3pp_rect.h:910
constexpr Rect & SetX(int newX)
Set the left x coordinate.
Definition: SDL3pp_rect.h:899
constexpr Rect & SetY2(int y2)
Set Y coordinate of the rect second corner.
Definition: SDL3pp_rect.h:1076
constexpr Point GetTopRight() const
Get top right corner of the rect.
Definition: SDL3pp_rect.h:1096
constexpr bool Contains(const RectRaw &other) const
Check whether the rect contains given point.
Definition: SDL3pp_rect.h:1248
constexpr int GetX2() const
Get X coordinate of the rect second corner.
Definition: SDL3pp_rect.h:1040