Stay organized with collections
Save and categorize content based on your preferences.
blockly > utils > Rect
utils.Rect class
Class for representing rectangular regions.
Signature:
export declare class Rect
Constructors
Properties
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. |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-24 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-24 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eutils.Rect\u003c/code\u003e class in Blockly is used for representing rectangular regions using top, bottom, left, and right coordinates.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to check if a point is within the rectangle (\u003ccode\u003econtains\u003c/code\u003e), determine the rectangle's dimensions (\u003ccode\u003egetHeight\u003c/code\u003e, \u003ccode\u003egetWidth\u003c/code\u003e), and if it overlaps with another rectangle (\u003ccode\u003eintersects\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eThe rectangle's position and size are defined by its \u003ccode\u003etop\u003c/code\u003e, \u003ccode\u003ebottom\u003c/code\u003e, \u003ccode\u003eleft\u003c/code\u003e, and \u003ccode\u003eright\u003c/code\u003e properties.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [utils](./blockly.utils_namespace.md) \\\u003e [Rect](./blockly.utils_namespace.rect_class.md)\n\nutils.Rect class\n----------------\n\nClass for representing rectangular regions.\n\n**Signature:** \n\n export declare class Rect \n\nConstructors\n------------\n\n| Constructor | Modifiers | Description |\n|----------------------------------------------------------------------------------------------------------------|-----------|-----------------------------------------------|\n| [(constructor)(top, bottom, left, right)](./blockly.utils_namespace.rect_class._constructor__1_constructor.md) | | Constructs a new instance of the `Rect` class |\n\nProperties\n----------\n\n| Property | Modifiers | Type | Description |\n|-------------------------------------------------------------------|-----------|--------|-------------|\n| [bottom](./blockly.utils_namespace.rect_class.bottom_property.md) | | number | |\n| [left](./blockly.utils_namespace.rect_class.left_property.md) | | number | |\n| [right](./blockly.utils_namespace.rect_class.right_property.md) | | number | |\n| [top](./blockly.utils_namespace.rect_class.top_property.md) | | number | |\n\nMethods\n-------\n\n| Method | Modifiers | Description |\n|--------------------------------------------------------------------------------------------------------------|-----------|-----------------------------------------------------------------------------------------------------------------------------------|\n| [clone()](./blockly.utils_namespace.rect_class.clone_1_method.md) | | Creates a new copy of this rectangle. |\n| [contains(x, y)](./blockly.utils_namespace.rect_class.contains_1_method.md) | | Tests whether this rectangle contains a x/y coordinate. |\n| [createFromPoint(position, width, height)](./blockly.utils_namespace.rect_class.createfrompoint_1_method.md) | `static` | Creates a new Rect using a position and supplied dimensions. |\n| [equals(a, b)](./blockly.utils_namespace.rect_class.equals_1_method.md) | `static` | Compares bounding rectangles for equality. |\n| [from(rect)](./blockly.utils_namespace.rect_class.from_1_method.md) | `static` | Converts a DOM or SVG Rect to a Blockly Rect. |\n| [getHeight()](./blockly.utils_namespace.rect_class.getheight_1_method.md) | | Returns the height of this rectangle. |\n| [getOrigin()](./blockly.utils_namespace.rect_class.getorigin_1_method.md) | | Returns the top left coordinate of this rectangle. |\n| [getWidth()](./blockly.utils_namespace.rect_class.getwidth_1_method.md) | | Returns the width of this rectangle. |\n| [intersects(other)](./blockly.utils_namespace.rect_class.intersects_1_method.md) | | Tests whether this rectangle intersects the provided rectangle. Assumes that the coordinate system increases going down and left. |"]]