Skip to content

Class: Shape

图形抽象基类, 只存储图形数据,不维护状态

Hierarchy

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

NameType
ctxCanvasRenderingContext2D
objectDisplayObject
points?PointLike[]

Returns

any


markDirty

markDirty(): void

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

Returns

void


setConnections

setConnections(connections): void

Parameters

NameType
connectionsany

Returns

void


toJSON

toJSON(): any

Returns

any


circle

Static circle(opt): any[]

生成圆上一列的点

Parameters

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

Returns

any[]


fromPoints

Static fromPoints(points, keepAspectRatio?): PolygonShape

Parameters

NameTypeDefault value
pointsPointLike[]undefined
keepAspectRatiobooleantrue

Returns

PolygonShape


innerGrid

Static innerGrid(rows, cols): PointLike[]

生成内网格坐标数组

Parameters

NameTypeDescription
rowsnumber
colsnumber

Returns

PointLike[]


normalPoints

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

将指定点坐标单位化

Parameters

NameTypeDefault value
pointsPointLike[]undefined
keepAspectRatiobooleantrue

Returns

{ x: number ; y: number }[]


outerGrid

Static outerGrid(rows, cols): PointLike[]

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

Parameters

NameTypeDescription
rowsnumber
colsnumber

Returns

PointLike[]

一维数组(单位坐标)


pointToSize

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

Parameters

NameTypeDefault value
pointsPointLike[]undefined
widthnumberundefined
heightnumberundefined
keepAspectRatiobooleanfalse

Returns

{ x: number ; y: number }[]


polygon

Static polygon(edgeCount?, initAngle?): PolygonShape

生成多边形Shape对象

Parameters

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

Returns

PolygonShape