Skip to main content

Rect

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

Properties

  • bottom - The offset of the bottom edge of this rectangle from the y-axis.
  • height - The distance between the top and bottom edges of this rectangle.
  • left - The offset of the left edge of this rectangle from the x-axis.
  • right - The offset of the right edge of this rectangle from the x-axis.
  • size - The distance between the upper-left corner and the lower-right corner of this rectangle.
  • top - The offset of the top edge of this rectangle from the y-axis.
  • width - The distance between the left and right edges of this rectangle.

Methods

  • copy - Returns a copy of this object with the specified properties overridden.
  • from_center - Constructs a rectangle from its center point, width, and height.
  • from_lwth - Construct a rectangle from its left and top edges, its width, and its height.
  • from_points - Construct the smallest rectangle that encloses the given offsets, treating them as vectors from the origin.

Properties

bottominstance-attribute

bottom: Number

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

heightproperty

height: Number

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

leftinstance-attribute

left: Number

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

rightinstance-attribute

right: Number

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

sizeproperty

size: Size

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

topinstance-attribute

top: Number

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

widthproperty

width: Number

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

Methods

copy

copy(
    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_centerclassmethod

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_lwthclassmethod

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_pointsclassmethod

from_points(a: Offset, b: Offset)

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