Afegides funcions per oscurir o aclarir colors

This commit is contained in:
2024-09-29 19:35:33 +02:00
parent fad6cddfb6
commit edc45b6cec
2 changed files with 26 additions and 0 deletions

View File

@@ -269,3 +269,23 @@ void DrawCircle(SDL_Renderer *renderer, int32_t centerX, int32_t centerY, int32_
} }
} }
} }
// Aclara el color
color_t lightenColor(color_t color, int amount)
{
color_t newColor;
newColor.r = std::min(255, (int)color.r + amount);
newColor.g = std::min(255, (int)color.g + amount);
newColor.b = std::min(255, (int)color.b + amount);
return newColor;
}
// Oscurece el color
color_t DarkenColor(color_t color, int amount)
{
color_t newColor;
newColor.r = std::max(0, (int)color.r - amount);
newColor.g = std::max(0, (int)color.g - amount);
newColor.b = std::max(0, (int)color.b - amount);
return newColor;
}

View File

@@ -296,6 +296,12 @@ hiScoreEntry_t sortHiScoreTable(hiScoreEntry_t entry1, hiScoreEntry_t entry2);
// Dibuja un circulo // Dibuja un circulo
void DrawCircle(SDL_Renderer *renderer, int32_t centerX, int32_t centerY, int32_t radius); void DrawCircle(SDL_Renderer *renderer, int32_t centerX, int32_t centerY, int32_t radius);
// Aclara el color
color_t lightenColor(color_t color, int amount);
// Oscurece el color
color_t DarkenColor(color_t color, int amount);
// Colores // Colores
extern const color_t bgColor; extern const color_t bgColor;
extern const color_t noColor; extern const color_t noColor;