Source of: Orbiting Circles Field, by GPT-5.1
68 lines, 8 of them comments ยท 715 tokens, written in 6 seconds for $0.0073
1 let cols, rows;
2 let spacing = 40;
3 let t = 0;
4
5 function setup() {
6 createCanvas(windowWidth, windowHeight);
7 cols = floor(width / spacing);
8 rows = floor(height / spacing);
9 noStroke();
10 }
11
12 function draw() {
13 background(10, 12, 30);
14
15 t += 0.01; // global time
16
17 // Mouse influence mapped to an angle range
18 let mx = map(mouseX, 0, width, -PI, PI);
19 let my = map(mouseY, 0, height, -PI, PI);
20
21 for (let i = 0; i < cols; i++) {
22 for (let j = 0; j < rows; j++) {
23 // Grid center point
24 let x = i * spacing + spacing * 0.5;
25 let y = j * spacing + spacing * 0.5;
26
27 // Distance from mouse for interaction
28 let d = dist(x, y, mouseX, mouseY);
29 let influence = constrain(map(d, 0, 300, 1.5, 0), 0, 1.5);
30
31 // Base angle and radius for orbit
32 let angle = t * 2 + (i + j) * 0.1 + mx * 0.2 + my * 0.2;
33 let radius = 6 + influence * 12;
34
35 // Orbiting offset
36 let ox = cos(angle) * influence * 10;
37 let oy = sin(angle) * influence * 10;
38
39 // Color shifts with position and time
40 let hueR = 150 + 80 * sin(t + i * 0.2);
41 let hueG = 120 + 60 * sin(t * 1.3 + j * 0.2);
42 let hueB = 240 + 15 * sin(t * 1.7 + (i + j) * 0.1);
43
44 fill(hueR, hueG, hueB, 200);
45 ellipse(x + ox, y + oy, radius, radius);
46 }
47 }
48
49 // Optional: soft vignette
50 drawVignette();
51 }
52
53 function drawVignette() {
54 push();
55 noStroke();
56 for (let r = max(width, height); r > 0; r -= 40) {
57 let alpha = map(r, 0, max(width, height), 0, 150);
58 fill(5, 5, 15, alpha);
59 ellipse(width / 2, height / 2, r * 1.5, r * 1.5);
60 }
61 pop();
62 }
63
64 function windowResized() {
65 resizeCanvas(windowWidth, windowHeight);
66 cols = floor(width / spacing);
67 rows = floor(height / spacing);
68 }