Skip to main content

Crate bbcat

Crate bbcat 

Source
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.
AnimationFrame
One decoded animation frame.
ArchiveEntry
An artwork entry selected from a ZIP art pack.
Asciimation
A parsed asciimation.co.nz-style frame stream.
AsciimationFrame
One frame from an Asciimation stream.
Cell
One character and color pair in a decoded text-art screen.
DecodeOptions
Options that influence format selection and text dimensions during decoding.
Document
Decoded artwork and its optional metadata and animation frames.
DocumentInfo
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.
LetterSpacing
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_artworks cannot 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.