diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/painter/canvas.h | 76 |
1 files changed, 76 insertions, 0 deletions
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 @@ | |||
1 | #ifndef UPEM_MORPHING_CANVAS | ||
2 | #define UPEM_MORPHING_CANVAS | ||
3 | |||
4 | /** | ||
5 | * File: canvas.h | ||
6 | * "Everyday is a good day when you paint" – Bob Ross | ||
7 | */ | ||
8 | |||
9 | #include <MLV/MLV_image.h> | ||
10 | #include "common/geom.h" | ||
11 | #include "painter/color.h" | ||
12 | |||
13 | /** | ||
14 | * Type: Canvas | ||
15 | * Represents a fixed size RGBa pixel matrix. | ||
16 | */ | ||
17 | typedef struct { | ||
18 | MLV_Image *mlv; | ||
19 | } Canvas; | ||
20 | |||
21 | /** | ||
22 | * Function: canvas_create | ||
23 | * Initialises a canvas of the given size | ||
24 | * | ||
25 | * Parameters: | ||
26 | * width - the width in pixels | ||
27 | * height - the height in pixels | ||
28 | */ | ||
29 | Canvas *canvas_create(IntVector width, IntVector height); | ||
30 | |||
31 | /** | ||
32 | * Function: canvas_destroy | ||
33 | * Frees all memory allocated to a canvas. | ||
34 | * | ||
35 | * Parameters: | ||
36 | * *c - the canvas to destroy | ||
37 | */ | ||
38 | void canvas_destroy(Canvas *c); | ||
39 | |||
40 | /** | ||
41 | * Function: canvas_set_pixel | ||
42 | * Sets the pixel colour at the given coordinates. | ||
43 | * | ||
44 | * Parameters: | ||
45 | * *c - the canvas to alter | ||
46 | * pos - the coordinate of the pixel to set | ||
47 | * color - the new colour to set | ||
48 | */ | ||
49 | void canvas_set_pixel(Canvas *c, CartesianVector pos, Color color); | ||
50 | |||
51 | /** | ||
52 | * Function: canvas_get_pixel | ||
53 | * Returns the colour of the pixel at the given position. | ||
54 | * | ||
55 | * Parameters: | ||
56 | * *c - the base canvas | ||
57 | * pos - the coordinate of the pixel to get | ||
58 | * | ||
59 | * Returns: | ||
60 | * The colour of the requested pixel | ||
61 | */ | ||
62 | Color canvas_get_pixel(Canvas *c, CartesianVector pos); | ||
63 | |||
64 | /** | ||
65 | * Function: canvas_get_dim | ||
66 | * Returns the size (in pixels) of the given canvas. | ||
67 | * | ||
68 | * Parameters: | ||
69 | * *c - the canvas | ||
70 | * | ||
71 | * Returns: | ||
72 | * The size of the canvas | ||
73 | */ | ||
74 | CartesianVector canvas_get_dim(Canvas *c); | ||
75 | |||
76 | #endif | ||