xxxxxxxxxx
// By Roni Kaufman
// Inspired by Sol LeWitt's "Squiggly Brushstrokes"
let particles = [];
let n = 500;
let colorZone = 0;
let squiggliness = 1/200;
function setup() {
createCanvas(windowWidth, windowHeight);
colorMode(HSB, 100);
noStroke();
background(10);
updateParticles();
setInterval(updateParticles, 2500);
}
function draw() {
for (let p of particles) {
p.draw();
p.move();
}
}
function updateParticles() {
particles = [];
for (let i = 0; i < n; i++) {
let x_ = random(width);
let y_ = random(height);
let s_ = 7;
let c_ = color((random(15) + colorZone) % 100, 90, 90, 100);
particles.push(new Particle(x_, y_, s_, c_));
}
colorZone += 10;
}
function Particle(x_, y_, s_, c_) {
this.x = x_;
this.y = y_;
this.size = s_;
this.c = c_;
this.alpha = 100;
this.dist = 1;
this.move = function() {
let theta = noise(this.x * squiggliness, this.y * squiggliness)*PI*4;
let v = p5.Vector.fromAngle(theta, this.dist);
this.x += v.x;
this.y += v.y;
this.dist *= 0.9999;
this.alpha *= 0.95;
}
this.draw = function() {
this.c.setAlpha(this.alpha);
fill(this.c);
circle(this.x, this.y, this.size);
this.c.setAlpha(100);
}
}