added vertical rendering helper and androgyne flag

This commit is contained in:
Valerie Wolfe 2024-02-12 18:38:32 -05:00
parent 5ee70eec05
commit 1f09997694
3 changed files with 42 additions and 2 deletions

View file

@ -151,6 +151,18 @@ pub fn progress(small: bool) -> Flag {
// everything below this point is in alphabetical order // everything below this point is in alphabetical order
pub fn androgyne(small: bool) -> Flag {
let magenta = rgb(0xFE007F);
let purple = rgb(0x9832FF);
let cyan = rgb(0x00B8E7);
let (width, height) = if small { (15, 5) } else { terminal_size().unwrap() };
let lines = draw::fg_vstripes(vec![magenta, purple, cyan], width, height);
Flag::Lines(lines)
}
pub fn aroace(small: bool) -> Flag { pub fn aroace(small: bool) -> Flag {
// pull colors from aro & ace stripe flags // pull colors from aro & ace stripe flags
let Flag::Stripes(aro) = flag::aromantic() else { panic!() }; let Flag::Stripes(aro) = flag::aromantic() else { panic!() };

View file

@ -13,7 +13,10 @@ use termion::{
}; };
use crate::{ use crate::{
color::{ RESET, RESET_BG }, color::{
RESET, RESET_BG,
Colors
},
flag::Flag flag::Flag
}; };
@ -48,7 +51,7 @@ pub fn draw_lines(lines: Vec<String>, hold: bool) {
} }
/// generates lines for foreground colors provided as a vec of strings for the draw_lines method /// generates lines for foreground colors provided as a vec of strings for the draw_lines method
pub fn fg_stripes(colors: Vec<Fg<Rgb>>, width: u16, height: u16) -> Vec<String> { pub fn fg_stripes(colors: Colors, width: u16, height: u16) -> Vec<String> {
let width = width as usize; let width = width as usize;
let height = height as usize; let height = height as usize;
let count = colors.len(); let count = colors.len();
@ -96,6 +99,28 @@ pub fn bg_stripes(colors: Vec<Bg<Rgb>>, width: u16, height: u16) -> Vec<String>
output output
} }
pub fn fg_vstripes(colors: Colors, width: u16, height: u16) -> Vec<String> {
let width = width as usize;
let height = height as usize;
let count = colors.len();
let thresh = width / count;
let mut output = Vec::new();
let section = BLOCK.repeat(thresh);
let mut line = "".to_owned();
for i in 0..count {
let color = colors[i];
line += &format!("{color}{section}");
}
for _ in 0..height {
output.push(line.to_string());
}
output
}
impl Flag { impl Flag {
/// renders a flag to stdout /// renders a flag to stdout
pub fn draw(self, hold: bool) { pub fn draw(self, hold: bool) {

View file

@ -78,6 +78,9 @@ fn main() {
Some("agender") Some("agender")
=> flag::agender(), => flag::agender(),
Some("androgyne")
=> complex::androgyne(small),
Some("aromantic" | "aro") Some("aromantic" | "aro")
=> flag::aromantic(), => flag::aromantic(),