Appearance
@jtopo/core
@jtopo/core
Table of contents
Enumerations
Classes
- AENode
- Anchor
- AnchorProxy
- Animation
- ArcLink
- AutoFoldLink
- BezierLink
- Camera
- CameraEvent
- CanvasNode
- Edge
- EllipseNode
- EventBase
- EventTarget
- FontInfo
- FontUtil
- ForceDirectLayout
- GeomUtils
- Graph
- GraphSystem
- HtmlNode
- ImageNode
- ImageUtil
- InputSystem
- Keyboard
- LShapeLink
- Layer
- Layout
- LayoutSystem
- LinearGradient
- Link
- NE
- NEHelper
- Node
- NodeHelper
- Observable
- Path
- PathLink
- Point
- PolygonShape
- QuadBezierLink
- RadialGradient
- Rectangle
- RegShape
- RegSystem
- SelectedGroup
- SerializerSystem
- Shape
- ShapeBuilder
- ShapeNode
- SpriteNode
- Stage
- StageEvent
- Style
- StylePattern
- StyleSystem
- TextNode
- Theme
- ThemeContent
- TipNode
- Vertext
- VideoNode
- ZShapeLink
- vec2
Interfaces
Type Aliases
- BuildCircleOpt
- CameraEventType
- ConnectToLinkAnchorType
- ConnectToNodeAnchorType
- CoreIconNames
- CoreNENames
- CurveMeasureResultType
- DirectionType
- DrawContentDesc
- EasingNameType
- EndpointOffsetType
- InputEventType
- LinkDirectionFirstType
- LinkSelectedStyleOptionsType
- LinkTarget
- NEEventType
- NearestInfo
- NodeAnchorNamesType
- NodeSelectedStyleOptionsType
- PartStyleOptionType
- PointLike
- Pojo
- RatioDirection
- RectPositionType
- RotateDirectionType
- SerializeableType
- SerializedDisplayObjectType
- SerializedJsonType
- SerializedLinkType
- StageConfig
- StageModeType
- StyleKeyType
- TextAlignType
- TextBaselineType
- ThemeContentType
- ThemeStyleNameType
- ToJsonOptionType
- Vec2Type
Variables
- Assets
- ConnectToNodePosition
- Cursor
- Debug
- Direction
- FunctionName
- JTType
- LinkPosition
- ObjectName
- RectPosition
- RectPositionNormalized
- RectPositionUnitNormals
- ResourceSystem
- StageMode
- TextAlign
- TextBaseline
- TextPosition
- VERSION
- geom
Functions
Type Aliases
BuildCircleOpt
BuildCircleOpt: Object
Type declaration
| Name | Type | Description |
|---|---|---|
beginAngle? | number | 开始角度,默认0 |
endAngle? | number | 结束角度,默认2π |
vertexCount? | number | 圆环的顶点数,小于3时,按3边形处理 |
CameraEventType
CameraEventType: "zoom"
ConnectToLinkAnchorType
ConnectToLinkAnchorType: "begin" | "end" | "auto" | "middle"
Link连接点
ConnectToNodeAnchorType
ConnectToNodeAnchorType: "lt" | "ct" | "rt" | "lm" | "center" | "rm" | "lb" | "cb" | "rb"
Node-默认连接点
CoreIconNames
CoreIconNames: "Rect" | "Ellipse" | "Arrow" | "Triangle" | "Diamond"
CoreNENames
CoreNENames: "Node" | "ImageNode" | "TextNode" | "EllipseNode" | "TipNode" | "ShapeNode" | "VideoNode" | "RatioNode" | "CanvasNode" | "Link" | "FoldLink" | "QuadBezierLink" | "AutoFoldLink" | "BezierLink" | "ArcLink" | "ZShapeLink" | "HtmlNode"
CurveMeasureResultType
CurveMeasureResultType: Object
Type declaration
| Name | Type |
|---|---|
dist | number |
t | number |
DirectionType
DirectionType: "up" | "down" | "left" | "right"
DrawContentDesc
DrawContentDesc: Object
Type declaration
| Name | Type |
|---|---|
hasBorder | boolean |
hasBackgroundColor | boolean |
shapeSize | { width: number ; height: number } |
shapeSize.width | number |
shapeSize.height | number |
EasingNameType
EasingNameType: "easeLinear" | "easeInQuad" | "easeOutQuad" | "easeInOutQuad" | "easeInSine" | "easeOutSine" | "easeInOutSine" | "easeInExpo" | "easeInOutExpo" | "easeInCirc" | "easeOutCirc" | "easeInOutCirc" | "easeInCubic" | "easeOutCubic" | "easeInOutCubic" | "easeInQuart" | "easeOutQuart" | "easeInOutQuart" | "easeInQuint" | "easeOutQuint" | "easeInOutQuint" | "easeInElastic" | "easeOutElastic" | "easeInOutElastic" | "easeInBack" | "easeOutBack" | "easeInOutBack" | "easeInBounce" | "easeOutBounce" | "easeInOutBounce"
EndpointOffsetType
EndpointOffsetType: number | PointLike
InputEventType
InputEventType: typeof InputEventList[number]
LinkDirectionFirstType
LinkDirectionFirstType: "horizontal" | "vertical"
连线方向, 水平优先 或者 垂直优先
LinkSelectedStyleOptionsType
LinkSelectedStyleOptionsType: Object
连线选中状态的样式
选中时连线会呈现阴影
当shadowColor不为null时生效
受以下参数影响(shadowBlur、shadowOffsetX、shadowOffsetY)
Type declaration
| Name | Type |
|---|---|
shadowColor? | string |
shadowBlur? | number |
shadowOffsetX? | number |
shadowOffsetY? | number |
LinkTarget
LinkTarget: Anchor | PointLike | AnchorProxy | NE
NEEventType
NEEventType: "pointerdown" | "pointerup" | "pointermove" | "pointerenter" | "pointerout" | "click" | "dblclick"
NearestInfo
NearestInfo: Object
Type declaration
| Name | Type |
|---|---|
object | any |
anchorName | string |
distance | number |
NodeAnchorNamesType
NodeAnchorNamesType: keyof typeof ConnectToNodePosition
NodeSelectedStyleOptionsType
NodeSelectedStyleOptionsType: Object
节点选中状态的样式
当borderWidth > 0 时, 选中时节点周围会呈现一个边框,受以下参数影响(borderWidth、borderColor)
当borderWidth为null或 == 0 时, 选中时节点会呈现阴影,受以下参数影响(shadowColor、shadowBlur、shadowOffsetX、shadowOffsetY)
Type declaration
| Name | Type |
|---|---|
borderWidth? | number |
borderColor? | string |
shadowColor? | string |
shadowBlur? | number |
shadowOffsetX? | number |
shadowOffsetY? | number |
PartStyleOptionType
PartStyleOptionType:
部分样式配置
PointLike
PointLike: Object
Point对象或者拥有x、y的对象
Type declaration
| Name | Type |
|---|---|
x | number |
y | number |
Pojo
Pojo: Object
Index signature
▪ [key: string]: any
RatioDirection
RatioDirection: DirectionType
RectPositionType
RectPositionType: "lt" | "ct" | "rt" | "lm" | "center" | "rm" | "lb" | "cb" | "rb"
矩形方位
RotateDirectionType
RotateDirectionType: "clockwise" | "anticlockwise"
SerializeableType
SerializeableType: Object
可被序列化的
Index signature
▪ [key: string]: any
SerializedDisplayObjectType
SerializedDisplayObjectType: { [key: string]: any; className: string ; id?: number | string ; name?: string ; type?: string ; attributes?: { [key: string]: any; } ; data?: { [key: string]: any; } ; pointerEnabled?: boolean ; visible?: boolean ; zIndex?: number ; style?: number ; shape?: any ; beginArrow?: {} ; endArrow?: {} } & SerializedLayerType | SerializedNodeType | SerializedLinkType
SerializedJsonType
SerializedJsonType: Object
序列化后的json格式
Type declaration
| Name | Type | Description |
|---|---|---|
version | string | jtopo版本 |
SerializeType | "Stage" | "Layer" | "Objects" | 序列化类型 |
Roots | any[] | - |
CustomStyle | { [themeName: string]: any; themes?: { [key: string]: ThemeType; } ; styles?: { [key: string]: PartStyleOptionType; } } | 用户自定义的样式 |
CustomStyle.themes? | { [key: string]: ThemeType; } | 用户自定义的主题 |
CustomStyle.styles? | { [key: string]: PartStyleOptionType; } | 通过defClass定义的样式 |
Styles | any[] | - |
Resources | any[] | 资源 |
Shapes | any[] | - |
DisplayObjects | SerializedDisplayObjectType[] | - |
EditInfo? | { uneditable?: number[] ; unconnectable?: number[] } | 编辑信息 |
EditInfo.uneditable? | number[] | 禁止编辑的节点 |
EditInfo.unconnectable? | number[] | 禁止连线的节点 |
SerializedLinkType
SerializedLinkType: Object
Type declaration
| Name | Type |
|---|---|
isLink | true |
label? | number |
parent? | number |
path? | [] |
begin? | {} |
end? | {} |
beginArrow? | number |
endArrow? | number |
StageConfig
StageConfig: Object
Type declaration
| Name | Type | Description |
|---|---|---|
dropAllowed | boolean | 是否启用drop,默认开启 |
autoResize | boolean | 是否自动调整尺寸(通过监控外层的容器尺寸) |
StageModeType
StageModeType: "normal" | "drag" | "edit" | "view" | "select" | "paint"
Stage模式
StyleKeyType
StyleKeyType: ClassPropertyNamesExclude<Style, `_${string}` | "className" | "dirty">
样式属性名字
TextAlignType
TextAlignType: "start" | "end" | "left" | "right" | "center"
文本对齐
TextBaselineType
TextBaselineType: "top" | "bottom" | "middle" | "alphabetic" | "hanging"
文本基线
ThemeContentType
ThemeContentType: { DefaultConfig?: { fillStyle?: string ; strokeStyle?: string ; font?: string } ; Layer?: PartStyleOptionType ; SelectArea?: PartStyleOptionType ; SelectedStyle?: NodeSelectedStyleOptionsType ; Link.Arrow?: PartStyleOptionType ; Link.Label?: PartStyleOptionType } &
ThemeStyleNameType
ThemeStyleNameType: Exclude<keyof ThemeContent, "toJSON"> | string & {}
主题样式名称类型
ToJsonOptionType
ToJsonOptionType: Object
Type declaration
| Name | Type | Description |
|---|---|---|
imageToBase64? | boolean | 是否将图片以base64的形式内联到json 默认值: false 1. GIF图片(目前不能内联) 2. 性能敏感时,不要使用内联 |
Vec2Type
Vec2Type: [number, number] | [number?, number?]
Variables
Assets
Const Assets: AssetsClass
ConnectToNodePosition
Const ConnectToNodePosition: Readonly<{ lt: "lt" = 'lt'; ct: "ct" = 'ct'; rt: "rt" = 'rt'; lm: "lm" = 'lm'; rm: "rm" = 'rm'; lb: "lb" = 'lb'; cb: "cb" = 'cb'; rb: "rb" = 'rb'; center: "center" = 'center'; auto: "auto" = 'auto' }>
Cursor
Const Cursor: Readonly<{ grabbing: "grabbing" = 'grabbing'; default: "default" = 'default'; grab: "grab" = 'grab'; auto: "auto" = 'auto'; move: "move" = 'move'; hand: "hand" = 'hand'; crosshair: "crosshair" = 'crosshair'; s_resize: "s-resize" = 's-resize'; n_resize: "n-resize" = 'n-resize'; w_resize: "w-resize" = 'w-resize'; e_resize: "e-resize" = 'e-resize'; ne_resize: "ne-resize" = 'ne-resize'; se_resize: "se-resize" = 'se-resize'; sw_resize: "sw-resize" = 'sw-resize'; nw_resize: "nw-resize" = 'nw-resize' }>
Debug
Debug: Object
Type declaration
| Name | Type |
|---|---|
paintAABB | boolean |
debugInfo | any |
build | string |
Direction
Const Direction: Readonly<{ horizontal: "horizontal" = 'horizontal'; vertical: "vertical" = 'vertical'; h: "h" = 'h'; v: "v" = 'v'; anticlockwise: "anticlockwise" = 'anticlockwise'; clockwise: "clockwise" = 'clockwise' }>
FunctionName
Const FunctionName: Readonly<{ AutoFoldLinkCenter: "com.jtopo.AutoFoldLink.center" = 'com.jtopo.AutoFoldLink.center'; AutoFoldLinkFold1: "fold1" = 'fold1'; AutoFoldLinkFold2: "fold2" = 'fold2'; LinkCenter: "center" = 'center'; LinkBegin: "begin" = 'begin'; LinkEnd: "end" = 'end'; QuadBezierLinkCtrlPoint: "ctrlPoint" = 'ctrlPoint'; BezierLinkCtrlPoint1: "ctrlPoint1" = 'ctrlPoint1'; BezierLinkCtrlPoint2: "ctrlPoint2" = 'ctrlPoint2'; QuadBezierLinkCenter: "com.jtopo.QuadBezierLink.center" = 'com.jtopo.QuadBezierLink.center'; BezierLinkCenter: "com.jtopo.BezierLink.center" = 'com.jtopo.BezierLink.center'; ArcLinkCenter: "com.jtopo.ArcLink.center" = 'com.jtopo.ArcLink.center' }>
JTType
Const JTType: Object = {}
LinkPosition
Const LinkPosition: Readonly<{ begin: "begin" = 'begin'; end: "end" = 'end'; middle: "middle" = 'middle'; ctrlPoint: "ctrlPoint" = 'ctrlPoint'; ctrlPoint1: "ctrlPoint1" = 'ctrlPoint1'; ctrlPoint2: "ctrlPoint2" = 'ctrlPoint2'; fold1: "fold1" = 'fold1'; fold2: "fold2" = 'fold2'; mid: "mid" = 'mid'; mid1: "mid1" = 'mid1'; mid2: "mid2" = 'mid2' }>
ObjectName
Const ObjectName: Readonly<{ AutoFoldLinkAnchors: "com.jtopo.AutoFoldLinkAnchors" = 'com.jtopo.AutoFoldLinkAnchors' }>
RectPosition
Const RectPosition: Readonly<{ lt: "lt" = 'lt'; ct: "ct" = 'ct'; rt: "rt" = 'rt'; lm: "lm" = 'lm'; rm: "rm" = 'rm'; lb: "lb" = 'lb'; cb: "cb" = 'cb'; rb: "rb" = 'rb'; center: "center" = 'center' }>
RectPositionNormalized
Const RectPositionNormalized: Object
Type declaration
| Name | Type |
|---|---|
lt | [number, number] |
ct | [number, number] |
rt | [number, number] |
lm | [number, number] |
rm | [number, number] |
lb | [number, number] |
cb | [number, number] |
rb | [number, number] |
center | [number, number] |
RectPositionUnitNormals
Const RectPositionUnitNormals: Object
Type declaration
| Name | Type |
|---|---|
lt | [number, number] |
ct | [number, number] |
rt | [number, number] |
lm | [number, number] |
rm | [number, number] |
lb | [number, number] |
cb | [number, number] |
rb | [number, number] |
center | [number, number] |
ResourceSystem
Const ResourceSystem: ResourceSystemBase
StageMode
Const StageMode: Readonly<{ drag: "drag" = "drag"; edit: "edit" = "edit"; normal: "normal" = "normal"; select: "select" = "select"; view: "view" = "view"; paint: "paint" = "paint" }>
StageMode 常量
TextAlign
Const TextAlign: Readonly<{ left: "left" = 'left'; center: "center" = 'center'; right: "right" = 'right' }>
TextBaseline
Const TextBaseline: Readonly<{ top: "top" = 'top'; middle: "middle" = 'middle'; bottom: "bottom" = 'bottom' }>
TextPosition
Const TextPosition: Readonly<{ lt: "lt" = 'lt'; ct: "ct" = 'ct'; rt: "rt" = 'rt'; lm: "lm" = 'lm'; rm: "rm" = 'rm'; lb: "lb" = 'lb'; cb: "cb" = 'cb'; rb: "rb" = 'rb'; center: "center" = 'center' }> = RectPosition
VERSION
Const VERSION: "#version#"
geom
Const geom: Object
Type declaration
| Name | Type |
|---|---|
clamp | (min: number, max: number, n: number) => number |
isHorizontal | (k: number) => boolean |
getNearestPositionName | (intersectInWorld: Intersect, minDist: number) => "ct" | "lm" | "rm" | "cb" | "begin" | "end" |
getNearestPointOnLines | (x: number, y: number, points: PointLike[], isClosed: boolean) => Intersect |
getLineIntersectPoint | (p1: PointLike, p2: PointLike, m1: PointLike, m2: PointLike, isLine: boolean) => { x: number ; y: number } |
isPointOnLineSegs |
Functions
distance
distance(x, y, x2, y2): number
Parameters
| Name | Type |
|---|---|
x | number |
y | number |
x2 | number |
y2 | number |
Returns
number
newtonsMethod
newtonsMethod(f, df, x0, maxIter?, tol?): number
Parameters
| Name | Type | Default value |
|---|---|---|
f | Function | undefined |
df | Function | undefined |
x0 | number | undefined |
maxIter | number | 100 |
tol | number | 1e-6 |
Returns
number
pointIntersectNode
pointIntersectNode(p, widthHalf, heightHalf): PointLike
Parameters
| Name | Type |
|---|---|
p | PointLike |
widthHalf | number |
heightHalf | number |
Returns
randomColor
randomColor(): string
随机生成颜色(不是完全随机,有jtopo的主题方案) 返回示例: '#c5aa99'
Deprecated
已过时,未来将被删除
Returns
string
十六进制颜色字符串