Giter Club home page Giter Club logo

nodegraphjs's Introduction

NodeGraphJS

NodeGraphJS is released under the MIT license. It is simple and easy to understand and places almost no restrictions on what you can do with NodeGraphJS. More Information

The NodeGraph will display a NodeGraph control using HTML5 canvas. Node objects can be defined in the NodeGraph.NodeList file or the NodePgraph.NodeList object can be overwritten in some other fashion. Node Types are defined in NodeGraph.Types. This is a very early version and has most of the feature, but it needs a good polish pass before 1.0.

Screenshot

Demo

How to use

Create a new NodeGraph object and optionally tell it which element to insert the graph into. If omitted, it defaults to document.body.

Next Define Nodes to fit your needs in the NodeGraph.NodeList object. The format is as follows:

NodeName: {
    properties: {
        name: "NodeLabel",
        color: "#d49a60"
    },
    ins: {
        'id': {
            'type': 'Number'
        }
    },
    outs: {
        'id': {
            'type': 'Number',
            'value': 1000
        }
    },
    run: function() {
        this.outs.id.value = this.ins.id.value * 2
    }
}

The properties section describes the node being displayed. You can also add id, x, and y, however these are probably best set at node creation.

The ins/outs are in incoming and outgoing rows of the node. They can be given a type and a default value.

The run function is used for evaluating data throug the graph. An example of this would be a Shader for a 3D engine.

Once you have the nodes defined, call .addNode() on the NodeGraph instance with the node definition as the only argument. For example:

var NG = new NodeGraph();
NG.addNode('NodeName', {x: 100, y: 100});

This should insert a node and allow you to drag it around and add links to other nodes.

Calling .save() on the NodeGraph instance will return a JSON string of the nodes in their current state.

TODO

  • Add better curve hit testing using maths
  • Add Thumbnails to nodes
  • Toggle display state to show/hide ins/outs on nodes
  • Add a way to expand a nodes outs on demand. This would prevent some graphs from loading too much at once

nodegraphjs's People

Contributors

theiviaxx avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.