diff options
author | pacien | 2017-12-28 01:24:14 +0100 |
---|---|---|
committer | pacien | 2017-12-28 01:27:14 +0100 |
commit | a1aa852d6e443394f79e7d1198b0bc2e5e6d2d66 (patch) | |
tree | 15468db1c658e9f93adc95e6d5c087c8bea01a4c /test/painter | |
parent | c502b20bac91ebc9128c2e3a586391fcabd84b6b (diff) | |
parent | 330fd85db8c89c178621d978929d911bbe93fec7 (diff) | |
download | morpher-a1aa852d6e443394f79e7d1198b0bc2e5e6d2d66.tar.gz |
Merge branch 'morpher'
Signed-off-by: pacien <pacien.trangirard@pacien.net>
Diffstat (limited to 'test/painter')
-rw-r--r-- | test/painter/color.c | 14 | ||||
-rw-r--r-- | test/painter/rasterizer.c | 27 |
2 files changed, 41 insertions, 0 deletions
diff --git a/test/painter/color.c b/test/painter/color.c new file mode 100644 index 0000000..bdfe9b3 --- /dev/null +++ b/test/painter/color.c | |||
@@ -0,0 +1,14 @@ | |||
1 | #include "painter/color.h" | ||
2 | #include <assert.h> | ||
3 | |||
4 | static void test_color_blend() { | ||
5 | Color a = {{1, 10, 100, 200}}, b = {{100, 1, 200, 10}}; | ||
6 | assert(color_equals(color_blend(a, b, TIME_ORIGIN), a)); | ||
7 | assert(color_equals(color_blend(a, b, TIME_UNIT), b)); | ||
8 | assert(color_equals(color_blend(a, b, 0.25), (Color) {{50, 9, 132, 173}})); | ||
9 | } | ||
10 | |||
11 | int main(int argc, char **argv) { | ||
12 | test_color_blend(); | ||
13 | return 0; | ||
14 | } | ||
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 | } | ||