diff options
Diffstat (limited to 'src/blender/canvas.c')
-rw-r--r-- | src/blender/canvas.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/blender/canvas.c b/src/blender/canvas.c new file mode 100644 index 0000000..3710249 --- /dev/null +++ b/src/blender/canvas.c | |||
@@ -0,0 +1,23 @@ | |||
1 | #include "blender/canvas.h" | ||
2 | |||
3 | void canvas_init(Canvas *canvas, IntVector width, IntVector height) { | ||
4 | canvas->mlv = MLV_create_image(width, height); | ||
5 | } | ||
6 | |||
7 | void canvas_free(Canvas *canvas) { | ||
8 | MLV_free_image(canvas->mlv); | ||
9 | } | ||
10 | |||
11 | void canvas_set_pixel(Canvas *canvas, CartesianVector position, Color color) { | ||
12 | MLV_set_pixel_on_image(position.x, position.x, color.mlv, canvas->mlv); | ||
13 | } | ||
14 | |||
15 | Color canvas_get_pixel(Canvas *canvas, CartesianVector position) { | ||
16 | int r, g, b, a; | ||
17 | MLV_get_pixel_on_image(canvas->mlv, position.x, position.y, &r, &g, &b, &a); | ||
18 | return (Color) {{r, g, b, a}}; | ||
19 | } | ||
20 | |||
21 | CartesianVector canvas_get_size(Canvas *canvas) { | ||
22 | return (CartesianVector) {MLV_get_image_width(canvas->mlv), MLV_get_image_height(canvas->mlv)}; | ||
23 | } | ||