animate northing

This commit is contained in:
Konstantin Käfer
2014-01-17 13:33:39 +01:00
parent fc8a0d00ac
commit 509b223fbf
10 changed files with 222 additions and 10 deletions

26
src/util/animation.cpp Normal file
View File

@@ -0,0 +1,26 @@
#include <llmr/util/animation.hpp>
#include <llmr/util/unitbezier.hpp>
#include <llmr/platform/platform.hpp>
using namespace llmr::util;
UnitBezier ease(0.25, 0.1, 0.25, 1);
animation::animation(double from, double to, double &value, double duration)
: start(platform::time()),
duration(duration),
from(from),
to(to),
value(value) {
}
animation::state animation::update() const {
double t = (platform::time() - start) / duration;
if (t >= 1) {
value = to;
return complete;
} else {
value = from + (to - from) * ease.solve(t, 0.001);
return running;
}
}