Skip to content

Rect

The Rect class is a struct used to represent a rectangle, including the position of the top-left corner and the width and height of the rectangle. It is commonly used to control the position and size of images.

构造方法

Rect.new ( x : number? , y : number? , w : number? , h : number? )
Create a new Rect object.

成员变量

Rect.x : number
(Read Only) The x coordinate of the top-left corner of the Rect.
Rect.y : number
(Read Only) The y coordinate of the top-left corner of the Rect.
Rect.width : number
(Read-only) The width of the rectangle.
Rect.height : number
(Read-only) The height of the rectangle.
Rect.area : number
(Read-only) The area of the rectangle.
Rect.min : Vector2
(Read Only) The coordinates of the top-left corner of the rectangle.
Rect.max : Vector2
(Read Only) The coordinates of the bottom right corner of the rectangle.

成员方法

Rect.SetValues ( x : number , y : number , w : number , h : number ) : void
Set the x, y, width, and height of the rectangle.
Rect.Overlaps ( other : Rect ) : boolean
Determines whether the specified rectangle overlaps with the current rectangle.
Rect.SetMinMax ( min : Vector2 , max : Vector2 ) : void
Set the minimum and maximum coordinates of a rectangle.
Rect.Contains ( point : Vector2 ) : boolean
Determines whether a point is inside a rectangle.
Rect.EncapsulatePoint ( point : Vector2 ) : void
Expands the rectangle to contain a point.
Rect.Scale ( scale_x : number , scale_y : number ) : void
Scale the rectangle.
Rect.Move ( delta_x : number , delta_y : number ) : void
Moves the position of the rectangle.
Rect.EncapsulateRect ( rect : Rect ) : void
Expands this rectangle to contain another given rectangle.
Rect.toString ( ) : string
Get the property string of Rect.
Rect.CopyFrom ( from : Rect ) : void
Copy from object to the current object.
Rect.EqualsTo ( other : Rect ) : boolean
Determines whether the current Rect is equal to the target Rect.

静态方法

Rect.Clone ( val : Rect ) : Rect
This is a static function that copies the given Rect object and returns a new Rect object.
Rect.EqualsTo ( lhs : Rect , rhs : Rect ) : boolean
Determines whether two Rects are equal.