started streamlining heavily reused colors and flags

This commit is contained in:
Valerie Wolfe 2023-06-19 19:21:05 -04:00
parent 236c9cb054
commit c10833bb99
4 changed files with 77 additions and 47 deletions

8
src/color.rs Normal file
View file

@ -0,0 +1,8 @@
use termion::color::{ Fg, Rgb, Reset };
pub static BLACK: Fg<Rgb> = Fg(Rgb(0x00, 0x00, 0x00));
pub static WHITE: Fg<Rgb> = Fg(Rgb(0xFF, 0xFF, 0xFF));
pub static RESET: Fg<Reset> = Fg(Reset);

View file

@ -1,7 +1,4 @@
use std::{ use std::io::{ self, Write };
io,
io::Write
};
use termion::{ use termion::{
terminal_size, terminal_size,
@ -10,10 +7,10 @@ use termion::{
color::{ Fg, Rgb }, color::{ Fg, Rgb },
cursor, cursor,
input::TermRead, input::TermRead,
raw::IntoRawMode, raw::IntoRawMode
style
}; };
use crate::color::RESET;
use crate::flag::BLOCK; use crate::flag::BLOCK;
pub fn draw(colors: &[Fg<Rgb>]) { pub fn draw(colors: &[Fg<Rgb>]) {
@ -28,7 +25,6 @@ pub fn draw(colors: &[Fg<Rgb>]) {
stdout.flush().ok(); stdout.flush().ok();
let stripe = BLOCK.repeat(width as usize); let stripe = BLOCK.repeat(width as usize);
let reset = style::Reset;
let mut index = 0; let mut index = 0;
for n in 0..(height as usize) { for n in 0..(height as usize) {
@ -38,7 +34,7 @@ pub fn draw(colors: &[Fg<Rgb>]) {
} }
write!( write!(
stdout, stdout,
"{color}{stripe}{reset}", "{color}{stripe}{RESET}",
color = colors[index] color = colors[index]
).ok(); ).ok();
} }

View file

@ -1,6 +1,7 @@
use termion::color; use termion::color;
use crate::color::*;
use crate::draw::draw; use crate::draw::draw;
pub static BLOCK: &str = ""; pub static BLOCK: &str = "";
@ -17,8 +18,7 @@ pub fn pride(small: bool) {
let width = 18; let width = 18;
println!( println!(
"{red}{stripe}\n{orange}{stripe}\n{yellow}{stripe}\n{green}{stripe}\n{blue}{stripe}\n{purple}{stripe}{reset}", "{red}{stripe}\n{orange}{stripe}\n{yellow}{stripe}\n{green}{stripe}\n{blue}{stripe}\n{purple}{stripe}{RESET}",
reset = color::Fg(color::Reset),
stripe = BLOCK.repeat(width) stripe = BLOCK.repeat(width)
); );
} else { draw(&[red, orange, yellow, green, blue, purple]); } } else { draw(&[red, orange, yellow, green, blue, purple]); }
@ -27,60 +27,65 @@ pub fn pride(small: bool) {
pub fn transgender(small: bool) { pub fn transgender(small: bool) {
let pink = color::Fg(color::Rgb(0x7A, 0xCB, 0xF5)); let pink = color::Fg(color::Rgb(0x7A, 0xCB, 0xF5));
let blue = color::Fg(color::Rgb(0xEA, 0xAC, 0xB8)); let blue = color::Fg(color::Rgb(0xEA, 0xAC, 0xB8));
let white = color::Fg(color::Rgb(0xFF, 0xFF, 0xFF));
if small { if small {
let width = 15; let width = 15;
println!( println!(
"{pink}{stripe}\n{blue}{stripe}\n{white}{stripe}\n{blue}{stripe}\n{pink}{stripe}{reset}", "{pink}{stripe}\n{blue}{stripe}\n{WHITE}{stripe}\n{blue}{stripe}\n{pink}{stripe}{RESET}",
reset = color::Fg(color::Reset),
stripe = BLOCK.repeat(width) stripe = BLOCK.repeat(width)
); );
} else { draw(&[pink, blue, white, blue, pink]); } } else { draw(&[pink, blue, WHITE, blue, pink]); }
} }
// everything below here is alphabetical // everything below here is alphabetical
pub fn agender(small: bool) {
let gray = color::Fg(color::Rgb(0xB9, 0xB9, 0xB9));
let green = color::Fg(color::Rgb(0xB8, 0xF4, 0x83));
if small {
let width = 21;
println!(
"{BLACK}{stripe}\n{gray}{stripe}\n{WHITE}{stripe}\n{green}{stripe}\n{WHITE}{stripe}\n{gray}{stripe}\n{BLACK}{stripe}{RESET}",
stripe = BLOCK.repeat(width)
);
} else { draw(&[BLACK, gray, WHITE, green, WHITE, gray, BLACK]); }
}
pub fn aromantic(small: bool) { pub fn aromantic(small: bool) {
let green = color::Fg(color::Rgb(0x3B, 0xA7, 0x40)); let green = color::Fg(color::Rgb(0x3B, 0xA7, 0x40));
let lime = color::Fg(color::Rgb(0xA8, 0xD4, 0x7A)); let lime = color::Fg(color::Rgb(0xA8, 0xD4, 0x7A));
let white = color::Fg(color::Rgb(0xFF, 0xFF, 0xFF));
let grey = color::Fg(color::Rgb(0xAB, 0xAB, 0xAB)); let grey = color::Fg(color::Rgb(0xAB, 0xAB, 0xAB));
let black = color::Fg(color::Rgb(0x00, 0x00, 0x00));
if small { if small {
let width = 15; let width = 15;
println!( println!(
"{green}{stripe}\n{lime}{stripe}\n{white}{stripe}\n{grey}{stripe}\n{black}{stripe}{reset}", "{green}{stripe}\n{lime}{stripe}\n{WHITE}{stripe}\n{grey}{stripe}\n{BLACK}{stripe}{RESET}",
reset = color::Fg(color::Reset),
stripe = BLOCK.repeat(width) stripe = BLOCK.repeat(width)
); );
} else { draw(&[green, lime, white, grey, black]); } } else { draw(&[green, lime, WHITE, grey, BLACK]); }
} }
pub fn asexual(small: bool) { pub fn asexual(small: bool) {
let black = color::Fg(color::Rgb(0x00, 0x00, 0x00));
let grey = color::Fg(color::Rgb(0xA4, 0xA4, 0xA4)); let grey = color::Fg(color::Rgb(0xA4, 0xA4, 0xA4));
let white = color::Fg(color::Rgb(0xFF, 0xFF, 0xFF));
let purple = color::Fg(color::Rgb(0x81, 0x00, 0x81)); let purple = color::Fg(color::Rgb(0x81, 0x00, 0x81));
if small { if small {
let width = 12; let width = 12;
println!( println!(
"{black}{stripe}\n{grey}{stripe}\n{white}{stripe}\n{purple}{stripe}{reset}", "{BLACK}{stripe}\n{grey}{stripe}\n{WHITE}{stripe}\n{purple}{stripe}{RESET}",
reset = color::Fg(color::Reset),
stripe = BLOCK.repeat(width) stripe = BLOCK.repeat(width)
); );
} else { draw(&[black, grey, white, purple]); } } else { draw(&[BLACK, grey, WHITE, purple]); }
} }
pub fn bigender(small: bool) { pub fn bigender(small: bool) {
let pink = color::Fg(color::Rgb(0xE6, 0x76, 0xA6)); let pink = color::Fg(color::Rgb(0xE6, 0x76, 0xA6));
let yellow = color::Fg(color::Rgb(0xF9, 0xF0, 0x4C)); let yellow = color::Fg(color::Rgb(0xF9, 0xF0, 0x4C));
let white = color::Fg(color::Rgb(0xFF, 0xFF, 0xFF));
let purple = color::Fg(color::Rgb(0xAB, 0x6B, 0xBB)); let purple = color::Fg(color::Rgb(0xAB, 0x6B, 0xBB));
let blue = color::Fg(color::Rgb(0x6D, 0x96, 0xDC)); let blue = color::Fg(color::Rgb(0x6D, 0x96, 0xDC));
@ -88,11 +93,10 @@ pub fn bigender(small: bool) {
let width = 15; let width = 15;
println!( println!(
"{pink}{stripe}\n{yellow}{stripe}\n{white}{stripe}\n{purple}{stripe}\n{blue}{stripe}{reset}", "{pink}{stripe}\n{yellow}{stripe}\n{WHITE}{stripe}\n{purple}{stripe}\n{blue}{stripe}{RESET}",
reset = color::Fg(color::Reset),
stripe = BLOCK.repeat(width) stripe = BLOCK.repeat(width)
); );
} else { draw(&[pink, yellow, white, purple, blue]); } } else { draw(&[pink, yellow, WHITE, purple, blue]); }
} }
pub fn bisexual(small: bool) { pub fn bisexual(small: bool) {
@ -104,33 +108,53 @@ pub fn bisexual(small: bool) {
let width = 15; let width = 15;
println!( println!(
"{magenta}{stripe}\n{stripe}\n{purple}{stripe}\n{blue}{stripe}\n{stripe}{reset}", "{magenta}{stripe}\n{stripe}\n{purple}{stripe}\n{blue}{stripe}\n{stripe}{RESET}",
reset = color::Fg(color::Reset),
stripe = BLOCK.repeat(width) stripe = BLOCK.repeat(width)
); );
} else { draw(&[magenta, magenta, purple, blue, blue]); } } else { draw(&[magenta, magenta, purple, blue, blue]); }
} }
pub fn genderfluid(small: bool) {
let pink = color::Fg(color::Rgb(0xFF, 0x75, 0xA2));
let violet = color::Fg(color::Rgb(0xBE, 0x18, 0xD6));
let blue = color::Fg(color::Rgb(0x33, 0x3E, 0xBD));
if small {
} else { draw(&[pink, WHITE, violet, BLACK, blue]); }
}
pub fn genderqueer(small: bool) {
let purple = color::Fg(color::Rgb(0xB8, 0x99, 0xDF));
let green = color::Fg(color::Rgb(0x6B, 0x8E, 0x3B));
if small {
let width = 18;
println!(
"{purple}{stripe}\n{stripe}\n{WHITE}{stripe}\n{stripe}\n{green}{stripe}\n{stripe}{RESET}",
stripe = BLOCK.repeat(width)
);
} else { draw(&[purple, WHITE, green]); }
}
pub fn gendervoid(small: bool) { pub fn gendervoid(small: bool) {
let navy = color::Fg(color::Rgb(0x08, 0x11, 0x4A)); let navy = color::Fg(color::Rgb(0x08, 0x11, 0x4A));
let gray = color::Fg(color::Rgb(0x4A, 0x48, 0x4B)); let gray = color::Fg(color::Rgb(0x4A, 0x48, 0x4B));
let black = color::Fg(color::Rgb(0x00, 0x00, 0x00));
if small { if small {
let width = 15; let width = 15;
println!( println!(
"{navy}{stripe}\n{gray}{stripe}\n{black}{stripe}\n{gray}{stripe}\n{navy}{stripe}{reset}", "{navy}{stripe}\n{gray}{stripe}\n{BLACK}{stripe}\n{gray}{stripe}\n{navy}{stripe}{RESET}",
reset = color::Fg(color::Reset),
stripe = BLOCK.repeat(width) stripe = BLOCK.repeat(width)
); );
} else { draw(&[navy, gray, black, gray, navy]); } } else { draw(&[navy, gray, BLACK, gray, navy]); }
} }
pub fn lesbian(small: bool) { pub fn lesbian(small: bool) {
let red = color::Fg(color::Rgb(0xD6, 0x28, 0x00)); let red = color::Fg(color::Rgb(0xD6, 0x28, 0x00));
let orange = color::Fg(color::Rgb(0xFF, 0x9B, 0x56)); let orange = color::Fg(color::Rgb(0xFF, 0x9B, 0x56));
let white = color::Fg(color::Rgb(0xFF, 0xFF, 0xFF));
let pink = color::Fg(color::Rgb(0xD4, 0x62, 0xA6)); let pink = color::Fg(color::Rgb(0xD4, 0x62, 0xA6));
let magenta = color::Fg(color::Rgb(0xA4, 0x00, 0x62)); let magenta = color::Fg(color::Rgb(0xA4, 0x00, 0x62));
@ -138,11 +162,10 @@ pub fn lesbian(small: bool) {
let width = 15; let width = 15;
println!( println!(
"{red}{stripe}\n{orange}{stripe}\n{white}{stripe}\n{pink}{stripe}\n{magenta}{stripe}{reset}", "{red}{stripe}\n{orange}{stripe}\n{WHITE}{stripe}\n{pink}{stripe}\n{magenta}{stripe}{RESET}",
reset = color::Fg(color::Reset),
stripe = BLOCK.repeat(width) stripe = BLOCK.repeat(width)
); );
} else { draw(&[red, orange, white, pink, magenta]); } } else { draw(&[red, orange, WHITE, pink, magenta]); }
} }
pub fn multigender(small: bool) { pub fn multigender(small: bool) {
@ -154,8 +177,7 @@ pub fn multigender(small: bool) {
let width = 15; let width = 15;
println!( println!(
"{blue}{stripe}\n{ltblue}{stripe}\n{orange}{stripe}\n{ltblue}{stripe}\n{blue}{stripe}{reset}", "{blue}{stripe}\n{ltblue}{stripe}\n{orange}{stripe}\n{ltblue}{stripe}\n{blue}{stripe}{RESET}",
reset = color::Fg(color::Reset),
stripe = BLOCK.repeat(width) stripe = BLOCK.repeat(width)
); );
} else { draw(&[blue, ltblue, orange, ltblue, blue]); } } else { draw(&[blue, ltblue, orange, ltblue, blue]); }
@ -163,19 +185,16 @@ pub fn multigender(small: bool) {
pub fn nonbinary(small: bool) { pub fn nonbinary(small: bool) {
let yellow = color::Fg(color::Rgb(0xFF, 0xF4, 0x33)); let yellow = color::Fg(color::Rgb(0xFF, 0xF4, 0x33));
let white = color::Fg(color::Rgb(0xFF, 0xFF, 0xFF));
let purple = color::Fg(color::Rgb(0x9B, 0x59, 0xD0)); let purple = color::Fg(color::Rgb(0x9B, 0x59, 0xD0));
let black = color::Fg(color::Rgb(0x00, 0x00, 0x00));
if small { if small {
let width = 12; let width = 12;
println!( println!(
"{yellow}{stripe}\n{white}{stripe}\n{purple}{stripe}\n{black}{stripe}{reset}", "{yellow}{stripe}\n{WHITE}{stripe}\n{purple}{stripe}\n{BLACK}{stripe}{RESET}",
reset = color::Fg(color::Reset),
stripe = BLOCK.repeat(width) stripe = BLOCK.repeat(width)
); );
} else { draw(&[yellow, white, purple, black]); } } else { draw(&[yellow, WHITE, purple, BLACK]); }
} }
pub fn pansexual(small: bool) { pub fn pansexual(small: bool) {
@ -187,8 +206,7 @@ pub fn pansexual(small: bool) {
let width = 18; let width = 18;
println!( println!(
"{magenta}{stripe}\n{stripe}\n{yellow}{stripe}\n{stripe}\n{cyan}{stripe}\n{stripe}{reset}", "{magenta}{stripe}\n{stripe}\n{yellow}{stripe}\n{stripe}\n{cyan}{stripe}\n{stripe}{RESET}",
reset = color::Fg(color::Reset),
stripe = BLOCK.repeat(width) stripe = BLOCK.repeat(width)
); );
} else { draw(&[magenta, yellow, cyan]); } } else { draw(&[magenta, yellow, cyan]); }

View file

@ -2,6 +2,7 @@ use std::process::exit;
use pico_args::Arguments; use pico_args::Arguments;
mod color;
mod draw; mod draw;
mod flag; mod flag;
@ -32,6 +33,8 @@ fn main() {
Some("transgender") => flag::transgender(small), Some("transgender") => flag::transgender(small),
Some("agender") => flag::agender(small),
Some("aro") | Some("aro") |
Some("aromantic") => flag::aromantic(small), Some("aromantic") => flag::aromantic(small),
@ -43,6 +46,10 @@ fn main() {
Some("bi") | Some("bi") |
Some("bisexual") => flag::bisexual(small), Some("bisexual") => flag::bisexual(small),
Some("genderfluid") => flag::genderfluid(small),
Some("genderqueer") => flag::genderqueer(small),
Some("gendervoid") => flag::gendervoid(small), Some("gendervoid") => flag::gendervoid(small),
Some("lesbian") => flag::lesbian(small), Some("lesbian") => flag::lesbian(small),
@ -86,6 +93,7 @@ fn list_text() {
println!(" bigender bigender pride flag"); println!(" bigender bigender pride flag");
println!(" bi, bisexual bisexual pride flag"); println!(" bi, bisexual bisexual pride flag");
println!(" gay, pride six-color rainbow flag"); println!(" gay, pride six-color rainbow flag");
println!(" genderqueer genderqueer pride flag");
println!(" gendervoid gendervoid pride flag"); println!(" gendervoid gendervoid pride flag");
println!(" lesbian lesbian pride flag"); println!(" lesbian lesbian pride flag");
println!(" multigender multigender pride flag"); println!(" multigender multigender pride flag");