From 0d1f5979dd1d6062af118fae3a1aa1863ea596f2 Mon Sep 17 00:00:00 2001 From: Christian C Date: Fri, 7 Mar 2025 21:58:41 -0800 Subject: Library directories --- lib/color.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 lib/color.c (limited to 'lib/color.c') diff --git a/lib/color.c b/lib/color.c new file mode 100644 index 0000000..902a93d --- /dev/null +++ b/lib/color.c @@ -0,0 +1,36 @@ +#include +#include +#include + +// 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"); +} -- cgit v1.2.1