diff options
-rw-r--r-- | include/blender/color.h | 16 | ||||
-rw-r--r-- | src/blender/color.c | 8 | ||||
-rw-r--r-- | test/blender/blender.c | 5 |
3 files changed, 25 insertions, 4 deletions
diff --git a/include/blender/color.h b/include/blender/color.h index 22ed563..1fef2cf 100644 --- a/include/blender/color.h +++ b/include/blender/color.h | |||
@@ -8,6 +8,9 @@ | |||
8 | * A rainbow | 8 | * A rainbow |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <MLV/MLV_color.h> | ||
12 | #include <stdbool.h> | ||
13 | |||
11 | /** | 14 | /** |
12 | * Type: ColorComponent | 15 | * Type: ColorComponent |
13 | * Represents a single colour component of 32-bits RGBa tuple. | 16 | * Represents a single colour component of 32-bits RGBa tuple. |
@@ -27,4 +30,17 @@ typedef union { | |||
27 | MLV_Color mlv; | 30 | MLV_Color mlv; |
28 | } Color; | 31 | } Color; |
29 | 32 | ||
33 | /** | ||
34 | * Function: color_equals | ||
35 | * Compares the supplied colors. | ||
36 | * | ||
37 | * Parameters: | ||
38 | * c1 - the first color | ||
39 | * c2 - the second color | ||
40 | * | ||
41 | * Returns: | ||
42 | * T(c1 is the same color as c2) | ||
43 | */ | ||
44 | bool color_equals(Color c1, Color c2); | ||
45 | |||
30 | #endif | 46 | #endif |
diff --git a/src/blender/color.c b/src/blender/color.c new file mode 100644 index 0000000..f92fba9 --- /dev/null +++ b/src/blender/color.c | |||
@@ -0,0 +1,8 @@ | |||
1 | #include "blender/color.h" | ||
2 | |||
3 | bool color_equals(Color c1, Color c2) { | ||
4 | return c1.rgba.r == c2.rgba.r && | ||
5 | c1.rgba.g == c2.rgba.g && | ||
6 | c1.rgba.b == c2.rgba.b && | ||
7 | c1.rgba.a == c2.rgba.a; | ||
8 | } | ||
diff --git a/test/blender/blender.c b/test/blender/blender.c index 7c33198..344ce04 100644 --- a/test/blender/blender.c +++ b/test/blender/blender.c | |||
@@ -6,10 +6,7 @@ static void test_color_blending() { | |||
6 | Color b = {{0x00, 0x47, 0xAB, 0x00}}; | 6 | Color b = {{0x00, 0x47, 0xAB, 0x00}}; |
7 | Color result = blender_blend_colors(a, b, 0.125); | 7 | Color result = blender_blend_colors(a, b, 0.125); |
8 | 8 | ||
9 | assert(result.rgba.r == 0xEE && | 9 | assert(color_equals(result, (Color) {{0xEE, 0xDF, 0x3C, 0x00}})); |
10 | result.rgba.g == 0xDF && | ||
11 | result.rgba.b == 0x3C && | ||
12 | result.rgba.a == 0x00); | ||
13 | } | 10 | } |
14 | 11 | ||
15 | int main(int argc, char **argv) { | 12 | int main(int argc, char **argv) { |