blob: dbc2c11d7879a6be279db636bc765561915989b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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;
}
|