aboutsummaryrefslogtreecommitdiff
path: root/lib/color.c
diff options
context:
space:
mode:
authorChristian C <cc@localhost>2025-03-07 21:58:41 -0800
committerChristian C <cc@localhost>2025-03-07 21:58:41 -0800
commit0d1f5979dd1d6062af118fae3a1aa1863ea596f2 (patch)
tree4cb9973682409cbc23cd6c93cb26f14c4702d8ed /lib/color.c
parent12a1b2269c64bfbe61490a9a2a8eaa84ec3b41de (diff)
Library directories
Diffstat (limited to 'lib/color.c')
-rw-r--r--lib/color.c36
1 files changed, 36 insertions, 0 deletions
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 <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");
+}