summaryrefslogtreecommitdiff
path: root/AnimationObject.c
diff options
context:
space:
mode:
authorSyndamia <kamen@syndamia.com>2026-03-15 12:23:21 +0200
committerSyndamia <kamen@syndamia.com>2026-03-15 12:23:21 +0200
commit2202e87c466803eeaddd974006aa9950d8e0d067 (patch)
tree55cac9843e5789ac6ff29345ecd4fc44775c6b31 /AnimationObject.c
parent47e28b44615b9b068776f61b8741ea8692461c1d (diff)
downloadppm_graphics-master.tar
ppm_graphics-master.tar.gz
ppm_graphics-master.zip
feat!: Split into separate filesHEADmaster
Diffstat (limited to 'AnimationObject.c')
-rw-r--r--AnimationObject.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/AnimationObject.c b/AnimationObject.c
new file mode 100644
index 0000000..af3798b
--- /dev/null
+++ b/AnimationObject.c
@@ -0,0 +1,55 @@
+#include "AnimationObject.h"
+#include <math.h>
+
+ARGB
+AO_CheckerPattern(const Animation* anim, u32 frameIndex, ARGB pixel, i32 r, i32 c, void* priv) {
+ struct AO_CheckerPattern chp = *(struct AO_CheckerPattern*)priv;
+
+ r /= chp.squareSize;
+ c /= chp.squareSize;
+
+ if ((r + c) % 2 == 0) {
+ ARGB_set(&pixel, 0xFF000000);
+ }
+ else {
+ ARGB_set(&pixel, 0xFFFF00FF);
+ }
+
+ return pixel;
+}
+
+ARGB
+AO_Square(const Animation* anim, u32 frameIndex, ARGB pixel, i32 r, i32 c, void* priv) {
+ struct AO_SquareSettings* set = (struct AO_SquareSettings*)priv;
+
+ if (0 <= r && r <= set->width && 0 <= c && c <= set->height) {
+ ARGB_set(&pixel, set->color);
+ }
+
+ return pixel;
+}
+
+ARGB
+AO_Image(const Animation* anim, u32 frameIndex, ARGB pixel, i32 r, i32 c, void* priv) {
+ struct AO_Image img = *(struct AO_Image*)priv;
+
+ if (img.noRepeat == true &&
+ (c < 0 || img.img.width * img.zoom <= c ||
+ r < 0 || img.img.height * img.zoom <= r))
+ {
+ return pixel;
+ }
+
+ return *RGBImage_at(*(RGBImage*)priv, r / img.zoom, c / img.zoom);
+}
+
+ARGB
+AO_Line(const Animation* anim, u32 frameIndex, ARGB pixel, i32 r, i32 c, void* priv) {
+ struct AO_Line l = *(struct AO_Line*)priv;
+
+ if (fabs(l.a * c + l.b * r + l.c) / sqrt(l.a * l.a + l.b * l.b) < l.width) {
+ ARGB_set(&pixel, l.color);
+ }
+
+ return pixel;
+}