xxxxxxxxxx
64
let stars = [];
function setup() {
createCanvas(400, 400);
// Create initial stars
for (let i = 0; i < 550; i++) {
stars.push(createStar());
}
}
function draw() {
background(0); // Set the background to black
// Update and display stars
for (let i = 0; i < stars.length; i++) {
let star = stars[i];
// Update star properties
star.opacity += star.fadeDirection * 2;
if (star.opacity <= 0 || star.opacity >= 255) {
star.fadeDirection *= -1;
}
// Draw star in light blue
fill(173, 216, 230, star.opacity); // Light blue color
noStroke();
ellipse(star.x, star.y, star.size);
}
// Drawing brain structure
stroke(255);
strokeWeight(1);
noFill();
beginShape();
curveVertex(20, 100);
curveVertex(20, 100);
curveVertex(70, 70);
curveVertex(140, 65);
curveVertex(200, 50);
curveVertex(230, 65);
curveVertex(290, 65);
curveVertex(350, 150);
curveVertex(280, 260);
curveVertex(150, 220);
curveVertex(40, 205);
endShape(CLOSE);
}
function createStar() {
return {
x: random(width),
y: random(height),
size: random(1, 4),
opacity: random(100, 255),
fadeDirection: random() > 0.5 ? 1 : -1,
};
}