mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 11:06:44 +01:00
tween: add function to just interpolate the value, without using Tween object
This commit is contained in:
parent
0f14629a15
commit
80f59dd749
2 changed files with 13 additions and 4 deletions
16
src/tween.c
16
src/tween.c
|
@ -264,9 +264,14 @@ double GetTweenPosition(struct Tween* tween) {
|
||||||
return tween->pos / tween->duration;
|
return tween->pos / tween->duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
double GetTweenInterpolation(struct Tween* tween) {
|
double Interpolate(double pos, TWEEN_STYLE style) {
|
||||||
double pos = GetTweenPosition(tween);
|
if (pos < 0.0) {
|
||||||
switch (tween->style) {
|
pos = 0.0;
|
||||||
|
}
|
||||||
|
if (pos > 1.0) {
|
||||||
|
pos = 1.0;
|
||||||
|
}
|
||||||
|
switch (style) {
|
||||||
case TWEEN_STYLE_LINEAR:
|
case TWEEN_STYLE_LINEAR:
|
||||||
return LinearInterpolation(pos);
|
return LinearInterpolation(pos);
|
||||||
case TWEEN_STYLE_QUADRATIC_IN:
|
case TWEEN_STYLE_QUADRATIC_IN:
|
||||||
|
@ -330,7 +335,10 @@ double GetTweenInterpolation(struct Tween* tween) {
|
||||||
case TWEEN_STYLE_BOUNCE_IN_OUT:
|
case TWEEN_STYLE_BOUNCE_IN_OUT:
|
||||||
return BounceEaseInOut(pos);
|
return BounceEaseInOut(pos);
|
||||||
}
|
}
|
||||||
return pos;
|
}
|
||||||
|
|
||||||
|
double GetTweenInterpolation(struct Tween* tween) {
|
||||||
|
return Interpolate(GetTweenPosition(tween), tween->style);
|
||||||
}
|
}
|
||||||
|
|
||||||
double GetTweenValue(struct Tween* tween) {
|
double GetTweenValue(struct Tween* tween) {
|
||||||
|
|
|
@ -84,5 +84,6 @@ double GetTweenPosition(struct Tween* tween);
|
||||||
double GetTweenInterpolation(struct Tween* tween);
|
double GetTweenInterpolation(struct Tween* tween);
|
||||||
double GetTweenValue(struct Tween* tween);
|
double GetTweenValue(struct Tween* tween);
|
||||||
void UpdateTween(struct Tween* tween, double delta);
|
void UpdateTween(struct Tween* tween, double delta);
|
||||||
|
double Interpolate(double pos, TWEEN_STYLE style);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue