Skip to content

Rect

Rect #

A 2D, axis-aligned, floating-point rectangle whose coordinates are relative to a given origin.

bottom #

bottom: Number

The offset of the bottom edge of this rectangle from the y-axis.

height #

height: Number

The distance between the top and bottom edges of this rectangle.

left #

left: Number

The offset of the left edge of this rectangle from the x-axis.

right #

right: Number

The offset of the right edge of this rectangle from the x-axis.

size #

size: Size

The distance between the upper-left corner and the lower-right corner of this rectangle.

top #

top: Number

The offset of the top edge of this rectangle from the y-axis.

width #

width: Number

The distance between the left and right edges of this rectangle.

copy_with #

copy_with(
    *,
    left: Number | None = None,
    top: Number | None = None,
    right: Number | None = None,
    bottom: Number | None = None,
) -> Rect

Returns a copy of this object with the specified properties overridden.

from_center #

from_center(
    *, center: Offset, width: Number, height: Number
)

Constructs a rectangle from its center point, width, and height. The center argument is assumed to be an offset from the origin.

from_lwth #

from_lwth(
    *,
    left: Number,
    top: Number,
    width: Number,
    height: Number,
) -> Rect

Construct a rectangle from its left and top edges, its width, and its height.

from_points #

from_points(a: Offset, b: Offset)

Construct the smallest rectangle that encloses the given offsets, treating them as vectors from the origin.