xxxxxxxxxx
let t = 0.0;
let vel = 0.01;
let num;
let particles = [];
let palette_selected;
function setup() {
createCanvas(800, 800);
pixelDensity(2)
background(51);
num = random(100);
palette_selected = random(palettes);
for (i = 0; i < 200; i++) {
particles[i] = new Particle(random(width), random(height))
}
}
function draw() {
randomSeed(num);
stroke("#355070");
push();
for (i = 0, len = particles.length; i < len; i++) {
particles[i].display();
particles[i].update();
}
pop();
t += vel;
}
class Particle {
constructor(x, y) {
this.ran = random(width * 0.2) * random(-1, 1)
this.position = createVector(x, y)
this.lifespan = 255.0;
this.d = width * random(0.005, 0.01)/10;
}
run() {
this.update();
this.display();
}
update() {
this.lifespan -= 2.0;
}
display() {
push();
fill(255);
let fomulas =[sin,cos,tan,exp,sq,sqrt,floor,fract,round,ceil,abs]
translate(this.position.x + random(fomulas)(this.ran * random(fomulas)(t)),
this.position.y + random(fomulas)(this.ran *random(fomulas)(t/10)))
poly(0, 0, this.d)
pop();
}
isDead() {
if (this.lifespan < 0.0) {
return true;
} else {
return false;
}
}
}
function poly(x, y, r) {
translate(x, y);
let radius = r
noStroke();
blendMode(SCREEN)
let colNum = int(random(palette_selected.length));
this.col = color(palette_selected[colNum]);
fill(this.col)
beginShape();
for (let i = 0; i < TAU; i += TAU / 6) {
let ex = radius * sin(i);
let ey = radius * cos(i);
vertex(ex, ey)
}
endShape(CLOSE)
}