# WEEK 4: Tut 6

## Tut 6: Drawing with Randomness

Randomness

• Show Sketch
``````/** @peep sketchcode */
size(200, 200);
smooth();
strokeWeight(20);
stroke(0, 130);
noFill();
bezier(0, random(height), 0, random(width), width, random(width), width, random(height));
bezier(0, random(height), 0, random(width), width, random(width), width, random(height));
bezier(0, random(height), 0, random(width), width, random(width), width, random(height));
bezier(0, random(height), 0, random(width), width, random(width), width, random(height));
bezier(0, random(height), 0, random(width), width, random(width), width, random(height));``````

Noise -- one of my favorite new functions! I used random to create a "piano wave" of patterns on each iteration

• Show Sketch
``````/** @peep sketchcode */
size(400, 100);
float inc = random(0,1);
noStroke();
fill(0);
noiseSeed(0);
for (int x = 0; x < width; x += 4) {
float n = noise(x * inc) * 70.0;
rect(x, 10 + n, 3, 20);
}``````

## Tut 6: Custom Code Combined

• Show Sketch
``````/** @peep sketchcode */

void setup () {
size(300, 300);
background(0);
}

void draw () {
noFill();
for (int i = 0; i<.5; i++) {
/*the sooner i becomes greater than the limit,
the slower it takes for the screen to fill up with
each ellipse
*/
stroke(random(255), random(255), random(255));
// stroke will always be a random color, set each rgb value so all colors have the chance to be played
float r = random(width/10);
strokeWeight(r);
float offset = r * 200.0;
// the higher the float r is multipled by, the bigger the circle, but it obviously appears thinner because there is no fill
ellipse(i, height/2, r+offset, r+offset);
}

}``````

## Comments

Nobody has said anything yet.