xxxxxxxxxx
42
function setup() {
createCanvas(800, 600);
}
function draw() {
background(0, 0, 50);
// Draw the moon
fill(255, 230, 180);
ellipse(400, 200, 80, 80);
// Draw the stars
fill(255);
stroke(255);
drawStars();
// Draw the swirling sky
noStroke();
drawSwirlingSky();
}
function drawStars() {
for (let i = 0; i < 100; i++) {
let x = random(width);
let y = random(height);
let size = random(1, 5);
ellipse(x, y, size, size);
}
}
function drawSwirlingSky() {
for (let y = 0; y < height; y += 5) {
for (let x = 0; x < width; x += 5) {
let r = map(sin(frameCount / 50 + x / 50), -1, 1, 0, 255);
let g = map(sin(frameCount / 40 + y / 50), -1, 1, 0, 255);
let b = map(sin(frameCount / 30 + (x + y) / 100), -1, 1, 0, 255);
fill(r, g, b);
rect(x, y, 5, 5);
}
}
}