2
#include "drawable-node.h"
5
cm_identity_deform (int u, int v,
6
int x, int y, int width, int height,
7
int *deformed_x, int *deformed_y,
15
cm_user_geometry_deform (int u, int v,
16
int x, int y, int width, int height,
17
int *deformed_x, int *deformed_y,
20
CmDrawableNode *node = p;
22
*deformed_x = node->user_x + node->user_width * u / width;
23
*deformed_y = node->user_y + node->user_height * v / height;
27
cm_wavy_deform (int u, int v,
28
int x, int y, int width, int height,
29
int *deformed_x, int *deformed_y,
32
*deformed_x = x + u + cos((x * 4 + u + y * 4 + v) / 64.0) * 8;
33
*deformed_y = y + v + sin((x * 4 + u + y * 4 + v) / 64.0) * 8;
37
cm_patch_deform (int u_in, int v_in,
38
int x, int y, int w, int h,
39
int *deformed_x, int *deformed_y,
42
CmDrawableNode *node = p;
43
double coeffs_u[4], coeffs_v[4];
44
double patch_x, patch_y;
48
u = (double) u_in / w;
49
v = (double) v_in / h;
51
coeffs_u[0] = (1 - u) * (1 - u) * (1 - u);
52
coeffs_u[1] = 3 * u * (1 - u) * (1 - u);
53
coeffs_u[2] = 3 * u * u * (1 - u);
54
coeffs_u[3] = u * u * u;
56
coeffs_v[0] = (1 - v) * (1 - v) * (1 - v);
57
coeffs_v[1] = 3 * v * (1 - v) * (1 - v);
58
coeffs_v[2] = 3 * v * v * (1 - v);
59
coeffs_v[3] = v * v * v;
64
for (i = 0; i < 4; i++)
66
for (j = 0; j < 4; j++)
68
patch_x += coeffs_u[i] * coeffs_v[j] * node->patch_points[j][i].x;
69
patch_y += coeffs_u[i] * coeffs_v[j] * node->patch_points[j][i].y;
73
*deformed_x = patch_x + 0.5;
74
*deformed_y = patch_y + 0.5;