diff options
-rw-r--r-- | include/blender/canvas.h | 4 | ||||
-rw-r--r-- | src/blender/canvas.c | 23 |
2 files changed, 25 insertions, 2 deletions
diff --git a/include/blender/canvas.h b/include/blender/canvas.h index 12f7ce1..7fb9fdd 100644 --- a/include/blender/canvas.h +++ b/include/blender/canvas.h | |||
@@ -8,7 +8,7 @@ | |||
8 | * Freedom, according to Bob Ross | 8 | * Freedom, according to Bob Ross |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <MLV_image.h> | 11 | #include <MLV/MLV_image.h> |
12 | #include "common/geom.h" | 12 | #include "common/geom.h" |
13 | #include "color.h" | 13 | #include "color.h" |
14 | 14 | ||
@@ -17,7 +17,7 @@ | |||
17 | * Represents a fixed size RGBa pixel matrix. | 17 | * Represents a fixed size RGBa pixel matrix. |
18 | */ | 18 | */ |
19 | typedef struct { | 19 | typedef struct { |
20 | MLV_Image mlv; | 20 | MLV_Image *mlv; |
21 | } Canvas; | 21 | } Canvas; |
22 | 22 | ||
23 | /** | 23 | /** |
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 | } | ||