From ad9a3fb5942d5707029f7179d5fc59a51950accc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Valor=20Mart=C3=ADnez?= Date: Sun, 28 May 2023 11:58:34 +0200 Subject: [PATCH] =?UTF-8?q?utils:=20A=C3=B1adida=20la=20funci=C3=B3n=20ran?= =?UTF-8?q?dColor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- units/utils.cpp | 10 ++++++++++ units/utils.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/units/utils.cpp b/units/utils.cpp index 0650d7d..5a33e87 100644 --- a/units/utils.cpp +++ b/units/utils.cpp @@ -601,4 +601,14 @@ color_t lightenColor(color_t color, int amount) newColor.g = min(255, color.g + amount); newColor.b = min(255, color.b + amount); return newColor; +} + +// Obtiene un color aleatorio +color_t randColor() +{ + color_t newColor; + newColor.r = rand() % 256; + newColor.g = rand() % 256; + newColor.b = rand() % 256; + return newColor; } \ No newline at end of file diff --git a/units/utils.h b/units/utils.h index b776c86..0b6daa7 100644 --- a/units/utils.h +++ b/units/utils.h @@ -207,4 +207,7 @@ color_t darkenColor(color_t color, int amount); // Aclara un color color_t lightenColor(color_t color, int amount); +// Obtiene un color aleatorio +color_t randColor(); + #endif \ No newline at end of file