fireworknighthamrdsky
Version:
This JavaScript code generates a simple animation of fireworks bursting in the night sky on a canvas element in a web browser.
14 lines (11 loc) • 1.03 kB
Markdown
## Firework Night Sky
This JavaScript code generates a simple animation of fireworks bursting in the night sky on a canvas element in a web browser.
## Usage
Ensure you have an HTML file with a <canvas> element with the id "canvas" where the fireworks animation will be displayed.
Include the provided index.js file in your project.
## Description
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.
## Animation
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.
## License
This code is provided under the MIT License. You are free to use and modify it according to your needs.