anitty/lib.rs
1//! Character animations rendered as RGBA frames and displayed in a terminal.
2//!
3//! [`SpriteAnimation`] supports frame sequences and regular RGBA sprite sheets.
4//! [`Iterm2`] preserves transparency in Konsole; [`Sixel`] provides solid-background
5//! output for SIXEL-capable terminals. [`Kitty`] sends RGBA to terminals supporting
6//! the Kitty graphics protocol.
7//! Applications own the clock, playback loop and terminal layout.
8//! [`TerminalProbe`] optionally queries capabilities when explicitly driven by
9//! the host; animation and backend APIs never start a probe themselves.
10//!
11//! ```no_run
12//! use std::{io, time::Duration};
13//! use anitty::{Animation, Backend, Sixel, SpriteAnimation};
14//!
15//! let image = image::open("character.webp")?.into_rgba8();
16//! let sheet = anitty::RgbaFrame::new(image.width(), image.height(), image.into_raw())?;
17//! let mut animation = SpriteAnimation::from_sheet(
18//! sheet, 64, 64, Duration::from_millis(100),
19//! )?;
20//! // A solid background paints over old frames. Use Iterm2 to preserve alpha;
21//! // Konsole replaces same-sized images at the same position without clearing.
22//! let mut backend = Sixel::new([0, 0, 0]);
23//! let mut output = io::stdout().lock();
24//! backend.draw(animation.render(Duration::ZERO, 64, 64)?, &mut output)?;
25//! // Advance time and draw at the same position to replace the previous frame.
26//! backend.draw(animation.render(Duration::from_millis(100), 64, 64)?, &mut output)?;
27//! # Ok::<(), anitty::Error>(())
28//! ```
29
30pub mod animation;
31mod error;
32mod frame;
33
34pub mod backend;
35pub mod terminal;
36
37pub use animation::{
38 Animation, Bounds, PlaybackMode, RenderMapping, RenderOptions, SpriteAnimation, SpriteClip,
39 Transform,
40};
41#[cfg(feature = "spine-38")]
42pub use animation::{SpineAnimation, SpineOptions};
43pub use backend::{Backend, Iterm2, Kitty, Sixel};
44pub use error::Error;
45pub use frame::RgbaFrame;
46pub use terminal::{Support, TerminalCapabilities, TerminalProbe};