
#Nodebox gui code
I didn't even write these, this is the code that NodeBox uses in the 'importer' node. ) - the next three lines are pure Python - they read the contents of the svg file into a string. If you miss this line out then every time you execute this box, you'll add more and more geometry to it. It clears the list of lines that this box is associated with. _() - this line should be very familiar to you if you've done any work with Field's 2d drawing system.(Some version of Jython throw a spurious exception at this point, you can ignore it). We can see this in the NodeBox environment itself. import svg - it also defines a (Python-based) svg parser in the package 'svg'.We just import them wholesale into Field with this statement. from aphics import * - NodeBox defines the bulk of it's Java classes in the aphics package.Better yet, this code is, like the example above, ripped right out of the NodeBox "import" node source visible right inside the NodeBox UI itself.īecause it's short, let's look at that example line by line: parse ( s, True ) for path in paths : g.

clear () f = file ( "/Users/marc/Downloads//iconic/vector/spin.svg", 'r' ) s = f. One just makes an ellipse, that ought to be easy - in fact we can just look at the code in the bottom right panel.įrom aphics import * import svg _self. Let's "rewrite" the text_scatter.ndbx example in Field/NodeBox, box by box.Īs we can see from the first screenshot above we are looking at a composition consisting of four boxes (look at the bottom right panel for the network). While we have mixed feelings about node-based editing interfaces we certainly like node-based abstraction.įortunately NodeBox's architecture and design means that we can just dig right into the good stuff. But hacking into NodeBox at this level misses a lot of the interesting part of their libraries - in particular it misses the compositional nature of their "network". Well, that was easy (really, with auto-completion and 'print' it took all of 5 mins). Now you can originate geometry using NodeBox routines and then integrate them with the FLine based drawing code - pretty cool. And see below for more ways of moving between FLine and Path) The rest of the _self.lines code should be familiar from the FLine drawing tutorials. appendShape(.) appends a Java 2D General Path to a Field FLine. ellipse ( 10, 10, 10, 10 ) # and this takes a nodebox path and turns it into a Field FLine line = FLine ().

clear () # this is pure nodebox np = Path () np. # this imports the nodebox libraries that we need from aphics import * _self. To make the connection to Field very easy first build NodeBox with this command: Building from source gets you documentation inside Field's autocomplete, but otherwise it's the same functionality.


#Nodebox gui download
You have two options - you can build NodeBox from source, or you can just download one of their binaries. We're going to use the "text_fx.ndbx" example: NodeBox2, meet Fieldįirst, let's download the beta of NodeBox from here. This can only mean one thing - it really is time to get Field's hooks into NodeBox and start tracking their beta releases. Let's assume that that NodeBox's spline code remains as well developed, tested and documented as it has been even as their team goes through this complete rewrite. Thankfully, we didn't bother figuring any of this out, because the latest beta version of NodeBox has taken a very interesting and unexpected twist - it's now a Java/Jython project (just like Field) with an all new, even more hybrid (and even more interesting) interface. It was going to be pretty tedious, because while Python-based, NodeBox was very much "non-pure" Python - much of it was a wrapper around Quartz (Apple's native drawing code). We like our API's but we don't think they are the last word on 2d drawing by any means. But NodeBox's 2d spline code has always been well developed, well tested and well documented - so much so that we'd been thinking about ways of hacking into it to let Field users use that API as well as "ours". Field's 2d drawing tools we're started before we heard of NodeBox, but our image filtering extensions we're directly provoked and inspired by that project. Not only is it a hybrid visual programming environment for making 2d vector & bitmapped images, but it uses Python as its programming language. For as long as the Field project has been going we've been keeping an eye on NodeBox.
