summaryrefslogtreecommitdiff
path: root/AnimationMove.c
diff options
context:
space:
mode:
Diffstat (limited to 'AnimationMove.c')
-rw-r--r--AnimationMove.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/AnimationMove.c b/AnimationMove.c
index 696150c..7ac52f9 100644
--- a/AnimationMove.c
+++ b/AnimationMove.c
@@ -2,31 +2,33 @@
#include <math.h>
ARGB
-AM_Linear(const Animation* anim, u32 frameIndex, ARGB pixel, i32 r, i32 c, void* priv) {
- struct AM_Linear ml = *(struct AM_Linear*)priv;
+AM_Linear(const Animation* anim, PixelRendererParams a) {
+ struct AM_Linear ml = *(struct AM_Linear*)a.priv;
- r = (r - ml.startRow - (i32)(frameIndex * ml.dRow));
- c = (c - ml.startCol - (i32)(frameIndex * ml.dCol));
+ a.row = (a.row - ml.startRow - (i32)(a.frame.current * ml.dRow));
+ a.col = (a.col - ml.startCol - (i32)(a.frame.current * ml.dCol));
if (ml.wrapCoordinates == true) {
- r %= anim->width;
- c %= anim->height;
+ a.row %= anim->width;
+ a.col %= anim->height;
}
- return ml.callback(anim, frameIndex, pixel, r, c, ml.priv);
+ a.priv = ml.priv;
+ return ml.callback(anim, a);
}
ARGB
-AM_Spin(const Animation* anim, u32 frameIndex, ARGB pixel, i32 r, i32 c, void* priv) {
- struct AM_Spin ms = *(struct AM_Spin*)priv;
+AM_Spin(const Animation* anim, PixelRendererParams a) {
+ struct AM_Spin ms = *(struct AM_Spin*)a.priv;
- double radius = sqrt(r * r + c * c);
- double phi = atan2(c, r);
+ double radius = sqrt(a.row * a.row + a.col * a.col);
+ double phi = atan2(a.col, a.row);
- phi += ms.theta + ms.dTheta * frameIndex;
+ phi += ms.theta + ms.dTheta * a.frame.current;
- r = (ms.centerRow + (i32)(radius * cos(phi)));
- c = (ms.centerCol + (i32)(radius * sin(phi)));
+ a.row = (ms.centerRow + (i32)(radius * cos(phi)));
+ a.col = (ms.centerCol + (i32)(radius * sin(phi)));
- return ms.callback(anim, frameIndex, pixel, r, c, ms.priv);
+ a.priv = ms.priv;
+ return ms.callback(anim, a);
}