LGraph

LGraph

LGraph

Constructor

# new LGraph(o)

Parameters:
Name Type Description
o Object data from previous serialization [optional]
Source:

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
Source:

# (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]
Source:

# (static) addOutput(name, type, value)

Creates a global graph output
Parameters:
Name Type Description
name String
type String
value *
Source:

# (static) arrange()

Positions every node in a more readable manner
Source:

# (static) attachCanvas(graphcanvas)

Attach Canvas to this graph
Parameters:
Name Type Description
graphcanvas GraphCanvas
Source:

# (static) changeInputType(name, type)

Changes the type of a global graph input
Parameters:
Name Type Description
name String
type String
Source:

# (static) changeOutputType(name, type)

Changes the type of a global graph output
Parameters:
Name Type Description
name String
type String
Source:

# (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
Source:

# (static) clear()

Removes all nodes from this graph
Source:

# (static) clearTriggeredSlots()

clears the triggered slot animation in all links (stop visual animation)
Source:

# (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
Source:

# (static) detachCanvas(graphcanvas)

Detach Canvas from this graph
Parameters:
Name Type Description
graphcanvas GraphCanvas
Source:

# (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
Source:
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
Source:
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
Source:
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
Source:
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
Source:
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
Source:
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
Source:
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
Source:
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
Source:
Returns:
the data
Type
*

# (static) getNodeById(id)

Returns a node by its id.
Parameters:
Name Type Description
id Number
Source:

# (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
Source:
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
Source:
Returns:
the data
Type
*

# (static) getTime() → {number}

Returns the amount of time the graph has been running in milliseconds
Source:
Returns:
number of milliseconds the graph has been running
Type
number

# (static) isLive()

returns if the graph is in live mode
Source:

# (static) remove(node)

Removes a node from the graph
Parameters:
Name Type Description
node LGraphNode the instance of the node
Source:

# (static) removeInput(name)

Removes a global graph input
Parameters:
Name Type Description
name String
Source:
Destroys a link
Parameters:
Name Type Description
linkId Number
Source:

# (static) removeOutput(name)

Removes a global graph output
Parameters:
Name Type Description
name String
Source:

# (static) renameInput(oldName, new_name)

Changes the newName of a global graph input
Parameters:
Name Type Description
oldName String
new_name String
Source:

# (static) renameOutput(oldName, newName)

Renames a global graph output
Parameters:
Name Type Description
oldName String
newName String
Source:

# (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)
Source:

# (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
Source:

# (static) serialize() → {Object}

Creates a Object containing all the info about this graph, it can be serialized
Source:
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 *
Source:

# (static) setOutputData(name, value)

Assign a data to the global output
Parameters:
Name Type Description
name String
value String
Source:

# (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
Source:

# (static) stop execution()

Stops the execution loop of the graph
Source:

# (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.
Source:

# computeExecutionOrder(onlyOnExecute, setLevel) → {this}

It computes the executable nodes in order and returns it
Parameters:
Name Type Description
onlyOnExecute
setLevel
Source:
Returns:
Type
this

# onNodeTrace(node, msg, color)

Node event manager
Parameters:
Name Type Description
node
msg
color
Source:
To Do:
  • Need create event