use std::io::{stdout, Write};
use crossterm::{
cursor::MoveTo,
queue,
style::{Color, Print, SetAttribute, SetBackgroundColor, SetForegroundColor},
terminal,
};
use crate::Config;
pub fn draw_base(config: &Config) {
let base_type = config.base;
let mut stdout = stdout();
let (cols, rows) = terminal::size().unwrap();
match base_type {
1 => {
let lines = [
":___________./~~~\\.___________:",
" \\ / ",
" \\_________________________/ ",
" (_) (_)",
];
let base_width = 31; let start_pos = (cols / 2) - (base_width / 2);
let y = rows - lines.len() as u16;
queue!(
stdout,
SetAttribute(crossterm::style::Attribute::Bold),
SetForegroundColor(Color::AnsiValue(8)),
SetBackgroundColor(Color::Reset),
MoveTo(start_pos, y),
Print(":"),
SetForegroundColor(Color::AnsiValue(2)),
Print("___________"),
SetForegroundColor(Color::AnsiValue(11)),
Print("./~~~\\."),
SetForegroundColor(Color::AnsiValue(2)),
Print("___________"),
SetAttribute(crossterm::style::Attribute::Bold),
SetForegroundColor(Color::AnsiValue(8)),
Print(":"),
MoveTo(start_pos, y + 1),
Print(" \\ / "),
MoveTo(start_pos, y + 2),
Print(" \\_________________________/ "),
MoveTo(start_pos, y + 3),
Print(" (_) (_)"),
)
.unwrap();
stdout.flush().unwrap();
}
2 => {
let base_width = 15; let start_pos = (cols / 2) - (base_width / 2);
let y = rows - 3;
queue!(
stdout,
SetAttribute(crossterm::style::Attribute::NormalIntensity), SetForegroundColor(Color::AnsiValue(8)),
SetBackgroundColor(Color::Reset),
MoveTo(start_pos, y),
Print("("),
SetForegroundColor(Color::AnsiValue(2)),
Print("---"),
SetForegroundColor(Color::AnsiValue(11)),
Print("./~~~\\."),
SetForegroundColor(Color::AnsiValue(2)),
Print("---"),
SetForegroundColor(Color::AnsiValue(8)),
Print(")"),
MoveTo(start_pos, y + 1),
Print(" ( ) "),
MoveTo(start_pos, y + 2),
Print(" (_________) "),
)
.unwrap();
stdout.flush().unwrap();
}
_ => {}
}
}