added glow

This commit is contained in:
2026-07-11 18:50:59 +03:00
parent 1c89b12d32
commit 26823609e7
5 changed files with 220 additions and 49 deletions
+25 -11
View File
@@ -42,16 +42,20 @@ namespace omath::hud
// ── Bars ─────────────────────────────────────────────────────────
EntityOverlay& add_right_bar(const widget::Paint& color, const Color& outline_color, const Color& bg_color,
float width, float ratio, float offset = 5.f);
float width, float ratio, float offset = 5.f,
const std::optional<widget::Glow>& glow = std::nullopt);
EntityOverlay& add_left_bar(const widget::Paint& color, const Color& outline_color, const Color& bg_color,
float width, float ratio, float offset = 5.f);
float width, float ratio, float offset = 5.f,
const std::optional<widget::Glow>& glow = std::nullopt);
EntityOverlay& add_top_bar(const widget::Paint& color, const Color& outline_color, const Color& bg_color,
float height, float ratio, float offset = 5.f);
float height, float ratio, float offset = 5.f,
const std::optional<widget::Glow>& glow = std::nullopt);
EntityOverlay& add_bottom_bar(const widget::Paint& color, const Color& outline_color, const Color& bg_color,
float height, float ratio, float offset = 5.f);
float height, float ratio, float offset = 5.f,
const std::optional<widget::Glow>& glow = std::nullopt);
EntityOverlay& add_right_dashed_bar(const Color& color, const Color& outline_color, const Color& bg_color,
float width, float ratio, float dash_len, float gap_len,
@@ -69,22 +73,26 @@ namespace omath::hud
// ── Labels ───────────────────────────────────────────────────────
EntityOverlay& add_right_label(const widget::Paint& color, float offset, widget::Outlined outlined,
const std::string_view& text);
const std::string_view& text,
const std::optional<widget::Glow>& glow = std::nullopt);
EntityOverlay& add_left_label(const widget::Paint& color, float offset, widget::Outlined outlined,
const std::string_view& text);
const std::string_view& text,
const std::optional<widget::Glow>& glow = std::nullopt);
EntityOverlay& add_top_label(const widget::Paint& color, float offset, widget::Outlined outlined,
std::string_view text);
std::string_view text, const std::optional<widget::Glow>& glow = std::nullopt);
EntityOverlay& add_bottom_label(const widget::Paint& color, float offset, widget::Outlined outlined,
std::string_view text);
std::string_view text, const std::optional<widget::Glow>& glow = std::nullopt);
EntityOverlay& add_centered_top_label(const widget::Paint& color, float offset, widget::Outlined outlined,
const std::string_view& text);
const std::string_view& text,
const std::optional<widget::Glow>& glow = std::nullopt);
EntityOverlay& add_centered_bottom_label(const widget::Paint& color, float offset, widget::Outlined outlined,
const std::string_view& text);
const std::string_view& text,
const std::optional<widget::Glow>& glow = std::nullopt);
template<typename... Args>
requires(sizeof...(Args) > 0)
@@ -253,7 +261,13 @@ namespace omath::hud
void dispatch(const widget::ProjectileAim& proj_widget);
void draw_progress_ring(const Vector2<float>& center, const widget::ProgressRing& ring);
void draw_label(const Vector2<float>& position, const widget::Paint& paint, widget::Outlined outlined,
const std::string_view& text);
const std::string_view& text, const std::optional<widget::Glow>& glow);
void draw_glow_polyline(const std::span<const Vector2<float>>& points, const widget::Glow& glow,
float thickness) const;
void draw_glow_line(const Vector2<float>& from, const Vector2<float>& to, const widget::Glow& glow,
float thickness) const;
void draw_glow_rectangle(const Vector2<float>& min, const Vector2<float>& max,
const std::optional<widget::Glow>& glow) const;
void draw_filled_rectangle(const Vector2<float>& min, const Vector2<float>& max,
const widget::Paint& paint) const;
void draw_dashed_line(const Vector2<float>& from, const Vector2<float>& to, const Color& color, float dash_len,
@@ -32,6 +32,13 @@ namespace omath::hud::widget
template<typename... Ts>
Overloaded(Ts...) -> Overloaded<Ts...>;
struct Glow
{
Color color;
float radius = 4.f;
float intensity = 1.f;
};
// ── Standalone widgets ────────────────────────────────────────────────────
struct Box
{
@@ -39,6 +46,7 @@ namespace omath::hud::widget
Paint fill{Color{0.f, 0.f, 0.f, 0.f}};
Color outline{0.f, 0.f, 0.f, 0.f};
float thickness = 1.f;
std::optional<Glow> glow = std::nullopt;
};
enum class Outlined
@@ -53,6 +61,7 @@ namespace omath::hud::widget
Color outline{0.f, 0.f, 0.f, 0.f};
float corner_ratio = 0.2f;
float thickness = 1.f;
std::optional<Glow> glow = std::nullopt;
};
struct DashedBox
@@ -114,6 +123,7 @@ namespace omath::hud::widget
float size;
float ratio;
float offset = 5.f;
std::optional<Glow> glow = std::nullopt;
};
/// A dashed bar. Same field semantics as Bar plus dash parameters.
@@ -135,6 +145,7 @@ namespace omath::hud::widget
float offset;
Outlined outlined;
std::string_view text;
std::optional<Glow> glow = std::nullopt;
};
/// Wraps a Label to request horizontal centering (only applied in TopSide / BottomSide).