Rect
Represents a rectangle with a set origin (top-left corner) and size(see example).
Name | Type | Default | Description |
---|---|---|---|
cornerRadius |
|
The size of the rectangle. | |
origin |
|
The origin (top-left corner) of the rectangle. | |
size |
|
The size of the rectangle. |
Constructors
Rect
(origin: Point | number[], size: number[] | Size, cornerRadius?: number | number[])
Creates a rectangle geometry with the specified parameters.
Parameters
origin
Point | number[]
The origin (top-left corner) of the rectangle or an equivalent `[x, y]` array.
size
number[] | Size
The size of the rectangle or an equivalent `[width, height]` array.
cornerRadius?
number | number[]
The corner radius of the rectangle as a single number or an `[rx, ry]` array.
Methods
bbox | ||||||
---|---|---|---|---|---|---|
Returns the bounding box of this rectangle after applying the specified transformation matrix. | ||||||
| ||||||
|
bottomLeft | ||||
---|---|---|---|---|
Gets the position of the bottom-left corner of the rectangle. This is also the rectangle origin. | ||||
|
bottomRight | ||||
---|---|---|---|---|
Gets the position of the bottom-right corner of the rectangle. | ||||
|
center | ||||
---|---|---|---|---|
Gets the position of the center of the rectangle. | ||||
|
clone | ||||
---|---|---|---|---|
Creates a new instance with the same origin and size. | ||||
|
equals | ||||||
---|---|---|---|---|---|---|
Compares this rectangle with another instance. | ||||||
| ||||||
|
fromPoints | |||||||||
---|---|---|---|---|---|---|---|---|---|
Creates a Rect instance that contains the points given as arguments. | |||||||||
| |||||||||
|
getOrigin | ||||
---|---|---|---|---|
Gets the origin (top-left point) of the rectangle. | ||||
|
getSize | ||||
---|---|---|---|---|
Gets the rectangle size. | ||||
|
height | ||||
---|---|---|---|---|
Gets the height of the rectangle. | ||||
|
setCornerRadius | ||||||
---|---|---|---|---|---|---|
Sets the corner radius of the rectangle. | ||||||
| ||||||
|
setOrigin | ||||||
---|---|---|---|---|---|---|
Sets the origin (top-left point) of the rectangle. | ||||||
| ||||||
|
setSize | ||||||
---|---|---|---|---|---|---|
Sets the size of the rectangle. | ||||||
| ||||||
|
topLeft | ||||
---|---|---|---|---|
Gets the position of the top-left corner of the rectangle. This is also the rectangle origin. | ||||
|
topRight | ||||
---|---|---|---|---|
Gets the position of the top-right corner of the rectangle. | ||||
|
union | |||||||||
---|---|---|---|---|---|---|---|---|---|
Creates a new Rect instance that encloses the two rectangles given as arguments. | |||||||||
| |||||||||
|
width | ||||
---|---|---|---|---|
Gets the rectangle width. | ||||
|