Particle Emitter
How do I make an particle emitter?
What is a particle emitter? How do you make a particle emitter? This script and codes were developed by Lloydwheeler on 26 January 2023, Thursday.
Particle Emitter - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Particle Emitter</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <canvas id="canvas"></canvas> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Particle Emitter - Script Codes CSS Codes
body { background: #333; height: 100%; margin: 0; overflow: hidden;
}
#canvas { background: #222; border-bottom: 1px solid #444;
}
Particle Emitter - Script Codes JS Codes
/* Horrible JS! Quickly hacked together so ignore the bad practices */
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
canvas.width = $(window).width();
canvas.height = $(window).height();
var particles = [];
var emissionPoint = {x: canvas.width/2, y: canvas.height/2};
var mouse = {x: 0, y: 0};
var mouseDelta = {x: 0, y: 0};
var gravity = 0.25;
function Particle(x, y, size, vx, vy, decayRate) { this.position = {x: x, y: y}; this.size = size; this.velocity = {x: vx, y: vy}; this.decayRate = decayRate;
}
$('#canvas').click(function(e) { emissionPoint.x = e.clientX; emissionPoint.y = e.clientY;
});
setInterval(function() { ctx.clearRect(0,0,canvas.width,canvas.height); particles.push(new Particle(emissionPoint.x, emissionPoint.y, Math.random()*10, randomRange(-10,10), randomRange(-5,5), Math.random())); for(var i = 0; i < particles.length; i++) { ctx.fillStyle = "rgba(0,255,255," + particles[i].decayRate + ")"; ctx.fillRect(particles[i].position.x, particles[i].position.y, particles[i].size, particles[i].size); particles[i].position.x += particles[i].velocity.x; particles[i].position.y += particles[i].velocity.y; particles[i].velocity.x *= .98; particles[i].velocity.y *= .98; particles[i].velocity.y += gravity; particles[i].decayRate -= Math.random()*.01; if (particles[i].position.x > canvas.width || particles[i].position.x < 0) { particles[i].velocity.x *= -1; } if (particles[i].position.y > canvas.height || particles[i].position.y + particles[i].size < 0) { particles[i].velocity.y *= -.75; } if(particles[i].decayRate <= 0) { particles.splice(i, 1); } }
}, 16);
function randomRange(min, max) { if (min < 0) { return min + Math.random() * (Math.abs(min)+max); }else { return min + Math.random() * max; }
}
Developer | Lloydwheeler |
Username | lloydwheeler |
Uploaded | January 26, 2023 |
Rating | 3 |
Size | 2,320 Kb |
Views | 6,072 |
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!
Name | Size |
Weather Icon | 3,352 Kb |
Loading Icon 2 | 2,803 Kb |
Profile Flip | 2,373 Kb |
Device Switcher | 4,297 Kb |
Spring Force | 5,229 Kb |
Breakpoints Example | 3,425 Kb |
Page Editor Animation | 8,456 Kb |
Mix Blend Mode | 2,391 Kb |
Triangle Generator | 3,947 Kb |
IOS Style Back Button | 2,006 Kb |
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!
Name | Username | Size |
Off Canvas | Mariamarica | 1,870 Kb |
Three js | Paulq | 2,353 Kb |
Bubble animation | Ftabor | 6,565 Kb |
About Us | Francescaedits | 1,902 Kb |
Falling Down the Rabbit Hole | Rachelnabors | 4,578 Kb |
Smoke Shader - Frame Buffer | Omarshe7ta | 2,672 Kb |
LeMandinque | Aadesida | 9,046 Kb |
A Pen by Theun | Tjoen | 6,152 Kb |
A Pen by Xand0r | Xand0r | 1,928 Kb |
Google Maps API Ground Overlay | Boycetrus | 2,961 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!