Rect
Lens Studio v2.0.0+
Inherits from ScriptObject
Description
An axis aligned rectangle. Used by anchors
and offsets
in ScreenTransform to represent screen boundaries.
Methods
getCenter()
: vec2
Returns the rectangle’s center position as (x, y).
getSize()
: vec2
Returns the size of the rectangle as (width, height).
setCenter(vec2 value)
: void
Sets the rectangle’s center position while maintaining its size.
setSize(vec2 value)
: void
Sets the rectangle’s size while maintaining its center position.
toString()
: String
Returns a string representation of the Rect.
static create(Number left, Number right, Number bottom, Number top)
: Rect
Creates a new Rect with the given properties.
Properties
bottom
: Number
The y position of the rectangle’s bottom side.
left
: Number
The x position of the rectangle’s left side.
right
: Number
The x position of the rectangle’s right side.
top
: Number
The y position of the rectangle’s top side.
Inherited Methods
getTypeName()
: String
Returns the name of this object’s type.
isOfType(String type)
: Boolean
Returns true if the object matches or derives from the passed in type.
Examples
// @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));
Still Looking for help?
Visit Support