This JavaScript code generates a simple animation of fireworks bursting in the night sky on a canvas element in a web browser.
Ensure you have an HTML file with a element with the id "canvas" where the fireworks animation will be displayed. Include the provided index.js file in your project.
The code defines a FireworkParticle class that represents a single particle in a firework explosion. Each particle has a random velocity, color, and alpha value to create a sparkling effect.
Fireworks are triggered by clicking the mouse anywhere on the canvas. Upon clicking, multiple particles are created and spread out with varying velocities and colors, simulating a fireworks explosion. The animation loop continuously updates the position and transparency of the particles, creating the illusion of twinkling lights in the night sky.
This code is provided under the MIT License. You are free to use and modify it according to your needs.