xxxxxxxxxx
function noiseLoop(diameter, min, max, rnd) {
let cx = random(rnd || 1000);
let cy = random(rnd || 1000);
return function (angle) {
let xoff = map(cos(angle), -1, 1, cx, cx + diameter);
let yoff = map(sin(angle), -1, 1, cy, cy + diameter);
let zoff = sin(angle) * 0.001;
let r = noise(xoff, yoff, zoff);
return map(r, 0, 1, min, max);
};
}
function Particle() {
this.xn = noiseLoop(0.05, -width, width * 2);
this.yn = noiseLoop(0.05, -height, height * 2);
this.rn = noiseLoop(0.5, 0, 255);
this.gn = noiseLoop(0.5, 0, 255);
this.bn = noiseLoop(0.5, 0, 255);
this.dn = noiseLoop(0.5, 1, 10);
this.an = noiseLoop(1, 5, 200);
this.render = function (a) {
noStroke();
fill(this.rn(a), this.gn(a), this.bn(a), this.an(a));
circle(this.xn(a), this.yn(a), this.dn(a));
};
}
var particles = new Array(200);
var totalFrames = 240;
var counter = 0;
function setup() {
createCanvas(800, 350);
for (let i = 0; i < particles.length; i++) {
particles[i] = new Particle();
}
}
function draw() {
background(0);
percent = (counter % totalFrames) / totalFrames;
let a = percent * TWO_PI;
for (let i = 0; i < particles.length; i++) {
particles[i].render(a);
}
counter++;
}