moved complex flags to their own module and initial code for small aroace flag

This commit is contained in:
Valerie Wolfe 2023-04-15 15:50:58 -04:00
parent a74f2e5acc
commit cadb1949a7
4 changed files with 165 additions and 77 deletions

103
src/complex.rs Normal file
View file

@ -0,0 +1,103 @@
use std::io::{
stdin, stdout,
Write
};
use termion::{
terminal_size,
color,
cursor,
color::{ Fg, Bg, Rgb },
raw::IntoRawMode
};
use crate::{ error, util };
use crate::flag::BLOCK;
pub static UHALF: &str = "";
//pub static LHALF: &str = "▄";
pub fn progress(small: bool) {
let red = color::Rgb(0xE5, 0x00, 0x00);
let orange = color::Rgb(0xFF, 0x8D, 0x00);
let yellow = color::Rgb(0xFF, 0xEE, 0x00);
let green = color::Rgb(0x02, 0x81, 0x21);
let blue = color::Rgb(0x00, 0x4C, 0xFF);
let purple = color::Rgb(0x77, 0x00, 0x88);
let white = color::Rgb(0xFF, 0xFF, 0xFF);
let pink = color::Rgb(0x7A, 0xCB, 0xF5);
let ltblue = color::Rgb(0xEA, 0xAC, 0xB8);
let brown = color::Rgb(0x61, 0x39, 0x15);
let black = color::Rgb(0x00, 0x00, 0x00);
}
// everything below here is alphabetical
pub fn aroace(small: bool) {
// set up colors
// shared colors
let black = color::Rgb(0x00, 0x00, 0x00);
let white = color::Rgb(0xFF, 0xFF, 0xFF);
// aro colors
let green = Fg(Rgb(0x3B, 0xA7, 0x40));
let lime = Fg(Rgb(0xA8, 0xD4, 0x7A));
let gray = Fg(Rgb(0xAB, 0xAB, 0xAB));
// ace colors
let grey = color::Rgb(0xA4, 0xA4, 0xA4);
let purple = color::Rgb(0x81, 0x00, 0x81);
// draw small
if small {
let solid = BLOCK.repeat(15);
let split = UHALF.repeat(15);
let reset = Bg(color::Reset);
for _ in 0..2 { println!("{green}{solid}{b}{solid}", b = Fg(black)); }
println!("{lime}{solid}{b}{g}{split}{reset}", b = Fg(black), g = Bg(grey));
println!("{lime}{solid}{g}{solid}", g = Fg(grey));
println!("{w}{solid}{g}{solid}", w = Fg(white), g = Fg(grey));
println!("{w}{solid}{solid}", w = Fg(white));
println!("{gray}{solid}{w}{solid}", w = Fg(white));
println!("{gray}{solid}{w}{p}{split}{reset}", w = Fg(white), p = Bg(purple));
for _ in 0..2 { println!("{b}{solid}{p}{solid}", b = Fg(black), p = Fg(purple)); }
print!("{}", termion::style::Reset);
return;
}
// draw full-size
/* the 4 and 5 stripe flags MUST line up; this means
* there have to be at least 20 steps; if we use half
* block characters, we can work this down to a minimum
* height of 10 by utilizing fg and bg.
*/
let min = 10;
let width: usize;
let height: usize;
let (twidth, theight) = terminal_size().unwrap();
if theight < min { error::too_small(Some("10 rows")); }
}
pub fn intersex(small: bool) {
let yellow = color::Rgb(0xFF, 0xDA, 0x00);
let purple = color::Rgb(0x7A, 0x00, 0xAC);
}
pub fn polyamorous(small: bool) {
let blue = color::Rgb(0x01, 0x9F, 0xE3);
let magenta = color::Rgb(0xE5, 0x00, 0x51);
let purple = color::Rgb(0x34, 0x0C, 0x46);
let white = color::Rgb(0xFF, 0xFF, 0xFF);
let yellow = color::Rgb(0x00, 0xFC, 0xBF);
}

8
src/error.rs Normal file
View file

@ -0,0 +1,8 @@
use std::process::exit;
pub fn too_small(spec: Option<&str>) {
println!("pride: terminal is too small!");
if spec.is_some() { println!("must be at least {}", spec.unwrap()); }
exit(2);
}

View file

@ -1,32 +1,17 @@
use termion::color;
use termion::color::{ Fg, Rgb };
use crate::draw;
pub static BLOCK: &str = "";
pub fn progress(small: bool) {
let red = color::Fg(color::Rgb(0xE5, 0x00, 0x00));
let orange = color::Fg(color::Rgb(0xFF, 0x8D, 0x00));
let yellow = color::Fg(color::Rgb(0xFF, 0xEE, 0x00));
let green = color::Fg(color::Rgb(0x02, 0x81, 0x21));
let blue = color::Fg(color::Rgb(0x00, 0x4C, 0xFF));
let purple = color::Fg(color::Rgb(0x77, 0x00, 0x88));
let white = color::Fg(color::Rgb(0xFF, 0xFF, 0xFF));
let pink = color::Fg(color::Rgb(0x7A, 0xCB, 0xF5));
let ltblue = color::Fg(color::Rgb(0xEA, 0xAC, 0xB8));
let brown = color::Fg(color::Rgb(0x61, 0x39, 0x15));
let black = color::Fg(color::Rgb(0x00, 0x00, 0x00));
}
pub fn pride(small: bool) {
let red = color::Fg(color::Rgb(0xE5, 0x00, 0x00));
let orange = color::Fg(color::Rgb(0xFF, 0x8D, 0x00));
let yellow = color::Fg(color::Rgb(0xFF, 0xEE, 0x00));
let green = color::Fg(color::Rgb(0x02, 0x81, 0x21));
let blue = color::Fg(color::Rgb(0x00, 0x4C, 0xFF));
let purple = color::Fg(color::Rgb(0x77, 0x00, 0x88));
let red =Fg(Rgb(0xE5, 0x00, 0x00));
let orange = Fg(Rgb(0xFF, 0x8D, 0x00));
let yellow = Fg(Rgb(0xFF, 0xEE, 0x00));
let green = Fg(Rgb(0x02, 0x81, 0x21));
let blue = Fg(Rgb(0x00, 0x4C, 0xFF));
let purple = Fg(Rgb(0x77, 0x00, 0x88));
let stripes = &[red, orange, yellow, green, blue, purple];
if small { draw::small(stripes); }
@ -34,9 +19,9 @@ pub fn pride(small: bool) {
}
pub fn transgender(small: bool) {
let pink = color::Fg(color::Rgb(0x7A, 0xCB, 0xF5));
let blue = color::Fg(color::Rgb(0xEA, 0xAC, 0xB8));
let white = color::Fg(color::Rgb(0xFF, 0xFF, 0xFF));
let pink = Fg(Rgb(0x7A, 0xCB, 0xF5));
let blue = Fg(Rgb(0xEA, 0xAC, 0xB8));
let white = Fg(Rgb(0xFF, 0xFF, 0xFF));
let stripes = &[pink, blue, white, blue, pink];
if small { draw::small(stripes); }
@ -46,11 +31,11 @@ pub fn transgender(small: bool) {
// everything below here is alphabetical
pub fn aromantic(small: bool) {
let green = color::Fg(color::Rgb(0x3B, 0xA7, 0x40));
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 black = color::Fg(color::Rgb(0x00, 0x00, 0x00));
let green = Fg(Rgb(0x3B, 0xA7, 0x40));
let lime = Fg(Rgb(0xA8, 0xD4, 0x7A));
let white = Fg(Rgb(0xFF, 0xFF, 0xFF));
let grey = Fg(Rgb(0xAB, 0xAB, 0xAB));
let black = Fg(Rgb(0x00, 0x00, 0x00));
let stripes = &[green, lime, white, grey, black];
if small { }
@ -58,10 +43,10 @@ pub fn aromantic(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 white = color::Fg(color::Rgb(0xFF, 0xFF, 0xFF));
let purple = color::Fg(color::Rgb(0x81, 0x00, 0x81));
let black = Fg(Rgb(0x00, 0x00, 0x00));
let grey = Fg(Rgb(0xA4, 0xA4, 0xA4));
let white = Fg(Rgb(0xFF, 0xFF, 0xFF));
let purple = Fg(Rgb(0x81, 0x00, 0x81));
let stripes = &[black, grey, white, purple];
if small { draw::small(stripes); }
@ -69,11 +54,11 @@ pub fn asexual(small: bool) {
}
pub fn bigender(small: bool) {
let pink = color::Fg(color::Rgb(0xE6, 0x76, 0xA6));
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 blue = color::Fg(color::Rgb(0x6D, 0x96, 0xDC));
let pink = Fg(Rgb(0xE6, 0x76, 0xA6));
let yellow = Fg(Rgb(0xF9, 0xF0, 0x4C));
let white = Fg(Rgb(0xFF, 0xFF, 0xFF));
let purple = Fg(Rgb(0xAB, 0x6B, 0xBB));
let blue = Fg(Rgb(0x6D, 0x96, 0xDC));
let stripes = &[pink, yellow, white, purple, blue];
if small { draw::small(stripes); }
@ -81,9 +66,9 @@ pub fn bigender(small: bool) {
}
pub fn bisexual(small: bool) {
let magenta = color::Fg(color::Rgb(0xC4, 0x2A, 0x6F));
let purple = color::Fg(color::Rgb(0x91, 0x53, 0x92));
let blue = color::Fg(color::Rgb(0x14, 0x37, 0xA2));
let magenta = Fg(Rgb(0xC4, 0x2A, 0x6F));
let purple = Fg(Rgb(0x91, 0x53, 0x92));
let blue = Fg(Rgb(0x14, 0x37, 0xA2));
let stripes = &[magenta, magenta, purple, blue, blue];
if small { draw::small(stripes); }
@ -91,26 +76,21 @@ pub fn bisexual(small: bool) {
}
pub fn gendervoid(small: bool) {
let navy = color::Fg(color::Rgb(0x08, 0x11, 0x4A));
let gray = color::Fg(color::Rgb(0x4A, 0x48, 0x4B));
let black = color::Fg(color::Rgb(0x00, 0x00, 0x00));
let navy = Fg(Rgb(0x08, 0x11, 0x4A));
let gray = Fg(Rgb(0x4A, 0x48, 0x4B));
let black = Fg(Rgb(0x00, 0x00, 0x00));
let stripes = &[navy, gray, black, gray, navy];
if small { draw::small(stripes); }
else { draw::simple(stripes); }
}
pub fn intersex(small: bool) {
let yellow = color::Fg(color::Rgb(0xFF, 0xDA, 0x00));
let purple = color::Fg(color::Rgb(0x7A, 0x00, 0xAC));
}
pub fn lesbian(small: bool) {
let red = color::Fg(color::Rgb(0xD6, 0x28, 0x00));
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 magenta = color::Fg(color::Rgb(0xA4, 0x00, 0x62));
let red = Fg(Rgb(0xD6, 0x28, 0x00));
let orange = Fg(Rgb(0xFF, 0x9B, 0x56));
let white = Fg(Rgb(0xFF, 0xFF, 0xFF));
let pink = Fg(Rgb(0xD4, 0x62, 0xA6));
let magenta = Fg(Rgb(0xA4, 0x00, 0x62));
let stripes = &[red, orange, white, pink, magenta];
if small { draw::small(stripes); }
@ -118,9 +98,9 @@ pub fn lesbian(small: bool) {
}
pub fn multigender(small: bool) {
let blue = color::Fg(color::Rgb(0x3F, 0x47, 0xCC));
let ltblue = color::Fg(color::Rgb(0x01, 0xA4, 0xE9));
let orange = color::Fg(color::Rgb(0xFB, 0x7F, 0x27));
let blue = Fg(Rgb(0x3F, 0x47, 0xCC));
let ltblue = Fg(Rgb(0x01, 0xA4, 0xE9));
let orange = Fg(Rgb(0xFB, 0x7F, 0x27));
let stripes = &[blue, ltblue, orange, ltblue, blue];
if small { draw::small(stripes); }
@ -128,10 +108,10 @@ pub fn multigender(small: bool) {
}
pub fn nonbinary(small: bool) {
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 black = color::Fg(color::Rgb(0x00, 0x00, 0x00));
let yellow = Fg(Rgb(0xFF, 0xF4, 0x33));
let white = Fg(Rgb(0xFF, 0xFF, 0xFF));
let purple = Fg(Rgb(0x9B, 0x59, 0xD0));
let black = Fg(Rgb(0x00, 0x00, 0x00));
let stripes = &[yellow, white, purple, black];
if small { draw::small(stripes); }
@ -139,20 +119,11 @@ pub fn nonbinary(small: bool) {
}
pub fn pansexual(small: bool) {
let magenta = color::Fg(color::Rgb(0xFF, 0x1B, 0x8D));
let yellow = color::Fg(color::Rgb(0xFF, 0xDA, 0x00));
let cyan = color::Fg(color::Rgb(0x1B, 0xB3, 0xFF));
let magenta = Fg(Rgb(0xFF, 0x1B, 0x8D));
let yellow = Fg(Rgb(0xFF, 0xDA, 0x00));
let cyan = Fg(Rgb(0x1B, 0xB3, 0xFF));
if small { draw::small(&[magenta, magenta, yellow, yellow, cyan, cyan]); }
else { draw::simple(&[magenta, yellow, cyan]); }
}
pub fn polyamorous() {
let blue = color::Fg(color::Rgb(0x01, 0x9F, 0xE3));
let magenta = color::Fg(color::Rgb(0xE5, 0x00, 0x51));
let purple = color::Fg(color::Rgb(0x34, 0x0C, 0x46));
let white = color::Fg(color::Rgb(0xFF, 0xFF, 0xFF));
let yellow = color::Fg(color::Rgb(0x00, 0xFC, 0xBF));
}

View file

@ -2,8 +2,11 @@ use std::process::exit;
use pico_args::Arguments;
mod complex;
mod draw;
mod error;
mod flag;
mod util;
fn main() {
let mut args = Arguments::from_env();
@ -25,7 +28,7 @@ fn main() {
let subcommand = args.subcommand().unwrap();
match subcommand.as_deref() {
Some("progress") => flag::progress(small),
Some("progress") => complex::progress(small),
Some("pride") |
Some("gay") => flag::pride(small),
@ -34,6 +37,8 @@ fn main() {
Some("transgender") => flag::transgender(small),
Some("aroace") => complex::aroace(small),
Some("aro") |
Some("aromantic") => flag::aromantic(small),
@ -47,7 +52,7 @@ fn main() {
Some("gendervoid") => flag::gendervoid(small),
Some("intersex") => flag::intersex(small),
Some("intersex") => complex::intersex(small),
Some("lesbian") => flag::lesbian(small),
@ -62,7 +67,7 @@ fn main() {
Some("poly") |
Some("polyam") |
Some("polyamory") |
Some("polyamorous") => flag::polyamorous(),
Some("polyamorous") => complex::polyamorous(small),
_ => { help_text(); exit(1) }
}
@ -90,6 +95,7 @@ fn help_text() {
fn list_text() {
println!("pride v{}", env!("CARGO_PKG_VERSION"));
println!("\nFlag list:");
println!(" aroace aromantic asexual pride flag");
println!(" aro, aromantic aromantic pride flag");
println!(" ace, asexual asexual pride flag");
println!(" bigender bigender pride flag");