Fireworks in your browser: particle systems using HTML5, javascript, paper.js
View the demo here.
A week or so ago, in celebration of the Fourth of July I decided to create fireworks using the the paper.js framework I played around with previously.
At first I used symbols1 but I couldn’t access the alpha (transparency) property of a symbol. So, instead I drew a bunch of circles2. Then I created a bunch of arrays to keep track of each circle’s (particle) gravity along the X-axis, the y-axis, and alpha value. It was important that I had access to each individual particle’s alpha because I wanted to fade out the particle as time went on. Once a particle’s alpha reaches 0, the code would stop rendering that particle. It’s important that old particles get removed from the canvas or else there would be speed issues.
- paper.js allows you to create symbols of an object (such as a Path), which is simply an instance of that object. If you’ve Adobe Illustrator before, the paper.js symbol works the same as Illustrator’s symbols [↩]
- in paper.js, circles are not pre-defined shapes but rather pre-define paths (i.e. lines [↩]


One comment.
Eric said:
Hi Amy,
Saw this on the paperjs group. Very cool! I noticed that dumping all of the particle calculations (rendering, opacity and aging) into one loop sped things up a bit.