Skip to main content

blockly > utils > Rect

utils.Rect class

Class for representing rectangular regions.

Signature:

export declare class Rect 

Constructors

Constructor

Modifiers

Description

(constructor)(top, bottom, left, right)

Constructs a new instance of the Rect class

Properties

Property

Modifiers

Type

Description

bottom

number

left

number

right

number

top

number

Methods

Method

Modifiers

Description

clone()

Creates a new copy of this rectangle.

contains(x, y)

Tests whether this rectangle contains a x/y coordinate.

createFromPoint(position, width, height)

static

Creates a new Rect using a position and supplied dimensions.

equals(a, b)

static

Compares bounding rectangles for equality.

from(rect)

static

Converts a DOM or SVG Rect to a Blockly Rect.

getHeight()

Returns the height of this rectangle.

getOrigin()

Returns the top left coordinate of this rectangle.

getWidth()

Returns the width of this rectangle.

intersects(other)

Tests whether this rectangle intersects the provided rectangle. Assumes that the coordinate system increases going down and left.