Skip to content

Commit dfa6afb

Browse files
Deploy to GitHub pages
0 parents  commit dfa6afb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+20174
-0
lines changed

README.md

+152
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# Node Flow
2+
3+
Another Flow-based Node graph Library.
4+
5+
Check it out [here](https://elicdavis.github.io/node-flow/).
6+
7+
![promotional image](./docs/promotional-image.png)
8+
9+
## About
10+
11+
Node Flow is a javascript library that enables developers to build node based tools similar to Unreal Blueprints or Blender Nodes.
12+
13+
## Features
14+
15+
* Nodes
16+
* Markdown Notes
17+
* More Nodes
18+
19+
## Install
20+
21+
Download the latest build [here](https://raw.githubusercontent.com/EliCDavis/node-flow/gh-pages/dist/web/NodeFlow.js).
22+
23+
## API
24+
25+
### Graph API
26+
27+
#### Creation
28+
29+
The only requirement for creating a graph is providing it an instance of a [canvas](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/canvas).
30+
31+
```javascript
32+
// Create a canvas to render our graph to
33+
var canvas = document.createElement("canvas");
34+
35+
// Create our Node Flow Graph
36+
var graph = new NodeFlowGraph(canvas)
37+
```
38+
39+
There are a bunch of optional parameters you can provide the graph:
40+
41+
```javascript
42+
var graph = new NodeFlowGraph(canvas, {
43+
// Background color of the graph.
44+
backgroundColor: "#FF5500",
45+
46+
// You can add extra items to the context
47+
// menu that pops up when you right click.
48+
contextMenu: {
49+
subMenus: [
50+
{
51+
// Text that shows up in the context
52+
// menu
53+
name: "Example Context Menu Item",
54+
55+
// This is recursive. We can nest as
56+
// many submenus within eachother as
57+
// we want. This field is optional.
58+
subMenus: [],
59+
60+
items: [
61+
{
62+
name: "Sub menu Item!!!"
63+
}
64+
]
65+
}
66+
],
67+
68+
// Items that show up at the base of the
69+
// context menu
70+
items: [
71+
{
72+
// Text that shows up in the context
73+
// menu
74+
name: "Example Context Menu Item",
75+
76+
// Function that get's executed when
77+
// Item is clicked.
78+
callback: () => {
79+
alert("Example Context Menu Item");
80+
}
81+
}
82+
]
83+
},
84+
85+
// Notes we want rendered on the graph.
86+
board: {
87+
notes: [
88+
{
89+
// Where to render the note
90+
position: { x: 20, y: 20 },
91+
92+
// Whether or not the note can be
93+
// interacted with on the graph
94+
locked: true,
95+
96+
// Markdown enabled text
97+
text: `
98+
# My First note!!!
99+
100+
Not sure what to write here
101+
`
102+
},
103+
]
104+
},
105+
});
106+
```
107+
108+
### Node API
109+
110+
#### Creation
111+
112+
```javascript
113+
// All nodes require a title. That's about it.
114+
var node = new FlowNode({
115+
title: "My First Node!",
116+
});
117+
118+
// Be sure to add it to the graph so it can be rendered.
119+
graph.addNode(node);
120+
```
121+
122+
#### Inputs and Outputs
123+
124+
Create a Add node that takes two numbers and outputs a single number
125+
126+
```javascript
127+
var node = new FlowNode({
128+
title: "Add",
129+
inputs: [
130+
{ name: "a", type: "float32" },
131+
{ name: "b", type: "float32" }
132+
],
133+
outputs: [
134+
{ name: "sum", type: "float32" }
135+
],
136+
});
137+
```
138+
139+
You can also add additional inputs and outputs to the node after it's been created
140+
141+
```javascript
142+
node.addInput({ name: "c", type: "float32" })
143+
node.addOutput({ name: "sum", type: "float32" })
144+
```
145+
146+
## Library Development
147+
148+
Just run
149+
150+
```bash
151+
npm run watch-dev
152+
```

0 commit comments

Comments
 (0)