diff options
| author | navewindre <boneyaard@gmail.com> | 2025-09-03 20:10:09 +0200 |
|---|---|---|
| committer | navewindre <boneyaard@gmail.com> | 2025-09-03 20:10:09 +0200 |
| commit | f8b92ce3aa08b1445c9f956d8166830946562d12 (patch) | |
| tree | 94e63a5aec9f8f52b577f56799e0c9201fd976a5 /src/util/anim.h | |
a
Diffstat (limited to 'src/util/anim.h')
| -rw-r--r-- | src/util/anim.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/util/anim.h b/src/util/anim.h new file mode 100644 index 0000000..dbc2c11 --- /dev/null +++ b/src/util/anim.h @@ -0,0 +1,27 @@ +#include "typedef.h" + +#include <SDL.h> + +template < typename T > +inline T lerp( T a, T b, F32 t ) { + return a + ( b - a ) * t; +} + +template < typename t > +inline t clamp( t a, t min, t max ) { + if ( a < min ) return min; + if ( a > max ) return max; + return a; +} + +inline F32 ease_in( F32 t, F32 pow = 2.f ) { + return powf( t, pow ); +} + +inline F32 ease_out( F32 t, F32 pow = 2.f ) { + return 1.f - powf( 1.f - t, pow ); +} + +inline F32 ease_in_out( F32 t, F32 pow = 2.f ) { + return t < 0.5f ? ease_in( t * 2.f, pow ) / 2.f : ease_out( t * 2.f - 1.f, pow ) / 2.f + 0.5f; +} |
