/* 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 int main() { Animation anim = Animation_new(512, 512, 120); // Background struct AO_CheckerPattern chp1 = { .squareSize = 32, .colorA = 0xFF000000, .colorB = 0xFFFF00FF, }; struct AM_MoveLinear ml1 = { .startRow = 0, .startCol = 0, .dRow = -1, .dCol = -1, .callback = AO_CheckerPattern, .priv = &chp1, }; Animation_pushEvent(&anim, 0, 120, AM_MoveLinear, &ml1); // Image FILE* fbclc = fopen("bclc.ppm", "r"); struct AO_Image bclc; struct AM_MoveLinear ml10; if (fbclc != NULL) { bclc.img = ppm_read(fbclc); bclc.noRepeat = true; bclc.zoom = 0.4; ml10 = (struct AM_MoveLinear){ .startRow = 0, .startCol = 0, .dRow = 0.5, .dCol = 0.5, .callback = AO_Image, .priv = &bclc, }; Animation_pushEvent(&anim, 0, 100, AM_MoveLinear, &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_SquareSettings s1 = { .width = 20, .height = 20, .color = 0xFFFFFF00, }; struct AM_MoveSpin ms1 = { .theta = 3.14159 / 15, .centerCol = 10, .centerRow = 10, .callback = AO_Square, .priv = &s1, }; struct AM_MoveLinear ml3 = { .startRow = 100, .startCol = 100, .dRow = 3, .dCol = 1, .callback = AM_MoveSpin, .priv = &ms1, }; Animation_pushEvent(&anim, 0, 80, AM_MoveLinear, &ml3); // White square struct AO_SquareSettings s4 = { .width = 20, .height = 20, .color = 0xFFFFFFFF, }; struct AM_MoveLinear ml4 = { .startRow = 40, .startCol = 40, .dRow = 2, .dCol = 2, .wrapCoordinates = true, .callback = AO_Square, .priv = &s4, }; Animation_pushEvent(&anim, 0, 80, AM_MoveLinear, &ml4); // Green square struct AO_SquareSettings s2 = { .width = 35, .height = 50, .color = 0xA009FAA5, }; struct AM_MoveLinear ml2 = { .startRow = 20, .startCol = 5, .dRow = -4, .dCol = -2, .wrapCoordinates = true, .callback = AO_Square, .priv = &s2, }; Animation_pushEvent(&anim, 30, 110, AM_MoveLinear, &ml2); Animation_render(&anim); fclose(fbclc); RGBImage_delete(&bclc.img); Animation_delete(&anim); return 0; }