tween: add function to just interpolate the value, without using Tween object

This commit is contained in:
Sebastian Krzyszkowiak 2018-04-23 03:24:13 +02:00
parent 0f14629a15
commit 80f59dd749
2 changed files with 13 additions and 4 deletions

View file

@ -264,9 +264,14 @@ double GetTweenPosition(struct Tween* tween) {
return tween->pos / tween->duration;
}
double GetTweenInterpolation(struct Tween* tween) {
double pos = GetTweenPosition(tween);
switch (tween->style) {
double Interpolate(double pos, TWEEN_STYLE style) {
if (pos < 0.0) {
pos = 0.0;
}
if (pos > 1.0) {
pos = 1.0;
}
switch (style) {
case TWEEN_STYLE_LINEAR:
return LinearInterpolation(pos);
case TWEEN_STYLE_QUADRATIC_IN:
@ -330,7 +335,10 @@ double GetTweenInterpolation(struct Tween* tween) {
case TWEEN_STYLE_BOUNCE_IN_OUT:
return BounceEaseInOut(pos);
}
return pos;
}
double GetTweenInterpolation(struct Tween* tween) {
return Interpolate(GetTweenPosition(tween), tween->style);
}
double GetTweenValue(struct Tween* tween) {

View file

@ -84,5 +84,6 @@ double GetTweenPosition(struct Tween* tween);
double GetTweenInterpolation(struct Tween* tween);
double GetTweenValue(struct Tween* tween);
void UpdateTween(struct Tween* tween, double delta);
double Interpolate(double pos, TWEEN_STYLE style);
#endif