use image::{DynamicImage, Rgba};
use imageproc::drawing;
use once_cell::sync::Lazy;
use rusttype::Font;
use crate::utils;
static FONT: Lazy<Font<'static>> = Lazy::new(|| {
let font_data = include_bytes!("fonts/PublicSans-Regular.ttf");
let font = Font::try_from_bytes(font_data).expect("font should load");
font
});
const COLOR: Rgba<u8> = Rgba([255, 255, 255, 255]);
pub fn draw(img: &mut DynamicImage, via: &str) {
let side_length = img.height();
let max_w = 5 * side_length / 6;
let max_h = side_length / 60;
let (scale, text_w, _) = utils::text_size(&FONT, max_w, max_h, via);
let text_x = (side_length - text_w) / 2;
let text_y = 19 * side_length / 20;
drawing::draw_text_mut(
img,
COLOR,
text_x.try_into().unwrap(),
text_y.try_into().unwrap(),
scale,
&FONT,
via,
);
}