diff options
Diffstat (limited to 'src/animation.h')
-rw-r--r-- | src/animation.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/animation.h b/src/animation.h new file mode 100644 index 0000000..3064d1b --- /dev/null +++ b/src/animation.h @@ -0,0 +1,59 @@ +/* + * animation.h + * + * Created by buzzert <buzzert@buzzert.net> 2019-01-20 + */ + +#pragma once +#include <stdbool.h> +#include <time.h> + +typedef double anim_time_interval_t; + +struct animation_t; +typedef void(*AnimationCompletion)(struct animation_t *anim, void *context); + +typedef enum { + _EmptyAnimationType, + ACursorAnimation, + ALogoAnimation, +} AnimationType; + +typedef struct { + AnimationType type; + + bool cursor_animating; + double cursor_fade_direction; +} CursorAnimation; + +typedef struct { + AnimationType type; + + bool direction; // false: in, true: out +} LogoAnimation; + +typedef union { + AnimationType type; + + CursorAnimation cursor_anim; + LogoAnimation logo_anim; +} Animation; + +typedef struct { + bool completed; + anim_time_interval_t start_time; + + AnimationCompletion completion_func; + void *completion_func_context; + + Animation anim; +} animation_t; + +// Convenience: returns current time as anim_time_interval_t +anim_time_interval_t anim_now(); + +// Easing functions +double anim_qubic_ease_out(double p); +double anim_quad_ease_out(double p); + + |