summaryrefslogtreecommitdiff
path: root/FrameRender/P_TransformRotate.c
diff options
context:
space:
mode:
Diffstat (limited to 'FrameRender/P_TransformRotate.c')
-rw-r--r--FrameRender/P_TransformRotate.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/FrameRender/P_TransformRotate.c b/FrameRender/P_TransformRotate.c
new file mode 100644
index 0000000..562c814
--- /dev/null
+++ b/FrameRender/P_TransformRotate.c
@@ -0,0 +1,23 @@
+#include "P_TransformRotate.h"
+#include "PixelCallback.h"
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+void TransformRotate_callback(TransformRotate* self, struct PixelContext* pc) {
+ u32 xR = pc->x * cos(self->angle) + pc->y * sin(self->angle);
+ u32 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;
+}