use console_engine::pixel;
use console_engine::screen::Screen;
use std::iter::successors;
mod function;
mod graph;
mod multi_graph;
mod traits;
mod types;
pub use crate::function::*;
pub use crate::graph::*;
pub use crate::multi_graph::*;
pub use crate::traits::*;
pub use crate::types::*;
pub use console_engine::Color;
#[doc(hidden)]
fn draw<F: Fn(u32) -> u32>(f: F, character: Character) {
let width = 80;
let y: Vec<u32> = (0..=width).map(|x| f(x)).collect();
let max = *y.iter().max().unwrap_or(&0);
let min = *y.iter().max().unwrap_or(&0);
let height = max + 1;
let max_height_digits = successors(Some(height), |&n| (n >= 10).then(|| n / 10)).count() as u32;
let mut scr = Screen::new(width + 1 + max_height_digits, height + 1);
scr.h_line(
(max_height_digits + 1) as i32,
height as i32,
width as i32,
pixel::pxl('_'),
);
scr.v_line(max_height_digits as i32, 0, height as i32, pixel::pxl('|'));
for h in 0..=height {
for (index, digit) in h.to_string().chars().enumerate() {
scr.set_pxl(index as i32, (height - h) as i32, pixel::pxl(digit));
}
}
scr.draw();
}