1 | // MIT License
|
2 |
|
3 | // Copyright (c) 2017 Vadim Grigoruk @nesbox // grigoruk@gmail.com
|
4 |
|
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 | // of this software and associated documentation files (the "Software"), to deal
|
7 | // in the Software without restriction, including without limitation the rights
|
8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 | // copies of the Software, and to permit persons to whom the Software is
|
10 | // furnished to do so, subject to the following conditions:
|
11 |
|
12 | // The above copyright notice and this permission notice shall be included in all
|
13 | // copies or substantial portions of the Software.
|
14 |
|
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 | // SOFTWARE.
|
22 |
|
23 | #pragma once
|
24 |
|
25 | typedef enum
|
26 | {
|
27 | AnimLinear,
|
28 | AnimEaseIn,
|
29 | AnimEaseOut,
|
30 | AnimEaseInOut,
|
31 | AnimEaseInCubic,
|
32 | AnimEaseOutCubic,
|
33 | AnimEaseInOutCubic,
|
34 | AnimEaseInQuart,
|
35 | AnimEaseOutQuart,
|
36 | AnimEaseInOutQuart,
|
37 | AnimEaseInQuint,
|
38 | AnimEaseOutQuint,
|
39 | AnimEaseInOutQuint,
|
40 | AnimEaseInSine,
|
41 | AnimEaseOutSine,
|
42 | AnimEaseInOutSine,
|
43 | AnimEaseInExpo,
|
44 | AnimEaseOutExpo,
|
45 | AnimEaseInOutExpo,
|
46 | AnimEaseInCirc,
|
47 | AnimEaseOutCirc,
|
48 | AnimEaseInOutCirc,
|
49 | AnimEaseInBack,
|
50 | AnimEaseOutBack,
|
51 | AnimEaseInOutBack,
|
52 | AnimEaseInElastic,
|
53 | AnimEaseOutElastic,
|
54 | AnimEaseInOutElastic,
|
55 | AnimEaseInBounce,
|
56 | AnimEaseOutBounce,
|
57 | AnimEaseInOutBounce,
|
58 | } AnimEffect;
|
59 |
|
60 | typedef struct
|
61 | {
|
62 | s32 start;
|
63 | s32 end;
|
64 | s32 time;
|
65 |
|
66 | s32 *value;
|
67 |
|
68 | AnimEffect effect;
|
69 | } Anim;
|
70 |
|
71 | typedef struct
|
72 | {
|
73 | void(*done)(void *data);
|
74 |
|
75 | s32 time;
|
76 | s32 tick;
|
77 |
|
78 | s32 count;
|
79 | Anim* items;
|
80 | } Movie;
|
81 |
|
82 | #define MOVIE_DEF(TIME, DONE, ...) \
|
83 | { \
|
84 | .time = TIME, \
|
85 | .done = DONE, \
|
86 | .count = COUNT_OF(((Anim[])__VA_ARGS__)), \
|
87 | .items = MOVE((Anim[])__VA_ARGS__), \
|
88 | }
|
89 |
|
90 | void processAnim(Movie* movie, void* data);
|
91 | Movie* resetMovie(Movie* movie);
|
92 | |