Skip to main content

Class: Rect

components.Rect

Represents a rectangle with an origin and size.

Constructors#

constructor#

new Rect(x, y, width?, height?)

Parameters#

NameTypeDefault value
xnumberundefined
ynumberundefined
widthnumber0
heightnumber0

Defined in#

components/rect.ts:20

Properties#

height#

height: number

The height of the rectangle.

Defined in#

components/rect.ts:20


width#

width: number

The width of the rectangle.

Defined in#

components/rect.ts:16


x#

x: number

The x-position of the rectangle.

Defined in#

components/rect.ts:8


y#

y: number

The y-position of the rectangle.

Defined in#

components/rect.ts:12


zero#

Static Readonly zero: Rect

Defined in#

components/rect.ts:29

Methods#

fromElement#

Static fromElement(element): Rect

Returns a new document-space rectangle from the specified element.

Parameters#

NameType
elementHTMLElement

Returns#

Rect

Defined in#

components/rect.ts:46


fromScreen#

Static fromScreen(): Rect

Returns a new document-space rectangle from the viewport's bounds.

Returns#

Rect

Defined in#

components/rect.ts:34