rs3a 2.3.8

Animated ascii art rust library
Documentation

An animated ASCII art rust library, implementing the 3a format.
Features:

Used in

  • aaa – a TUI tool for rendering 3a files

Examples of 3a art

Other 3a implementations

Example

You can run this example with cargo run --example edit-and-export

use rs3a::{Art, font::Font, CSSColorMap};
use std::fs::File;
use std::io::Write;

fn main() {
    // Reading
    let mut art = Art::from_file("./examples/dna.3a").unwrap();

    // Add new color mapping
    let color_pair = "fg:black bg:yellow".parse().unwrap();
    let color = art.search_or_create_color_map(color_pair);

    // Editing example: add frame numbers
    for frame in 0..art.frames() {
        art.print(frame, 0, 0, &format!("{}", frame), Some(Some(color)));
    }

    // Saving
    art.to_file("./examples/edited_dna.3a").unwrap();

    // Exporting to SVG
    let mut output = File::create("./examples/dna.svg").unwrap();
    write!(
        output, "{}",
        art.to_svg_frames(&CSSColorMap::default(), &Font::default())
    ).unwrap();

    // Exporting to asciicast (asciinema format).
    // You can play it with `asciinema play examples/dna.cast`.
    let mut output = File::create("./examples/dna.cast").unwrap();
    write!(output, "{}", art.to_asciicast2()).unwrap();

    // Printing as ANSI colored frames to stdout
    for frame in art.to_ansi_frames() {
        println!("{}\n", frame);
    }
}

TODO

  • art optimisation
  • SVG render optimisation
  • conversion to
    • image
    • gif
    • video

License

This project is licensed under either of

at your option.