LGraph Class
LGraph is the class that contain a full graph. We instantiate one and add nodes to it, and then we can run the execution loop.
Constructor
LGraph
()
Item Index
Methods
- add
- addGlobalInput
- addGlobalOutput
- arrange
- attachCanvas
- changeGlobalInputType
- changeGlobalOutputType
- clear
- configure
- detachCanvas
- findNodesByClass
- findNodesByTitle
- findNodesByType
- getElapsedTime
- getFixedTime
- getGlobalInputData
- getGlobalOutputData
- getNodeById
- getNodeOnPos
- getOutputData
- getTime
- isLive
- remove
- removeGlobalInput
- removeGlobalOutput
- renameGlobalInput
- renameGlobalOutput
- runStep
- sendEventToAllNodes
- serialize
- setGlobalInputData
- setGlobalOutputData
- setInputData
- start
- stop execution
- updateExecutionOrder
Methods
add
-
node
Adds a new node instasnce to this graph
Parameters:
-
nodeLGraphNodethe instance of the node
addGlobalInput
-
name -
type -
value
Tell this graph it has a global graph input of this type
Parameters:
-
nameString -
typeString -
value[optional]
addGlobalOutput
-
name -
type -
value
Creates a global graph output
Parameters:
-
nameString -
typeString -
value
arrange
()
Positions every node in a more readable manner
attachCanvas
-
graph_canvas
Attach Canvas to this graph
Parameters:
-
graph_canvasGraphCanvas
changeGlobalInputType
-
name -
type
Changes the type of a global graph input
Parameters:
-
nameString -
typeString
changeGlobalOutputType
-
name -
type
Changes the type of a global graph output
Parameters:
-
nameString -
typeString
clear
()
Removes all nodes from this graph
configure
-
str
Configure a graph from a JSON string
Parameters:
-
strStringconfigure a graph from a JSON string
detachCanvas
-
graph_canvas
Detach Canvas from this graph
Parameters:
-
graph_canvasGraphCanvas
findNodesByClass
-
classObject
Returns a list of nodes that matches a class
Parameters:
-
classObjectClassthe class itself (not an string)
Returns:
a list with all the nodes of this type
findNodesByTitle
-
name
Returns a list of nodes that matches a name
Parameters:
-
nameStringthe name of the node to search
Returns:
a list with all the nodes with this name
findNodesByType
-
type
Returns a list of nodes that matches a type
Parameters:
-
typeStringthe name of the node type
Returns:
a list with all the nodes of this type
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
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
getGlobalInputData
-
name
Returns the current value of a global graph input
Parameters:
-
nameString
Returns:
the data
getGlobalOutputData
-
name
Returns the current value of a global graph output
Parameters:
-
nameString
Returns:
the data
getNodeById
-
id
Returns a node by its id.
Parameters:
-
idNumber
getNodeOnPos
-
x -
y -
nodes_list
Returns the top-most node in this position of the canvas
Parameters:
-
xNumberthe x coordinate in canvas space
-
yNumberthe y coordinate in canvas space
-
nodes_listArraya list with all the nodes to search from, by default is all the nodes in the graph
Returns:
a list with all the nodes that intersect this coordinate
getOutputData
-
name
Returns the current value of a global graph output (sames as getGlobalOutputData)
Parameters:
-
nameString
Returns:
the data
getTime
()
Number
Returns the amount of time the graph has been running in milliseconds
Returns:
number of milliseconds the graph has been running
isLive
()
returns if the graph is in live mode
removeGlobalInput
-
name -
type
Removes a global graph input
Parameters:
-
nameString -
typeString
removeGlobalOutput
-
name
Removes a global graph output
Parameters:
-
nameString
renameGlobalInput
-
old_name -
new_name
Changes the name of a global graph input
Parameters:
-
old_nameString -
new_nameString
renameGlobalOutput
-
old_name -
new_name
Renames a global graph output
Parameters:
-
old_nameString -
new_nameString
runStep
-
num
Run N steps (cycles) of the graph
Parameters:
-
numNumbernumber of steps to run, default is 1
sendEventToAllNodes
-
eventname -
params
Sends an event to all the nodes, useful to trigger stuff
Parameters:
-
eventnameStringthe name of the event (function to be called)
-
paramsArrayparameters in array format
serialize
()
Object
Creates a Object containing all the info about this graph, it can be serialized
Returns:
value of the node
setGlobalInputData
-
name -
data
Assign a data to the global graph input
Parameters:
-
nameString -
data
setGlobalOutputData
-
name -
value
Assign a data to the global output
Parameters:
-
nameString -
valueString
setInputData
-
name -
data
Assign a data to the global graph input (same as setGlobalInputData)
Parameters:
-
nameString -
data
start
-
interval
Starts running this graph every interval milliseconds.
Parameters:
-
intervalNumberamount of milliseconds between executions, default is 1
stop execution
()
Stops the execution loop of the graph
updateExecutionOrder
()
Updates the graph execution order according to relevance of the nodes (nodes with only outputs have more relevance than nodes with only inputs.
