Add opacity

This commit is contained in:
Isaac Mills 2024-03-18 18:30:28 -04:00
parent 4590abae08
commit 01ab64704b
Signed by: fnmain
GPG key ID: B67D7410F33A0F61
3 changed files with 11 additions and 2 deletions

View file

@ -10,8 +10,8 @@ license = "MIT OR Apache-2.0 OR Zlib"
[dependencies]
wgpu = "0.19"
etagere = "0.2.10"
cosmic-text = "0.10"
lru = "0.12.1"
cosmic-text = "0.11.2"
[dev-dependencies]
winit = { version = "0.29.10", features = ["rwh_05"] }

View file

@ -111,6 +111,8 @@ pub struct TextArea<'a> {
/// The visible bounds of the text area. This is used to clip the text and doesn't have to
/// match the `left` and `top` values.
pub bounds: TextBounds,
// The default color of the text area.
/// The default color of the text area.
pub default_color: Color,
/// The opacity to set the text area to (in gamma space)
pub opacity: f32,
}

View file

@ -268,6 +268,13 @@ impl TextRenderer {
None => text_area.default_color,
};
let color = cosmic_text::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,
);
let depth = metadata_to_depth(glyph.metadata);
glyph_vertices.extend(