Rect
ClassAn axis aligned rectangle.
- Available on all platforms
An axis aligned rectangle.
Used by anchors and offsets in ScreenTransform to represent screen boundaries.
Rect can only store finite numbers in the range Number.MIN_VALUE to Number.MAX_VALUE.
Index
Properties
Methods
Example
// @input Component.ScreenTransform screenTransform
// Move the ScreenTransform's anchor center
script.screenTransform.anchors.setCenter(new vec2(-0.25, 0.5));
// Change the ScreenTransform's anchor size
script.screenTransform.anchors.setSize(new vec2(0.25, 0.25));
Extends
Properties
bottom
bottom:
number
The y position of the rectangle's bottom side.
Default Value
0
left
left:
number
The x position of the rectangle's left side.
Default Value
0
right
right:
number
The x position of the rectangle's right side.
Default Value
0
top
top:
number
The y position of the rectangle's top side.
Default Value
0
Methods
create()
staticcreate(left,right,bottom,top):Rect
Creates a new Rect with the given properties.
Parameters
| Parameter | Type |
|---|---|
left | number |
right | number |
bottom | number |
top | number |
Returns
Rect
getCenter()
getCenter():
vec2
Returns the rectangle's center position as (x, y).
Returns
getSize()
getSize():
vec2
Returns the size of the rectangle as (width, height).
Returns
getTypeName()
staticgetTypeName():TypeName<Rect>
Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().
Returns
TypeName<Rect>
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
setCenter()
setCenter(
value):void
Sets the rectangle's center position while maintaining its size.
Parameters
| Parameter | Type |
|---|---|
value | vec2 |
Returns
void
setSize()
setSize(
value):void
Sets the rectangle's size while maintaining its center position.
Parameters
| Parameter | Type |
|---|---|
value | vec2 |
Returns
void
toString()
toString():
string
Returns a string representation of the Rect.
Returns
string