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

core image append() error

Posted by Keith O'Hara on Apr 23, 2009

I'm trying to use the mandelbrot example from the docs:

coreimage = ximport("coreimage")

def fractal(x, y, depth=64):
z = complex(x, y)
o = complex(0, 0)
for i in range(depth):
if abs(o) <= 2: o = o*o + z
else:
return i
return 0 #default, black

pixels = []
w = h = 150
for i in range(w):
for j in range(h):
v = fractal(float(i)/w, float(j)/h)
pixels.append(color(v/10.0, v/20.0, v/10.0))

l = canvas.append(pixels, w, h)

But I get this error:

Traceback (most recent call last):
File "nodebox/gui/mac/__init__.pyo", line 358, in _execScript
File "", line 20, in
TypeError: append() takes exactly 2 arguments (4 given)


 
Posted by Keith O'Hara on Apr 23, 2009

Sorry about that, I missed the first few lines, this works:

coreimage = ximport("coreimage")
canvas = coreimage.canvas(150, 150)

def fractal(x, y, depth=64):
z = complex(x, y)
o = complex(0, 0)
for i in range(depth):
if abs(o) <= 2: o = o*o + z
else:
return i
return 0 #default, black

pixels = []
w = h = 150
for i in range(w):
for j in range(h):
v = fractal(float(i)/w, float(j)/h)
pixels.append(color(v/10.0, v/20.0, v/10.0))

l = canvas.append(pixels, w, h)
canvas.draw()