Skip to content

Class: Rect

Rectangular region

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Rect(x?, y?, width?, height?): Rect

Creates a new rectangular area object

Parameters

NameTypeDefault valueDescription
xnumber0The x-coordinate of the rectangle
ynumber0The y coordinate of the rectangle
widthnumber0Width of a rectangle
heightnumber0Height of rectangle

Returns

Rect

Defined in

src/math/Rect.ts:34

Properties

x

x: number

The x-coordinate of the rectangle

Defined in

src/math/Rect.ts:10


y

y: number

The y-coordinate of the rectangle

Defined in

src/math/Rect.ts:15


w

w: number

Width of a rectangle

Defined in

src/math/Rect.ts:20


h

h: number

Height of rectangle

Defined in

src/math/Rect.ts:25

Accessors

width

get width(): number

Width of a rectangle

Returns

number

Defined in

src/math/Rect.ts:44

set width(v): void

Parameters

NameType
vnumber

Returns

void

Defined in

src/math/Rect.ts:48


height

get height(): number

Height of rectangle

Returns

number

Defined in

src/math/Rect.ts:55

set height(v): void

Parameters

NameType
vnumber

Returns

void

Defined in

src/math/Rect.ts:59

Methods

pointInRect

pointInRect(x, y, lt_x, lt_y, rb_x, rb_y): boolean

Whether the point is within the specified area

Parameters

NameTypeDescription
xnumberx value of point
ynumbery value of point
lt_xnumberThe x value in the upper left corner
lt_ynumberThe y value in the upper left corner
rb_xnumberThe x value in the lower right corner
rb_ynumberThe y value in the lower right corner

Returns

boolean

Defined in

src/math/Rect.ts:73


clone

clone(): Rect

Returns a new rectangular area object with the same properties as the current rectangular area

Returns

Rect

Defined in

src/math/Rect.ts:85


copyFrom

copyFrom(rect): void

Copy the properties of the source object to this object

Parameters

NameType
rectRect

Returns

void

Defined in

src/math/Rect.ts:94


copyTo

copyTo(rect): void

Copy the properties of this object to the target object

Parameters

NameType
rectRect

Returns

void

Defined in

src/math/Rect.ts:106


inner

inner(x, y): boolean

Whether the point is in this area

Parameters

NameTypeDescription
xnumberx value of point
ynumbery value of point

Returns

boolean

Defined in

src/math/Rect.ts:116


equal

equal(rectangle): boolean

Whether the current rectangle is equal to the target rectangle

Parameters

NameTypeDescription
rectangleRectTarget rectangle

Returns

boolean

Defined in

src/math/Rect.ts:128


equalArea

equalArea(x, y, width, height): boolean

Whether the current rectangle is equal to the target rectangle

Parameters

NameTypeDescription
xnumberThe x value of the rectangle
ynumberThe y value of the rectangle
widthnumberRectangle width
heightnumberRectangular height

Returns

boolean

Defined in

src/math/Rect.ts:140


equalInnerArea

equalInnerArea(source): boolean

Whether this rectangle overlaps with the target object

Parameters

NameTypeDescription
sourceRectSource object

Returns

boolean

Defined in

src/math/Rect.ts:149


innerArea

innerArea(source, target): Rect

Returns the overlap of two rectangles

Parameters

NameTypeDescription
sourceRectsource object
targetRecttarget object

Returns

Rect

Defined in

src/math/Rect.ts:174


setTo

setTo(x, y, width, height): void

Sets the properties of the rectangle

Parameters

NameTypeDescription
xnumberx value
ynumbery value
widthnumberRectangle width
heightnumberRectangular height

Returns

void

Defined in

src/math/Rect.ts:213

Released under the MIT License