Skip to content

Class: Shape

图形抽象基类

Hierarchy

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new Shape()

Properties

className

Readonly className: any

类名称


height

height: number

默认或建议的高度,默认32


isClosed

isClosed: boolean = true

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


isUnit

isUnit: boolean


vertices

Readonly vertices: PointLike[] = []

顶点集合(归一化坐标)


width

width: number

默认或建议的宽度,默认32

Methods

draw

Abstract draw(ctx, object): any

绘制图形

Parameters

NameType
ctxCanvasRenderingContext2D
objectNE

Returns

any


getAnchors

getAnchors(): Map<string, Anchor>

Returns

Map<string, Anchor>


getConnectAutoPoint

getConnectAutoPoint(x, y, obj): Object

获取连接点 (x,y) -> 本对象中心 与边框的交点

Parameters

NameType
xnumber
ynumber
objNE

Returns

Object

NameType
xnumber
ynumber

getConnectionAnchor

getConnectionAnchor(name): Anchor

获取连接点

Parameters

NameType
namestring

Returns

Anchor


getConnectionAnchors

getConnectionAnchors(): IterableIterator<Anchor>

获取所有连接点

Returns

IterableIterator<Anchor>


getIntersect

getIntersect(x, y, obj): Intersect

获取 图形上距离(x,y)最近的点

Parameters

NameType
xnumber
ynumber
objNE

Returns

Intersect


hasAnchor

hasAnchor(name): boolean

Parameters

NameType
namestring

Returns

boolean


setConnections

setConnections(connections): void

设置连接点

Parameters

NameType
connections{ name: string ; x: number ; y: number ; usage?: AnchorUsageType }[]

Returns

void


toJSON

toJSON(): any

Returns

any


circle

Static circle(opt): any[]

生成圆环点坐标

Parameters

NameType
optBuildCircleOpt

Returns

any[]

PointLike[] 顶点坐标集合


fromJSON

Static fromJSON(json): Shape

Parameters

NameType
jsonany

Returns

Shape


grid

Static grid(rows, cols): PointLike[]

生成二维网格坐标数组

Parameters

NameTypeDescription
rowsnumber
colsnumber

Returns

PointLike[]

PointLike[] 顶点坐标集合


innerGrid

Static innerGrid(rows, cols): PointLike[]

生成二维内网格坐标数组(有内边距)

Parameters

NameTypeDescription
rowsnumber
colsnumber

Returns

PointLike[]

PointLike[] 顶点坐标集合


polygon

Static polygon(edgeCount): any[]

生成 正多边形 (最小为3边形,小于3边形时,按3边形处理)

Parameters

NameTypeDescription
edgeCountnumber边数

Returns

any[]

PointLike[] 顶点坐标集合