Expand description
Decode and render ANSI and BBS artwork.
Every supported input is decoded into a Screen. Character formats fill
its grid of Cell values; TundraDraw additionally carries per-cell RGB
colors, while RIPscrip fills its indexed-color raster instead.
The text, PNG, and Kitty writers therefore do not need to understand the
original file format.
Use decode when the input format can be detected from its contents. Pass
DecodeOptions::file_name when a file extension should disambiguate ADF,
DDW, RIPscrip, or TundraDraw input, and DecodeOptions::width to override
the inferred text width.
ZIP art packs can be inspected with extract_archive_preview or
list_archive_artworks, and a named entry can be read with
extract_archive_artwork before passing it to decode_with_options.
use bbcat::{DecodeOptions, Format};
use std::path::Path;
let data = b"\x1b[31mANSI art";
let document = bbcat::decode_with_options(
data,
DecodeOptions {
file_name: Some(Path::new("demo.ans")),
width: Some(80),
},
)?;
assert_eq!(document.format, Format::AnsiText);
assert_eq!(document.screen.width, 80);
let png = document.encode_png(1)?;
assert!(png.starts_with(b"\x89PNG\r\n\x1a\n"));Structs§
- Animation
- A decoded animation and its terminal cleanup behavior.
- Animation
Frame - One decoded animation frame.
- Archive
Entry - An artwork entry selected from a ZIP art pack.
- Asciimation
- A parsed asciimation.co.nz-style frame stream.
- Asciimation
Frame - One frame from an
Asciimationstream. - Cell
- One character and color pair in a decoded text-art screen.
- Decode
Options - Options that influence format selection and text dimensions during decoding.
- Document
- Decoded artwork and its optional metadata and animation frames.
- Document
Info - Summary of the information discovered while decoding a document.
- Error
- An error produced while decoding or encoding artwork.
- Raster
- An indexed-color pixel canvas produced by a raster format such as RIPscrip.
- Sauce
- Metadata decoded from a SAUCE trailer or equivalent format metadata.
- Screen
- A decoded character grid or indexed raster shared by all input formats.
Enums§
- Format
- The source format represented by a decoded
Document. - Letter
Spacing - Horizontal VGA character-cell spacing declared by SAUCE.
Constants§
- DEFAULT_
ANIMATION_ BAUD - Default ANSI playback rate and the baseline for native frame timing.
- VGA_
PALETTE - The default 16-color VGA palette as RGB triples.
- XTERM_
256_ PALETTE - The xterm 256-color palette, using VGA-compatible values for its first 16 entries and the standard color cube and grayscale ramp for the remainder.
Functions§
- decode
- Decodes artwork using content-based format detection and inferred dimensions.
- decode_
asciimation - Decodes an explicit asciimation.co.nz-style text stream.
- decode_
with_ options - Decodes artwork with optional filename and width hints.
- encode_
animation_ apng - Encodes decoded animation frames as a looping indexed-color APNG.
- encode_
animation_ gif - Encodes decoded animation frames as a looping indexed-color GIF.
- encode_
screen - Encodes a contiguous range of character rows as a PNG.
- encode_
screen_ fit - Encodes the complete screen within a pixel bounding box while preserving its aspect ratio. Screens already inside the bounds are not enlarged.
- encode_
screen_ scaled - Encodes character rows as a PNG at an integer scale.
- extract_
archive_ artwork - Extracts a supported ANSI/BBS artwork entry by its exact, case-sensitive ZIP
entry name. Entries omitted by
list_archive_artworkscannot be extracted. - extract_
archive_ preview - Extracts the preferred ANSI/BBS preview entry from a ZIP art pack.
- is_zip
- Returns whether bytes begin with a recognized ZIP record signature.
- list_
archive_ artworks - Lists supported ANSI/BBS artwork entry names in a ZIP art pack.
- parse_
asciimation - Parses an explicit asciimation.co.nz-style text stream.
- render
- Decodes artwork with an optional width override.
- render_
named - Decodes artwork with filename and optional width hints.
- write_
animation - Plays an animation at
DEFAULT_ANIMATION_BAUD. - write_
animation_ at_ baud - Plays an animation at the requested source-byte rate.
- write_
asciimation - Plays an asciimation stream to terminal output using its native timing.
- write_
screen - Writes a screen through the Kitty graphics protocol in vertical chunks.
- write_
screen_ cropped - Writes Kitty graphics cropped to a terminal column count.
- write_
screen_ fit - Fits the complete screen within a terminal column count and writes it.
- write_
screen_ scaled - Writes Kitty graphics at an integer pixel scale.
- write_
screen_ scaled_ cropped - Writes scaled Kitty graphics cropped to a terminal column count.
- write_
screen_ scaled_ fit - Fits and writes the complete screen after applying an integer scale.
- write_
screen_ slow - Writes one Kitty image per character row with a delay between rows.
- write_
screen_ slow_ cropped - Slowly writes Kitty graphics cropped to a terminal column count.
- write_
screen_ slow_ fit - Slowly writes Kitty graphics fitted to a terminal column count.
- write_
screen_ slow_ scaled - Slowly writes Kitty graphics at an integer pixel scale.
- write_
screen_ slow_ scaled_ cropped - Slowly writes scaled Kitty graphics cropped to terminal columns.
- write_
screen_ slow_ scaled_ fit - Slowly writes scaled Kitty graphics fitted to terminal columns.
- write_
text - Writes a complete character screen as UTF-8 with ANSI colors.
- write_
text_ cropped - Writes UTF-8 text cropped to a maximum character-column count.
- write_
text_ slow - Writes UTF-8 text one character row at a time with a delay.
- write_
text_ slow_ cropped - Slowly writes UTF-8 text cropped to a maximum column count.
Type Aliases§
- Result
- The result type used by bbcat’s high-level library API.