Giter Site home page Giter Site logo

edgency / kznodes Goto Github PK

View Code? Open in Web Editor NEW

This project forked from krzysztofzablocki/kznodes

0.0 2.0 0.0 3.9 MB

Have you ever wonder how you could make Origami like editor in 1h ?

Home Page: http://twitter.com/merowing_

License: MIT License

Objective-C 94.76% Ruby 1.00% C 1.98% Shell 2.27%

kznodes's Introduction

KZNodes - editors like Origami made easy.

Version License Platform

Watch demo

Have you ever wondered how you could create an editor like Origami? How about creating a subset of Origami in less than 100 lines of code?

Joining nodes is like functional programming, only visual.

Features:

  • Domain agnostic, can be used to create editors for:
    • Animations
    • 3D Graphics
    • Image processing
    • Data Processing
    • Artificial Inteligence
    • Anything that you can express as a data / function pipeline?
  • Sockets have data types, you specify what classes are supported, that way you never get unsupported connections.
  • Fully native with 0 dependencies
  • Slick looking out of the box
  • Ultra simple to create new node classes, want to add class that can be used to apply sqrtf to it's input? 3 lines of code.

NodeType creation

Think of NodeTypes like objc classes, they define common behaviour for all instances. You can create a new node class as follows:

[KZNNodeType registerType:@"sqrtf" inputs:@{ @"Input" : NSNumber.class } outputs:@{ @"Output" : NSNumber.class } processingBlock:^(KZNNode *node, NSDictionary *inputs, NSMutableDictionary *outputs) {
    outputs[@"Output"] = @(sqrtf([inputs[@"Input"] floatValue]));
  }];
  • sqrtf is the name
  • it has input socket "Input" that accepts NSNumbers
  • it has output socket "Output" that generates NSNumbers
  • Output = sqrtf(input)

There are also 2 more advanced creator functions:

  1. KZNNodeType withClass allows you to change base class used for a node, eg. use node with slider.
  2. KZNNodeType withBuilder allows you to use builder pattern instead of simplified syntax.

Setup block

You can also add setup block which will allow you to further configure new instances of your NodeType, eg. disable continuous slider.

Node evaluation mode

Nodes are lazy evaluated by default, they will only evaluate when there is a change on their sockets or connected nodes. Changes propagate to connections, so if you modify a node in the beginning of a graph it will propagate to all connected nodes.

If you mark node type to use continuous evaluation, it will evaluate 60 times per second if possible, eg. time node in sample app.

Built-in node classes

KZNNodeWithSlider

KZNNodeWithText

Adding new node classes

It's simple:

  1. Create a subclass of KZNNode
  2. Do whatever you want with it
  3. when you register Node type you can specify your class as baseClass, and reference it in processingBlock.

Installation and setup

KZNodes is distributed as a CocoaPod: pod 'KZNodes' so you can either add it to your existing project or clone this repository and play with it.

Roadmap & Contributing

  • Serialization of workspaces.
  • Idiot-proofing.
  • Lazy evaluation of sockets.

Pull-requests are welcomed.

It took me around 18h to get from idea to release so the code is likely to change before 1.0 release.

If you'd like to get specific features I'm available for iOS consulting.

Changelog

0.1.1

  • much nicer bezier curves, based on the-graph

0.1.0

  • initial release

License

KZNodes is available under the MIT license. See the LICENSE file for more info.

Author

Krzysztof Zablocki, [email protected]

Follow me on twitter.

Check-out my blog or GitHub profile for more cool stuff.

kznodes's People

Watchers

James Cloos avatar edgency 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.