30 lines, no comments ยท 2,234 tokens, written in 10 seconds for $0.0046


 1  let x = 200;
 2  let y = 200;
 3  let dx = 3;
 4  let dy = 2;
 5  let radius = 30;
 6  let col;
 7  
 8  function setup() {
 9    createCanvas(400, 400);
10    col = color(random(255), random(255), random(255));
11  }
12  
13  function draw() {
14    background(200);
15    fill(col);
16    noStroke();
17    ellipse(x, y, radius * 2, radius * 2);
18    
19    x += dx;
20    y += dy;
21    
22    if (x > width - radius || x < radius) {
23      dx *= -1;
24      col = color(random(255), random(255), random(255));
25    }
26    if (y > height - radius || y < radius) {
27      dy *= -1;
28      col = color(random(255), random(255), random(255));
29    }
30  }