
An application built in HTML5 and canvas is used to illustrate some intriguing mathematics.
Are you fading out images in the HTML5 canvas by painting a transparent black rectangle over the top? Did you test your animation in different browsers? You may be unaware that ugly gray remnants are being left behind. I discuss the problem, how to predict the color of these remnants, and some workarounds.
Drawing 3D objects in a 2D canvas is rather straightforward if the objects are simple dots and you’re not worried about depth-sorting. I show you a simple example of a sphere made out of dust particles which fly around and fade away. I also discuss how to properly select a point at random on a sphere, in such a way as to ensure an even distribution of points.
A little HTML5 canvas experiment: a digital clock created from particles. The particles take the form of numerals which slide into place to display the correct current time. A repelling force pushes inactive particles away from the time display particles. Full source code available for you to experiment with.