From 93b2fab53e808f67a6472794fc62abec029f9e4a Mon Sep 17 00:00:00 2001 From: "Amine B. Hassouna" Date: Thu, 29 Nov 2018 21:10:16 +0100 Subject: [PATCH] Add function to compare colors --- include/utils.h | 4 ++++ src/utils.c | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/include/utils.h b/include/utils.h index 5c509fd..e1eb288 100644 --- a/include/utils.h +++ b/include/utils.h @@ -31,6 +31,8 @@ #ifndef UTILS_H #define UTILS_H +#include + #include @@ -63,4 +65,6 @@ long long Utils_time(); void Utils_randInit(); int Utils_rand(int min, int max); +bool Utils_equalColors(SDL_Color color1, SDL_Color color2); + #endif // UTILS_H diff --git a/src/utils.c b/src/utils.c index 44f3e23..60bac9e 100644 --- a/src/utils.c +++ b/src/utils.c @@ -72,3 +72,9 @@ int Utils_rand(int min, int max) { return ( rand() % (max + 1) ) + min; } + +bool Utils_equalColors(SDL_Color color1, SDL_Color color2) +{ + //return color1.r == color2.r && color1.g == color2.g && color1.b == color2.b && color1.a == color2.a; + return *((Sint32 *) &color1) == *((Sint32 *) &color2); +}