#include "AnimationObject.h" #include #include ARGB AO_CheckerPattern(const Animation* anim, PixelRendererParams a) { struct AO_CheckerPattern chp = *(struct AO_CheckerPattern*)a.priv; a.row /= chp.squareSize; a.col /= chp.squareSize; if ((a.row + a.col) % 2 == 0) { ARGB_set(&a.pixel, 0xFF000000); } else { ARGB_set(&a.pixel, 0xFFFF00FF); } return a.pixel; } ARGB AO_Square(const Animation* anim, PixelRendererParams a) { struct AO_Square* set = (struct AO_Square*)a.priv; if (0 <= a.row && a.row <= set->width && 0 <= a.col && a.col <= set->height) { ARGB_set(&a.pixel, set->color); } return a.pixel; } ARGB AO_Circle(const Animation* anim, PixelRendererParams a) { struct AO_Circle* cir = (struct AO_Circle*)a.priv; if (a.row * a.row + a.col * a.col < cir->radius * cir->radius) { ARGB_set(&a.pixel, cir->color); } return a.pixel; } ARGB AO_Image(const Animation* anim, PixelRendererParams a) { struct AO_Image img = *(struct AO_Image*)a.priv; if (img.noRepeat == true && (a.col < 0 || img.img.width * img.zoom <= a.col || a.row < 0 || img.img.height * img.zoom <= a.row)) { return a.pixel; } return *RGBImage_at(*(RGBImage*)a.priv, a.row / img.zoom, a.col / img.zoom); } ARGB AO_Line(const Animation* anim, PixelRendererParams a) { struct AO_Line l = *(struct AO_Line*)a.priv; if (fabs(l.a * a.col + l.b * a.row + l.c) / sqrt(l.a * l.a + l.b * l.b) < l.width) { ARGB_set(&a.pixel, l.color); } return a.pixel; } ARGB AO_HorSegment(const Animation* anim, PixelRendererParams a) { struct AO_HorSegment hs = *(struct AO_HorSegment*)a.priv; if (abs(a.row) <= hs.width && hs.left <= a.col && a.col <= hs.right) { ARGB_set(&a.pixel, hs.color); } return a.pixel; }