Source of: Circular Ripple Pattern, by GPT-4o
36 lines, no comments ยท 279 tokens, written in 3 seconds for $0.0031
1 let circles = [];
2
3 function setup() {
4 createCanvas(windowWidth, windowHeight);
5 noFill();
6 }
7
8 function draw() {
9 background(30);
10 let cx = width / 2;
11 let cy = height / 2;
12 let maxRadius = min(width, height) * 0.6;
13
14 stroke(255, 150);
15 strokeWeight(2);
16
17 for (let i = 0; i < circles.length; i++) {
18 let circle = circles[i];
19 let radius = map(circle.age, 0, circle.lifetime, 0, maxRadius);
20 ellipse(cx, cy, radius * 2);
21 circle.age++;
22
23 if(circle.age > circle.lifetime) {
24 circles.splice(i, 1);
25 i--;
26 }
27 }
28
29 if (frameCount % 20 === 0) {
30 circles.push({ age: 0, lifetime: 150 });
31 }
32 }
33
34 function windowResized() {
35 resizeCanvas(windowWidth, windowHeight);
36 }