Damn Particlez
How do I make an damn particlez?
Playing with particles. move the mouse and click. What is a damn particlez? How do you make a damn particlez? This script and codes were developed by Moklick on 20 November 2022, Sunday.
Damn Particlez - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Damn Particlez</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <span class="info">CLICK!</span>
<canvas id="app"></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>
Damn Particlez - Script Codes CSS Codes
html, body { margin: 0; padding: 0; overflow: hidden; background-color: #000; color:#efe;
}
.info{ position:absolute; width:200px; text-align:center; left:50%; margin:5px 0 0 -100px; font-weight:bold;
}
Damn Particlez - Script Codes JS Codes
window.requestAnimFrame = (function(){ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function( callback ){ window.setTimeout(callback, 1000 / 60); }; })();
var RandomGen = { randomize : function(a, b) { return Math.random() * (b - a) + a; }, randomInt : function(a, b) { return Math.floor(Math.random() * (b - a) + a); }, getDirVec : function(x,y){ var angle = this.randomize(0,(2 * Math.PI)); return new Vector(Math.sin(angle) * x, - Math.cos(angle) * y); },
}
var Vector = function(x,y){ this.x = x || 0; this.y = y || 0; this.add = function(v){ this.x += v.x; this.y += v.y; return this; }; this.mult = function(v){ this.x *= v.x; this.y *= v.y; };
}
var App = { init : function(){ this.canvas = document.getElementById('app'); this.context = this.canvas.getContext('2d'); this.particles = []; this.WIDTH = window.innerWidth; this.HEIGHT = window.innerHeight; this.canvas.width = this.WIDTH; this.canvas.height = this.HEIGHT; this.bindHandlers(); this.draw(); }, bindHandlers : function(){ this.canvas.addEventListener( 'click', this.fireParticles,false); this.canvas.addEventListener( 'mousemove', this.fireSmallParticles,false); this.createParticles(this.WIDTH / 2, this.HEIGHT / 2, false); window.onresize = App.resize; }, fireParticles : function(e){ var xPos = e.pageX; var yPos = e.pageY; App.createParticles(xPos,yPos,false); }, fireSmallParticles : function(e){ var xPos = e.pageX; var yPos = e.pageY; App.createParticles(xPos,yPos,true); }, createParticles : function(x,y,isSmall){ var amount = isSmall ? RandomGen.randomInt(10,25) : RandomGen.randomInt(150,350); for (var i = 0; i < amount; i++){ var particle = new Particle(x,y,isSmall); this.particles.push(particle); } }, draw : function(){ for (var i = 0; i < App.particles.length; i++){ App.particles[i].update(); if(App.particles[i].lifetime < 0){ App.particles.splice(i,1); } } App.context.fillStyle = "rgba(0,0,0,0.25)"; App.context.fillRect(0, 0, App.canvas.width, App.canvas.height); window.requestAnimFrame(App.draw); }, resize : function(){ App.canvas.width = window.innerWidth; App.canvas.height = window.innerHeight; }
}
var Particle = function(x,y,isSmall){ this.pos = new Vector(x,y); this.size = isSmall ? RandomGen.randomize(1,1) : RandomGen.randomize(1,8); var acc = RandomGen.randomize(0,this.size); this.dir = RandomGen.getDirVec(acc,acc); this.lifetime = RandomGen.randomize(20,60);
} Particle.prototype.draw = function(){ App.context.fillStyle = "#fff"; App.context.beginPath(); App.context.rect( this.pos.x,this.pos.y,this.size,this.size); App.context.closePath(); App.context.stroke(); App.context.fill(); }; Particle.prototype.update = function(){ this.lifetime--; this.dir.mult(new Vector(.97,.97)); this.pos.add(this.dir); this.draw(); }
App.init();
Developer | Moklick |
Username | moklick |
Uploaded | November 20, 2022 |
Rating | 4 |
Size | 2,805 Kb |
Views | 14,168 |
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 |
CSS Color Fading | 1,975 Kb |
Leaflet Transition Example | 33,818 Kb |
Zeichensatz | 2,058 Kb |
CCTV Everywhere | 3,723 Kb |
Damn Particlez | 2,805 Kb |
Hitman Loading Sequence pure css3 | 3,402 Kb |
... is watching you | 2,423 Kb |
Money Over Everything | 3,392 Kb |
Berlin Building Map | 2,477 Kb |
A Pen by moklick | 33,698 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 |
Fluid Responsive Typography | Jonmilner | 4,205 Kb |
Toggle Time | Petebot | 5,345 Kb |
Michelle, submit your photography to Unsplash. | Zaneriley | 3,368 Kb |
A Pen by Jess | Jessamyne | 5,100 Kb |
Drifting Clouds | Benedikte | 2,247 Kb |
Growing Root - Scroll control - CANVAS | Cjonasw | 2,342 Kb |
Touch Carousel - last, no gaps. | Berkin | 4,332 Kb |
3D Text in Sass | Bookcasey | 2,766 Kb |
Vue.js Lazy Loading | Kjbrum | 3,620 Kb |
Learning canvas drawing | Aurer | 2,204 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!