jsFrames

A JavaScript library for creating frame-based animations.

Example usage:

Register any functions to be called on each frame. The functions accept a single parameter for the timestamp of the current frame.

jsFrames.registerAnimation(function (thisFrameTimestamp) {
    // Get the ball position based on thisFrameTimestamp
    var position = ...

   // Draw the frame...
});

(Optionally), subscribe to get frames per second updates.

jsFrames.onFpsUpdate(function (fps) {
    // Display frames per second
});

Start the animation.

jsFrames.start();

See the complete JavaScript for this example.

There is also experimental support for particles with some very basic physics. See fireworks.js for the code used to create this example…

Some implementation details:

The frames are scheduled using the requestAnimationFrame function and a polyfill to get around varied support.