xxxxxxxxxx
61
//size
let n = 60;
//width = 4-10
let widthMult = 3;
//height = 4-10
let heightMult = 6;
function setup() {
createCanvas(800, 800);
angleMode(DEGREES);
strokeWeight(3);
//noStroke();
let startR = random(150);
let startG = random(150);
let startB = random(150);
let a = 160;
//background(startR + 90, startG + 90, startB + 90 + 80);
background(255, 255, 255, 100);
for (let x = width; x > -n * widthMult; x -= n) {
for (let y = height; y > -n * heightMult; y -= n) {
//random shape
let shape = random(1);
if (shape >= 0.5 && dist(x + n / 2, y + n / 2, mouseX, mouseY) < n / 2) {
fill(255, 0, 0);
} else {
//fill color
fill(
random(startR, startR + 90),
random(startG, startG + 90),
random(startB, startB + 90) + 100
);
}
push();
translate(x + n / 2, y + n / 2);
rotate(floor(random(8)) * 180);
if (shape < 0.9) {
//random width and height for rectangle
let rectWidth = n * floor(random(1, widthMult));
let rectHeight = n * floor(random(1, heightMult));
//rectangle with random width and height
rect(-rectWidth / 2, -rectHeight / 2, rectWidth, rectHeight);
} else {
//random diameter for circle
let diameter = n * floor(random(1, min(widthMult, heightMult)));
//circle with random diameter
ellipse(50, 50, diameter, diameter);
}
pop();
}
}
}