32 #include "Portability.h" 36 #ifndef DOXYGEN_SHOULD_SKIP_THIS 91 :
Box<
T, 2>({
T(0),
T(0) })
124 return Rect<T>(position, position + size);
135 return Rect<T>(center - size /
T(2), center + size /
T(2));
149 return { (this->min.x + this->max.x) /
T(2), this->min.y };
151 return { this->max.x, this->min.y };
153 return { this->min.x, (this->min.y + this->max.y) /
T(2) };
155 return this->getCenter();
157 return { this->max.x, (this->min.y + this->max.y) /
T(2) };
159 return { this->min.x, this->max.y };
161 return { (this->min.x + this->max.x) /
T(2), this->max.y };
211 return this->max.x - this->min.x;
220 return this->max.y - this->min.y;
303 return !(lhs == rhs);
314 template<
typename Archive,
typename T>
316 return ar | rect.
min.x | rect.
min.y | rect.
max.x | rect.
max.y;
320 #ifndef DOXYGEN_SHOULD_SKIP_THIS
constexpr Vector< T, 2 > getBottomLeft() const noexcept
Get the bottom left corner.
Definition: Rect.h:192
bool operator!=(const Rect< T > &lhs, const Rect< T > &rhs)
Inequality operator.
Definition: Rect.h:302
constexpr Vector< T, 2 > getPositionFromAnchor(Anchor anchor) const noexcept
Get a position from the rectangle and an anchor.
Definition: Rect.h:144
Vector< T, N > min
The minimum point of the box.
Definition: Box.h:53
Archive & operator|(Archive &ar, Rect< T > &rect)
Serialize a rectangle.
Definition: Rect.h:315
static constexpr Rect< T > fromMinMax(Vector< T, 2 > min, Vector< T, 2 > max) noexcept
Create a rectangle from a min point and a max point.
Definition: Rect.h:112
constexpr Rect(const Box< T, 2 > &box)
Constructor from a box.
Definition: Rect.h:100
constexpr Vector< T, 2 > getTopRight() const noexcept
Get the top right corner.
Definition: Rect.h:183
Utility class for manipulating 2D axis aligned rectangles.
Definition: Rect.h:84
The namespace for gf classes.
Definition: Action.h:35
static constexpr Rect< T > fromPositionSize(Vector< T, 2 > position, Vector< T, 2 > size) noexcept
Create a rectangle from a position (top-left) and a size.
Definition: Rect.h:123
Vector< T, N > max
The maximum point of the box.
Definition: Box.h:54
A 2D vector.
Definition: Vector.h:316
constexpr T getWidth() const noexcept
Get the width of the rectangle.
Definition: Rect.h:210
constexpr Rect() noexcept
Default constructor.
Definition: Rect.h:90
constexpr Vector< T, 2 > getTopLeft() const noexcept
Get the top left corner.
Definition: Rect.h:174
static constexpr Rect< T > fromCenterSize(Vector< T, 2 > center, Vector< T, 2 > size) noexcept
Create a rectangle from a center and a size.
Definition: Rect.h:134
constexpr Vector< T, 2 > getBottomRight() const noexcept
Get the bottom right corner.
Definition: Rect.h:201
Anchor
An anchor of a box.
Definition: Anchor.h:38
A multi-dimensional box.
Definition: Box.h:52
bool operator==(const Rect< T > &lhs, const Rect< T > &rhs)
Equality operator.
Definition: Rect.h:288
constexpr T getHeight() const noexcept
Get the height of the rectangle.
Definition: Rect.h:219