litegraph.js
LiteGraph 1.0
JavaScript中的一个库在浏览器中创建图形,类似于虚幻蓝图。节点可以轻松编程,其中包括一个编辑器来构建和测试图形。
它可以轻松地集成到任何现有的Web应用程序中,并且可以在无需编辑器的情况下运行图形。
在演示网站上尝试。

尽管很容易创建新的节点类型,但LiteGraph带有一些默认节点,这些节点在许多情况下可能很有用:
您可以使用NPM安装它
npm install litegraph.js
或从此存储库下载build/litegraph.js和css/litegraph.css版本。
< html >
< head >
< link rel =" stylesheet " type =" text/css " href =" litegraph.css " >
< script type =" text/javascript " src =" litegraph.js " > </ script >
</ head >
< body style =' width:100%; height:100% ' >
< canvas id =' mycanvas ' width =' 1024 ' height =' 720 ' style =' border: 1px solid ' > </ canvas >
< script >
var graph = new LGraph ( ) ;
var canvas = new LGraphCanvas ( "#mycanvas" , 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 ) ;
node_const . connect ( 0 , node_watch , 0 ) ;
graph . start ( )
</ script >
</ body >
</ html > 这是如何构建一个总和两个输入的节点的示例:
//node constructor class
function MyAddNode ( )
{
this . addInput ( "A" , "number" ) ;
this . addInput ( "B" , "number" ) ;
this . addOutput ( "A+B" , "number" ) ;
this . properties = { precision : 1 } ;
}
//name to show
MyAddNode . title = "Sum" ;
//function to call when the node is executed
MyAddNode . prototype . onExecute = function ( )
{
var A = this . getInputData ( 0 ) ;
if ( A === undefined )
A = 0 ;
var B = this . getInputData ( 1 ) ;
if ( B === undefined )
B = 0 ;
this . setOutputData ( 0 , A + B ) ;
}
//register in the system
LiteGraph . registerNodeType ( "basic/sum" , MyAddNode ) ;或者您可以包装现有功能:
function sum ( a , b )
{
return a + b ;
}
LiteGraph . wrapFunctionAsNode ( "math/sum" , sum , [ "Number" , "Number" ] , "Number" ) ; 尽管某些节点在服务器(音频,图形,输入等)中不起作用,但它还使用nodejs工作服务器端。
var LiteGraph = require ( "./litegraph.js" ) . LiteGraph ;
var graph = new LiteGraph . LGraph ( ) ;
var node_time = LiteGraph . createNode ( "basic/time" ) ;
graph . add ( node_time ) ;
var node_console = LiteGraph . createNode ( "basic/console" ) ;
node_console . mode = LiteGraph . ALWAYS ;
graph . add ( node_console ) ;
node_time . connect ( 0 , node_console , 1 ) ;
graph . start ( ) 



它在UTILS文件夹中包含几个命令,以生成DOC,检查错误并构建缩小版本。
该演示包括一些图形示例。为了尝试它们,您可以访问演示站点或在本地计算机上安装它,以便您需要git , node和npm 。考虑到这些依赖项已安装,请运行以下命令以尝试:
$ git clone https://github.com/jagenjo/litegraph.js.git
$ cd litegraph.js
$ npm install
$ node utils/server.js
Example app listening on port 80 !打开浏览器,并将其指向http:// localhost:8000/。您可以从页面顶部的下拉列表中选择一个演示。
您可以将任何反馈写给[email protected]