diff --git a/src/lib.rs b/src/lib.rs index 0ab9ffb..5e6b452 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,12 +9,14 @@ use tui::widgets::{Block, Widget}; pub enum ColorMode { Luma, Rgb, + Rgba, } const BLOCK_LIGHT: char = '\u{2591}'; const BLOCK_MEDIUM: char = '\u{2592}'; const BLOCK_DARK: char = '\u{2593}'; const BLOCK_FULL: char = '\u{2588}'; +const EMPTY: char = ' '; /// A tui-rs Widget which displays an image. pub struct Image<'a> { @@ -151,6 +153,17 @@ impl<'a> Image<'a> { (255.0 * b) as u8, )); } + ColorMode::Rgba => { + if a == 0. { + cell.set_char(EMPTY); + } else { + cell.set_char(BLOCK_FULL).set_fg(Color::Rgb( + (255.0 * r) as u8, + (255.0 * g) as u8, + (255.0 * b) as u8, + )); + } + } } } }