Fireflies

Size
2,572 Kb
Views
64,768

How do I make an fireflies?

Click canvas to reset.My collection with Brownian Motion based Pens: http://codepen.io/collection/XwMNBR/. What is a fireflies? How do you make a fireflies? This script and codes were developed by Johan Karlsson on 24 July 2022, Sunday.

Fireflies Previews

Fireflies - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Fireflies</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <script src='https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.6/p5.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Fireflies - Script Codes CSS Codes

html, body { margin: 0;
}
canvas { display: block;
}

Fireflies - Script Codes JS Codes

"use strict";
/* Johan Karlsson (DonKarlssonSan)
*/
function Particle() { this.x = w / 2; this.y = h / 3; this.z = random(1);
}
Particle.prototype.move = function () { this.x += random(-particleStepMax, particleStepMax); this.y += random(-particleStepMax, particleStepMax); this.z += random(-0.01, 0.01); this.z = min(max(this.z, 0), 1);
};
Particle.prototype.draw = function () { ellipse(this.x, this.y, this.z * 7);
};
var particles;
var particleStepMax;
var w, h;
function setup() { cursor(HAND); particleStepMax = 2; w = windowWidth; h = windowHeight; initParticles(); createCanvas(w, h); noStroke(); fill("yellow"); background(0);
}
function draw() { background(0, 40); particles.forEach(function (p) { p.move(); p.draw(); });
}
function initParticles() { particles = []; for (var i = 0; i < 200; i++) { particles.push(new Particle()); }
}
function windowResized() { resizeCanvas(windowWidth, windowHeight);
}
function mouseClicked() { initParticles(); background(0);
}
Fireflies - Script Codes
Fireflies - Script Codes
Home Page Home
Developer Johan Karlsson
Username DonKarlssonSan
Uploaded July 24, 2022
Rating 4
Size 2,572 Kb
Views 64,768
Do you need developer help for Fireflies?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Johan Karlsson (DonKarlssonSan) Script Codes
Create amazing marketing copy with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!