Skip to content

rect

twod.rect

a rectangle for humans™

Classes

Rect(x: float | int = 0, y: float | int = 0, w: float | int = 0, h: float | int = 0)

A rectangle specified by an origin at (x,y) and dimensions (w,h).

Attributes
A: Point property

Point at (x,y).

B: Point property

Point at (x+w, y).

C: Point property

Point at (x+w, y+h).

D: Point property

Point at (x, y+h).

vertices: list[Point] property

The points A, B, C, and D in a list.

sides: list[float] property

The lengths of each side: AB, BC, CD, and DA.

center: Point property writable

Point at the center of the rectangle (midpoint of AC).

perimeter: float property

The distance around this rectangle.

area: float property

The area of this rectangle.