Class: Rect
Rectangular region
Constructors
Properties
Accessors
Methods
Constructors
constructor
• new Rect(x?
, y?
, width?
, height?
): Rect
Creates a new rectangular area object
Parameters
Name | Type | Default value | Description |
---|---|---|---|
x | number | 0 | The x-coordinate of the rectangle |
y | number | 0 | The y coordinate of the rectangle |
width | number | 0 | Width of a rectangle |
height | number | 0 | Height of rectangle |
Returns
Defined in
Properties
x
• x: number
The x-coordinate of the rectangle
Defined in
y
• y: number
The y-coordinate of the rectangle
Defined in
w
• w: number
Width of a rectangle
Defined in
h
• h: number
Height of rectangle
Defined in
Accessors
width
• get
width(): number
Width of a rectangle
Returns
number
Defined in
• set
width(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Defined in
height
• get
height(): number
Height of rectangle
Returns
number
Defined in
• set
height(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Defined in
Methods
pointInRect
▸ pointInRect(x
, y
, lt_x
, lt_y
, rb_x
, rb_y
): boolean
Whether the point is within the specified area
Parameters
Name | Type | Description |
---|---|---|
x | number | x value of point |
y | number | y value of point |
lt_x | number | The x value in the upper left corner |
lt_y | number | The y value in the upper left corner |
rb_x | number | The x value in the lower right corner |
rb_y | number | The y value in the lower right corner |
Returns
boolean
Defined in
clone
▸ clone(): Rect
Returns a new rectangular area object with the same properties as the current rectangular area
Returns
Defined in
copyFrom
▸ copyFrom(rect
): void
Copy the properties of the source object to this object
Parameters
Name | Type |
---|---|
rect | Rect |
Returns
void
Defined in
copyTo
▸ copyTo(rect
): void
Copy the properties of this object to the target object
Parameters
Name | Type |
---|---|
rect | Rect |
Returns
void
Defined in
inner
▸ inner(x
, y
): boolean
Whether the point is in this area
Parameters
Name | Type | Description |
---|---|---|
x | number | x value of point |
y | number | y value of point |
Returns
boolean
Defined in
equal
▸ equal(rectangle
): boolean
Whether the current rectangle is equal to the target rectangle
Parameters
Name | Type | Description |
---|---|---|
rectangle | Rect | Target rectangle |
Returns
boolean
Defined in
equalArea
▸ equalArea(x
, y
, width
, height
): boolean
Whether the current rectangle is equal to the target rectangle
Parameters
Name | Type | Description |
---|---|---|
x | number | The x value of the rectangle |
y | number | The y value of the rectangle |
width | number | Rectangle width |
height | number | Rectangular height |
Returns
boolean
Defined in
equalInnerArea
▸ equalInnerArea(source
): boolean
Whether this rectangle overlaps with the target object
Parameters
Name | Type | Description |
---|---|---|
source | Rect | Source object |
Returns
boolean
Defined in
innerArea
▸ innerArea(source
, target
): Rect
Returns the overlap of two rectangles
Parameters
Name | Type | Description |
---|---|---|
source | Rect | source object |
target | Rect | target object |
Returns
Defined in
setTo
▸ setTo(x
, y
, width
, height
): void
Sets the properties of the rectangle
Parameters
Name | Type | Description |
---|---|---|
x | number | x value |
y | number | y value |
width | number | Rectangle width |
height | number | Rectangular height |
Returns
void