Skip to content

tswaters/fireworks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

dcdd8ae · Dec 3, 2017

History

23 Commits
Jul 3, 2016
Dec 3, 2017
Jul 4, 2016
Dec 3, 2017
Jul 4, 2016
Jul 4, 2016
Dec 3, 2017
Jul 3, 2016
Dec 3, 2017
Dec 3, 2017
Dec 3, 2017
Dec 3, 2017
Dec 3, 2017
Dec 3, 2017
Jul 3, 2016
Dec 3, 2017

Repository files navigation

Fireworks Canvas Example

Take a look at the live example!

install

bower install --save fireworks-canvas
npm install --save fireworks-canvas

usage

// exports a standard umd boiler:
const Fireworks = require('fireworks-canvas') // cjs
define(['fireworks-canvas'], (FireWorks) =>  {}) // amd
const Fireworks = window.Fireforks // browser global

// needs at least a container element, you can provide options
// (options are optional, defaults defined below)
const container = document.getElementById('container')
const options = {
  maxRockets: 3,            // max # of rockets to spawn
  rocketSpawnInterval: 150, // millisends to check if new rockets should spawn
  numParticles: 100,        // number of particles to spawn when rocket explodes (+0-10)
  explosionMinHeight: 0.2,  // percentage. min height at which rockets can explode
  explosionMaxHeight: 0.9,  // percentage. max height before a particle is exploded
  explosionChance: 0.08     // chance in each tick the rocket will explode
}

// instantiate the class and call start
// this returns a disposable - calling it will stop fireworks.
const fireworks = new Fireworks(container, options)
const stop = fireworks.start()
stop() // stop rockets from spawning
fireworks.stop() // also stops fireworks.

support

Requires es6 in the browser

development

npm i
npm run build
# open ./index.html in your favourite evergreen browser