xxxxxxxxxx
62
let lastNoiseChange = 0;
const noiseChangeInterval = 3000;
let airParticles = [];
function setup() {
createCanvas(640, 400);
for (let i = 0; i < 1000; i++) {
airParticles.push(new AirBending());
}
}
function draw() {
background(0, 10);
// Check if it's time to change the noiseSeed
if (millis() - lastNoiseChange > noiseChangeInterval) {
noiseSeed(millis());
lastNoiseChange = millis();
}
for (let i = 0; i < airParticles.length; i++) {
airParticles[i].update();
airParticles[i].display();
}
}
class AirBending {
constructor() {
this.position = createVector(random(width), random(height));
this.size = 3; // Adjust the size as needed
this.noiseScale = 0.01 / 2;
}
update() {
let n = noise(this.position.x * this.noiseScale, this.position.y * this.noiseScale, frameCount * this.noiseScale * this.noiseScale);
let a = TAU * n;
this.position.x += cos(a);
this.position.y += sin(a);
if (!this.onScreen()) {
this.position.x = random(width);
this.position.y = random(height);
}
}
display() {
stroke(255);
fill(random(200, 255), random(200, 255), random(200, 255), 200);
ellipse(this.position.x, this.position.y, this.size, this.size);
}
onScreen() {
return (
this.position.x >= 0 &&
this.position.x <= width &&
this.position.y >= 0 &&
this.position.y <= height
);
}
}