From 487b7bbe3c767c95364fe304123ae75f76cb019e Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Fri, 11 Oct 2024 12:01:17 -0600 Subject: [PATCH] Update --- src/lib.rs | 2 ++ src/text_render.rs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index fafe9f5..02b5167 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -119,6 +119,8 @@ pub struct TextArea<'a> { pub bounds: TextBounds, /// The default color of the text area. pub default_color: Color, + /// The opacity of the text + pub opacity: f32, /// Additional custom glyphs to render. pub custom_glyphs: &'a [CustomGlyph], } diff --git a/src/text_render.rs b/src/text_render.rs index a4b45cf..c9dc5f2 100644 --- a/src/text_render.rs +++ b/src/text_render.rs @@ -246,6 +246,12 @@ impl TextRenderer { Some(some) => some, None => text_area.default_color, }; + let color = Color::rgba( + (color.r() as f32 * text_area.opacity + 0.5) as u8, + (color.g() as f32 * text_area.opacity + 0.5) as u8, + (color.b() as f32 * text_area.opacity + 0.5) as u8, + (color.a() as f32 * text_area.opacity + 0.5) as u8, + ); if let Some(glyph_to_render) = prepare_glyph( physical_glyph.x,