#include "P_TransformRotate.h"
#include "PixelCallback.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>

void TransformRotate_callback(TransformRotate* self, struct PixelContext* pc) {
	i32 xR = pc->x * cos(self->angle) + pc->y * sin(self->angle);
	i32 yR = - pc->x * sin(self->angle) + pc->y * cos(self->angle);

	pc->x = xR;
	pc->y = yR;
}

PixelCallback* TransformRotate_setup(TransformRotate obj) {
	PixelCallback* pca = malloc(sizeof(struct PixelCallback));

	pca->callback = (PixelCallback_callback)TransformRotate_callback;
	pca->callback_self = malloc(sizeof(obj));
	memcpy(pca->callback_self, &obj, sizeof(obj));

	return pca;
}
