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