const ROWS: usize = 5;
fn glyph(c: char) -> [&'static str; ROWS] {
match c {
'P' => ["####.", "#...#", "####.", "#....", "#...."],
'E' => ["#####", "#....", "###..", "#....", "#####"],
'R' => ["####.", "#...#", "####.", "#..#.", "#...#"],
'F' => ["#####", "#....", "###..", "#....", "#...."],
'C' => [".####", "#....", "#....", "#....", ".####"],
'T' => ["#####", "..#..", "..#..", "..#..", "..#.."],
'S' => [".####", "#....", ".###.", "....#", "####."],
'A' => [".###.", "#...#", "#####", "#...#", "#...#"],
_ => [".....", ".....", ".....", ".....", "....."],
}
}
pub fn banner(word: &str) -> [String; ROWS] {
let mut rows: [String; ROWS] = std::array::from_fn(|_| String::new());
for (i, letter) in word.chars().enumerate() {
if i > 0 {
for row in rows.iter_mut() {
row.push(' ');
}
}
let g = glyph(letter);
for (row, glyph_row) in rows.iter_mut().zip(g.iter()) {
row.extend(
glyph_row
.chars()
.map(|px| if px == '#' { '█' } else { ' ' }),
);
}
}
rows
}