Using Randomized Variable Values to Enhance HTML5 Canvas Animations
/The HTML5 Canvas feature is bringing additional animation power to web pages. HTML5 Canvas allows web developers to embed sophisticated bit map animated graphics directly into web pages.
In developing examples for my book on HTML5 Canvas (HTML5 Canvas for Dummies) I experimented with using randomized variable values to improve the realism of an animated fireworks display. I used random values within specified ranges for parameters such as fireworks colors, number of exploding particles, trajectory of particles, lifespan of particles and flight trajectories. I found that adding well constructed values (not too much or too little randomization) significantly increased the realism and appeal of the results. Here's one example from the Fireworks app of setting a randomized value:
part[newPart].life = lifeMin +(Math.random()*(lifeMax-lifeMin));
See what you think ... click here to see it in action.