1 lines, no comments ยท 642 tokens, written in 11 seconds for $0.010


1  const balls = []; const NUM_BALLS = 18; let trailGraphics; function setup() { createCanvas(windowWidth, windowHeight); trailGraphics = createGraphics(windowWidth, windowHeight); trailGraphics.background(15, 15, 30); colorMode(HSB, 360, 100, 100, 100); for (let i = 0; i < NUM_BALLS; i++) { balls.push({ x: random(50, width - 50), y: random(50, height - 50), vx: random(-4, 4) || 2, vy: random(-4, 4) || 2, r: random(12, 36), hue: random(360), speed: random(2, 5) }); } } function draw() { trailGraphics.colorMode(HSB, 360, 100, 100, 100); trailGraphics.noStroke(); trailGraphics.fill(240, 30, 12, 18); trailGraphics.rect(0, 0, width, height); for (let b of balls) { b.x += b.vx; b.y += b.vy; if (b.x - b.r < 0) { b.x = b.r; b.vx *= -1; } if (b.x + b.r > width) { b.x = width - b.r; b.vx *= -1; } if (b.y - b.r < 0) { b.y = b.r; b.vy *= -1; } if (b.y + b.r > height) { b.y = height - b.r; b.vy *= -1; } b.hue = (b.hue + 0.5) % 360; trailGraphics.drawingContext.shadowBlur = 30; trailGraphics.drawingContext.shadowColor = `hsla(${b.hue}, 100%, 70%, 0.9)`; trailGraphics.fill(b.hue, 90, 100, 90); trailGraphics.ellipse(b.x, b.y, b.r * 2); trailGraphics.drawingContext.shadowBlur = 0; } image(trailGraphics, 0, 0); } function windowResized() { resizeCanvas(windowWidth, windowHeight); trailGraphics.resizeCanvas(windowWidth, windowHeight); trailGraphics.background(15, 15, 30); }