35 TSize2(T width, T height) : width(width), height(height) {}
90 TRect2(
T x,
T y,
T width,
T height) : origin(x, y), size(width, height) {}
170 size.width = topRight.x - origin.x;
171 origin.y = topRight.y;
178 origin.x = bottomLeft.x;
179 size.height = bottomLeft.y - origin.y;
186 size.width = bottomRight.x - origin.x;
187 size.height = bottomRight.y - origin.y;
198 static_assert(
I <= 3);
199 if constexpr(
I == 0) {
200 return rect.origin.x;
201 }
else if constexpr(
I == 1) {
202 return rect.origin.y;
203 }
else if constexpr(
I == 2) {
204 return rect.size.width;
205 }
else if constexpr(
I == 3) {
206 return rect.size.height;
215 static_assert(
I <= 3);
216 if constexpr(
I == 0) {
217 return rect.origin.x;
218 }
else if constexpr(
I == 1) {
219 return rect.origin.y;
220 }
else if constexpr(
I == 2) {
221 return rect.size.width;
222 }
else if constexpr(
I == 3) {
223 return rect.size.height;
405template<
typename T>
struct std::tuple_size<
CeresEngine::TRect2<T>> : std::integral_constant<std::size_t, 4> {};
407template<std::
size_t N,
typename T>
struct std::tuple_element<
N,
CeresEngine::TRect2<T>> {
411template<
typename T>
struct std::tuple_size<const
CeresEngine::TRect2<T>> : std::tuple_size<CeresEngine::TRect2<T>> {};
413template<std::
size_t N,
typename T>
struct std::tuple_element<
N, const
CeresEngine::TRect2<T>> {
417template<
typename T>
struct std::hash<
CeresEngine::TSize2<T>> {
419 size_t operator()(
const Type& obj)
const {
return CeresEngine::hash(obj.width, obj.height); }
422template<
typename T>
struct std::hash<
CeresEngine::TRect2Edge<T>> {
424 size_t operator()(
const Type& obj)
const {
return CeresEngine::hash(obj.origin, obj.size); }
427template<
typename T>
struct std::hash<
CeresEngine::TRect2<T>> {
429 size_t operator()(
const Type& obj)
const {
return CeresEngine::hash(obj.origin, obj.size); }
432template<
typename T>
struct std::hash<
CeresEngine::TAffineTransform<T>> {
434 constexpr size_t operator()(
const Type& obj)
const {
return CeresEngine::hash(obj.raw); }
#define CE_EXPLICIT(EXPR)
Definition Macros.hpp:413
Definition Application.hpp:19
@ Width
The view's width is flexible.
@ Height
The view's height is flexible.
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
constexpr T MidX(const TRect2< T > &rect)
Definition Rect.hpp:236
TVector2< double > Vector2
A two dimensional vector with (x, y) coordinates.
Definition Vector.hpp:49
constexpr T MidY(const TRect2< T > &rect)
Definition Rect.hpp:237
constexpr T MaxX(const TRect2< T > &rect)
Definition Rect.hpp:234
TMatrix< 3, 3, T > TMatrix3
A 3x3 type that uses a internal representation of type T
Definition Matrix.hpp:41
TMatrix< 4, 4, T > TMatrix4
A 4x4 type that uses a internal representation of type T
Definition Matrix.hpp:54
constexpr T MinY(const TRect2< T > &rect)
Definition Rect.hpp:231
T angle(const TVector2< T > &v1, const TVector2< T > &v2)
Definition Math.hpp:670
constexpr T MinX(const TRect2< T > &rect)
Definition Rect.hpp:230
constexpr T MaxY(const TRect2< T > &rect)
Definition Rect.hpp:235
TPoint2< double > Point2
A type that contains a point in a two-dimensional coordinate system.
Definition Rect.hpp:24
TVector< 2, T > TVector2
A two dimensional vector type that uses a internal representation of type T
Definition Vector.hpp:45
TVector< 3, T > TVector3
A three dimensional vector type that uses a internal representation of type T
Definition Vector.hpp:80
TMatrix4< T > rotate(const TVector3< T > &angle)
Definition Math.hpp:737
TVector2< T > TPoint2
A type that contains a point in a two-dimensional coordinate system.
Definition Rect.hpp:21
Represents a 2D rectangle using real values.
Definition Rect.hpp:83
friend T & get(TRect2 &rect) noexcept
Gets a value from the rectangle.
Definition Rect.hpp:197
TPoint2< T > getTopRight() const
Definition Rect.hpp:166
TSize2< T > size
Definition Rect.hpp:85
TRect2 intersection(const TRect2 &other) const
TRect2(const TPoint2< T > &origin, const TSize2< T > &size)
Definition Rect.hpp:88
TPoint2< T > getBottomLeft() const
Definition Rect.hpp:174
bool contains(const TPoint2< T > &point) const
Returns true if the rectangle contains the provided point.
TRect2(T x, T y, T width, T height)
Definition Rect.hpp:90
TRect2 outset(T value) const
Definition Rect.hpp:128
void transform(const TMatrix4< T > &matrix)
Transforms the bounds by the given matrix.
bool overlaps(const TRect2 &other) const
Returns true if the rectangle overlaps the provided rectangle.
void setBottomLeft(const TPoint2< T > &bottomLeft)
Definition Rect.hpp:177
TPoint2< T > getBottomRight() const
Definition Rect.hpp:182
void transform(const TMatrix3< T > &matrix)
Transforms the bounds by the given matrix.
void setTopLeft(const TPoint2< T > &topLeft)
Definition Rect.hpp:164
TPoint2< T > origin
Definition Rect.hpp:84
TRect2 outset(const TRect2Edge< T > &insets) const
void setBottomRight(const TPoint2< T > &bottomRight)
Definition Rect.hpp:185
TRect2 inset(T value) const
Definition Rect.hpp:123
TRect2 inset(const TRect2Edge< T > &insets) const
void encapsulate(const TRect2 &other)
Extends this rectangle so that the provided rectangle is completely contained within it.
void setTopRight(const TPoint2< T > &topRight)
Definition Rect.hpp:169
TSize2< T > getHalfSize() const
Extents of the rectangle (distance from center to one of the corners)
bool contains(const TRect2< T > &rect) const
void clip(const TRect2 &clipRect)
Clips current rectangle so that it does not overlap the provided rectangle.
static TRect2 fromCenterAndSize(const TPoint2< T > ¢er, T size)
Creates a new 2D rect by passing the center and it's size.
Definition Rect.hpp:96
friend bool operator==(const TRect2 &lhs, const TRect2 &rhs)
Definition Rect.hpp:190
TPoint2< T > getCenter() const
Center of the rectangle.
static Vector< TRect2 > getIntersectionGroups(const Vector< TRect2 > &rects)
Computes a set of non-intersecting rects that enclose all given rects.
TPoint2< T > getTopLeft() const
Definition Rect.hpp:161
static TRect2 fromCenterAndSize(const TPoint2< T > ¢er, const TSize2< T > &size)
Creates a new 2D rect by passing the center and it's size.
Definition Rect.hpp:93
friend bool operator!=(const TRect2 &lhs, const TRect2 &rhs)
Definition Rect.hpp:191
friend const T & get(const TRect2 &rect) noexcept
Gets a value from the rectangle.
Definition Rect.hpp:214
bool fullyContained(const TRect2 &other) const
TRect2(const TPoint2< T > ¢er, const TRect2Edge< T > &edge)
A structure that contains width and height values.
Definition Rect.hpp:27
friend TSize2 operator-(const TSize2 &lhs, T rhs)
Definition Rect.hpp:51
TSize2(const TVector2< T > &vec)
Definition Rect.hpp:37
TSize2 transform(const TMatrix3< T > &matrix) const
Transforms the size by the given matrix.
friend TSize2 operator+(const TSize2 &lhs, T rhs)
Definition Rect.hpp:48
friend TSize2 operator/(const TSize2 &lhs, T rhs)
Definition Rect.hpp:54
friend TSize2 operator-(const TSize2 &lhs, const TSize2 &rhs)
Definition Rect.hpp:50
TSize2(T width, T height)
Definition Rect.hpp:35
friend bool operator!=(const TSize2 &lhs, const TSize2 &rhs)
Definition Rect.hpp:45
friend bool operator==(const TSize2 &lhs, const TSize2 &rhs)
Definition Rect.hpp:44
T width
A width value.
Definition Rect.hpp:29
friend TSize2 operator+(const TSize2 &lhs, const TSize2 &rhs)
Definition Rect.hpp:47
friend TSize2 operator*(const TSize2 &lhs, T rhs)
Definition Rect.hpp:53
T height
A height value.
Definition Rect.hpp:32