Add opacity
This commit is contained in:
parent
4590abae08
commit
01ab64704b
3 changed files with 11 additions and 2 deletions
|
@ -10,8 +10,8 @@ license = "MIT OR Apache-2.0 OR Zlib"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
wgpu = "0.19"
|
wgpu = "0.19"
|
||||||
etagere = "0.2.10"
|
etagere = "0.2.10"
|
||||||
cosmic-text = "0.10"
|
|
||||||
lru = "0.12.1"
|
lru = "0.12.1"
|
||||||
|
cosmic-text = "0.11.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
winit = { version = "0.29.10", features = ["rwh_05"] }
|
winit = { version = "0.29.10", features = ["rwh_05"] }
|
||||||
|
|
|
@ -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
|
/// 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.
|
/// match the `left` and `top` values.
|
||||||
pub bounds: TextBounds,
|
pub bounds: TextBounds,
|
||||||
// The default color of the text area.
|
/// The default color of the text area.
|
||||||
pub default_color: Color,
|
pub default_color: Color,
|
||||||
|
/// The opacity to set the text area to (in gamma space)
|
||||||
|
pub opacity: f32,
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,6 +268,13 @@ impl TextRenderer {
|
||||||
None => text_area.default_color,
|
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);
|
let depth = metadata_to_depth(glyph.metadata);
|
||||||
|
|
||||||
glyph_vertices.extend(
|
glyph_vertices.extend(
|
||||||
|
|
Loading…
Reference in a new issue