Source of: Interactive Colorful Spiral, by GPT-4o
27 lines, no comments ยท 301 tokens, written in 2 seconds for $0.0033
1 function setup() {
2 createCanvas(600, 400);
3 angleMode(DEGREES);
4 noFill();
5 }
6
7 function draw() {
8 background(220);
9 let numLines = 100;
10 let centerX = width / 2;
11 let centerY = height / 2;
12 let mouseFactor = map(mouseX, 0, width, 2, 10);
13 let colorFactor = map(mouseY, 0, height, 0, 255);
14
15 strokeWeight(2);
16
17 for (let i = 0; i < numLines; i++) {
18 let angle = i * mouseFactor;
19 let x = centerX + cos(angle) * i * 3;
20 let y = centerY + sin(angle) * i * 3;
21 let r = map(i, 0, numLines, 100, 255);
22 let g = map(i, 0, numLines, 50, colorFactor);
23 let b = map(i, 0, numLines, colorFactor, 50);
24 stroke(r, g, b);
25 line(centerX, centerY, x, y);
26 }
27 }