diff options
author | pacien | 2017-12-28 01:23:08 +0100 |
---|---|---|
committer | pacien | 2017-12-28 01:23:08 +0100 |
commit | 330fd85db8c89c178621d978929d911bbe93fec7 (patch) | |
tree | b47e049846b10641776af8ea3673ab61dd2d4d45 /test | |
parent | 190449ee18bec69b2e385dccd9bd42ddc83dd418 (diff) | |
download | morpher-330fd85db8c89c178621d978929d911bbe93fec7.tar.gz |
Refactor canvas blender into rasterizer
Signed-off-by: pacien <pacien.trangirard@pacien.net>
Diffstat (limited to 'test')
-rw-r--r-- | test/blender/blender.c | 29 | ||||
-rw-r--r-- | test/painter/rasterizer.c | 27 |
2 files changed, 27 insertions, 29 deletions
diff --git a/test/blender/blender.c b/test/blender/blender.c deleted file mode 100644 index f42322f..0000000 --- a/test/blender/blender.c +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | #include "blender/blender.h" | ||
2 | #include <assert.h> | ||
3 | |||
4 | static void test_canvas_blending() { | ||
5 | Morphing *morphing; | ||
6 | Canvas origin, target, result; | ||
7 | CartesianVector sample_point = {13, 17}; | ||
8 | |||
9 | morphing = morphing_create(64, 64); | ||
10 | canvas_init(&origin, 64, 64); | ||
11 | canvas_init(&target, 64, 64); | ||
12 | canvas_init(&result, 64, 64); | ||
13 | |||
14 | canvas_set_pixel(&origin, sample_point, (Color) {{0xFF, 0xED, 0x00, 0x00}}); | ||
15 | canvas_set_pixel(&target, sample_point, (Color) {{0x00, 0x47, 0xAB, 0x00}}); | ||
16 | |||
17 | blender_blend_canvas(&result, &origin, &target, morphing, 0.125); | ||
18 | assert(color_equals(canvas_get_pixel(&result, sample_point), (Color) {{0xEE, 0xDF, 0x3C, 0x00}})); | ||
19 | |||
20 | canvas_free(&result); | ||
21 | canvas_free(&target); | ||
22 | canvas_free(&origin); | ||
23 | morphing_destroy(morphing); | ||
24 | } | ||
25 | |||
26 | int main(int argc, char **argv) { | ||
27 | test_canvas_blending(); | ||
28 | return 0; | ||
29 | } | ||
diff --git a/test/painter/rasterizer.c b/test/painter/rasterizer.c new file mode 100644 index 0000000..99a70b4 --- /dev/null +++ b/test/painter/rasterizer.c | |||
@@ -0,0 +1,27 @@ | |||
1 | #include "painter/rasterizer.h" | ||
2 | #include <assert.h> | ||
3 | |||
4 | static void test_rasterize() { | ||
5 | Morphing *morphing; | ||
6 | Canvas *origin, *target, *result; | ||
7 | CartesianVector sample_point = {13, 17}; | ||
8 | |||
9 | morphing = morphing_create(100, 100); | ||
10 | origin = canvas_create(100, 100); | ||
11 | target = canvas_create(100, 100); | ||
12 | canvas_set_pixel(origin, sample_point, (Color) {{0xFF, 0x00, 0xED, 0xFF}}); | ||
13 | canvas_set_pixel(target, sample_point, (Color) {{0xFF, 0xAB, 0x47, 0x00}}); | ||
14 | |||
15 | result = rasterize(origin, target, morphing, 0.125); | ||
16 | assert(color_equals(canvas_get_pixel(result, sample_point), (Color) {{0xFF, 0x3C, 0xDF, 0xEF}})); | ||
17 | |||
18 | canvas_destroy(result); | ||
19 | canvas_destroy(target); | ||
20 | canvas_destroy(origin); | ||
21 | morphing_destroy(morphing); | ||
22 | } | ||
23 | |||
24 | int main(int argc, char **argv) { | ||
25 | test_rasterize(); | ||
26 | return 0; | ||
27 | } | ||