Make a value animation with keyframes and easing function.
- Functional C++ STD Library
- Vector C++ STD Library
First of all, you will need to include this library into your project. For this, you just need to include "ValueAnimation.h" file.
Call the function Update(float timeElapsed) specifying the time elapsed since last frame (in milliseconds). Update() function will return the current value of animation.
auto valueAnimation = Delta3D::Math::ValueAnimation<int>();
valueAnimation.From( 0 ).To( 100 ).During( 500 ).Ease( Delta3D::Math::Easing::BounceIn ); //from 0 to 100 during 500ms using bounce in easing
valueAnimation.To( 200 ).During( 1000 ); //from 100 (last value) to 200 during 1000ms using linear easing (default)
valueAnimation.To( 300 ).During( 2000 ); //from 200 (last value) to 300 during 2000ms using linear easing (default)
auto valueAnimation = Delta3D::Math::ValueAnimation<float>();
valueAnimation.SetLoop( true ); //put animation in loop
valueAnimation.SetKeyFrame( 0.f, 0.f, Delta3D::Math::Easing::Linear ); //set keyframe on time 0.0ms with value 0.0
valueAnimation.SetKeyFrame( 1000.f, 10.f, Delta3D::Math::Easing::BackIn ); //set keyframe on time 1000ms with value 10.0 using back in easing
valueAnimation.SetKeyFrame( 3000.f, 35.f, Delta3D::Math::Easing::QuadOut ); //set keyframe on time 3000ms with value 35.0 using quadOut in easing
How the library is very simple, have not a documentation generated by Doxygen, but the code comments are already supported to do this.
- Code style very inspired by Tweeny
- Easing Functions by Robert Penner