Skip to content

@jtopo/core / RegShape

Class: RegShape

通过Assets.regShape 注册的图形

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new RegShape()

Inherited from

Shape.constructor

Properties

className

className: any

类名称

Overrides

Shape.className


height

height: number

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

Inherited from

Shape.height


isClosed

isClosed: boolean = true

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

Inherited from

Shape.isClosed


isUnit

isUnit: boolean

Inherited from

Shape.isUnit


vertices

Readonly vertices: PointLike[] = []

顶点集合(归一化坐标)

Inherited from

Shape.vertices


width

width: number

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

Inherited from

Shape.width

Methods

draw

draw(ctx, node): void

绘制图形

Parameters

NameType
ctxCanvasRenderingContext2D
nodeNE

Returns

void

Overrides

Shape.draw


getAnchors

getAnchors(): Map<string, Anchor>

Returns

Map<string, Anchor>

Inherited from

Shape.getAnchors


getConnectAutoPoint

getConnectAutoPoint(x, y, obj): Object

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

Parameters

NameType
xnumber
ynumber
objNE

Returns

Object

NameType
xnumber
ynumber

Inherited from

Shape.getConnectAutoPoint


getConnectionAnchor

getConnectionAnchor(name): Anchor

获取连接点

Parameters

NameType
namestring

Returns

Anchor

Inherited from

Shape.getConnectionAnchor


getConnectionAnchors

getConnectionAnchors(): IterableIterator<Anchor>

获取所有连接点

Returns

IterableIterator<Anchor>

Inherited from

Shape.getConnectionAnchors


getIntersect

getIntersect(x, y, obj): Intersect

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

Parameters

NameType
xnumber
ynumber
objNE

Returns

Intersect

Inherited from

Shape.getIntersect


hasAnchor

hasAnchor(name): boolean

Parameters

NameType
namestring

Returns

boolean

Inherited from

Shape.hasAnchor


setConnections

setConnections(connections): void

设置连接点

Parameters

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

Returns

void

Inherited from

Shape.setConnections


toJSON

toJSON(): any

Returns

any

Inherited from

Shape.toJSON


circle

Static circle(opt): any[]

生成圆环点坐标

Parameters

NameType
optBuildCircleOpt

Returns

any[]

PointLike[] 顶点坐标集合

Inherited from

Shape.circle


fromJSON

Static fromJSON(json): Shape

Parameters

NameType
jsonany

Returns

Shape

Inherited from

Shape.fromJSON


grid

Static grid(rows, cols): PointLike[]

生成二维网格坐标数组

Parameters

NameTypeDescription
rowsnumber
colsnumber

Returns

PointLike[]

PointLike[] 顶点坐标集合

Inherited from

Shape.grid


innerGrid

Static innerGrid(rows, cols): PointLike[]

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

Parameters

NameTypeDescription
rowsnumber
colsnumber

Returns

PointLike[]

PointLike[] 顶点坐标集合

Inherited from

Shape.innerGrid


polygon

Static polygon(edgeCount): any[]

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

Parameters

NameTypeDescription
edgeCountnumber边数

Returns

any[]

PointLike[] 顶点坐标集合

Inherited from

Shape.polygon