Fireworks
How do I make an fireworks?
Well my first canvas pen!!! Dedicate to all the great codepen's masters of canvas for all the inspiration and the wonderfull things that you do!!! :) I am learning with videotutorials so the credit for all who teach this!!! Canvas is not my speciallity but I wanted to do something !!! :). What is a fireworks? How do you make a fireworks? This script and codes were developed by Judith Neumann on 13 October 2022, Thursday.
Fireworks - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Fireworks</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div>
<canvas id="canvas"></canvas> </div> <script src="js/index.js"></script>
</body>
</html>
Fireworks - Script Codes CSS Codes
body{ background:black; overflow:hidden; margin:0;
}
canvas{ background:#000;
}
Fireworks - Script Codes JS Codes
window.addEventListener("resize", resizeCanvas, false); window.addEventListener("DOMContentLoaded", onLoad, false); window.requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) { window.setTimeout(callback, 1000/60); }; var canvas, ctx, w, h, particles = [], probability = 0.04, xPoint, yPoint; function onLoad() { canvas = document.getElementById("canvas"); ctx = canvas.getContext("2d"); resizeCanvas(); window.requestAnimationFrame(updateWorld); } function resizeCanvas() { if (!!canvas) { w = canvas.width = window.innerWidth; h = canvas.height = window.innerHeight; } } function updateWorld() { update(); paint(); window.requestAnimationFrame(updateWorld); } function update() { if (particles.length < 500 && Math.random() < probability) { createFirework(); } var alive = []; for (var i=0; i<particles.length; i++) { if (particles[i].move()) { alive.push(particles[i]); } } particles = alive; } function paint() { ctx.globalCompositeOperation = 'source-over'; ctx.fillStyle = "rgba(0,0,0,0.2)"; ctx.fillRect(0, 0, w, h); ctx.globalCompositeOperation = 'lighter'; for (var i=0; i<particles.length; i++) { particles[i].draw(ctx); } } function createFirework() { xPoint = Math.random()*(w-200)+100; yPoint = Math.random()*(h-200)+100; var nFire = Math.random()*50+100; var c = "rgb("+(~~(Math.random()*200+55))+"," +(~~(Math.random()*200+55))+","+(~~(Math.random()*200+55))+")"; for (var i=0; i<nFire; i++) { var particle = new Particle(); particle.color = c; var vy = Math.sqrt(25-particle.vx*particle.vx); if (Math.abs(particle.vy) > vy) { particle.vy = particle.vy>0 ? vy: -vy; } particles.push(particle); } } function Particle() { this.w = this.h = Math.random()*4+1; this.x = xPoint-this.w/2; this.y = yPoint-this.h/2; this.vx = (Math.random()-0.5)*10; this.vy = (Math.random()-0.5)*10; this.alpha = Math.random()*.5+.5; this.color; } Particle.prototype = { gravity: 0.05, move: function () { this.x += this.vx; this.vy += this.gravity; this.y += this.vy; this.alpha -= 0.01; if (this.x <= -this.w || this.x >= screen.width || this.y >= screen.height || this.alpha <= 0) { return false; } return true; }, draw: function (c) { c.save(); c.beginPath(); c.translate(this.x+this.w/2, this.y+this.h/2); c.arc(0, 0, this.w, 0, Math.PI*2); c.fillStyle = this.color; c.globalAlpha = this.alpha; c.closePath(); c.fill(); c.restore(); } }
![Fireworks - Script Codes](http://shots.codepen.io/judag/pen/XmXMOL-512.jpg)
Developer | Judith Neumann |
Username | judag |
Uploaded | October 13, 2022 |
Rating | 4.5 |
Size | 2,722 Kb |
Views | 30,360 |
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 |
Be in touch | 3,222 Kb |
Parrot preloader... | 2,691 Kb |
Css flat day landscape | 4,610 Kb |
Sad kitty | 2,643 Kb |
Take a beer | 2,581 Kb |
Css or Czz.. | 4,111 Kb |
Night baloons | 2,511 Kb |
Code and view | 3,096 Kb |
Fantasy earth... | 2,403 Kb |
Responsive flexbox letters... | 2,002 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 |
Scifi-style Radio-based Tab | Aaronchuo | 4,427 Kb |
FCC Portfolio | Cmwebby | 4,304 Kb |
Toggling Divs with jQuery | Yying6 | 1,967 Kb |
Fireworks Show | Arianalynn | 3,048 Kb |
Buttons for autumn | Nikazawila | 1,795 Kb |
FontAwesome icons with animation | Nicotinell | 2,083 Kb |
Matrix | Stathisnikolaidis | 1,922 Kb |
Blockquote design | Sjmcpherson | 1,863 Kb |
Heartbeat | Apetrov | 2,079 Kb |
C.Rowe Button | Brownerd | 2,473 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!