Skip to content

Class: PolygonShape

多边形

由多个连续的点坐标构成

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new PolygonShape(unitPoints)

Parameters

NameType
unitPointsPointLike[]

Overrides

Shape.constructor

Properties

_pathArray

Optional _pathArray: any[]

Inherited from

Shape._pathArray


aspect

aspect: "fixed" | "variable"

Inherited from

Shape.aspect


className

className: any

类名称

Overrides

Shape.className


connectionMap

connectionMap: Object

Index signature

▪ [key: string]: any

Inherited from

Shape.connectionMap


ctrlPoints

ctrlPoints: string[]

Inherited from

Shape.ctrlPoints


dirty

dirty: boolean

Inherited from

Shape.dirty


isClosed

isClosed: boolean = true

是否封闭图形(最后一个点是否连接到第一个点形成封闭图形),默认true


isUnit

isUnit: boolean

是否单位坐标

Inherited from

Shape.isUnit


package

package: string

包名称

Inherited from

Shape.package


points

points: PointLike[]

单位点列表 x:[-0.5, 0.5] y: [-0.5, 0.5]


positions

positions: any = {}

Inherited from

Shape.positions

Methods

draw

draw(ctx, object, points?): void

Parameters

NameType
ctxCanvasRenderingContext2D
objectDisplayObject
points?PointLike[]

Returns

void

Overrides

Shape.draw


markDirty

markDirty(): void

标记‘脏’,请求更新绘制

Returns

void

Inherited from

Shape.markDirty


rotate

rotate(angle): PolygonShape

旋转,会修改points属性

Parameters

NameType
anglenumber

Returns

PolygonShape


scale

scale(sx, sy): PolygonShape

缩放,会修改points属性

Parameters

NameType
sxnumber
synumber

Returns

PolygonShape


setConnections

setConnections(connections): void

Parameters

NameType
connectionsany

Returns

void

Inherited from

Shape.setConnections


skew

skew(sx, sy): PolygonShape

Parameters

NameType
sxnumber
synumber

Returns

PolygonShape


toJSON

toJSON(): any

Returns

any

Overrides

Shape.toJSON


updatePoints

updatePoints(unitPoints): void

更新数据点

Parameters

NameTypeDescription
unitPointsPointLike[]单位点列表 x:[-0.5, 0.5] y: [-0.5, 0.5]

Returns

void


Scale

Static Scale(sx, sy): (p: PointLike) => PointLike

Deprecated

Parameters

NameType
sxnumber
synumber

Returns

fn

(p): PointLike

Parameters
NameType
pPointLike
Returns

PointLike


circle

Static circle(opt): any[]

生成圆上一列的点

Parameters

NameType
optObject
opt.beginnumber
opt.endnumber
opt.pointCount?number
opt.stepnumber

Returns

any[]

Inherited from

Shape.circle


fromJSON

Static fromJSON(json): PolygonShape

Parameters

NameType
jsonany

Returns

PolygonShape


fromPoints

Static fromPoints(points, keepAspectRatio?): PolygonShape

Parameters

NameTypeDefault value
pointsPointLike[]undefined
keepAspectRatiobooleantrue

Returns

PolygonShape

Inherited from

Shape.fromPoints


innerGrid

Static innerGrid(rows, cols): PointLike[]

生成内网格坐标数组

Parameters

NameTypeDescription
rowsnumber
colsnumber

Returns

PointLike[]

Inherited from

Shape.innerGrid


normalPoints

Static normalPoints(points, keepAspectRatio?): { x: number ; y: number }[]

将指定点坐标单位化

Parameters

NameTypeDefault value
pointsPointLike[]undefined
keepAspectRatiobooleantrue

Returns

{ x: number ; y: number }[]

Inherited from

Shape.normalPoints


outerGrid

Static outerGrid(rows, cols): PointLike[]

生成网格坐标(外边框)数组

Parameters

NameTypeDescription
rowsnumber
colsnumber

Returns

PointLike[]

一维数组(单位坐标)

Inherited from

Shape.outerGrid


pointToSize

Static pointToSize(points, width, height, keepAspectRatio?): { x: number ; y: number }[]

Parameters

NameTypeDefault value
pointsPointLike[]undefined
widthnumberundefined
heightnumberundefined
keepAspectRatiobooleanfalse

Returns

{ x: number ; y: number }[]

Inherited from

Shape.pointToSize


polygon

Static polygon(edgeCount?, initAngle?): PolygonShape

生成多边形Shape对象

Parameters

NameTypeDefault valueDescription
edgeCountnumber3边的条数
initAnglenumber0初始角度

Returns

PolygonShape

Inherited from

Shape.polygon