blob: 7b95e9c77930c5381d5ce64bf5f508c38a6bca39 (
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
|
#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
|