xxxxxxxxxx
function setup() {
createCanvas(500, 500);
background("beige");
colorMode(HSL, 360, 100, 100); // Color mode allows me to pick colors with hue saturation and lightness
for (let i = 0; i < 10; i++){
// Draw lines in the nest
push();
translate(250, 250); // Shift canvas to center of nest
for (let i = 0; i < 60; i++) { // Draw 200 lines
stroke(color( random()*20+20, // Random HSL color in the brown range
random()*30+70,
random()*20+10));
strokeWeight(easeOutQuad(random())*3+1);
// Pick a random location in a circle
// To keep it in a circle, I pick a radius and angle for for each point
// To ensure that points closer to the circle aren't more common, I used an easing.
theta1 = random()*2*PI;
theta2 = random()*2*PI;
r1 = easeOutQuad(random())*220;
r2 = easeOutQuad(random())*220;
// Convert radial coordinates to xy coordinates
line(r1*cos(theta1), r1*sin(theta1), r2*cos(theta2), r2*sin(theta2))
}
pop();
// Draw ovals in nest
noFill();
for (let i = 0; i < 50; i++) { // Draw 20 ovals
push();
stroke(color( random()*20+20, // Random HSL color in the brown range
random()*30+70,
random()*20+10));
strokeWeight(easeOutQuad(random())*3+1);
translate(random()*50+225, random()*50+225); // Shift canvas to random center point
rotate(random()*2*PI); // Rotate oval randomly
let start = random()*2*PI;
arc(0, 0, easeOutQuad(random())*250+150, easeOutQuad(random())*250+150, start, start+PI/2+random()*PI/2);
pop();
}
}
fill("rgb(196,249,250)");
stroke("black"); strokeWeight(1);
for (let i = 0; i < 5; i++){
theta1 = easeOutSine(random())*2*PI;
r1 = random()*150;
push(); translate(250, 250); rotate(random()*2*PI);
ellipse(r1*cos(theta1), r1*sin(theta1), 70, 120); pop();
}
}
function easeOutQuad(x) {
return Math.sqrt(1 - Math.pow(x - 1, 2));
}
function easeOutSine(x) {
return Math.sin((x * Math.PI) / 2);
}