59 lines, 2 of them comments ยท 463 tokens, written in 6 seconds for $0.0046


 1  let circles = [];
 2  
 3  function setup() {
 4    createCanvas(windowWidth, windowHeight);
 5  }
 6  
 7  function draw() {
 8    background(240);
 9    
10    // Create a new circle if mouse is pressed
11    if (mouseIsPressed) {
12      circles.push(new Circle(mouseX, mouseY));
13    }
14    
15    // Display and update all circles
16    for (let i = circles.length - 1; i >= 0; i--) {
17      circles[i].update();
18      circles[i].display();
19      if (circles[i].isFinished()) {
20        circles.splice(i, 1);
21      }
22    }
23  }
24  
25  class Circle {
26    constructor(x, y) {
27      this.x = x;
28      this.y = y;
29      this.size = 10;
30      this.maxSize = random(50, 100);
31      this.color = color(random(255), random(255), random(255));
32      this.growing = true;
33    }
34  
35    update() {
36      if (this.growing) {
37        this.size += 2;
38        if (this.size >= this.maxSize) {
39          this.growing = false;
40        }
41      } else {
42        this.size -= 1;
43      }
44    }
45  
46    display() {
47      fill(this.color);
48      noStroke();
49      ellipse(this.x, this.y, this.size, this.size);
50    }
51  
52    isFinished() {
53      return this.size <= 0;
54    }
55  }
56  
57  function windowResized() {
58    resizeCanvas(windowWidth, windowHeight);
59  }