Add color inverting support
This commit is contained in:
parent
9707e9c6cf
commit
675f627c9c
2 changed files with 10 additions and 4 deletions
|
@ -121,6 +121,8 @@ pub struct TextArea<'a> {
|
|||
pub default_color: Color,
|
||||
/// The opacity of the text
|
||||
pub opacity: f32,
|
||||
/// The amount to invert the color
|
||||
pub invert: f32,
|
||||
/// Additional custom glyphs to render.
|
||||
pub custom_glyphs: &'a [CustomGlyph],
|
||||
}
|
||||
|
|
|
@ -247,10 +247,14 @@ impl TextRenderer {
|
|||
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,
|
||||
((text_area.invert - color.r() as f32).abs() * text_area.opacity + 0.5)
|
||||
as u8,
|
||||
((text_area.invert - color.g() as f32).abs() * text_area.opacity + 0.5)
|
||||
as u8,
|
||||
((text_area.invert - color.b() as f32).abs() * text_area.opacity + 0.5)
|
||||
as u8,
|
||||
((text_area.invert - color.a() as f32).abs() * text_area.opacity + 0.5)
|
||||
as u8,
|
||||
);
|
||||
|
||||
if let Some(glyph_to_render) = prepare_glyph(
|
||||
|
|
Loading…
Reference in a new issue