Transition allows to seamlessly animate variables assignements.
#include "transition.hpp"
trn::Transition<float> zoom(1.0f);
float twoTimes(float f)
{
return 2.0f * f;
}
// Use our object
float twoZoom = twoTimes(zoom);
zoom = 30.0f;
When affecting a new value to the transition object, it justs update the target value. When accessing zoom
, its value will automatically transition from its current value to 30.0f
over the next second.
By default the transition takes 1sec to complete (taking into account the fact that sigmoid never strictly reaches 1).
The setSpeed method allows you to speed the transition up by a specified factor.
// Now the transition takes 0.5s
zoom.setSpeed(2.0f);
-
The transition type only supports types implementing
operator+
,operator-
andoperator*(float, const T&)
. WhereT
is the transition's template argument. -
The interpolation function is limited to a sigmoid
- Add support for custom interpolation functions
- Add support for manual update