CanvasNode
means two thing in this doc. One is the exposed object with all the methods described below. Another one is internal class, definition of which can be found here. Should be easy to tell which is which based on the context.And here you can find out what is
ArrowNode
- option
<object>
- canvas
<HTMLCanvasElement>
- [updateLineCb]
<function(box, line, isFrom)>
: define how to place the connecting line between two boxes. Details could be found here. - [arrowPath]
<Path2D>
: path for arrow on line. Details could be found here - [arrowH]
<number>
: when use customarrowPath
above, should provide with this as well. Stands for the height of the arrow shape. - [useCubicBezier]
<boolean>
: default tofalse
and use quadratic Bezier curves. - [safePointOnLine]
<boolean>
: use old-fashioned point-to-point process to detect whether a point is on a specific line. Default tofalse
, and use binary search, WHICH COULD CAUSE PROBLEMS WITHOUT CAUTION.
- canvas
CanvasNode.init({
canvas: canvasDom
})
Internally, just call:
new CanvasNode.CanvasNode(option)
- option
<object>
- name
<string>
: name of the instance. - pos
<object>
: starting point of the box. In form of{x: number, y: number}
. - path
<Path2D>
: path for the box. - rawVertexes
<number[]>
: [x, y, width, height] of the box. More likely should be [0, 0, width, height]. - [text]
<string>
: text to show. - [color]
<string>
: color of the text - [data]
<any>
: any thing to bind with the box. - [style]
<string>
: fill style of the box. - [strokeStyle]
<string>
: stroke style of the box. - [lineWidth]
<number>
: width of stoke line. - [font]
<string>
: font style of the text. - [beforeDrawCbs]
<function[]>
: custom callback for extra drawing. Execute before all default drawing process. - [drawCbs]
<function[]>
: custom callback for extra drawing. Execute after all default drawing process. - [updateLineCb]
<function(box, line, isFrom)>
: see here
- name
return <CanvasNode>
- from
<object>
: starting point in form of{x: number, y: number}
. - [to]
<object>
: ending point.
return <ArrowNode>
- line
<ArrowNode>
- fromBox
<CanvasNode>
- toBox
<CanvasNode>
- type
<string>
: type of event to be listened to. Type name just like the native ones, likeclick
etc. - cb
<function(event, node)>
: handler function.- event
<Event>
: the native event object. - node
<CanvasNode>
: the target node that such event happening on.
- event
CanvasNode.addEvent('mouseover', (e, node) => {
console.log(e, node) // when the cursor is over the node, this will execute
})
- type
<string>
: type of event wish to stop listening to.
- el
<HTMLElement>
: delegating element. - type
<string>
: type of native event to listen to. - handler
<function(event)>
: event handler.
- el
<HTMLElement>
: delegating element. - type
<string>
: type of native event wish to stop listening to. - [handler]
<function(event)>
: specific handler to be removed. If not provided, all handlers registered byCanvasNode.nativeAddEvent
for such type of event will be removed.
- position
<object>
: clicked position in form of{x: number, y: number}
.
return ArrowNode
- position
<object>
: clicked position in form of{x: number, y: number}
.
return CanvasNode
- position
<object>
: clicked position in form of{x: number, y: number}
.
return CanvasNode
but exclude ArrowNode
- node
<CanvasNode>
: the center point of which will be returned.
return {x: number, y: number}
- startPos
<object>
: start point position. - endPos
<object>
: end point position. - node
<CanvasNode>
: of which the point will be placed on. - [isStart]: if the point is starting point, default
true
.
- node1
<CanvasNode>
- node2
<CanvasNode>
return <boolean>
- node1
<CanvasNode>
- node2
<CanvasNode>
- [isFromFirst]
<boolean>
: whethernode1
is the starting node, default totrue
return <boolean>
The difference between
isConnected
andisConnectedSeq
is thatisConnectedSeq
takes sequence into account. In other words, which one of the nodes is the starting one matters.
Destroy all instances
return the class of ArrowNode
.
return the class of Menu
, which is just a subclass of CanvasNode
.
return the class of CanvasNode
.
return all the instances of CanvasNode
.
return all the instances of ArrowNode
.
return all the instances of Menu