add circ animation function and remove undocumented animation functions

This commit is contained in:
Felix Kratz 2023-02-23 20:51:03 +01:00
parent 07c0c9a0f3
commit a39f5305c5
3 changed files with 5 additions and 18 deletions

View file

@ -37,12 +37,10 @@ void animation_setup(struct animation* animation, void* target, animator_functio
animation->interp_function = &function_sin;
} else if (interp_function == INTERP_FUNCTION_QUADRATIC) {
animation->interp_function = &function_square;
} else if (interp_function == INTERP_FUNCTION_BOUNCE) {
animation->interp_function = &function_bounce;
} else if (interp_function == INTERP_FUNCTION_EXP) {
animation->interp_function = &function_exp;
} else if (interp_function == INTERP_FUNCTION_OVERSHOOT) {
animation->interp_function = &function_overshoot;
} else if (interp_function == INTERP_FUNCTION_CIRC) {
animation->interp_function = &function_circ;
} else {
animation->interp_function = &function_linear;
}

View file

@ -74,6 +74,7 @@ typedef ANIMATION_FUNCTION(animation_function);
#define INTERP_FUNCTION_QUADRATIC 'q'
#define INTERP_FUNCTION_SIN 's'
#define INTERP_FUNCTION_TANH 't'
#define INTERP_FUNCTION_CIRC 'c'
#define INTERP_FUNCTION_BOUNCE 'b'
#define INTERP_FUNCTION_EXP 'e'
#define INTERP_FUNCTION_OVERSHOOT 'o'

View file

@ -81,20 +81,8 @@ static inline double function_exp(double x) {
return x*exp(x - 1.);
}
static inline double function_bounce(double x) {
double alpha = 2.;
double beta = 0.8;
if (x < 1. / alpha) {
return alpha*alpha * x * x;
}
else {
return beta * beta * (x - 1./2. + 1./alpha/2.)
+ 1. - beta*beta* (1./2. + 1./alpha/2.);
}
}
static inline double function_overshoot(double x) {
return x * (1. + 0.5*(sin(3. * M_PI * x)));
static inline double function_circ(double x) {
return sqrt(1.f - powf(x - 1.f, 2.f));
}
static inline char* format_bool(bool b) {