createCanvas(windowWidth, windowHeight);
for (let i = 0; i < nums; i++) {
snows.push(new Snow(random(1, 3)));
rect(0, 0, width, height);
ellipse(mouseX, mouseY, 50, 50);
attractor = createVector(mouseX, mouseY);
for (i = 0; i < nums; i++) {
if (dist(snows[i].location.x, snows[i].location.y, mouseX, mouseY) < 100) {
let force = snows[i].attracted(attractor);
snows[i].applyForce(force);
for (var j = 0; j < nums; j++) {
if (dist(snows[i].location.x, snows[i].location.y, snows[j].location.x, snows[j].location.y) < 30
&&dist(snows[i].location.x, snows[i].location.y, mouseX, mouseY) < 100) {
line(snows[i].location.x, snows[i].location.y, snows[j].location.x, snows[j].location.y)
let Snow = function(mass) {
this.location = new p5.Vector(random(width), random(height));
this.velocity = new p5.Vector(noise(2, 8), random(1, 5));
this.acceleration = new p5.Vector(0, 0);
this.radius = sqrt(random(pow(width /2, 2)));
this.initialangle = random(0, 2 * PI);
this.size = random(1, 5);
this.a = random(60, 255);
var choice = int(random(0, 4));
this.update = function(time) {
this.velocity.add(this.acceleration);
this.location.add(this.velocity);
this.acceleration.mult(0);
let angle = w * time + this.initialangle;
this.location.x = width / 2 + this.radius * sin(angle) * 0.3;
this.location.y += pow(this.size, 0.1);
this.display = function(color) {
} else if (choice == 1) {
fill(75, 255, 230, this.a);
} else if (choice == 2) {
fill(20, 210, 250, this.a);
fill(69, 115, 190, this.a);
ellipse(this.location.x, this.location.y, this.size, this.size);
ellipse(this.location.x, this.location.y, this.size, this.size);
this.checkEdge = function() {
if (this.location.y > height) {
if (this.location.y < 0) {
this.location.y = height;
this.applyForce = function(force) {
var f = p5.Vector.div(force, this.size);
this.acceleration.add(f);
this.attracted = function(target) {
var force = p5.Vector.sub(target, this.location);
d = constrain(d, 5.0, 15.0);
var strength = 50 * this.size / (d * d);