litegraph.js

Litegraph.js is a library that allows to create modular graphs on the web, similar to PureData.

Graphs can be used to create workflows, image processing, audio, or any kind of network of modules interacting with each other.

Some of the main features:

  • Automatic sorting of modules according to basic rules.
  • Dynamic number of input/outputs per module.
  • Persistence, graphs can be serialized in a JSON.
  • Optimized render in a HTML5 Canvas (supports hundres of modules on the screen).
  • Allows to run the graphs without the need of the canvas (standalone mode).
  • Simple API. It is very easy to create new modules.
  • Edit and Live mode, (in live mode only modules with widgets are rendered.
  • Contextual menu in the editor.

Usage

Include the library

<script type="text/javascript" src="../src/litegraph.js"></script>

Create a graph

var graph = new LGraph();

Create a canvas renderer

var canvas = new LGraphCanvas("#mycanvas");

Add some nodes to the graph

var node_const = LiteGraph.createNode("basic/const");
node_const.pos = [200,200];
graph.add(node_const);
node_const.setValue(4.5);

var node_watch = LiteGraph.createNode("basic/watch");
node_watch.pos = [700,200];
graph.add(node_watch);

Connect them

node_const.connect(0, node_watch, 0 );

Run the graph

graph.start();

Example of editor

Documentation

Here you can check automatically generated documentation.