xxxxxxxxxx
function setup() {
createCanvas(400, 400);
background(255);
noLoop();
drawArtwork();
}
function draw() {
// Leave this empty, as we want a static image.
}
function drawArtwork() {
let numShapes = 160; // Number of shapes
for (let i = 0; i < numShapes; i++) {
let x = random(width);
let y = random(height);
let size = random(5, 50);
let rotation = random(TWO_PI);
drawShape(x, y, size, rotation);
}
}
function drawShape(x, y, size, rotation) {
push();
translate(x, y);
rotate(rotation);
stroke(random(255), random(255), random(255));
noFill();
strokeWeight(random(1, 5));
let sides = int(random(3, 8));
beginShape();
for (let j = 0; j < sides; j++) {
let angle = TWO_PI / sides * j;
let xOffset = cos(angle) * size;
let yOffset = sin(angle) * size;
vertex(xOffset, yOffset);
}
endShape(CLOSE);
pop();
}