animate northing
This commit is contained in:
26
src/util/animation.cpp
Normal file
26
src/util/animation.cpp
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user