diff --git a/src/complex.rs b/src/complex.rs index 901f003..96d18bb 100644 --- a/src/complex.rs +++ b/src/complex.rs @@ -6,9 +6,11 @@ use termion::{ color::{ Bg, Rgb } }; -use crate::color::*; -use crate::draw::{ self, Flag }; -use crate::flag; +use crate::{ + color::*, + draw, + flag::{ self, Flag } +}; /// vertically stacking eighths pub static V_EIGHTH: [char; 7] = ['▁', '▂', '▃', '▄', '▅', '▆', '▇']; @@ -39,7 +41,7 @@ pub fn progress(small: bool) -> Flag { let pink: u32 = 0xEAACB8; let white: u32 = 0xFFFFFF; - let (height, width) = if small { (6, 18) } else { terminal_size().unwrap() }; + let (width, height) = if small { (18, 6) } else { terminal_size().unwrap() }; // create color slices and line buffer let stripes = [red, orange, yellow, green, blue, purple]; @@ -77,6 +79,7 @@ pub fn progress(small: bool) -> Flag { // get this line's depth? // get chevron start: (full_depth - line_depth) / chevron_width = chevron_start + let start: i16 = 2 - (n as i16); // for chevron_index in chevron_start..5 // if chevron_index = 4, draw stripe after (stripe width = width - line_depth - 1) @@ -107,10 +110,34 @@ pub fn progress(small: bool) -> Flag { // everything below this point is in alphabetical order -pub fn aroace() { - let aro = flag::aromantic(); - let ace = flag::asexual(); +pub fn aroace(small: bool) -> Flag { + // pull colors from aro & ace stripe flags + let Flag::Stripes(aro) = flag::aromantic() else { panic!() }; + let Flag::Stripes(ace) = flag::asexual() else { panic!() }; + let (width, height) = if small { (60, 20) } else { terminal_size().unwrap() }; + + let mut lines: Vec = Vec::new(); + + // set up constraints + let linecount = height - (height % 20); + let aro_thresh = linecount / 5; // threshold for aromantic colors + let ace_thresh = linecount / 4; // threshold for asexual colors + let stripe = draw::BLOCK.repeat((width / 2) as usize); + + let mut aro_index = 0; + let mut ace_index = 0; + for n in 0..linecount { + // switch colors on thresholds + if n != 0 { + if n % aro_thresh == 0 { aro_index += 1; } + if n % ace_thresh == 0 { ace_index += 1; } + } + let line = format!("{}{stripe}{}{stripe}", aro[aro_index], ace[ace_index]); + lines.push(line); + } + + Flag::Lines(lines) } fn demi_orientation_render(middle: Bg, bottom: Bg, width: u16, height: u16) -> Vec { diff --git a/src/draw.rs b/src/draw.rs index 6e6de37..edfc164 100644 --- a/src/draw.rs +++ b/src/draw.rs @@ -10,58 +10,14 @@ use termion::{ raw::IntoRawMode }; -use crate::color::{ RESET, RESET_BG, Colors }; +use crate::{ + color::{ RESET, RESET_BG }, + flag::Flag +}; pub static BLOCK: &str = "█"; pub static UHALF: &str = "▀"; -pub fn full(colors: Colors) { - let mut stdout = io::stdout().into_raw_mode().unwrap(); - let stdin = io::stdin(); - - let count = colors.len(); - let (width, height) = terminal_size().unwrap(); - let thresh = height as usize / count; - - write!(stdout, "{}{}", cursor::Hide, clear::All).ok(); - stdout.flush().ok(); - - let stripe = BLOCK.repeat(width as usize); - - let mut index = 0; - for n in 0..(height as usize) { - if n != 0 && n % thresh == 0 { - index += 1; - if index >= count { break; } - } - write!( - stdout, - "{color}{stripe}{RESET}", - color = colors[index] - ).ok(); - } - stdout.flush().ok(); - - for _ in stdin.keys() { break; } - write!(stdout, "{}{}", cursor::Show, clear::All).ok(); - stdout.flush().ok(); -} - -pub fn small(colors: Colors) { - let mut stdout = io::stdout(); - - let count = colors.len(); - let width = count * 3; - - let stripe = BLOCK.repeat(width); - - for color in colors { - println!("{color}{stripe}"); - } - print!("{RESET}"); - stdout.flush().ok(); -} - pub fn draw_lines(lines: Vec, hold: bool) { let mut stdout = io::stdout().into_raw_mode().unwrap(); @@ -133,10 +89,6 @@ pub fn bg_stripes(colors: Vec>, width: u16, height: u16) -> Vec output } -pub enum Flag { - Stripes(Colors), - Lines(Vec) -} impl Flag { pub fn draw(self, hold: bool) { let lines = match self { diff --git a/src/flag.rs b/src/flag.rs index ca1e62c..e4c28c0 100644 --- a/src/flag.rs +++ b/src/flag.rs @@ -1,6 +1,11 @@ use crate::color::*; -use crate::draw::Flag; + +pub enum Flag { + Stripes(Colors), + Lines(Vec) +} + pub fn pride() -> Flag { let red = rgb(0xE50000); diff --git a/src/main.rs b/src/main.rs index 9d1c208..6fd10ec 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,7 @@ mod draw; mod flag; mod variant; -use crate::draw::Flag; +use crate::flag::Flag; static VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -67,8 +67,8 @@ fn main() { Some("asexual" | "ace") => flag::asexual(), -// Some("aroace" | "aromantic-asexual") -// => complex::aroace(), + Some("aroace" | "aromantic-asexual") + => complex::aroace(small), Some("bigender") => flag::bigender(), @@ -145,7 +145,7 @@ fn list_text() { println!(" agender agender pride flag"); println!(" aro, aromantic aromantic pride flag"); println!(" ace, asexual asexual pride flag"); -// println!(" aroace aromantic/asexual pride flag"); + println!(" aroace aromantic/asexual pride flag"); println!(" bigender bigender pride flag"); println!(" bi, bisexual bisexual pride flag"); println!(" demiromantic demiromantic pride flag"); diff --git a/src/variant.rs b/src/variant.rs index daa2076..2dbd8fb 100644 --- a/src/variant.rs +++ b/src/variant.rs @@ -1,8 +1,7 @@ use crate::{ color::*, - draw::Flag, - flag + flag::{ self, Flag } }; pub fn gilbert_baker() -> Flag {