From c970da3f5830fae5b4d98dcdcc8d34d678ec0434 Mon Sep 17 00:00:00 2001 From: pacien Date: Thu, 28 Dec 2017 01:22:03 +0100 Subject: Refactor canvas Signed-off-by: pacien --- include/painter/canvas.h | 76 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 include/painter/canvas.h (limited to 'include/painter/canvas.h') diff --git a/include/painter/canvas.h b/include/painter/canvas.h new file mode 100644 index 0000000..e354938 --- /dev/null +++ b/include/painter/canvas.h @@ -0,0 +1,76 @@ +#ifndef UPEM_MORPHING_CANVAS +#define UPEM_MORPHING_CANVAS + +/** + * File: canvas.h + * "Everyday is a good day when you paint" – Bob Ross + */ + +#include +#include "common/geom.h" +#include "painter/color.h" + +/** + * Type: Canvas + * Represents a fixed size RGBa pixel matrix. + */ +typedef struct { + MLV_Image *mlv; +} Canvas; + +/** + * Function: canvas_create + * Initialises a canvas of the given size + * + * Parameters: + * width - the width in pixels + * height - the height in pixels + */ +Canvas *canvas_create(IntVector width, IntVector height); + +/** + * Function: canvas_destroy + * Frees all memory allocated to a canvas. + * + * Parameters: + * *c - the canvas to destroy + */ +void canvas_destroy(Canvas *c); + +/** + * Function: canvas_set_pixel + * Sets the pixel colour at the given coordinates. + * + * Parameters: + * *c - the canvas to alter + * pos - the coordinate of the pixel to set + * color - the new colour to set + */ +void canvas_set_pixel(Canvas *c, CartesianVector pos, Color color); + +/** + * Function: canvas_get_pixel + * Returns the colour of the pixel at the given position. + * + * Parameters: + * *c - the base canvas + * pos - the coordinate of the pixel to get + * + * Returns: + * The colour of the requested pixel + */ +Color canvas_get_pixel(Canvas *c, CartesianVector pos); + +/** + * Function: canvas_get_dim + * Returns the size (in pixels) of the given canvas. + * + * Parameters: + * *c - the canvas + * + * Returns: + * The size of the canvas + */ +CartesianVector canvas_get_dim(Canvas *c); + +#endif -- cgit v1.2.3