1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

Is there a tutorial for the cornu library?

Posted by flo on Mar 5, 2007

hi there,

I´m new to nodebox. Can you help me width the cornu library? Is there anywhere a documentation or a tutorial?

tanks, flo



Posted by Mark Meyer on Mar 12, 2007

I was looking around for this as well. It wasn't clear at first, but I found these pages, which were helpful:

http://nodebox.net/code/index.php/cornu.path()
http://nodebox.net/code/index.php/cornu.drawpath()

One things which I think might be an error in the path() doc is that it says it returns a list of coords between 0.0 and 1.0, describing a point's position relative to the box, but it appears to return absolute positions.

For example:
#########
size(800,800)

cornu = ximport("cornu")
aPath = cornu.path([(.2, .5), (.6, .7), (.9, .1), (.5, .5)], tweaks=50)
for point in aPath:
print '%d : %d' % (point.x, point.y)
##########

the above prints out:
160 : 400
162 : 402
164 : 405
167 : 408
...



Posted by Tom De Smedt on Mar 12, 2007

The documentation is perhaps a bit unclear. The path() command accepts relative coordinates. The points returned are absolute.

I've changed the documentation to:

"Returns a path object from a given list of (x,y)-tuples. The x and y coordinates in this list range between 0.0 and 1.0, describing a point's position relative to the drawing area's size(). The points in the returned path object are absolute positions."

Hopefully that is more clear.

As for a tutorial, the cornu library is not that hard. Try Mark's above example:

size(800,800)
 
cornu = ximport("cornu")
aPath = cornu.path([(.2, .5), (.6, .7), (.9, .1), (.5, .5)], tweaks=50)
 
nofill()
stroke(0)
drawpath(aPath)

As you see, a curve is drawn from a list of numbers ranging between 0.0 and 1.0.

(.5, .5) means the middle of the screen, (.0, .0) would mean top left, and so on.