xxxxxxxxxx
43
// Random composition
//
// Shows how we might use randomness to create a
// random composition - but not totally random.
function setup() {
createCanvas(400, 400);
noStroke();
fill(0);
}
function draw() {
background(255);
let w1 = width / 5;
let y = height / 2;
for (let x = w1 / 2; x < width; x += w1){
let r = random(-10, 10);
circle(x, y, w1 + r);
}
for (let i = 0; i < 5; i++){
let w = random(50, 200);
x = random(width);
y = random(0, (height - w1 - w) / 2);
circle(x, y, w);
}
for (let i = 0; i < 5; i++){
let w = random(50, 200);
x = random(width);
y = random((height + w1 + w) / 2, height);
circle(x, y, w);
}
noLoop();
}
function keyPressed(){
loop();
}