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

grid before grid

Posted by Frank on Jun 27, 2008

Folks...

I was playing with ( read: again cobbling together code ) the grid function and creating some ( what I thought was ) interesting results. I was just about ready to share this code and a new library for grid comes out that has what I was doing almost built in. And a very cool library of commands it is.

Well, be that as it may... here are a couple of examples of what I was fooling with:

First one with ovals

size(610,610)
web = ximport("web")
 
thesearch = "october"
colormode(RGB)
themes = web.kuler.search(thesearch)
thecolors = choice(themes)
 
for x, y in grid(8, 8, 75, 75):
    fill(0.2)
    c = color(0, 0, 0)
    stroke(c)
    strokewidth(2)
    rect(x+2, y+2, 70, 70,)
    path = rect(x+3, y+3, 68, 68, draw=False)
    beginclip(path)
    for i in range(15):
        c = choice(thecolors)
        stroke(c)
        strokewidth(random(50))
        radius = random(200)
        oval(random(x-70,x+140), random(y-70,y+140), radius, radius)
    endclip()
And the second with images from flickr
size(600,600)
colormode(HSB)
web = ximport("web")
rnd = ximport("random")
images = web.flickr.search("rap")
rnd.shuffle(images)
z = 0
for x, y in grid(8, 8, 75, 75):
    fill(0.2)
    c = color(0, 0, 0)
    stroke(c)
    strokewidth(2)
    rect(x, y, 70, 70,)
    path = rect(x, y, 70, 70, draw=False)
    beginclip(path)
    ##img = choice (images)
    img = images[z]
    f= img.download(thumbnail=True)
    w,h = imagesize(f)
    image(f, x, y, width=90)
    endclip()
    z += 1
Just change the search text for new color or image sets.
Happy cobbling....
Frank


 
Posted by Tom De Smedt on Jul 10, 2008

Hi Frank,

Thanks for sharing your scripts! Even with the new Grid library these are still clear and useful NodeBox examples.