diff options
Diffstat (limited to 'include/painter/canvas.h')
-rw-r--r-- | include/painter/canvas.h | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/include/painter/canvas.h b/include/painter/canvas.h new file mode 100644 index 0000000..928121a --- /dev/null +++ b/include/painter/canvas.h | |||
@@ -0,0 +1,92 @@ | |||
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. | ||
7 | * -- Bob Ross | ||
8 | */ | ||
9 | |||
10 | #include <MLV/MLV_image.h> | ||
11 | #include "common/geom.h" | ||
12 | #include "painter/color.h" | ||
13 | |||
14 | /** | ||
15 | * Type: Canvas | ||
16 | * Represents a fixed size RGBa pixel matrix. | ||
17 | */ | ||
18 | typedef struct { | ||
19 | MLV_Image *mlv; | ||
20 | } Canvas; | ||
21 | |||
22 | /** | ||
23 | * Function: canvas_create | ||
24 | * Initialises a canvas of the given size | ||
25 | * | ||
26 | * Parameters: | ||
27 | * width - the width in pixels | ||
28 | * height - the height in pixels | ||
29 | * | ||
30 | * Returns: | ||
31 | * The initialised canvas | ||
32 | */ | ||
33 | Canvas *canvas_create(IntVector width, IntVector height); | ||
34 | |||
35 | /** | ||
36 | * Function: canvas_create_from_image | ||
37 | * Initialises a canvas with an image loaded from the given path. | ||
38 | * | ||
39 | * Parameters: | ||
40 | * *fpath - path to the base image file | ||
41 | * | ||
42 | * Returns: | ||
43 | * The initialised canvas | ||
44 | */ | ||
45 | Canvas *canvas_create_from_image(const char *fpath); | ||
46 | |||
47 | /** | ||
48 | * Function: canvas_destroy | ||
49 | * Frees all memory allocated to a canvas. | ||
50 | * | ||
51 | * Parameters: | ||
52 | * *c - the canvas to destroy | ||
53 | */ | ||
54 | void canvas_destroy(Canvas *c); | ||
55 | |||
56 | /** | ||
57 | * Function: canvas_set_pixel | ||
58 | * Sets the pixel colour at the given coordinates. | ||
59 | * | ||
60 | * Parameters: | ||
61 | * *c - the canvas to alter | ||
62 | * pos - the coordinate of the pixel to set | ||
63 | * color - the new colour to set | ||
64 | */ | ||
65 | void canvas_set_pixel(Canvas *c, CartesianVector pos, Color color); | ||
66 | |||
67 | /** | ||
68 | * Function: canvas_get_pixel | ||
69 | * Returns the colour of the pixel at the given position. | ||
70 | * | ||
71 | * Parameters: | ||
72 | * *c - the base canvas | ||
73 | * pos - the coordinate of the pixel to get | ||
74 | * | ||
75 | * Returns: | ||
76 | * The colour of the requested pixel | ||
77 | */ | ||
78 | Color canvas_get_pixel(Canvas *c, CartesianVector pos); | ||
79 | |||
80 | /** | ||
81 | * Function: canvas_get_dim | ||
82 | * Returns the size (in pixels) of the given canvas. | ||
83 | * | ||
84 | * Parameters: | ||
85 | * *c - the canvas | ||
86 | * | ||
87 | * Returns: | ||
88 | * The size of the canvas | ||
89 | */ | ||
90 | CartesianVector canvas_get_dim(Canvas *c); | ||
91 | |||
92 | #endif | ||