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

autoclosepath(False) doesn't work with compound paths?

Posted by Craig on Feb 15, 2011

Hello:

I am attempting to create a compound path but autoclosepath() seems set itself to True even if I tell it False. Here is my code:

background(None)
size(50, 50)
colormode(RGB, range=255)
DARK = color(0, 0, 0)
stroke(DARK)
nofill()
strokewidth(2)
nofill()
square = rect(0, 0, 50, 50, draw=True)
autoclosepath(False)
beginpath(20, 0)
lineto(20, 25)
curveto(20, 35, 20, 35, 30, 30)
widget = endpath(draw=True)
#square_and_widget = square.xor(widget)
#drawpath(square_and_widget)
Now if I set the square and widget draw=True, the curve stops just as expected. But if I set draw=False and uncomment the last two lines the curve returns to its origin. What am I doing wrong here? Thanks for your help in advance.


 
Posted by Josh Caswell on Feb 18, 2011

It looks like the trouble is in the xor call. If you try

drawpath(widget)
drawpath(square)
#square_and_widget = square.xor(widget)
#drawpath(square_and_widget)
it works as you want. The xor calls into a C library called GPC, which you'll find in the libs/polymagic/ directory in the NodeBox source. It's this C library that does the XOR of the two paths. I haven't read the code thoroughly enough to check what it's really doing, but it seems safe to assume that it ignores the closed/open setting of the two paths it works on (and it certainly has no knowledge of NB's autoclosepath setting).

So you're not doing anything wrong, really. You may need to find a way to avoid that xor, that's all.

Hope that's helpful.