From 1f09997694ff684b8ec5131db8f10b61cf9ed1ec Mon Sep 17 00:00:00 2001 From: Valerie Date: Mon, 12 Feb 2024 18:38:32 -0500 Subject: [PATCH] added vertical rendering helper and androgyne flag --- src/complex.rs | 12 ++++++++++++ src/draw.rs | 29 +++++++++++++++++++++++++++-- src/main.rs | 3 +++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/complex.rs b/src/complex.rs index 0eb0c01..69a3006 100644 --- a/src/complex.rs +++ b/src/complex.rs @@ -151,6 +151,18 @@ pub fn progress(small: bool) -> Flag { // 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 { // pull colors from aro & ace stripe flags let Flag::Stripes(aro) = flag::aromantic() else { panic!() }; diff --git a/src/draw.rs b/src/draw.rs index 3ebf02f..33204fa 100644 --- a/src/draw.rs +++ b/src/draw.rs @@ -13,7 +13,10 @@ use termion::{ }; use crate::{ - color::{ RESET, RESET_BG }, + color::{ + RESET, RESET_BG, + Colors + }, flag::Flag }; @@ -48,7 +51,7 @@ pub fn draw_lines(lines: Vec, hold: bool) { } /// generates lines for foreground colors provided as a vec of strings for the draw_lines method -pub fn fg_stripes(colors: Vec>, width: u16, height: u16) -> Vec { +pub fn fg_stripes(colors: Colors, width: u16, height: u16) -> Vec { let width = width as usize; let height = height as usize; let count = colors.len(); @@ -96,6 +99,28 @@ pub fn bg_stripes(colors: Vec>, width: u16, height: u16) -> Vec output } +pub fn fg_vstripes(colors: Colors, width: u16, height: u16) -> Vec { + 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 { /// renders a flag to stdout pub fn draw(self, hold: bool) { diff --git a/src/main.rs b/src/main.rs index cada741..65c2021 100644 --- a/src/main.rs +++ b/src/main.rs @@ -78,6 +78,9 @@ fn main() { Some("agender") => flag::agender(), + Some("androgyne") + => complex::androgyne(small), + Some("aromantic" | "aro") => flag::aromantic(),