diff options
| author | Syndamia <kamen@syndamia.com> | 2026-03-15 12:23:21 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2026-03-15 12:23:21 +0200 |
| commit | 2202e87c466803eeaddd974006aa9950d8e0d067 (patch) | |
| tree | 55cac9843e5789ac6ff29345ecd4fc44775c6b31 /AnimationMove.c | |
| parent | 47e28b44615b9b068776f61b8741ea8692461c1d (diff) | |
| download | ppm_graphics-2202e87c466803eeaddd974006aa9950d8e0d067.tar ppm_graphics-2202e87c466803eeaddd974006aa9950d8e0d067.tar.gz ppm_graphics-2202e87c466803eeaddd974006aa9950d8e0d067.zip | |
Diffstat (limited to 'AnimationMove.c')
| -rw-r--r-- | AnimationMove.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/AnimationMove.c b/AnimationMove.c new file mode 100644 index 0000000..487d220 --- /dev/null +++ b/AnimationMove.c @@ -0,0 +1,32 @@ +#include "AnimationMove.h" +#include <math.h> + +ARGB +AM_MoveLinear(const Animation* anim, u32 frameIndex, ARGB pixel, i32 r, i32 c, void* priv) { + struct AM_MoveLinear ml = *(struct AM_MoveLinear*)priv; + + r = (r - ml.startRow - (i32)(frameIndex * ml.dRow)); + c = (c - ml.startCol - (i32)(frameIndex * ml.dCol)); + + if (ml.wrapCoordinates == true) { + r %= anim->width; + c %= anim->height; + } + + return ml.callback(anim, frameIndex, pixel, r, c, ml.priv); +} + +ARGB +AM_MoveSpin(const Animation* anim, u32 frameIndex, ARGB pixel, i32 r, i32 c, void* priv) { + struct AM_MoveSpin ms = *(struct AM_MoveSpin*)priv; + + double radius = sqrt(r * r + c * c); + double phi = atan2(c, r); + + phi += ms.theta * frameIndex; + + r = (ms.centerRow + (i32)(radius * cos(phi))); + c = (ms.centerCol + (i32)(radius * sin(phi))); + + return ms.callback(anim, frameIndex, pixel, r, c, ms.priv); +} |
