#include #include "tuples.h" struct canvas { int width; int height; struct tuple * pixels; }; struct canvas canvas(int width, int height) { return (struct canvas){ width, height, calloc(width * height, (sizeof (struct tuple))) }; } void canvas_write_pixel(struct canvas canvas, int x, int y, struct tuple color) { struct tuple * pixel = &canvas.pixels[y * canvas.width + x]; pixel->r = color.r; pixel->g = color.g; pixel->b = color.b; pixel->a = color.a; } struct tuple canvas_pixel_at(struct canvas canvas, int x, int y) { return canvas.pixels[y * canvas.width + x]; }