Appearance
@jtopo/core / PolygonShape
Class: PolygonShape
多边形
由多个连续的点坐标构成
Hierarchy
↳
PolygonShape
Table of contents
Constructors
Properties
Methods
- draw
- getAnchors
- getConnectAutoPoint
- getConnectionAnchor
- getConnectionAnchors
- getIntersect
- hasAnchor
- rotate
- scale
- setConnections
- skew
- toJSON
- updatePoints
- circle
- fromJSON
- grid
- innerGrid
- polygon
Constructors
constructor
new PolygonShape(normalPoints
)
构造函数
Parameters
Name | Type | Description |
---|---|---|
normalPoints | PointLike [] | 归一化点列表 x和y取值区间:[-1, 1] |
Overrides
Properties
className
className: any
类名称
Overrides
dirty
dirty: boolean
是否更新了数据
height
height: number
默认或建议的高度,默认32
Inherited from
isClosed
isClosed: boolean
= true
是否封闭图形(最后一个点是否连接到第一个点形成封闭图形),默认true
Overrides
isUnit
isUnit: boolean
Inherited from
vertices
Readonly
vertices: PointLike
[] = []
顶点集合(归一化坐标)
Inherited from
width
width: number
默认或建议的宽度,默认32
Inherited from
Methods
draw
draw(ctx
, node
): void
绘制图形
Parameters
Name | Type |
---|---|
ctx | CanvasRenderingContext2D |
node | NE |
Returns
void
Overrides
getAnchors
getAnchors(): Map
<string
, Anchor
>
Returns
Map
<string
, Anchor
>
Inherited from
getConnectAutoPoint
getConnectAutoPoint(x
, y
, obj
): Object
获取连接点 (x,y) -> 本对象中心 与边框的交点
Parameters
Name | Type |
---|---|
x | number |
y | number |
obj | NE |
Returns
Object
Name | Type |
---|---|
x | number |
y | number |
Inherited from
getConnectionAnchor
getConnectionAnchor(name
): Anchor
获取连接点
Parameters
Name | Type |
---|---|
name | string |
Returns
Inherited from
getConnectionAnchors
getConnectionAnchors(): IterableIterator
<Anchor
>
获取所有连接点
Returns
IterableIterator
<Anchor
>
Inherited from
getIntersect
getIntersect(x
, y
, obj
): Intersect
获取 图形上距离(x,y)最近的点
Parameters
Name | Type |
---|---|
x | number |
y | number |
obj | NE |
Returns
Intersect
Inherited from
hasAnchor
hasAnchor(name
): boolean
Parameters
Name | Type |
---|---|
name | string |
Returns
boolean
Inherited from
rotate
rotate(angle
): PolygonShape
旋转
Parameters
Name | Type | Description |
---|---|---|
angle | number | 角度(弧度) |
Returns
scale
scale(scaleX
, scaleY
): PolygonShape
缩放,对于shape而言,宽高的缩放不一致时才有意义(用于压扁、变宽)
Parameters
Name | Type |
---|---|
scaleX | number |
scaleY | number |
Returns
setConnections
setConnections(connections
): void
设置连接点
Parameters
Name | Type |
---|---|
connections | { name : string ; x : number ; y : number ; usage? : AnchorUsageType }[] |
Returns
void
Inherited from
skew
skew(scaleX
, scaleY
): PolygonShape
倾斜
Parameters
Name | Type |
---|---|
scaleX | number |
scaleY | number |
Returns
toJSON
toJSON(): any
Returns
any
Inherited from
updatePoints
updatePoints(normalPoints
): void
更新数据点
Parameters
Name | Type | Description |
---|---|---|
normalPoints | PointLike [] | 归一化点列表 x和y取值区间:[-1, 1] |
Returns
void
circle
Static
circle(opt
): any
[]
生成圆环点坐标
Parameters
Name | Type |
---|---|
opt | BuildCircleOpt |
Returns
any
[]
PointLike[] 顶点坐标集合
Inherited from
fromJSON
Static
fromJSON(json
): Shape
Parameters
Name | Type |
---|---|
json | any |
Returns
Inherited from
grid
Static
grid(rows
, cols
): PointLike
[]
生成二维网格坐标数组
Parameters
Name | Type | Description |
---|---|---|
rows | number | 行 |
cols | number | 列 |
Returns
PointLike[] 顶点坐标集合
Inherited from
innerGrid
Static
innerGrid(rows
, cols
): PointLike
[]
生成二维内网格坐标数组(有内边距)
Parameters
Name | Type | Description |
---|---|---|
rows | number | 行 |
cols | number | 列 |
Returns
PointLike[] 顶点坐标集合
Inherited from
polygon
Static
polygon(edgeCount
): any
[]
生成 正多边形 (最小为3边形,小于3边形时,按3边形处理)
Parameters
Name | Type | Description |
---|---|---|
edgeCount | number | 边数 |
Returns
any
[]
PointLike[] 顶点坐标集合