#include "P_Checker.h"
#include "PixelCallback.h"
#include <stdlib.h>
#include <string.h>

void Checker_callback(Checker* self, struct PixelContext* fc) {
	u32 x = fc->x / self->squareSize;
	u32 y = fc->y / self->squareSize;

	if ((x + y) % 2 == 0) {
		ARGB_merge(&fc->pixel, self->colorA);
	}
	else {
		ARGB_merge(&fc->pixel, self->colorB);
	}
}

PixelCallback* Checker_setup(Checker obj) {
	PixelCallback* pca = malloc(sizeof(struct PixelCallback));

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

	return pca;
}
