2 #include "cgmath/cgmath.h"
11 #define CPLERP(res, a, b, t) \
13 (res).x = (a).x + ((b).x - (a).x) * (t); \
14 (res).y = (a).y + ((b).y - (a).y) * (t); \
20 int init_logo(const char *fname)
27 static void eval_seg(float *res, int a, int b, float t)
32 res[0] = cp[a].x + (cp[b].x - cp[a].x) * t;
33 res[1] = cp[a].y + (cp[b].y - cp[a].y) * t;
37 prev = a <= 0 ? a : a - 1;
38 next = b >= numcp - 1 ? b : b + 1;
40 res[0] = cgm_bspline(cp[prev].x, cp[a].x, cp[b].x, cp[next].x, t);
41 res[1] = cgm_bspline(cp[prev].y, cp[a].y, cp[b].y, cp[next].y, t);
44 void eval_logo(float *res, float t)
49 if(!cp || numcp <= 0) {
59 if(t < 0.0f) t = 0.0f;
60 if(t > 1.0f) t = 1.0f;
62 idx0 = (int)(t * (numcp - 1));
63 if(idx0 > numcp - 2) idx0 = numcp - 2;
66 dt = 1.0f / (float)(numcp - 1);
67 t0 = (float)idx0 * dt;
68 t1 = (float)idx1 * dt;
69 t = (t - t0) / (t1 - t0);
71 eval_seg(res, idx0, idx1, t);