Skip to content

johnBuffer/Transition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published

Languages