Class: Shape
图形抽象基类, 只存储图形数据,不维护状态
Hierarchy
Shape
Table of contents
Constructors
Properties
Methods
Constructors
constructor
new Shape()
Properties
_pathArray
Optional
_pathArray: any
[]
aspect
aspect: "fixed"
| "variable"
className
className: any
类名称
connectionMap
connectionMap: Object
Index signature
▪ [key: string
]: any
ctrlPoints
ctrlPoints: string
[]
dirty
dirty: boolean
isUnit
isUnit: boolean
是否单位坐标
package
package: string
包名称
positions
positions: any
= {}
Methods
draw
Abstract
draw(ctx
, object
, points?
): any
Parameters
Name | Type |
---|---|
ctx | CanvasRenderingContext2D |
object | DisplayObject |
points? | PointLike [] |
Returns
any
markDirty
markDirty(): void
标记‘脏’,请求更新绘制
Returns
void
setConnections
setConnections(connections
): void
Parameters
Name | Type |
---|---|
connections | any |
Returns
void
toJSON
toJSON(): any
Returns
any
circle
Static
circle(opt
): any
[]
生成圆上一列的点
Parameters
Name | Type |
---|---|
opt | Object |
opt.begin | number |
opt.end | number |
opt.pointCount? | number |
opt.step | number |
Returns
any
[]
fromPoints
Static
fromPoints(points
, keepAspectRatio?
): PolygonShape
Parameters
Name | Type | Default value |
---|---|---|
points | PointLike [] | undefined |
keepAspectRatio | boolean | true |
Returns
innerGrid
Static
innerGrid(rows
, cols
): PointLike
[]
生成内网格坐标数组
Parameters
Name | Type | Description |
---|---|---|
rows | number | 行 |
cols | number | 列 |
Returns
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
}[]
outerGrid
Static
outerGrid(rows
, cols
): PointLike
[]
生成网格坐标(外边框)数组
Parameters
Name | Type | Description |
---|---|---|
rows | number | 行 |
cols | number | 列 |
Returns
一维数组(单位坐标)
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
}[]
polygon
Static
polygon(edgeCount?
, initAngle?
): PolygonShape
生成多边形Shape对象
Parameters
Name | Type | Default value | Description |
---|---|---|---|
edgeCount | number | 3 | 边的条数 |
initAngle | number | 0 | 初始角度 |