Categories
Animation JavaScript Web development

Move eased dot along a curve

Demonstration of the effect of timing functions on an animation, using a Bezier curve controller.

How to use: Drag the handles (green dots) of the control below to adjust the way the red dot runs its loop. It starts and ends in its ‘home’, but the speed may vary, and the dot may even temporarily go backwards.

In the Bezier curve, perceived as a graph, the horizontal axis shows the time passed, on a scale of zero (at the start) to one (at the end point). The vertical axis shows the progress in distance covered, also from zero (no progress) to one (loop completed), although progress can dive below zero or exceed the value 1.

The CSS analogue

Perhaps you know Lea Verou’s cubic Bezier tool for CSS transitions and animations. In our case, the Bezier curve influences a JavaScript animation, instead of a CSS animation.

Open paths

The curve does not have to be a closed path. However, for a curve that does not end where it has started it makes no sense to define a timing function with undershoot (values smaller than zero) or overshoot (values larger than 1). Therefor in this case the value is clipped to the interval [0, 1].

Let’s try that out on the path used before in Move a dot along a path.

Ease sound

In the same vein, sound variables may be treated. See this experiment to play with easing the frequency of a note, creating a portamento.