xxxxxxxxxx
87
let maxBox = 100;
function setup() {
createCanvas(500, 500);
angleMode(DEGREES);
}
function draw() {
grid();
for (let i = 0; i < 500; i += 100) {
for (let j = 0; j < 500; j += 100) {
noFill();
stroke(100);
strokeWeight(3);
rect(i, j, maxBox);
}
}
noLoop();
}
function grid() {
noStroke();
for (let i = 0; i < 500; i += 100) {
for (let j = 0; j < 500; j += 100) {
fill(pastelColour());
rect(i, j, maxBox);
// curvy(i, j);
horizontalBlocks(i, j);
}
}
}
function pastelColour() {
// generate pastel colours by making the minimum value 150
let r = random() * 220 + 36;
let g = random() * 220 + 36;
let b = random() * 220 + 36;
let a = random(50, 200);
return color(r, g, b, a);
}
function horizontalBlocks(x, y) {
noStroke();
let times = floor(random(5, 15));
for (let i = 0; i < times; i++) {
fill(pastelColour());
y = y + random(maxBox) * 0.1;
let horiSpace = random(maxBox);
let vertySpace = random(maxBox) * 0.3;
rect(x, y, horiSpace, vertySpace);
}
}
function curvy(x, y) {
let randy = random();
push();
if (randy > 0.5) {
rotate(90);
translate(maxBox * 0.1, -maxBox);
}
let space = 14.6;
for (let k = 0; k < 5; k++) {
stroke(pastelColour());
strokeWeight(random(1, 5));
noFill();
let y = random(maxBox) * 0.8;
beginShape();
curveVertex(x, y);
for (let l = 0; l < maxBox; l++) {
curveVertex(x, y);
x += space;
if (l % 2 === 0) {
y += sin(space) * 15;
} else {
y -= sin(space) * 15;
}
}
curveVertex(x, y);
endShape();
}
pop();
}