Implementar sistema flexible de temas con cantidad variable de colores

- Refactorizar ThemeColors para usar std::vector<Color> en lugar de array fijo
- Cada tema puede tener cualquier cantidad de colores (8, 12, 24, etc.)
- Expandir tema RGB a 24 colores del círculo cromático (cada 15°)
- Añadir función initializeThemes() para configuración dinámica
- Mantener temas originales con 8 colores cada uno
- Tema RGB ahora incluye transiciones suaves por todo el espectro

Paleta RGB matemáticamente perfecta:
- 6 colores primarios: R, Y, G, C, B, M (cada 60°)
- 18 colores intermedios: transiciones cada 15°
- Cobertura completa del círculo cromático 0°-345°

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-18 22:22:57 +02:00
parent ac57755bd2
commit 4e030e4ef9
2 changed files with 68 additions and 27 deletions

View File

@@ -76,6 +76,7 @@ bool Engine::initialize() {
texture_ = std::make_shared<Texture>(renderer_, texture_path);
srand(static_cast<unsigned>(time(nullptr)));
dbg_init(renderer_);
initializeThemes();
initBalls(scenario_);
}
@@ -404,10 +405,8 @@ void Engine::initBalls(int value) {
const float VY = ((rand() % 60) - 30) * 0.1f; // Velocidad en Y
// Seleccionar color de la paleta del tema actual
ThemeColors &theme = themes_[static_cast<int>(current_theme_)];
int color_index = rand() % 8; // 8 colores por tema
const Color COLOR = {theme.ball_colors[color_index][0],
theme.ball_colors[color_index][1],
theme.ball_colors[color_index][2]};
int color_index = rand() % theme.ball_colors.size(); // Cantidad variable de colores por tema
const Color COLOR = theme.ball_colors[color_index];
// Generar factor de masa aleatorio (0.7 = ligera, 1.3 = pesada)
float mass_factor = GRAVITY_MASS_MIN + (rand() % 1000) / 1000.0f * (GRAVITY_MASS_MAX - GRAVITY_MASS_MIN);
balls_.emplace_back(std::make_unique<Ball>(X, VX, VY, COLOR, texture_, current_screen_width_, current_screen_height_, current_gravity_, mass_factor));
@@ -688,4 +687,66 @@ void Engine::zoomIn() {
void Engine::zoomOut() {
setWindowZoom(current_window_zoom_ - 1);
}
void Engine::initializeThemes() {
// SUNSET: Naranjas, rojos, amarillos, rosas (8 colores)
themes_[0] = {
180.0f / 255.0f, 140.0f / 255.0f, 100.0f / 255.0f, // Fondo superior (naranja suave)
40.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, // Fondo inferior (púrpura oscuro)
{{255, 140, 0}, {255, 69, 0}, {255, 215, 0}, {255, 20, 147}, {255, 99, 71}, {255, 165, 0}, {255, 192, 203}, {220, 20, 60}}
};
// OCEAN: Azules, turquesas, blancos (8 colores)
themes_[1] = {
100.0f / 255.0f, 150.0f / 255.0f, 200.0f / 255.0f, // Fondo superior (azul cielo)
20.0f / 255.0f, 40.0f / 255.0f, 80.0f / 255.0f, // Fondo inferior (azul marino)
{{0, 191, 255}, {0, 255, 255}, {32, 178, 170}, {176, 224, 230}, {70, 130, 180}, {0, 206, 209}, {240, 248, 255}, {64, 224, 208}}
};
// NEON: Cian, magenta, verde lima, amarillo vibrante (8 colores)
themes_[2] = {
20.0f / 255.0f, 20.0f / 255.0f, 40.0f / 255.0f, // Fondo superior (negro azulado)
0.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, // Fondo inferior (negro)
{{0, 255, 255}, {255, 0, 255}, {50, 205, 50}, {255, 255, 0}, {255, 20, 147}, {0, 255, 127}, {138, 43, 226}, {255, 69, 0}}
};
// FOREST: Verdes, marrones, amarillos otoño (8 colores)
themes_[3] = {
144.0f / 255.0f, 238.0f / 255.0f, 144.0f / 255.0f, // Fondo superior (verde claro)
101.0f / 255.0f, 67.0f / 255.0f, 33.0f / 255.0f, // Fondo inferior (marrón tierra)
{{34, 139, 34}, {107, 142, 35}, {154, 205, 50}, {255, 215, 0}, {210, 180, 140}, {160, 82, 45}, {218, 165, 32}, {50, 205, 50}}
};
// RGB: Círculo cromático con 24 puntos (cada 15°) - Ultra precisión matemática
themes_[4] = {
1.0f, 1.0f, 1.0f, // Fondo superior (blanco puro)
1.0f, 1.0f, 1.0f, // Fondo inferior (blanco puro) - sin degradado
{
{255, 0, 0}, // 0° - Rojo puro
{255, 64, 0}, // 15° - Rojo-Naranja
{255, 128, 0}, // 30° - Naranja
{255, 191, 0}, // 45° - Naranja-Amarillo
{255, 255, 0}, // 60° - Amarillo puro
{191, 255, 0}, // 75° - Amarillo-Verde claro
{128, 255, 0}, // 90° - Verde-Amarillo
{64, 255, 0}, // 105° - Verde claro-Amarillo
{0, 255, 0}, // 120° - Verde puro
{0, 255, 64}, // 135° - Verde-Cian claro
{0, 255, 128}, // 150° - Verde-Cian
{0, 255, 191}, // 165° - Verde claro-Cian
{0, 255, 255}, // 180° - Cian puro
{0, 191, 255}, // 195° - Cian-Azul claro
{0, 128, 255}, // 210° - Azul-Cian
{0, 64, 255}, // 225° - Azul claro-Cian
{0, 0, 255}, // 240° - Azul puro
{64, 0, 255}, // 255° - Azul-Magenta claro
{128, 0, 255}, // 270° - Azul-Magenta
{191, 0, 255}, // 285° - Azul claro-Magenta
{255, 0, 255}, // 300° - Magenta puro
{255, 0, 191}, // 315° - Magenta-Rojo claro
{255, 0, 128}, // 330° - Magenta-Rojo
{255, 0, 64} // 345° - Magenta claro-Rojo
}
};
}

View File

@@ -69,32 +69,11 @@ private:
struct ThemeColors {
float bg_top_r, bg_top_g, bg_top_b;
float bg_bottom_r, bg_bottom_g, bg_bottom_b;
int ball_colors[8][3];
std::vector<Color> ball_colors;
};
// Temas de colores definidos
ThemeColors themes_[5] = {
// SUNSET: Naranjas, rojos, amarillos, rosas
{180.0f / 255.0f, 140.0f / 255.0f, 100.0f / 255.0f, // Fondo superior (naranja suave)
40.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, // Fondo inferior (púrpura oscuro)
{{255, 140, 0}, {255, 69, 0}, {255, 215, 0}, {255, 20, 147}, {255, 99, 71}, {255, 165, 0}, {255, 192, 203}, {220, 20, 60}}},
// OCEAN: Azules, turquesas, blancos
{100.0f / 255.0f, 150.0f / 255.0f, 200.0f / 255.0f, // Fondo superior (azul cielo)
20.0f / 255.0f, 40.0f / 255.0f, 80.0f / 255.0f, // Fondo inferior (azul marino)
{{0, 191, 255}, {0, 255, 255}, {32, 178, 170}, {176, 224, 230}, {70, 130, 180}, {0, 206, 209}, {240, 248, 255}, {64, 224, 208}}},
// NEON: Cian, magenta, verde lima, amarillo vibrante
{20.0f / 255.0f, 20.0f / 255.0f, 40.0f / 255.0f, // Fondo superior (negro azulado)
0.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, // Fondo inferior (negro)
{{0, 255, 255}, {255, 0, 255}, {50, 205, 50}, {255, 255, 0}, {255, 20, 147}, {0, 255, 127}, {138, 43, 226}, {255, 69, 0}}},
// FOREST: Verdes, marrones, amarillos otoño
{144.0f / 255.0f, 238.0f / 255.0f, 144.0f / 255.0f, // Fondo superior (verde claro)
101.0f / 255.0f, 67.0f / 255.0f, 33.0f / 255.0f, // Fondo inferior (marrón tierra)
{{34, 139, 34}, {107, 142, 35}, {154, 205, 50}, {255, 215, 0}, {210, 180, 140}, {160, 82, 45}, {218, 165, 32}, {50, 205, 50}}},
// RGB: Colores RGB puros y subdivisiones matemáticas
{1.0f, 1.0f, 1.0f, // Fondo superior (blanco puro)
1.0f, 1.0f, 1.0f, // Fondo inferior (blanco puro) - sin degradado
{{255, 0, 0}, {0, 255, 0}, {0, 0, 255}, {255, 255, 0}, {0, 255, 255}, {255, 0, 255}, {128, 255, 128}, {255, 128, 128}}}
};
ThemeColors themes_[5];
// Batch rendering
std::vector<SDL_Vertex> batch_vertices_;
@@ -116,6 +95,7 @@ private:
void toggleFullscreen();
void toggleRealFullscreen();
std::string gravityDirectionToString(GravityDirection direction) const;
void initializeThemes();
// Sistema de zoom dinámico
int calculateMaxWindowZoom() const;