diff --git a/units/on_screen_keyboard.cpp b/units/on_screen_keyboard.cpp index a668afc..1bd55b7 100644 --- a/units/on_screen_keyboard.cpp +++ b/units/on_screen_keyboard.cpp @@ -61,7 +61,8 @@ void OnScreenKeyboard::fillTexture() text->write(text->getCharacterSize(), text->getCharacterSize(), caption); // Dibuja el cuadro donde va el texto que se escribirá - SDL_SetRenderDrawColor(renderer, bgColor.r - 10, bgColor.g - 10, bgColor.b - 10, 255); + const color_t darkColor = darkenColor(bgColor, 10); + SDL_SetRenderDrawColor(renderer, darkColor.r, darkColor.g, darkColor.b, 255); const int x_rect = (text->getCharacterSize() * 2) + text->lenght(caption); const int y_rect = text->getCharacterSize(); const int w_rect = width - text->getCharacterSize() - x_rect; diff --git a/units/utils.cpp b/units/utils.cpp index 0ec44e6..0650d7d 100644 --- a/units/utils.cpp +++ b/units/utils.cpp @@ -1,6 +1,8 @@ #include "utils.h" #include +using namespace std; + // Calcula el cuadrado de la distancia entre dos puntos double distanceSquared(int x1, int y1, int x2, int y2) { @@ -576,7 +578,27 @@ void initOptions(options_t *options) options->screen.borderHeight = 0; options->notifications.posV = pos_top; - options->notifications.posH = pos_left; - options->notifications.sound = true; - options->notifications.color = {48, 48, 48}; + options->notifications.posH = pos_left; + options->notifications.sound = true; + options->notifications.color = {48, 48, 48}; +} + +// Oscurece un color +color_t darkenColor(color_t color, int amount) +{ + color_t newColor; + newColor.r = max(0, color.r - amount); + newColor.g = max(0, color.g - amount); + newColor.b = max(0, color.b - amount); + return newColor; +} + +// Aclara un color +color_t lightenColor(color_t color, int amount) +{ + color_t newColor; + newColor.r = min(255, color.r + amount); + newColor.g = min(255, color.g + amount); + newColor.b = min(255, color.b + amount); + return newColor; } \ No newline at end of file diff --git a/units/utils.h b/units/utils.h index 3e80288..b776c86 100644 --- a/units/utils.h +++ b/units/utils.h @@ -201,4 +201,10 @@ bool colorAreEqual(color_t color1, color_t color2); // Inicializa la estructura de opciones void initOptions(options_t *options); +// Oscurece un color +color_t darkenColor(color_t color, int amount); + +// Aclara un color +color_t lightenColor(color_t color, int amount); + #endif \ No newline at end of file