Where $t$ is the progress along the transition (“time”), going from $0$ to $1$, $S\left(t \right)$ is the state at time $t$ (e.g., the colour or position of an object), $S_0$ is the state at the start of the transition and $S_1$ is the state at the end of the transition. For example, if an object is moving from a point with coordinates (0, 0) to (100, 84) over a transition that lasts 1 second, after 0.5 seconds the object will be at coordinates (50, 42).
This can be altered with an “easing”, which makes it possible to obtain interesting effects, such as having the object accelerate at the start of the transition or slow down at its end.
An “easing” is essentially a real function $f\left (t \right)$ that is computed with an argument between 0 (start of the transition) and 1 (end of the transition) and which returns a value that is used to linearly interpolate between the start and end state of the transition:
As mentioned, the default behaviour of VectSharp is to use a linear easing (or, no easing), i.e. $f \left( t \right) = t$; an easing function can be applied by using the optional parameters of the Transition constructor:
The IEasing easing parameter is used to provide a single easing that will be applied to all elements in the transition.
The Dictionary<string, IEasing> easings parameter is used, instead, to provide a different easing for each object being animated.
Applying a single easing
The IEasing interface defines a single member: double Ease(double value) which applies the easing. In principle, this could be implemented using any function (even returning values smaller than 0 or greater than 1), and this is supported when producing animated GIFs or PNGs (you will just have to create a class implementing the interface); however, because animated SVGs only support a limited set of easings, only two concrete implementations of this interface are provided by VectSharp:
LinearEasing, which represents linear interpolation without any easing.
SplineEasing, which represents an easing performed using a cubic Bézier curve. The constructor for this class accepts two parameters, representing the control points of the Bézier curve; again, because of limitations of the SVG format, the coordinates for these points all have to be between 0 and 1.
The following example shows how to apply an easing to the simple animation from Creating a simple animation (again, the progress bar has just been added for clarity and will not be present in your output file):
Spline easings
A spline easing is defined by the two control points of the spline. The following interactive example shows the effect of changing the coordinates of these points on the spline and on the animation:
Applying multiple easings
It is also possible to apply a different easing to each object in the transition. In this way, the start and end of the transition will happen for all objects at the same time, but each object will move in a different way.
This can be achieved by using the easings parameter of the Transition constructor, providing a Dictionary<string, IEasing> that associates the tag of each animated object with the respective easing, as demonstrated by the following example: