#ascii-art #convert-text #text-image #string

bin+lib text-to-ascii-art

A simple program to convert text to ASCII art

7 releases

0.1.10 Jul 17, 2024
0.1.9 Jul 16, 2023
0.1.4 Jun 28, 2023

#298 in Text processing

Download history 10/week @ 2024-07-08 141/week @ 2024-07-15 24/week @ 2024-07-22 35/week @ 2024-07-29 12/week @ 2024-08-05 8/week @ 2024-08-12 4/week @ 2024-08-19 14/week @ 2024-08-26 9/week @ 2024-09-02 46/week @ 2024-09-09 35/week @ 2024-09-16 50/week @ 2024-09-23 51/week @ 2024-09-30 5/week @ 2024-10-07 19/week @ 2024-10-14

128 downloads per month
Used in leetcode-cli-rs

MIT license

155KB
2.5K SLoC

Usage

Provides some functions for working with and creating ascii art from simple text.


Convert text and symbols into ascii art

fn to_art (input: String, leading: usize, gap: usize, trailing: usize) -> Result<String, String>

To align the art within some space, please use align function with Alignment enum width parameter represents space for your art that will be aligned inside it

fn align(art: &str, alignment: Alignment, width: usize) -> String

Join 2 ascii art images together (they both need to be same width and height rectangle to work, add spaces to the end so it's rectangle)

gap parameter sets number of spaces between arts to be joined

fn join_art (s1: &str, s2: &str, gap: usize) -> String

If you run this crate, it will print ascii symbols with 'small' named font and waits you enter your own string for previewing

https://github.com/osmak1234/text-to-ascii-art/assets/91377215/ea937074-fdc6-4c67-839e-15d6854f0bee

Usage in Rust

main.rs

use textart::to_art;

fn main () {
  match to_art("Hello in ascii".to_string()) {
      Ok(string) => println!("{}", string),
      Err(err) => println!("Error: {}", err),
  }
}

Cargo.toml

[dependencies]
text-to-ascii-art="0.1.5"

Road map

  • kindof monospace
  • full monospace
  • add some more special characters
  • auto spacing for join art
  • better documentation

No runtime deps