Skip to content

Rect ​

Axis-aligned rectangle defined by an origin and a size.

Rect represents a 2D region with a top-left origin and Y increasing downward, matching canvas and image coordinates. It is used to select a sub-region of a texture.

Construction ​

Constructors ​


Rect() constexpr ​

Constructs a rectangle from its origin and size.

cpp
Rect::Rect(float x, float y, float width, float height);
ParameterDescription
xLeft edge.
yTop edge.
widthWidth of the rectangle.
heightHeight of the rectangle.

Properties ​

height float ​

Height of the rectangle.

cpp
float height {0.0f};

width float ​

Width of the rectangle.

cpp
float width {0.0f};

x float ​

Left edge.

cpp
float x {0.0f};

y float ​

Top edge.

cpp
float y {0.0f};

Functions ​

Size() Vector2 ​

Returns the size of the rectangle.

cpp
Vector2 Rect::Size() const;

Released under the MIT License.