Skip to content

Latest commit

 

History

History
53 lines (39 loc) · 1.39 KB

README.md

File metadata and controls

53 lines (39 loc) · 1.39 KB

Transition

Transition allows to seamlessly animate variables assignements.

Usage

1. Include header

#include "transition.hpp"

2. Create a Transition object (here with a float)

trn::Transition<float> zoom(1.0f);

3. Use the Transition object as any object of your type

float twoTimes(float f)
{
    return 2.0f * f;
}

// Use our object
float twoZoom = twoTimes(zoom);

Change the value of the Transistion object

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.

Ajust transition time

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);

Technical limitations

  • The transition type only supports types implementing operator+, operator- and operator*(float, const T&). Where T is the transition's template argument.

  • The interpolation function is limited to a sigmoid

sigm

Future work

  • Add support for custom interpolation functions
  • Add support for manual update