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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
/* gcc -std=c99 *.c -lm && ./a.out | mpv --no-correct-pts --container-fps-override=30 -
* gcc -std=c99 *.c -lm && ./a.out | ffmpeg -r 30 -i - output.mp4
*/
#include "Animation.h"
#include "AnimationObject.h"
#include "AnimationMove.h"
#include "AnimationInterpolate.h"
#include <stdio.h>
int
main() {
Animation anim = Animation_new(512, 512, 120);
// Background
struct AO_CheckerPattern chp1 = {
.squareSize = 32,
.colorA = 0xFF000000, .colorB = 0xFFFF00FF,
};
struct AM_Linear ml1 = {
.startRow = 0, .startCol = 0,
.dRow = -1, .dCol = -1,
.callback = AO_CheckerPattern, .priv = &chp1,
};
Animation_pushEvent(&anim, 0, 120, AM_Linear, &ml1);
// Image
FILE* fbclc = fopen("bclc.ppm", "r");
struct AO_Image bclc;
struct AM_Linear ml10;
if (fbclc != NULL) {
bclc.img = ppm_read(fbclc);
bclc.noRepeat = true;
bclc.zoom = 0.4;
ml10 = (struct AM_Linear){
.startRow = 0, .startCol = 0,
.dRow = 0.5, .dCol = 0.5,
.callback = AO_Image, .priv = &bclc,
};
Animation_pushEvent(&anim, 0, 100, AM_Linear, &ml10);
}
// Line
struct AO_Line l1start = {
.a = -8, .b = 6, .c = -128,
.width = 0.5,
.color = 0xFF50F0F5
};
struct AO_Line l1end = {
.a = 8, .b = -4, .c = 0,
.width = 10,
.color = 0xFFF550F0
};
struct AO_Line l1;
struct A_Interpolate i1 = {
.startFrame = 0, .endFrame = 120,
.value = &l1, .initialState = &l1start, .finalState = &l1end,
.interpolate = AO_LineInterpolate,
.callback = AO_Line, .priv = &l1,
};
Animation_pushEvent(&anim, 0, 120, A_Interpolate, &i1);
// Yellow square
struct AO_Square s1 = {
.width = 20, .height = 20, .color = 0xFFFFFF00,
};
struct AM_Spin ms1 = {
.theta = 3.14159 / 15, .centerCol = 10, .centerRow = 10,
.callback = AO_Square, .priv = &s1,
};
struct AM_Linear ml3 = {
.startRow = 100, .startCol = 100,
.dRow = 3, .dCol = 1,
.callback = AM_Spin, .priv = &ms1,
};
Animation_pushEvent(&anim, 0, 80, AM_Linear, &ml3);
// White circle
struct AO_Circle s4 = {
.radius = 20, .color = 0xFFFFFFFF,
};
struct AM_Linear ml4 = {
.startRow = 40, .startCol = 40,
.dRow = 2, .dCol = 2,
.callback = AO_Circle, .priv = &s4,
};
Animation_pushEvent(&anim, 0, 80, AM_Linear, &ml4);
// Green square
struct AO_Square s2 = {
.width = 35, .height = 50, .color = 0xA009FAA5,
};
struct AM_Linear ml2 = {
.startRow = 20, .startCol = 5,
.dRow = -4, .dCol = -2,
.wrapCoordinates = true,
.callback = AO_Square, .priv = &s2,
};
Animation_pushEvent(&anim, 30, 110, AM_Linear, &ml2);
// Segment
struct AO_HorSegment ls1 = {
.left = -40, .right = 40,
.width = 3, .color = 0xFFA0A0A0,
};
struct AM_Spin ms3 = {
.theta = 3.14159 / 10,
.centerRow = 0, .centerCol = 0,
.callback = AO_HorSegment, .priv = &ls1,
};
struct AM_Linear ml6 = {
.startRow = 0, .startCol = 0,
.dRow = 4, .dCol = 4,
.callback = AM_Spin, .priv = &ms3,
};
Animation_pushEvent(&anim, 0, 120, AM_Linear, &ml6);
Animation_render(&anim);
fclose(fbclc);
RGBImage_delete(&bclc.img);
Animation_delete(&anim);
return 0;
}
|