week 5, generative art

Screen Shot 2014-12-13 at 4.27.07 PM

// create two noise counters that have random starting values
float noiseCounterA = random(100);
float noiseCounterB = random(100);

// create the x positions
float x = 0;

void setup() {
size(500, 500, OPENGL);
smooth();
background(255);

// start at screen center
x = width/2;

}

void draw() {

noStroke();
fill(random(255),random(150),random(78));

// calculate y position using noise
float yOffset = 200 * noise(noiseCounterA);

// draw applying noise to both y and size
rect(mouseX, yOffset, mouseY, yOffset*.25);

// move x with noise
x += 2 * noise(noiseCounterB) -1;

// increment noise counters
noiseCounterA += .005f;
noiseCounterB += .01f;

// reset when offscreen
if (x<0 || x > width){
x = random(width);
}

}
void keyPressed() {
if( key == ‘r’){
background(random(150),random(100),random(150));
}

}

Leave a reply