Calling Nodebox functions from a library Module
I am sure this is an easy question.
I have built many Nodebox 1 utilities that I want to put in a library module. The routines that just use raw Python mathematics work just fine, but any with Nodebox functions (lineto, oval, push, etc etc) fail since the function does not seem to be recognised.
I have tried
from node box.graphics import *
and many other variations - but nothing seems to resolve this for me.
I am a heavy user of Nodebox 1 but am a very lightweight Python user.....
Any help would be appreciated
Kevin
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Frederik De Ble... on 09 Mar, 2015 09:27 AM
You're right: the NodeBox 3 graphics API is different from the NodeBox 1 API. That's because the new API uses Path objects instead of directly drawing which is what NodeBox 1 did. We do this because we can take these generated Path objects and modify them using different nodes, for example the "wiggle" node.
So whereas in NodeBox 1 you would write:
In NodeBox 3, you would construct a Path and add a rectangle to it:
We call these nodes generators: they only take in primitive values (numbers) and generate shapes. Nodes that take in shapes and modify them are called filters. They might look like this:
Note that these nodes are required to clone the input shape, instead of modifying the input shape directly.
The documentation for the graphics API is unfortunately still missing. You can look at the source code for the Path class to see how it works internally.
I hope this helps. Feel free to ask any additional questions.