#include "AnimationMove.h"
#include <math.h>

ARGB
AM_Linear(const Animation* anim, PixelRendererParams a) {
	struct AM_Linear ml = *(struct AM_Linear*)a.priv;

	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) {
		a.row %= anim->width;
		a.col %= anim->height;
	}

	a.priv = ml.priv;
	return ml.callback(anim, a);
}

ARGB
AM_Spin(const Animation* anim, PixelRendererParams a) {
	struct AM_Spin ms = *(struct AM_Spin*)a.priv;

	double radius = sqrt(a.row * a.row + a.col * a.col);
	double phi = atan2(a.col, a.row);

	phi += ms.theta + ms.dTheta * a.frame.current;

	a.row = (ms.centerRow + (i32)(radius * cos(phi)));
	a.col = (ms.centerCol + (i32)(radius * sin(phi)));

	a.priv = ms.priv;
	return ms.callback(anim, a);
}
