feat(firework): halo neon per partícula amb color de glow propi (explosió enemic: línia blanca + halo daurat)
This commit is contained in:
@@ -29,6 +29,22 @@ namespace Defaults::FX::Glow {
|
||||
{.thickness_ratio = -1.0F, .alpha = 1.0F}, // core: línia "real"
|
||||
};
|
||||
|
||||
// Glow per a línies "raw" (sense shape). Gruixos absoluts (px), no
|
||||
// ratios — una línia individual no té bounding radius. Útil per a
|
||||
// partícules de firework, sparks, etc.
|
||||
namespace Line {
|
||||
struct Pass {
|
||||
float thickness; // px. <0 → usa el thickness passat pel caller (core)
|
||||
float alpha;
|
||||
};
|
||||
constexpr Pass PASSES[] = {
|
||||
{.thickness = 18.0F, .alpha = 0.10F},
|
||||
{.thickness = 12.0F, .alpha = 0.20F},
|
||||
{.thickness = 6.0F, .alpha = 0.40F},
|
||||
{.thickness = -1.0F, .alpha = 1.0F}, // core: línia "real"
|
||||
};
|
||||
} // namespace Line
|
||||
|
||||
} // namespace Defaults::FX::Glow
|
||||
|
||||
namespace Defaults::FX::Firework {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "core/rendering/line_renderer.hpp"
|
||||
|
||||
#include "core/defaults.hpp"
|
||||
#include "core/defaults/effects.hpp"
|
||||
|
||||
namespace Rendering {
|
||||
|
||||
@@ -46,6 +47,27 @@ namespace Rendering {
|
||||
renderer->pushLine(FX1, FY1, FX2, FY2, W, R, G, B, alpha);
|
||||
}
|
||||
|
||||
void lineaGlow(Renderer* renderer,
|
||||
int x1,
|
||||
int y1,
|
||||
int x2,
|
||||
int y2,
|
||||
float brightness,
|
||||
float thickness,
|
||||
SDL_Color color,
|
||||
SDL_Color glow_color) {
|
||||
// Color dels passes de halo: si glow_color té alpha>0, l'usem;
|
||||
// altrament fem servir el color de la línia.
|
||||
const SDL_Color HALO_COLOR = (glow_color.a > 0) ? glow_color : color;
|
||||
|
||||
for (const auto& pass : Defaults::FX::Glow::Line::PASSES) {
|
||||
const bool IS_CORE = pass.thickness < 0.0F;
|
||||
const float PASS_T = IS_CORE ? thickness : pass.thickness;
|
||||
const SDL_Color PASS_C = IS_CORE ? color : HALO_COLOR;
|
||||
linea(renderer, x1, y1, x2, y2, brightness, PASS_T, PASS_C, pass.alpha);
|
||||
}
|
||||
}
|
||||
|
||||
void setLineColor(SDL_Color color) { g_current_line_color = color; }
|
||||
|
||||
auto getLineColor() -> SDL_Color { return g_current_line_color; }
|
||||
|
||||
@@ -34,6 +34,21 @@ namespace Rendering {
|
||||
SDL_Color color = {0, 0, 0, 0},
|
||||
float alpha = 1.0F);
|
||||
|
||||
// Versió amb halo neon: dibuixa la línia amb diversos passos de gruix
|
||||
// creixent i alfa decreixent (config a Defaults::FX::Glow::Line::PASSES).
|
||||
// El core (últim pass) usa el thickness/alpha que passa el caller.
|
||||
// glow_color: si alpha>0, els passes de halo usen aquest color en lloc
|
||||
// del color de la línia (p.ex. línia blanca amb halo daurat).
|
||||
void lineaGlow(Renderer* renderer,
|
||||
int x1,
|
||||
int y1,
|
||||
int x2,
|
||||
int y2,
|
||||
float brightness = 1.0F,
|
||||
float thickness = 0.0F,
|
||||
SDL_Color color = {0, 0, 0, 0},
|
||||
SDL_Color glow_color = {0, 0, 0, 0});
|
||||
|
||||
// Color global de las líneas (lo actualiza ColorOscillator vía SDLManager).
|
||||
void setLineColor(SDL_Color color);
|
||||
[[nodiscard]] auto getLineColor() -> SDL_Color;
|
||||
|
||||
Reference in New Issue
Block a user