diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -839,19 +839,26 @@ pub struct Fade to: Palette, hz: u8, duration: Duration, + clear: bool, } impl Fade { - pub fn new(from: Palette, to: Palette, duration: Duration, hz: u8) -> Self + pub fn new( + from: Palette, + to: Palette, + duration: Duration, + hz: u8, + clear: bool, + ) -> Self { let hz = if hz == 0 { 1 } else { hz }; - Self { from, to, hz, duration } + Self { from, to, hz, duration, clear } } pub fn commence(self, con: &Console) -> io::Result<()> { - let Self { from, to, hz, duration } = self; + let Self { from, to, hz, duration, clear } = self; con.apply_palette(&from)?; let fade = FadePalette::from(&con.current_palette()?); @@ -866,6 +873,9 @@ impl Fade let progress = f64::from(i) / f64::from(iters); let pal = Palette::from(&fade.towards(&fade_to, progress)); con.apply_palette(&pal)?; + if clear { + con.clear()?; + } let next = i * tick; std::thread::sleep(next.saturating_sub(t_0.elapsed())); } |