Constructor
# new LGraph(o)
Parameters:
Name | Type | Description |
---|---|---|
o |
Object | data from previous serialization [optional] |
Methods
# (static) add(node, skipComputeOrder)
Adds a new node instance to this graph
Parameters:
Name | Type | Description |
---|---|---|
node |
LGraphNode | the instance of the node |
skipComputeOrder |
boolean |
# (static) addGlobalInput(name, type, value)
Tell this graph it has a global graph input of this type
Parameters:
Name | Type | Description |
---|---|---|
name |
String | |
type |
String | |
value |
* | [optional] |
# (static) addOutput(name, type, value)
Creates a global graph output
Parameters:
Name | Type | Description |
---|---|---|
name |
String | |
type |
String | |
value |
* |
# (static) arrange()
Positions every node in a more readable manner
# (static) attachCanvas(graphcanvas)
Attach Canvas to this graph
Parameters:
Name | Type | Description |
---|---|---|
graphcanvas |
GraphCanvas |
# (static) changeInputType(name, type)
Changes the type of a global graph input
Parameters:
Name | Type | Description |
---|---|---|
name |
String | |
type |
String |
# (static) changeOutputType(name, type)
Changes the type of a global graph output
Parameters:
Name | Type | Description |
---|---|---|
name |
String | |
type |
String |
# (static) checkNodeTypes()
Checks that the node type matches the node type registered, used when replacing a nodetype
by a newer version during execution this replaces the ones using the old version with the
new version
# (static) clear()
Removes all nodes from this graph
# (static) clearTriggeredSlots()
clears the triggered slot animation in all links (stop visual animation)
# (static) configure(str, returns)
Configure a graph from a JSON string
Parameters:
Name | Type | Description |
---|---|---|
str |
String | configure a graph from a JSON string |
returns |
Boolean | if there was any error parsing |
# (static) detachCanvas(graphcanvas)
Detach Canvas from this graph
Parameters:
Name | Type | Description |
---|---|---|
graphcanvas |
GraphCanvas |
# (static) findNodeByTitle(title) → {Node}
Returns the first node that matches a name in its title
Parameters:
Name | Type | Description |
---|---|---|
title |
String | the name of the node to search |
Returns:
the node or null
- Type
- Node
# (static) findNodesByClass(classObject, result) → {Array}
Returns a list of nodes that matches a class
Parameters:
Name | Type | Description |
---|---|---|
classObject |
Class | the class itself (not an string) |
result |
Array |
Returns:
a list with all the nodes of this type
- Type
- Array
# (static) findNodesByTitle(title) → {Array}
Returns a list of nodes that matches a name
Parameters:
Name | Type | Description |
---|---|---|
title |
String | the name of the node to search |
Returns:
a list with all the nodes with this name
- Type
- Array
# (static) findNodesByType(type, result) → {Array}
Returns a list of nodes that matches a type
Parameters:
Name | Type | Description |
---|---|---|
type |
String | the name of the node type |
result |
Array |
Returns:
a list with all the nodes of this type
- Type
- Array
# (static) getAncestors() → {Array}
Returns all the nodes that could affect this one (ancestors) by crawling all the inputs
recursively. It doesn't include the node itself
Returns:
an array with all the LGraphNodes that affect this node, in order of
execution
- Type
- Array
# (static) getElapsedTime() → {number}
Returns the amount of time it took to compute the latest iteration. Take into account that
this number could be not correct if the nodes are using graphical actions
Returns:
number of milliseconds it took the last cycle
- Type
- number
# (static) getFixedTime() → {number}
Returns the amount of time accumulated using the fixedtime_lapse var. This is used in
context where the time increments should be constant
Returns:
number of milliseconds the graph has been running
- Type
- number
# (static) getGroupOnPos(x, y) → {LGraphGroup}
Returns the top-most group in that position
Parameters:
Name | Type | Description |
---|---|---|
x |
number | the x coordinate in canvas space |
y |
number | the y coordinate in canvas space |
Returns:
the group or null
- Type
- LGraphGroup
# (static) getInputData(name) → {*}
Returns the current value of a global graph input
Parameters:
Name | Type | Description |
---|---|---|
name |
String |
Returns:
the data
- Type
- *
# (static) getNodeById(id)
Returns a node by its id.
Parameters:
Name | Type | Description |
---|---|---|
id |
Number |
# (static) getNodeOnPos(x, y, nodesList, margin) → {LGraphNode}
Returns the top-most node in this position of the canvas
Parameters:
Name | Type | Description |
---|---|---|
x |
number | the x coordinate in canvas space |
y |
number | the y coordinate in canvas space |
nodesList |
Array | a list with all the nodes to search from, by default is all the nodes in the graph |
margin |
number |
Returns:
the node at this position or null
- Type
- LGraphNode
# (static) getOutputData(name) → {*}
Returns the current value of a global graph output
Parameters:
Name | Type | Description |
---|---|---|
name |
String |
Returns:
the data
- Type
- *
# (static) getTime() → {number}
Returns the amount of time the graph has been running in milliseconds
Returns:
number of milliseconds the graph has been running
- Type
- number
# (static) isLive()
returns if the graph is in live mode
# (static) remove(node)
Removes a node from the graph
Parameters:
Name | Type | Description |
---|---|---|
node |
LGraphNode | the instance of the node |
# (static) removeInput(name)
Removes a global graph input
Parameters:
Name | Type | Description |
---|---|---|
name |
String |
# (static) removeLink(linkId)
Destroys a link
Parameters:
Name | Type | Description |
---|---|---|
linkId |
Number |
# (static) removeOutput(name)
Removes a global graph output
Parameters:
Name | Type | Description |
---|---|---|
name |
String |
# (static) renameInput(oldName, new_name)
Changes the newName of a global graph input
Parameters:
Name | Type | Description |
---|---|---|
oldName |
String | |
new_name |
String |
# (static) renameOutput(oldName, newName)
Renames a global graph output
Parameters:
Name | Type | Description |
---|---|---|
oldName |
String | |
newName |
String |
# (static) runStep(num, doNotCatchError, limit)
Run N steps (cycles) of the graph
Parameters:
Name | Type | Description |
---|---|---|
num |
number | number of steps to run, default is 1 |
doNotCatchError |
Boolean | [optional] if you want to try/catch errors |
limit |
number | max number of nodes to execute (used to execute from start to a node) |
# (static) sendEventToAllNodes(eventname, params)
Sends an event to all the nodes, useful to trigger stuff
Parameters:
Name | Type | Description |
---|---|---|
eventname |
String | the name of the event (function to be called) |
params |
Array | parameters in array format |
# (static) serialize() → {Object}
Creates a Object containing all the info about this graph, it can be serialized
Returns:
value of the node
- Type
- Object
# (static) setGlobalInputData(name, data)
Assign a data to the global graph input
Parameters:
Name | Type | Description |
---|---|---|
name |
String | |
data |
* |
# (static) setOutputData(name, value)
Assign a data to the global output
Parameters:
Name | Type | Description |
---|---|---|
name |
String | |
value |
String |
# (static) start(interval)
Starts running this graph every interval milliseconds.
Parameters:
Name | Type | Description |
---|---|---|
interval |
number | amount of milliseconds between executions, if 0 then it renders to the monitor refresh rate |
# (static) stop execution()
Stops the execution loop of the graph
# (static) updateExecutionOrder()
Updates the graph execution order according to relevance of the nodes (nodes with only
outputs have more relevance than nodes with only inputs.
# computeExecutionOrder(onlyOnExecute, setLevel) → {this}
It computes the executable nodes in order and returns it
Parameters:
Name | Type | Description |
---|---|---|
onlyOnExecute |
||
setLevel |
Returns:
- Type
- this
# onNodeTrace(node, msg, color)
Node event manager
Parameters:
Name | Type | Description |
---|---|---|
node |
||
msg |
||
color |
- To Do:
-
- Need create event