anitty 0.1.0

Anime character animation rendering for terminals
Documentation
//! Terminal output consumes RGBA frames without knowing their animation source.

mod iterm2;
mod kitty;
mod sixel;

pub use iterm2::Iterm2;
pub use kitty::Kitty;
pub use sixel::Sixel;

use std::io::Write;

use crate::{Error, RgbaFrame};

/// Display frames at the current terminal cursor position.
///
/// The caller owns cursor positioning, terminal modes and backend selection,
/// and must serialize access to the output stream.
pub trait Backend {
    /// Draw a full frame and flush the writer, preserving the cursor position.
    ///
    /// Use a fixed canvas size and position for animation. The canvas must fit
    /// in the remaining terminal viewport to avoid scrolling or clipping.
    /// Transparent pixels may leave existing content visible; the caller owns
    /// clearing the previous frame when the backend cannot replace it directly.
    fn draw(&mut self, frame: &RgbaFrame, output: &mut dyn Write) -> Result<(), Error>;

    /// Release terminal resources owned by this backend after playback.
    ///
    /// Call this on the same output and terminal screen as `draw`, before
    /// leaving the screen. Backends without addressable resources do nothing;
    /// this is not a general screen-clear operation. Drawing again is allowed.
    fn finish(&mut self, _output: &mut dyn Write) -> Result<(), Error> {
        Ok(())
    }
}