template<class T>
nCine::Rect class

Rectangle in a two dimensional space.

Public static variables

static const Rect Empty
Empty rectangle.

Public static functions

static auto FromCenterSize(T xx, T yy, T ww, T hh) -> Rect
Creates a rectangle from center and size.
static auto FromCenterSize(const Vector2<T>& center, const Vector2<T>& size) -> Rect
Creates a rectangle from center and size as two Vector2
static auto FromMinMax(T minX, T minY, T maxX, T maxY) -> Rect
Creates a rectangle from minimum and maximum coordinates.
static auto FromMinMax(const Vector2<T>& min, const Vector2<T>& max) -> Rect
Creates a rectangle from minimum and maximum coordinates as two Vector2

Constructors, destructors, conversion operators

Rect() constexpr noexcept
Default constructor, all zeros.
Rect(NoInitT) explicit noexcept
Rect(T x, T y, T w, T h) constexpr noexcept
Constructs a rectangle from top-left point and size.
Rect(const Vector2<T>& point, const Vector2<T>& size) constexpr noexcept
Constructs a rectangle from top-left point and size as two Vector2

Public functions

auto GetSize() const -> Vector2<T>
Returns size.
auto GetLocation() const -> Vector2<T>
Returns location.
auto Center() const -> Vector2<T>
Calculates center of the rectangle.
auto Min() const -> Vector2<T>
Calculates minimum coordinates of the rectangle.
auto Max() const -> Vector2<T>
Calculates maximum coordinates of the rectangle.
void Set(T x, T y, T w, T h)
Sets rectangle top-left point and size.
void Set(const Vector2<T>& point, const Vector2<T>& size)
Sets rectangle top-left point and size as two Vector2
void SetCenter(float cx, float cy)
Retains rectangle size but moves its center to another position.
void SetCenter(const Vector2<T>& center)
Retains rectangle size but moves its center to another position with a Vector2
void SetSize(float ww, float hh)
Retains rectangle center but changes its size.
void SetSize(const Vector2<T>& size)
Retains rectangle center but changes its size with a Vector2
void SetCenterSize(T xx, T yy, T ww, T hh)
Sets rectangle center and size.
void SetCenterSize(const Vector2<T>& center, const Vector2<T>& size)
Sets rectangle center and size as two Vector2
void SetMinMax(T minX, T minY, T maxX, T maxY)
Sets rectangle minimum and maximum coordinates.
void SetMinMax(const Vector2<T>& min, const Vector2<T>& max)
Sets rectangle minimum and maximum coordinates as two Vector2
template<class S>
auto As() -> Rect<S>
Converts elements of the rectangle to a specified type.
void InvertSize()
Inverts rectangle size and moves (x, y) to a different angle.
auto Contains(T px, T py) const -> bool
Returns true if the point is inside this rectangle.
auto Contains(const Vector2<T>& p) const -> bool
Returns true if the point vector is inside this rectangle.
auto Contains(const Rect<T>& rect) const -> bool
Returns true if the other rectangle is contained inside this one.
auto Overlaps(const Rect<T>& rect) const -> bool
Returns true if this rect does overlap the other rectangle in any way.
void Intersect(const Rect<T>& rect)
Intersects this rectangle with the other rectangle.
void Union(const Rect<T>& rect)
Unions this rectangle with the other rectangle.
auto operator==(const Rect& rect) const -> bool
auto operator!=(const Rect& rect) const -> bool

Public variables

T X
Top-left X coordinate as a public property (left with positive width)
T Y
Top-left Y coordinate as a public property (top with positive height)
T W
Width as a public property.
T H
Height as a public property.