/*settings variables*/
var fireworkDimensions = 10; //make each firework 10px in width and height
var fireworkTransitionTime = 1000; //in milliseconds
var resizeTimer = false; //resize delay timer (not set)
var rayWidth = 2; //width of firework ray
var rayLength = 100; //length of firework ray
var fireworkRayPositions = [
[0, 3],
[10, 5],
[8, 6],
[5, 8],
[2, 8],
[2, 6],
[0, 4],
[0, 2],
[2, 2],
[4, 0],
[8, 2],
[10, 2]
]; //firework array positions in px format: bottom,right
var blurLights = true;
var windowWidth = window.innerWidth; //get width of viewport (updated when window is resized)
var windowHeight = window.innerHeight; //get height of viewport (updated when window is resized)
// IF THE BROWSER IS INTERNET EXPLORER 10 OR 11 disable the blurring background
var UAString = navigator.userAgent;
if ((navigator.appVersion.indexOf("MSIE 10") != -1) || (UAString.indexOf("Trident") !== -1 && UAString.indexOf("rv:11") !== -1)) {
//ie 10 and 11 don't support filter blurring so disable it in the program
blurLights = false;
}
var fireworkCounter = 0; //count how many fireworks have exploded
var fireworkRayRotation = [0, -30, -60, -90, -120, -150, -180, -210, -240, 90, 60, 30]; //the rotation of each ray of an exploded firework
window.addEventListener('load', function () {
initialize(); //initialize everything when the page loads
});
function initialize() {
fireworkTimers = []; //create empty global array to store all the timeouts for the firework explode time
createStars(); //call function to create the star background
createFireworks(); //call function to create the fireworks
function createStars() { //function create stars
var starContainer = document.getElementById('starContainer'); //get the container
starContainer.innerHTML = ''; //empty it incase anything is already in it
for (var i = 0; i < window.innerWidth; i++) { //add a star for each pixel of the viewport...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.