Source of: Flow Field Ribbons, by Claude Sonnet 5.5
42 lines, no comments ยท 1,213 tokens, written in 8 seconds for $0.013
1 let particles = [];
2 function setup() {
3 createCanvas(windowWidth, windowHeight);
4 colorMode(HSB, 360, 100, 100, 100);
5 background(0, 0, 5);
6 for (let i = 0; i < 900; i++) particles.push(new Particle());
7 }
8 class Particle {
9 constructor() { this.reset(); }
10 reset() {
11 this.x = random(width);
12 this.y = random(height);
13 this.life = random(100, 300);
14 }
15 update() {
16 let a = noise(this.x * 0.003, this.y * 0.003, frameCount * 0.002) * TWO_PI * 2;
17 let nx = this.x + cos(a) * 1.6;
18 let ny = this.y + sin(a) * 1.6;
19 let h = (degrees(a) + frameCount * 0.2) % 360;
20 stroke(h, 80, 100, 30);
21 strokeWeight(1.2);
22 line(this.x, this.y, nx, ny);
23 this.x = nx;
24 this.y = ny;
25 this.life--;
26 if (this.life < 0 || this.x < 0 || this.x > width || this.y < 0 || this.y > height) this.reset();
27 }
28 }
29 function draw() {
30 noStroke();
31 fill(0, 0, 5, 3);
32 rect(0, 0, width, height);
33 for (let p of particles) p.update();
34 }
35 function mousePressed() {
36 background(0, 0, 5);
37 noiseSeed(floor(random(100000)));
38 }
39 function windowResized() {
40 resizeCanvas(windowWidth, windowHeight);
41 background(0, 0, 5);
42 }