Class: Rectangle
矩形类型,四个核心属性:x、y、width、height
和 Node 节点不同,Rect的坐标原点在左上角,不在中间
Table of contents
Constructors
Properties
Accessors
Methods
- clone
- contains
- containsRect
- equals
- getBottom
- getCenter
- getRect
- getRight
- isEmpty
- isIntersectRect
- setTo
- setToEmpty
- toPoints
- toString
- normal
- union
- unionRects
Constructors
constructor
new Rectangle(x?
, y?
, width?
, height?
)
Parameters
Name | Type | Default value |
---|---|---|
x | number | 0 |
y | number | 0 |
width | number | 0 |
height | number | 0 |
Properties
height
height: number
= 0
width
width: number
= 0
x
x: number
= 0
y
y: number
= 0
Accessors
bottom
get
bottom(): number
Returns
number
set
bottom(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
center
get
center(): number
Returns
number
set
center(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
left
get
left(): number
Returns
number
set
left(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
middle
get
middle(): number
Returns
number
set
middle(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
right
get
right(): number
Returns
number
set
right(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
top
get
top(): number
Returns
number
set
top(v
): void
Parameters
Name | Type |
---|---|
v | number |
Returns
void
Methods
clone
clone(): Rectangle
Returns
contains
contains(x
, y
): boolean
Parameters
Name | Type |
---|---|
x | number |
y | number |
Returns
boolean
containsRect
containsRect(rect
): boolean
Parameters
Name | Type |
---|---|
rect | Rectangle |
Returns
boolean
equals
equals(rect
): boolean
Parameters
Name | Type |
---|---|
rect | Rectangle |
Returns
boolean
getBottom
getBottom(): number
Returns
number
getCenter
getCenter(): Object
Returns
Object
Name | Type |
---|---|
x | number |
y | number |
getRect
getRect(): Rectangle
Returns
getRight
getRight(): number
Returns
number
isEmpty
isEmpty(): boolean
Returns
boolean
isIntersectRect
isIntersectRect(rect
): boolean
Parameters
Name | Type |
---|---|
rect | any |
Returns
boolean
setTo
setTo(x?
, y?
, width?
, height?
): void
Parameters
Name | Type | Default value |
---|---|---|
x | number | 0 |
y | number | 0 |
width | number | 0 |
height | number | 0 |
Returns
void
setToEmpty
setToEmpty(): void
Returns
void
toPoints
toPoints(): { x
: number
; y
: number
}[]
Returns
{ x
: number
; y
: number
}[]
toString
toString(): string
Returns
string
normal
Static
normal(center
, p
): number
[]
Parameters
Name | Type |
---|---|
center | PointLike |
p | PointLike |
Returns
number
[]
union
Static
union(out
, rect
): Rectangle
Parameters
Name | Type |
---|---|
out | Rectangle |
rect | Rectangle |
Returns
unionRects
Static
unionRects(rects
): Rectangle
Parameters
Name | Type |
---|---|
rects | Rectangle [] |