Class: PolygonShape
多边形
由多个连续的点坐标构成
Hierarchy
↳
PolygonShape
Table of contents
Constructors
Properties
Methods
- draw
- markDirty
- rotate
- scale
- setConnections
- skew
- toJSON
- updatePoints
- Scale
- circle
- fromJSON
- fromPoints
- innerGrid
- normalPoints
- outerGrid
- pointToSize
- polygon
Constructors
constructor
new PolygonShape(unitPoints)
Parameters
| Name | Type |
|---|---|
unitPoints | PointLike[] |
Overrides
Properties
_pathArray
Optional _pathArray: any[]
Inherited from
aspect
aspect: "fixed" | "variable"
Inherited from
className
className: any
类名称
Overrides
connectionMap
connectionMap: Object
Index signature
▪ [key: string]: any
Inherited from
ctrlPoints
ctrlPoints: string[]
Inherited from
dirty
dirty: boolean
Inherited from
isClosed
isClosed: boolean = true
是否封闭图形(最后一个点是否连接到第一个点形成封闭图形),默认true
isUnit
isUnit: boolean
是否单位坐标
Inherited from
package
package: string
包名称
Inherited from
points
points: PointLike[]
单位点列表 x:[-0.5, 0.5] y: [-0.5, 0.5]
positions
positions: any = {}
Inherited from
Methods
draw
draw(ctx, object, points?): void
Parameters
| Name | Type |
|---|---|
ctx | CanvasRenderingContext2D |
object | DisplayObject |
points? | PointLike[] |
Returns
void
Overrides
markDirty
markDirty(): void
标记‘脏’,请求更新绘制
Returns
void
Inherited from
rotate
rotate(angle): PolygonShape
旋转,会修改points属性
Parameters
| Name | Type |
|---|---|
angle | number |
Returns
scale
scale(sx, sy): PolygonShape
缩放,会修改points属性
Parameters
| Name | Type |
|---|---|
sx | number |
sy | number |
Returns
setConnections
setConnections(connections): void
Parameters
| Name | Type |
|---|---|
connections | any |
Returns
void
Inherited from
skew
skew(sx, sy): PolygonShape
Parameters
| Name | Type |
|---|---|
sx | number |
sy | number |
Returns
toJSON
toJSON(): any
Returns
any
Overrides
updatePoints
updatePoints(unitPoints): void
更新数据点
Parameters
| Name | Type | Description |
|---|---|---|
unitPoints | PointLike[] | 单位点列表 x:[-0.5, 0.5] y: [-0.5, 0.5] |
Returns
void
Scale
Static Scale(sx, sy): (p: PointLike) => PointLike
Deprecated
Parameters
| Name | Type |
|---|---|
sx | number |
sy | number |
Returns
fn
(p): PointLike
Parameters
| Name | Type |
|---|---|
p | PointLike |
Returns
circle
Static circle(opt): any[]
生成圆上一列的点
Parameters
| Name | Type |
|---|---|
opt | Object |
opt.begin | number |
opt.end | number |
opt.pointCount? | number |
opt.step | number |
Returns
any[]
Inherited from
fromJSON
Static fromJSON(json): PolygonShape
Parameters
| Name | Type |
|---|---|
json | any |
Returns
fromPoints
Static fromPoints(points, keepAspectRatio?): PolygonShape
Parameters
| Name | Type | Default value |
|---|---|---|
points | PointLike[] | undefined |
keepAspectRatio | boolean | true |
Returns
Inherited from
innerGrid
Static innerGrid(rows, cols): PointLike[]
生成内网格坐标数组
Parameters
| Name | Type | Description |
|---|---|---|
rows | number | 行 |
cols | number | 列 |
Returns
Inherited from
normalPoints
Static normalPoints(points, keepAspectRatio?): { x: number ; y: number }[]
将指定点坐标单位化
Parameters
| Name | Type | Default value |
|---|---|---|
points | PointLike[] | undefined |
keepAspectRatio | boolean | true |
Returns
{ x: number ; y: number }[]
Inherited from
outerGrid
Static outerGrid(rows, cols): PointLike[]
生成网格坐标(外边框)数组
Parameters
| Name | Type | Description |
|---|---|---|
rows | number | 行 |
cols | number | 列 |
Returns
一维数组(单位坐标)
Inherited from
pointToSize
Static pointToSize(points, width, height, keepAspectRatio?): { x: number ; y: number }[]
Parameters
| Name | Type | Default value |
|---|---|---|
points | PointLike[] | undefined |
width | number | undefined |
height | number | undefined |
keepAspectRatio | boolean | false |
Returns
{ x: number ; y: number }[]
Inherited from
polygon
Static polygon(edgeCount?, initAngle?): PolygonShape
生成多边形Shape对象
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
edgeCount | number | 3 | 边的条数 |
initAngle | number | 0 | 初始角度 |