1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
mod canvas; mod errors; mod renderer; use crate::renderer::AsciiColorMode; pub use crate::{ canvas::{AsciiCanvas, AsciiCanvasItem}, errors::{AsciiArtError, Result}, renderer::{AsciiData, AsciiSet}, }; use fontdue::Font; pub use image::{Luma, Rgb}; #[derive(Debug, Clone)] pub struct AsciiArt { pub pixel_aligned: bool, pub reverse_color: bool, pub font_size: f32, pub char_set: AsciiSet, pub color_mode: AsciiColorMode, } impl Default for AsciiArt { fn default() -> Self { Self { pixel_aligned: false, reverse_color: false, font_size: 16.0, char_set: Default::default(), color_mode: Default::default(), } } } pub fn get_ascii_art_set(name: &str, font: &Font) -> Option<AsciiArt> { let s = match name.to_lowercase().as_str() { "ascii" => "a", _ => return None, }; let mut ctx = AsciiArt::default(); ctx.build_font_cache(font, s); Some(ctx) }