Processing Shapes and Colours

Processing Shapes and Colours

Here's another generative art piece we explored semi-randomly today. Adapting the tiling examples, first we played around with changing the colours of the lines to make the repainting and calling draw every frame more visible.

We made the stroke width nice and wide so we could see the colours change more easily and then animated once per frame to generate a new sequence. The resultant images were very pleasing and looked quite retro to the students.

first


def draw_tile(x, y, w, h):
    left_to_right = True if random(2) >= 1 else False
    
    r = random(255)
    g = random(255)
    b = random(255)
    
    strokeWeight(10)
    stroke(r, g, b)
    
    if left_to_right:
        line(x, y, x + w, y + h)
    else:
        line(x + w, y, x, y + h)

        
def setup():
    size(800, 800)
    background(255)
    stroke(0)
    frameRate(1)


def draw():
    background(255)
    
    tile_size = 20
    
    for x in range(0, width, tile_size):
        for y in range(0, height, tile_size):
            draw_tile(x, y, tile_size, tile_size)

Next, instead of using lines that we had for the last several weeks, we experimented with shapes and vertices and each student came up with their own version of a figure to draw on each tile. Here I am drawing boxes with a slight skew the further down the page the boxes go, by modifying the position of the top right corner and the bottom left corner.

second


def draw_tile(x, y, w, h, i):
    r = random(255)
    g = random(255)
    b = random(255)
    
    strokeWeight(3)
    stroke(r, g, b)
    
    beginShape()
    vertex(x, y)
    vertex(x + w - i, y + i)
    vertex(x + w, y + h)
    vertex(x, y + h - i)
    endShape(CLOSE)
            
        
def setup():
    size(800, 800)
    background(255)
    stroke(0)
    frameRate(1)
   
    
def draw():
    background(255)
    
    tile_size = 100

    across = 0.0
    for x in range(0, width, tile_size):
        down = 0
        across += 0.5
        for y in range(0, height, tile_size):
            draw_tile(x, y, tile_size, tile_size, across * down)
            down += 0.5