Tinkering with NodeBox

I’m no Daniel Shiffman, but I can work my way around Processing well enough. My biggest gripe with it (and hey, I still use it) is that I need to write Java. At the risk of sounding far too alternative for my own taste, I’m just not a fan of Java. It gets the job done for Processing, and thankfully I don’t need to use it elsewhere. It does have the great advantage of being able to be easily distributed via applets, but I’d much, much rather use Python.

I was pretty excited when I heard about NodeBox. It is unfortunately Mac-only, but it’s fantastic. Essentially, it is Processing for Python. The commands are kind of the same, the general feel of the community and the general end-result of my little hacks are quite similar, but there are a few notable differences. While the Processing community has a huge array of third-party libraries, NodeBox has a small, but extremely high-quality set. That’s not to knock Processing’s contributers; I just like how the documentation, download links and examples are all centralized on NodeBox’s main website. I downloaded some of these libraries, and just tinkered around. I hacked together a few examples and sample code, tweaking a few things here and there.

Abstract Swirls

Here’s another. These were generated using the following code:

colors = ximport("colors")
boids = ximport("boids")
cornu = ximport("cornu")

size(500, 500)
bg = rect(0, 0, WIDTH, HEIGHT, draw=False)
colors.gradientpath(bg, color(0.125, 0.2, 0), color(0, 0, 0))
colors.shadow()
nofill()

relativize = lambda x, y: (x / (1.0 * WIDTH), y / (1.0 * HEIGHT))

flock = boids.flock(10, 0, 0, WIDTH, HEIGHT)
n = 15

for i in range(n):
    flock.update(shuffled=False)

    points = [(boid.x, boid.y) for boid in flock]
    for j in range(len(points)):
        points[j] = relativize(points[j][0], points[j][1])

    t = float(i) / n
    stroke(0.2 + t * 0.4, 0.4 + t * 0.3, 0, 0.5 * t)
    cornu.drawpath(points, close = True)

Easy to read Python! There will be some NodeBox specific stuff you might not recognize, but the entire thing works so simply. Apple-R, and it runs a new, completely random trial (handled by boids). I ran the script a few times, picked two of the best in a five trial run and uploaded them. I liked it so much, I tweaked the resolution and made myself a wallpaper out of it. Here it is. It’s 1280x800, the right fit for my Macbook. If you use this, shoot me an email. If you want a specific resolution of that wallpaper, contact me. I guarantee it will be the only one like it in the world!

—★—

« I’m live! | Hover Menu »