var particles;
function setup() {
createCanvas(500, 300);
frameRate(3);
particles = [];
for (var i = 0; i < 1000; i++) {
particles.push(new Particle());
}
background(0);
noStroke();
}
function draw() {
translate(width / 2, height / 2);
fill(lerpColor(color(249, 231, 40), color(111, 186, 44), map(sin(frameCount * 0.1), -1, 1, 0, 1)));
for (var i = 0; i < particles.length; i++) {
var particle = particles[i];
particle.render();
}
filter(ERODE);
}
function Particle() {
this.posAng = random(TWO_PI);
this.posXAng = random(TWO_PI);
this.posYAng = random(TWO_PI);
this.sizeAng = random(TWO_PI);
}
Particle.prototype = {
render: function() {
var size = map(sin(frameCount * 0.023 + this.sizeAng), -1, 1, 2, 5);
var x = map(sin(frameCount * 0.01 + this.posXAng), -1, 1, 130, 220);
var y = map(sin(frameCount * 0.01 + this.posYAng), -1, 1, 50, 100) * map(sin(frameCount * 0.07), -1, 1, -1, 1);
ellipse(x * cos(-frameCount * 0.043 + this.posAng), y * sin(-frameCount * 0.043 + this.posAng), size, size);
},
}