blob: a74bb60ef885ddb6810a000f9911f1195470edb2 (
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/*
* 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 {
IN,
OUT
} AnimationDirection;
typedef enum {
_EmptyAnimationType,
ACursorAnimation,
ALogoAnimation,
ARedFlashAnimation,
} AnimationType;
typedef struct {
bool cursor_animating;
double cursor_fade_direction;
} CursorAnimation;
typedef struct {
AnimationDirection direction;
} LogoAnimation;
typedef struct {
AnimationDirection direction;
unsigned flash_count;
} RedFlashAnimation;
typedef union {
CursorAnimation cursor_anim;
LogoAnimation logo_anim;
RedFlashAnimation redflash_anim;
} Animation;
typedef struct {
AnimationType type;
Animation anim;
bool completed;
anim_time_interval_t start_time;
AnimationCompletion completion_func;
void *completion_func_context;
} 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);
|