diff options
| author | Federico Angelilli <code@fedang.net> | 2024-03-14 00:58:05 +0100 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2024-03-14 00:58:05 +0100 |
| commit | 398fdbaa5c02bbd138c59004053d2e8ad0082ead (patch) | |
| tree | d846ed2d4e811ffeddde9dc77a5549fe38edbd34 /src/animate.c | |
| parent | cbe94d7c42422856275ad41332cbc980054d6bee (diff) | |
Add animation scaffolding
Diffstat (limited to 'src/animate.c')
| -rw-r--r-- | src/animate.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/animate.c b/src/animate.c new file mode 100644 index 0000000..7b95e9c --- /dev/null +++ b/src/animate.c @@ -0,0 +1,40 @@ +#include <glib.h> + +#include "animate.h" + +double quadratic_bezier(double x, double a, double b, double c) +{ + g_assert(x >= 0 && x <= 1); + g_assert(a >= 0 && a <= 1); + g_assert(b >= 0 && b <= 1); + g_assert(c >= 0 && c <= 1); + + const double t = 1 - x; + return a * t * t + 2 * b * t * x + c * x * x; +} + +double cubic_bezier(double x, double a, double b, double c, double d) +{ + g_assert(x >= 0 && x <= 1); + g_assert(a >= 0 && a <= 1); + g_assert(b >= 0 && b <= 1); + g_assert(c >= 0 && c <= 1); + g_assert(d >= 0 && d <= 1); + + const double t = 1 - x; + return a * (t * t * t) + 3 * b * (t * t * x) + 3 * c * (t * x * x) + d * (x * x * x); +} + +Animation *animation_create() +{ + Animation *anim = g_malloc0(sizeof(Animation)); + // TODO + return anim; +} + +void animation_destroy(Animation *anim) +{ + g_free(anim); +} + +// vim: ts=4 sw=4 et |
