JSFiddle - React, Tailwind, and code Playground
by HYEONGJINKIM
HTML
<body>
<!-- Hiding library elements in the DOM is fun -->
<aside id="library">
<img src="https://github.com/paullewis/Fireworks/blob/master/images/nightsky.png" id="nightsky" />
<img src="https://github.com/paullewis/Fireworks/blob/master/images/big-glow.png" id="big-glow" />
<img src="https://github.com/paullewis/Fireworks/blob/master/images/small-glow.png" id="small-glow" />
</aside>
</body>
CSS
html, body {
padding: 0;
margin: 0;
width: 100%;
height: 100%;
background: #000;
overflow: hidden;
}
#library {
display: none;
}
canvas {
-webkit-transform: translateZ(0);
}
JavaScript
/**
* Copyright (C) 2011 by Paul Lewis for CreativeJS. We love you all :)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
var Fireworks = (function() {
// declare the variables we need
var particles = [],
mainCanvas = null,
mainContext = null,
fireworkCanvas = null,
fireworkContext = null,
viewportWidth = 0,
viewportHeight = 0;
/**
* Create DOM elements and get your game on
*/
function initialize() {
// start by measuring the viewport
onWindowResize();
// create a canvas for the fireworks
mainCanvas = document.createElement('canvas');
mainContext = mainCanvas.getContext('2d');
// and another one for, like, an off screen buffer
// because that's rad n all
fireworkCanvas = document.createElement('canvas');
fireworkContext = fireworkCanvas.getContext('2d');
// set up the colours for the fireworks
createFireworkPalette(12);
// set the dimensions on...