Animated PNG Example

This page shows an example of the AnimatedPNG javascript library in action. The example uses images named fish0001.png through fish0023.png.

The animation is initialised with the following code:

fishAnim = new AnimatedPNG('fish', 'fish0001.png', 23, 100);
fishAnim.draw(false);

Click the various links below to alter the behaviour of the animation.

Change background colour

(just to prove it’s a PNG with transparency)

document.getElementById('fishAnimDiv').style.backgroundColor = '#<color>';

Stop animation

fishAnim.stopAnimation();

Start animation

fishAnim.startAnimation();

Disable repeat

fishAnim.setRepeat(false);

Enable repeat

fishAnim.setRepeat(true);

Add frame delays

fishAnim.setFrameDelay(3, 500);
fishAnim.setFrameDelay(15, 500);

Clear frame delays

fishAnim.clearFrameDelays();