diff options
author | Christian C <cc@localhost> | 2025-03-04 19:10:07 -0800 |
---|---|---|
committer | Christian C <cc@localhost> | 2025-03-04 19:10:07 -0800 |
commit | c61bb864c026d26a393f2a09c82de9bbc5043c6f (patch) | |
tree | 9f589bd8c0fa0823fe04da0753004386f0968844 /src/lib/color.c | |
parent | 49412195efd93573eb96ddbae6e41099964fdb65 (diff) |
Modularization
Diffstat (limited to 'src/lib/color.c')
-rw-r--r-- | src/lib/color.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/lib/color.c b/src/lib/color.c new file mode 100644 index 0000000..035a3e9 --- /dev/null +++ b/src/lib/color.c @@ -0,0 +1,39 @@ +#include <stdio.h> +#include <lib/color.h> +#include <lib/bool.h> + +//----------------------------------------------- +// Color Equal to Background +// Background: zeros in RGB, alpha can be whatever +bool_t color_zero(uint8_t* color1, size_t channels) { + for (size_t idx = 0; idx < channels; idx++) { + if (idx == 3) { + break; + } + if (color1[idx] != 0) { + return FALSE; + } + } + return TRUE; +} + +//----------------------------------------------- +// Color Equality +// Determine if two colors are identical +bool_t color_equal(uint8_t* color1, uint8_t* color2, size_t channels) { + for (size_t idx = 0; idx < channels; idx++) { + if (color1[idx] != color2[idx]) { + return FALSE; + } + } + return TRUE; +} + +//----------------------------------------------- +// Print out the `channels` length color vector +void print_color(uint8_t* color, size_t channels) { + for (size_t index = 0; index < channels; index++) { + printf("%hhu ", color[index]); + } + printf("\n"); +} |