Class: Rect
Defined in: packages/blockly/core/utils/rect.ts:21
Class for representing rectangular regions.
Properties index
| Property | Description |
|---|---|
| top | Top. |
| bottom | Bottom. |
| left | Left. |
| right | Right. |
Methods index
| Method | Description |
|---|---|
| from | Converts a DOM or SVG Rect to a Blockly Rect. |
| clone | Creates a new copy of this rectangle. |
| getHeight | Returns the height of this rectangle. |
| getWidth | Returns the width of this rectangle. |
| getOrigin | Returns the top left coordinate of this rectangle. |
| contains | Tests whether this rectangle contains a x/y coordinate. |
| intersects | Tests whether this rectangle intersects the provided rectangle. Assumes that the coordinate system increases going down and left. |
| equals | Compares bounding rectangles for equality. |
| createFromPoint | Creates a new Rect using a position and supplied dimensions. |
Constructors
Constructor
new Rect(
top,
bottom,
left,
right
): Rect;
Defined in: packages/blockly/core/utils/rect.ts:28
Parameters
| Parameter | Type | Description |
|---|---|---|
top | number | Top. |
bottom | number | Bottom. |
left | number | Left. |
right | number | Right. |
Returns
Rect
Properties
top
top: number;
Defined in: packages/blockly/core/utils/rect.ts:29
Top.
bottom
bottom: number;
Defined in: packages/blockly/core/utils/rect.ts:30
Bottom.
left
left: number;
Defined in: packages/blockly/core/utils/rect.ts:31
Left.
right
right: number;
Defined in: packages/blockly/core/utils/rect.ts:32
Right.
Methods
from()
static from(rect): Rect;
Defined in: packages/blockly/core/utils/rect.ts:41
Converts a DOM or SVG Rect to a Blockly Rect.
Parameters
| Parameter | Type | Description |
|---|---|---|
rect | DOMRect | The rectangle to convert. |
Returns
Rect
A representation of the same rectangle as a Blockly Rect.
clone()
clone(): Rect;
Defined in: packages/blockly/core/utils/rect.ts:50
Creates a new copy of this rectangle.
Returns
Rect
A copy of this Rect.
getHeight()
getHeight(): number;
Defined in: packages/blockly/core/utils/rect.ts:55
Returns the height of this rectangle.
Returns
number
getWidth()
getWidth(): number;
Defined in: packages/blockly/core/utils/rect.ts:60
Returns the width of this rectangle.
Returns
number
getOrigin()
getOrigin(): Coordinate;
Defined in: packages/blockly/core/utils/rect.ts:65
Returns the top left coordinate of this rectangle.
Returns
contains()
contains(x, y): boolean;
Defined in: packages/blockly/core/utils/rect.ts:76
Tests whether this rectangle contains a x/y coordinate.
Parameters
| Parameter | Type | Description |
|---|---|---|
x | number | The x coordinate to test for containment. |
y | number | The y coordinate to test for containment. |
Returns
boolean
Whether this rectangle contains given coordinate.
intersects()
intersects(other): boolean;
Defined in: packages/blockly/core/utils/rect.ts:89
Tests whether this rectangle intersects the provided rectangle. Assumes that the coordinate system increases going down and left.
Parameters
| Parameter | Type | Description |
|---|---|---|
other | Rect | The other rectangle to check for intersection with. |
Returns
boolean
Whether this rectangle intersects the provided rectangle.
equals()
static equals(a?, b?): boolean;
Defined in: packages/blockly/core/utils/rect.ts:110
Compares bounding rectangles for equality.
Parameters
| Parameter | Type | Description |
|---|---|---|
a? | Rect | null | A Rect. |
b? | Rect | null | A Rect. |
Returns
boolean
True iff the bounding rectangles are equal, or if both are null.
createFromPoint()
static createFromPoint(
position,
width,
height
): Rect;
Defined in: packages/blockly/core/utils/rect.ts:133
Creates a new Rect using a position and supplied dimensions.
Parameters
| Parameter | Type | Description |
|---|---|---|
position | Coordinate | The upper left coordinate of the new rectangle. |
width | number | The width of the rectangle, in pixels. |
height | number | The height of the rectangle, in pixels. |
Returns
Rect
A newly created Rect using the provided Coordinate and dimensions.