41 lines, no comments ยท 359 tokens, written in 6 seconds for $0.0056


 1  let balls = [];
 2  const count = 20;
 3  
 4  function setup() {
 5    createCanvas(windowWidth, windowHeight);
 6    noStroke();
 7  
 8    for (let i = 0; i < count; i++) {
 9      balls.push({
10        x: random(width),
11        y: random(height),
12        vx: random(-3, 3),
13        vy: random(-3, 3),
14        r: random(15, 40),
15        color: color(random(80, 255), random(80, 255), random(80, 255), 180)
16      });
17    }
18  }
19  
20  function draw() {
21    background(15, 20, 30, 40);
22  
23    for (let b of balls) {
24      b.x += b.vx;
25      b.y += b.vy;
26  
27      if (b.x - b.r < 0 || b.x + b.r > width) {
28        b.vx *= -1;
29      }
30      if (b.y - b.r < 0 || b.y + b.r > height) {
31        b.vy *= -1;
32      }
33  
34      fill(b.color);
35      ellipse(b.x, b.y, b.r * 2);
36    }
37  }
38  
39  function windowResized() {
40    resizeCanvas(windowWidth, windowHeight);
41  }