From c10833bb992fdb304620dc1edbde724b593a1d62 Mon Sep 17 00:00:00 2001 From: Valerie Date: Mon, 19 Jun 2023 19:21:05 -0400 Subject: [PATCH 1/9] started streamlining heavily reused colors and flags --- src/color.rs | 8 +++++ src/draw.rs | 12 +++---- src/flag.rs | 96 +++++++++++++++++++++++++++++++--------------------- src/main.rs | 8 +++++ 4 files changed, 77 insertions(+), 47 deletions(-) create mode 100644 src/color.rs diff --git a/src/color.rs b/src/color.rs new file mode 100644 index 0000000..63f76b9 --- /dev/null +++ b/src/color.rs @@ -0,0 +1,8 @@ + +use termion::color::{ Fg, Rgb, Reset }; + +pub static BLACK: Fg = Fg(Rgb(0x00, 0x00, 0x00)); +pub static WHITE: Fg = Fg(Rgb(0xFF, 0xFF, 0xFF)); + +pub static RESET: Fg = Fg(Reset); + diff --git a/src/draw.rs b/src/draw.rs index ce7957f..7114252 100644 --- a/src/draw.rs +++ b/src/draw.rs @@ -1,7 +1,4 @@ -use std::{ - io, - io::Write -}; +use std::io::{ self, Write }; use termion::{ terminal_size, @@ -10,10 +7,10 @@ use termion::{ color::{ Fg, Rgb }, cursor, input::TermRead, - raw::IntoRawMode, - style + raw::IntoRawMode }; +use crate::color::RESET; use crate::flag::BLOCK; pub fn draw(colors: &[Fg]) { @@ -28,7 +25,6 @@ pub fn draw(colors: &[Fg]) { stdout.flush().ok(); let stripe = BLOCK.repeat(width as usize); - let reset = style::Reset; let mut index = 0; for n in 0..(height as usize) { @@ -38,7 +34,7 @@ pub fn draw(colors: &[Fg]) { } write!( stdout, - "{color}{stripe}{reset}", + "{color}{stripe}{RESET}", color = colors[index] ).ok(); } diff --git a/src/flag.rs b/src/flag.rs index d0c3bd0..2a76160 100644 --- a/src/flag.rs +++ b/src/flag.rs @@ -1,6 +1,7 @@ use termion::color; +use crate::color::*; use crate::draw::draw; pub static BLOCK: &str = "█"; @@ -17,8 +18,7 @@ pub fn pride(small: bool) { let width = 18; println!( - "{red}{stripe}\n{orange}{stripe}\n{yellow}{stripe}\n{green}{stripe}\n{blue}{stripe}\n{purple}{stripe}{reset}", - reset = color::Fg(color::Reset), + "{red}{stripe}\n{orange}{stripe}\n{yellow}{stripe}\n{green}{stripe}\n{blue}{stripe}\n{purple}{stripe}{RESET}", stripe = BLOCK.repeat(width) ); } else { draw(&[red, orange, yellow, green, blue, purple]); } @@ -27,60 +27,65 @@ 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)); if small { let width = 15; println!( - "{pink}{stripe}\n{blue}{stripe}\n{white}{stripe}\n{blue}{stripe}\n{pink}{stripe}{reset}", - reset = color::Fg(color::Reset), + "{pink}{stripe}\n{blue}{stripe}\n{WHITE}{stripe}\n{blue}{stripe}\n{pink}{stripe}{RESET}", stripe = BLOCK.repeat(width) ); - } else { draw(&[pink, blue, white, blue, pink]); } + } else { draw(&[pink, blue, WHITE, blue, pink]); } } // 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) { 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)); if small { let width = 15; println!( - "{green}{stripe}\n{lime}{stripe}\n{white}{stripe}\n{grey}{stripe}\n{black}{stripe}{reset}", - reset = color::Fg(color::Reset), + "{green}{stripe}\n{lime}{stripe}\n{WHITE}{stripe}\n{grey}{stripe}\n{BLACK}{stripe}{RESET}", stripe = BLOCK.repeat(width) ); - } else { draw(&[green, lime, white, grey, black]); } + } else { draw(&[green, lime, WHITE, grey, BLACK]); } } 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)); if small { let width = 12; println!( - "{black}{stripe}\n{grey}{stripe}\n{white}{stripe}\n{purple}{stripe}{reset}", - reset = color::Fg(color::Reset), + "{BLACK}{stripe}\n{grey}{stripe}\n{WHITE}{stripe}\n{purple}{stripe}{RESET}", stripe = BLOCK.repeat(width) ); - } else { draw(&[black, grey, white, purple]); } + } else { draw(&[BLACK, grey, WHITE, purple]); } } 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)); @@ -88,11 +93,10 @@ pub fn bigender(small: bool) { let width = 15; println!( - "{pink}{stripe}\n{yellow}{stripe}\n{white}{stripe}\n{purple}{stripe}\n{blue}{stripe}{reset}", - reset = color::Fg(color::Reset), + "{pink}{stripe}\n{yellow}{stripe}\n{WHITE}{stripe}\n{purple}{stripe}\n{blue}{stripe}{RESET}", stripe = BLOCK.repeat(width) ); - } else { draw(&[pink, yellow, white, purple, blue]); } + } else { draw(&[pink, yellow, WHITE, purple, blue]); } } pub fn bisexual(small: bool) { @@ -104,33 +108,53 @@ pub fn bisexual(small: bool) { let width = 15; println!( - "{magenta}{stripe}\n{stripe}\n{purple}{stripe}\n{blue}{stripe}\n{stripe}{reset}", - reset = color::Fg(color::Reset), + "{magenta}{stripe}\n{stripe}\n{purple}{stripe}\n{blue}{stripe}\n{stripe}{RESET}", stripe = BLOCK.repeat(width) ); } 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) { 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)); if small { let width = 15; println!( - "{navy}{stripe}\n{gray}{stripe}\n{black}{stripe}\n{gray}{stripe}\n{navy}{stripe}{reset}", - reset = color::Fg(color::Reset), + "{navy}{stripe}\n{gray}{stripe}\n{BLACK}{stripe}\n{gray}{stripe}\n{navy}{stripe}{RESET}", stripe = BLOCK.repeat(width) ); - } else { draw(&[navy, gray, black, gray, navy]); } + } else { draw(&[navy, gray, BLACK, gray, navy]); } } 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)); @@ -138,11 +162,10 @@ pub fn lesbian(small: bool) { let width = 15; println!( - "{red}{stripe}\n{orange}{stripe}\n{white}{stripe}\n{pink}{stripe}\n{magenta}{stripe}{reset}", - reset = color::Fg(color::Reset), + "{red}{stripe}\n{orange}{stripe}\n{WHITE}{stripe}\n{pink}{stripe}\n{magenta}{stripe}{RESET}", stripe = BLOCK.repeat(width) ); - } else { draw(&[red, orange, white, pink, magenta]); } + } else { draw(&[red, orange, WHITE, pink, magenta]); } } pub fn multigender(small: bool) { @@ -154,8 +177,7 @@ pub fn multigender(small: bool) { let width = 15; println!( - "{blue}{stripe}\n{ltblue}{stripe}\n{orange}{stripe}\n{ltblue}{stripe}\n{blue}{stripe}{reset}", - reset = color::Fg(color::Reset), + "{blue}{stripe}\n{ltblue}{stripe}\n{orange}{stripe}\n{ltblue}{stripe}\n{blue}{stripe}{RESET}", stripe = BLOCK.repeat(width) ); } else { draw(&[blue, ltblue, orange, ltblue, blue]); } @@ -163,19 +185,16 @@ 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)); if small { let width = 12; println!( - "{yellow}{stripe}\n{white}{stripe}\n{purple}{stripe}\n{black}{stripe}{reset}", - reset = color::Fg(color::Reset), + "{yellow}{stripe}\n{WHITE}{stripe}\n{purple}{stripe}\n{BLACK}{stripe}{RESET}", stripe = BLOCK.repeat(width) ); - } else { draw(&[yellow, white, purple, black]); } + } else { draw(&[yellow, WHITE, purple, BLACK]); } } pub fn pansexual(small: bool) { @@ -187,8 +206,7 @@ pub fn pansexual(small: bool) { let width = 18; println!( - "{magenta}{stripe}\n{stripe}\n{yellow}{stripe}\n{stripe}\n{cyan}{stripe}\n{stripe}{reset}", - reset = color::Fg(color::Reset), + "{magenta}{stripe}\n{stripe}\n{yellow}{stripe}\n{stripe}\n{cyan}{stripe}\n{stripe}{RESET}", stripe = BLOCK.repeat(width) ); } else { draw(&[magenta, yellow, cyan]); } diff --git a/src/main.rs b/src/main.rs index 5a52c0d..3c827f8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ use std::process::exit; use pico_args::Arguments; +mod color; mod draw; mod flag; @@ -32,6 +33,8 @@ fn main() { Some("transgender") => flag::transgender(small), + Some("agender") => flag::agender(small), + Some("aro") | Some("aromantic") => flag::aromantic(small), @@ -43,6 +46,10 @@ fn main() { Some("bi") | Some("bisexual") => flag::bisexual(small), + Some("genderfluid") => flag::genderfluid(small), + + Some("genderqueer") => flag::genderqueer(small), + Some("gendervoid") => flag::gendervoid(small), Some("lesbian") => flag::lesbian(small), @@ -86,6 +93,7 @@ fn list_text() { println!(" bigender bigender pride flag"); println!(" bi, bisexual bisexual pride flag"); println!(" gay, pride six-color rainbow flag"); + println!(" genderqueer genderqueer pride flag"); println!(" gendervoid gendervoid pride flag"); println!(" lesbian lesbian pride flag"); println!(" multigender multigender pride flag"); From 7a587f0c2e970c28a29f0c2a1251e2f9d2e031b3 Mon Sep 17 00:00:00 2001 From: Valerie Date: Mon, 19 Jun 2023 19:25:16 -0400 Subject: [PATCH 2/9] finished adding agender, genderfluid, and genderqueer flags --- src/flag.rs | 7 ++++++- src/main.rs | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/flag.rs b/src/flag.rs index 2a76160..61c557f 100644 --- a/src/flag.rs +++ b/src/flag.rs @@ -120,7 +120,12 @@ pub fn genderfluid(small: bool) { let blue = color::Fg(color::Rgb(0x33, 0x3E, 0xBD)); if small { - + let width = 15; + + println!( + "{pink}{stripe}\n{WHITE}{stripe}\n{violet}{stripe}\n{BLACK}{stripe}\n{blue}{stripe}", + stripe = BLOCK.repeat(width) + ); } else { draw(&[pink, WHITE, violet, BLACK, blue]); } } diff --git a/src/main.rs b/src/main.rs index 3c827f8..32c3e26 100644 --- a/src/main.rs +++ b/src/main.rs @@ -88,11 +88,13 @@ fn help_text() { fn list_text() { println!("pride v{}", env!("CARGO_PKG_VERSION")); println!("\nFlag list:"); + println!(" agender agender pride flag"); println!(" aro, aromantic aromantic pride flag"); println!(" ace, asexual asexual pride flag"); println!(" bigender bigender pride flag"); println!(" bi, bisexual bisexual pride flag"); println!(" gay, pride six-color rainbow flag"); + println!(" genderfluid genderfluid pride flag"); println!(" genderqueer genderqueer pride flag"); println!(" gendervoid gendervoid pride flag"); println!(" lesbian lesbian pride flag"); From 31d0acd1de26fd597cddc3cbaaed51cb22757399 Mon Sep 17 00:00:00 2001 From: Valerie Date: Mon, 19 Jun 2023 19:25:38 -0400 Subject: [PATCH 3/9] version bump --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 10e60af..a0ce99b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pride" -version = "0.0.1" +version = "0.0.2" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 4f051170ac566619dd99ab13334adcd51435a7f3 Mon Sep 17 00:00:00 2001 From: Valerie Date: Mon, 19 Jun 2023 20:08:05 -0400 Subject: [PATCH 4/9] major refactor: flag methods now return their stripe colors as vectors --- Cargo.toml | 2 +- src/color.rs | 7 ++- src/draw.rs | 19 ++++++- src/flag.rs | 155 ++++++++++----------------------------------------- src/main.rs | 59 ++++++++++++-------- 5 files changed, 86 insertions(+), 156 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a0ce99b..de83030 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pride" -version = "0.0.2" +version = "0.1.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/color.rs b/src/color.rs index 63f76b9..4b73b78 100644 --- a/src/color.rs +++ b/src/color.rs @@ -1,8 +1,11 @@ use termion::color::{ Fg, Rgb, Reset }; -pub static BLACK: Fg = Fg(Rgb(0x00, 0x00, 0x00)); -pub static WHITE: Fg = Fg(Rgb(0xFF, 0xFF, 0xFF)); +pub type Color = Fg; +pub type Colors = Vec>; + +pub static BLACK: Color = Fg(Rgb(0x00, 0x00, 0x00)); +pub static WHITE: Color = Fg(Rgb(0xFF, 0xFF, 0xFF)); pub static RESET: Fg = Fg(Reset); diff --git a/src/draw.rs b/src/draw.rs index 7114252..c60a747 100644 --- a/src/draw.rs +++ b/src/draw.rs @@ -4,16 +4,15 @@ use termion::{ terminal_size, clear, - color::{ Fg, Rgb }, cursor, input::TermRead, raw::IntoRawMode }; -use crate::color::RESET; +use crate::color::{ RESET, Colors }; use crate::flag::BLOCK; -pub fn draw(colors: &[Fg]) { +pub fn full(colors: Colors) { let mut stdout = io::stdout().into_raw_mode().unwrap(); let stdin = io::stdin(); @@ -45,4 +44,18 @@ pub fn draw(colors: &[Fg]) { 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(); +} diff --git a/src/flag.rs b/src/flag.rs index 61c557f..4ca579e 100644 --- a/src/flag.rs +++ b/src/flag.rs @@ -2,11 +2,10 @@ use termion::color; use crate::color::*; -use crate::draw::draw; pub static BLOCK: &str = "█"; -pub fn pride(small: bool) { +pub fn pride() -> Colors { 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)); @@ -14,206 +13,108 @@ pub fn pride(small: bool) { let blue = color::Fg(color::Rgb(0x00, 0x4C, 0xFF)); let purple = color::Fg(color::Rgb(0x77, 0x00, 0x88)); - if small { // small flag: 18x6 - let width = 18; - - println!( - "{red}{stripe}\n{orange}{stripe}\n{yellow}{stripe}\n{green}{stripe}\n{blue}{stripe}\n{purple}{stripe}{RESET}", - stripe = BLOCK.repeat(width) - ); - } else { draw(&[red, orange, yellow, green, blue, purple]); } + vec![red, orange, yellow, green, blue, purple] } -pub fn transgender(small: bool) { +pub fn transgender() -> Colors { let pink = color::Fg(color::Rgb(0x7A, 0xCB, 0xF5)); let blue = color::Fg(color::Rgb(0xEA, 0xAC, 0xB8)); - if small { - let width = 15; - - println!( - "{pink}{stripe}\n{blue}{stripe}\n{WHITE}{stripe}\n{blue}{stripe}\n{pink}{stripe}{RESET}", - stripe = BLOCK.repeat(width) - ); - } else { draw(&[pink, blue, WHITE, blue, pink]); } + vec![pink, blue, WHITE, blue, pink] } // everything below here is alphabetical -pub fn agender(small: bool) { +pub fn agender() -> Colors { 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]); } + vec![BLACK, gray, WHITE, green, WHITE, gray, BLACK] } -pub fn aromantic(small: bool) { +pub fn aromantic() -> Colors { let green = color::Fg(color::Rgb(0x3B, 0xA7, 0x40)); let lime = color::Fg(color::Rgb(0xA8, 0xD4, 0x7A)); let grey = color::Fg(color::Rgb(0xAB, 0xAB, 0xAB)); - if small { - let width = 15; - - println!( - "{green}{stripe}\n{lime}{stripe}\n{WHITE}{stripe}\n{grey}{stripe}\n{BLACK}{stripe}{RESET}", - stripe = BLOCK.repeat(width) - ); - } else { draw(&[green, lime, WHITE, grey, BLACK]); } + vec![green, lime, WHITE, grey, BLACK] } -pub fn asexual(small: bool) { +pub fn asexual() -> Colors { let grey = color::Fg(color::Rgb(0xA4, 0xA4, 0xA4)); let purple = color::Fg(color::Rgb(0x81, 0x00, 0x81)); - if small { - let width = 12; - - println!( - "{BLACK}{stripe}\n{grey}{stripe}\n{WHITE}{stripe}\n{purple}{stripe}{RESET}", - stripe = BLOCK.repeat(width) - ); - } else { draw(&[BLACK, grey, WHITE, purple]); } + vec![BLACK, grey, WHITE, purple] } -pub fn bigender(small: bool) { +pub fn bigender() -> Colors { let pink = color::Fg(color::Rgb(0xE6, 0x76, 0xA6)); let yellow = color::Fg(color::Rgb(0xF9, 0xF0, 0x4C)); let purple = color::Fg(color::Rgb(0xAB, 0x6B, 0xBB)); let blue = color::Fg(color::Rgb(0x6D, 0x96, 0xDC)); - if small { - let width = 15; - - println!( - "{pink}{stripe}\n{yellow}{stripe}\n{WHITE}{stripe}\n{purple}{stripe}\n{blue}{stripe}{RESET}", - stripe = BLOCK.repeat(width) - ); - } else { draw(&[pink, yellow, WHITE, purple, blue]); } + vec![pink, yellow, WHITE, purple, blue] } -pub fn bisexual(small: bool) { +pub fn bisexual() -> Colors { 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)); - if small { - let width = 15; - - println!( - "{magenta}{stripe}\n{stripe}\n{purple}{stripe}\n{blue}{stripe}\n{stripe}{RESET}", - stripe = BLOCK.repeat(width) - ); - } else { draw(&[magenta, magenta, purple, blue, blue]); } + vec![magenta, magenta, purple, blue, blue] } -pub fn genderfluid(small: bool) { +pub fn genderfluid() -> Colors { 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 { - let width = 15; - - println!( - "{pink}{stripe}\n{WHITE}{stripe}\n{violet}{stripe}\n{BLACK}{stripe}\n{blue}{stripe}", - stripe = BLOCK.repeat(width) - ); - } else { draw(&[pink, WHITE, violet, BLACK, blue]); } + vec![pink, WHITE, violet, BLACK, blue] } -pub fn genderqueer(small: bool) { +pub fn genderqueer() -> Colors { 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]); } + vec![purple, WHITE, green] } -pub fn gendervoid(small: bool) { +pub fn gendervoid() -> Colors { let navy = color::Fg(color::Rgb(0x08, 0x11, 0x4A)); let gray = color::Fg(color::Rgb(0x4A, 0x48, 0x4B)); - if small { - let width = 15; - - println!( - "{navy}{stripe}\n{gray}{stripe}\n{BLACK}{stripe}\n{gray}{stripe}\n{navy}{stripe}{RESET}", - stripe = BLOCK.repeat(width) - ); - } else { draw(&[navy, gray, BLACK, gray, navy]); } + vec![navy, gray, BLACK, gray, navy] } -pub fn lesbian(small: bool) { +pub fn lesbian() -> Colors { let red = color::Fg(color::Rgb(0xD6, 0x28, 0x00)); let orange = color::Fg(color::Rgb(0xFF, 0x9B, 0x56)); let pink = color::Fg(color::Rgb(0xD4, 0x62, 0xA6)); let magenta = color::Fg(color::Rgb(0xA4, 0x00, 0x62)); - if small { - let width = 15; - - println!( - "{red}{stripe}\n{orange}{stripe}\n{WHITE}{stripe}\n{pink}{stripe}\n{magenta}{stripe}{RESET}", - stripe = BLOCK.repeat(width) - ); - } else { draw(&[red, orange, WHITE, pink, magenta]); } + vec![red, orange, WHITE, pink, magenta] } -pub fn multigender(small: bool) { +pub fn multigender() -> Colors { 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)); - if small { - let width = 15; - - println!( - "{blue}{stripe}\n{ltblue}{stripe}\n{orange}{stripe}\n{ltblue}{stripe}\n{blue}{stripe}{RESET}", - stripe = BLOCK.repeat(width) - ); - } else { draw(&[blue, ltblue, orange, ltblue, blue]); } + vec![blue, ltblue, orange, ltblue, blue] } -pub fn nonbinary(small: bool) { +pub fn nonbinary() -> Colors { let yellow = color::Fg(color::Rgb(0xFF, 0xF4, 0x33)); let purple = color::Fg(color::Rgb(0x9B, 0x59, 0xD0)); - if small { - let width = 12; - - println!( - "{yellow}{stripe}\n{WHITE}{stripe}\n{purple}{stripe}\n{BLACK}{stripe}{RESET}", - stripe = BLOCK.repeat(width) - ); - } else { draw(&[yellow, WHITE, purple, BLACK]); } + vec![yellow, WHITE, purple, BLACK] } -pub fn pansexual(small: bool) { +pub fn pansexual() -> Colors { 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)); - if small { - let width = 18; - - println!( - "{magenta}{stripe}\n{stripe}\n{yellow}{stripe}\n{stripe}\n{cyan}{stripe}\n{stripe}{RESET}", - stripe = BLOCK.repeat(width) - ); - } else { draw(&[magenta, yellow, cyan]); } + vec![magenta, yellow, cyan] } diff --git a/src/main.rs b/src/main.rs index 32c3e26..37aed81 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,8 @@ mod color; mod draw; mod flag; +use crate::color::Colors; + fn main() { let mut args = Arguments::from_env(); @@ -25,45 +27,56 @@ fn main() { let subcommand = args.subcommand().unwrap(); - match subcommand.as_deref() { - Some("pride") | - Some("gay") => flag::pride(small), + let colors: Colors = match subcommand.as_deref() { + Some("pride" | "gay") + => flag::pride(), - Some("trans") | - Some("transgender") => flag::transgender(small), + Some("transgender" | "trans") + => flag::transgender(), - Some("agender") => flag::agender(small), + Some("agender") + => flag::agender(), - Some("aro") | - Some("aromantic") => flag::aromantic(small), + Some("aromantic" | "aro") + => flag::aromantic(), - Some("ace") | - Some("asexual") => flag::asexual(small), + Some("asexual" | "ace") + => flag::asexual(), - Some("bigender") => flag::bigender(small), + Some("bigender") + => flag::bigender(), - Some("bi") | - Some("bisexual") => flag::bisexual(small), + Some("bisexual" | "bi") + => flag::bisexual(), - Some("genderfluid") => flag::genderfluid(small), + Some("genderfluid") + => flag::genderfluid(), - Some("genderqueer") => flag::genderqueer(small), + Some("genderqueer") + => flag::genderqueer(), - Some("gendervoid") => flag::gendervoid(small), + Some("gendervoid") + => flag::gendervoid(), - Some("lesbian") => flag::lesbian(small), + Some("lesbian") + => flag::lesbian(), - Some("multigender") => flag::multigender(small), + Some("multigender") + => flag::multigender(), - Some("nb") | - Some("nonbinary") => flag::nonbinary(small), + Some("nonbinary" | "nb") + => flag::nonbinary(), - Some("pan") | - Some("pansexual") => flag::pansexual(small), + Some("pansexual" | "pan") + => flag::pansexual(), _ => { help_text(); exit(1) } - } + }; + + if small { draw::small(colors); } + else { draw::full(colors); } + } fn help_text() { From a5ea3da3b6de9f4b461379efefc8ae4390b88540 Mon Sep 17 00:00:00 2001 From: Valerie Date: Mon, 19 Jun 2023 20:31:30 -0400 Subject: [PATCH 5/9] added rgb byte splitter method to clean up color definitions --- src/color.rs | 6 ++++ src/flag.rs | 82 ++++++++++++++++++++++++++-------------------------- 2 files changed, 47 insertions(+), 41 deletions(-) diff --git a/src/color.rs b/src/color.rs index 4b73b78..5a3a0b5 100644 --- a/src/color.rs +++ b/src/color.rs @@ -9,3 +9,9 @@ pub static WHITE: Color = Fg(Rgb(0xFF, 0xFF, 0xFF)); pub static RESET: Fg = Fg(Reset); +pub fn rgb(hex: u32) -> Color { + let [_, r, g, b] = hex.to_be_bytes(); + + Fg(Rgb(r, g, b)) +} + diff --git a/src/flag.rs b/src/flag.rs index 4ca579e..0e358da 100644 --- a/src/flag.rs +++ b/src/flag.rs @@ -6,19 +6,19 @@ use crate::color::*; pub static BLOCK: &str = "█"; pub fn pride() -> Colors { - 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 = rgb(0xE50000); + let orange = rgb(0xFF8D00); + let yellow = rgb(0xFFEE00); + let green = rgb(0x028121); + let blue = rgb(0x004CFF); + let purple = rgb(0x770088); vec![red, orange, yellow, green, blue, purple] } pub fn transgender() -> Colors { - let pink = color::Fg(color::Rgb(0x7A, 0xCB, 0xF5)); - let blue = color::Fg(color::Rgb(0xEA, 0xAC, 0xB8)); + let pink = rgb(0x7ACBF5); + let blue = rgb(0xEAACB8); vec![pink, blue, WHITE, blue, pink] } @@ -26,94 +26,94 @@ pub fn transgender() -> Colors { // everything below here is alphabetical pub fn agender() -> Colors { - let gray = color::Fg(color::Rgb(0xB9, 0xB9, 0xB9)); - let green = color::Fg(color::Rgb(0xB8, 0xF4, 0x83)); + let gray = rgb(0xB9B9B9); + let green = rgb(0xB8F483); vec![BLACK, gray, WHITE, green, WHITE, gray, BLACK] } pub fn aromantic() -> Colors { - let green = color::Fg(color::Rgb(0x3B, 0xA7, 0x40)); - let lime = color::Fg(color::Rgb(0xA8, 0xD4, 0x7A)); - let grey = color::Fg(color::Rgb(0xAB, 0xAB, 0xAB)); + let green = rgb(0x3BA740); + let lime = rgb(0xA8D47A); + let grey = rgb(0xABABAB); vec![green, lime, WHITE, grey, BLACK] } pub fn asexual() -> Colors { - let grey = color::Fg(color::Rgb(0xA4, 0xA4, 0xA4)); - let purple = color::Fg(color::Rgb(0x81, 0x00, 0x81)); + let grey = rgb(0xA4A4A4); + let purple = rgb(0x810081); vec![BLACK, grey, WHITE, purple] } pub fn bigender() -> Colors { - let pink = color::Fg(color::Rgb(0xE6, 0x76, 0xA6)); - let yellow = color::Fg(color::Rgb(0xF9, 0xF0, 0x4C)); - let purple = color::Fg(color::Rgb(0xAB, 0x6B, 0xBB)); - let blue = color::Fg(color::Rgb(0x6D, 0x96, 0xDC)); + let pink = rgb(0xE676A6); + let yellow = rgb(0xF9F04C); + let purple = rgb(0xAB6BBB); + let blue = rgb(0x6D96DC); vec![pink, yellow, WHITE, purple, blue] } pub fn bisexual() -> Colors { - 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 = rgb(0xC42A6F); + let purple = rgb(0x915392); + let blue = rgb(0x1437A2); vec![magenta, magenta, purple, blue, blue] } pub fn genderfluid() -> Colors { - 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)); + let pink = rgb(0xFF75A2); + let violet = rgb(0xBE18D6); + let blue = rgb(0x333EBD); vec![pink, WHITE, violet, BLACK, blue] } pub fn genderqueer() -> Colors { - let purple = color::Fg(color::Rgb(0xB8, 0x99, 0xDF)); - let green = color::Fg(color::Rgb(0x6B, 0x8E, 0x3B)); + let purple = rgb(0xB899DF); + let green = rgb(0x6B8E3B); vec![purple, WHITE, green] } pub fn gendervoid() -> Colors { - let navy = color::Fg(color::Rgb(0x08, 0x11, 0x4A)); - let gray = color::Fg(color::Rgb(0x4A, 0x48, 0x4B)); + let navy = rgb(0x08114A); + let gray = rgb(0x4A484B); vec![navy, gray, BLACK, gray, navy] } pub fn lesbian() -> Colors { - let red = color::Fg(color::Rgb(0xD6, 0x28, 0x00)); - let orange = color::Fg(color::Rgb(0xFF, 0x9B, 0x56)); - let pink = color::Fg(color::Rgb(0xD4, 0x62, 0xA6)); - let magenta = color::Fg(color::Rgb(0xA4, 0x00, 0x62)); + let red = rgb(0xD62800); + let orange = rgb(0xFF9B56); + let pink = rgb(0xD462A6); + let magenta = rgb(0xA40062); vec![red, orange, WHITE, pink, magenta] } pub fn multigender() -> Colors { - 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 = rgb(0x3F47CC); + let ltblue = rgb(0x01A4E9); + let orange = rgb(0xFB7F27); vec![blue, ltblue, orange, ltblue, blue] } pub fn nonbinary() -> Colors { - let yellow = color::Fg(color::Rgb(0xFF, 0xF4, 0x33)); - let purple = color::Fg(color::Rgb(0x9B, 0x59, 0xD0)); + let yellow = rgb(0xFFF433); + let purple = rgb(0x9B59D0); vec![yellow, WHITE, purple, BLACK] } pub fn pansexual() -> Colors { - 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 = rgb(0xFF1B8D); + let yellow = rgb(0xFFDA00); + let cyan = rgb(0x1BB3FF); vec![magenta, yellow, cyan] } From d12052877af332629cb802a8b401fd9508c87336 Mon Sep 17 00:00:00 2001 From: Valerie Date: Mon, 19 Jun 2023 20:36:03 -0400 Subject: [PATCH 6/9] version bump and minor use statement cleanup --- Cargo.toml | 2 +- src/flag.rs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index de83030..9d7fe7c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pride" -version = "0.1.0" +version = "0.1.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/flag.rs b/src/flag.rs index 0e358da..2da1984 100644 --- a/src/flag.rs +++ b/src/flag.rs @@ -1,6 +1,4 @@ -use termion::color; - use crate::color::*; pub static BLOCK: &str = "█"; From bbbfc924dea036e31801adc4c3de01981999e751 Mon Sep 17 00:00:00 2001 From: Valerie Date: Mon, 19 Jun 2023 20:38:09 -0400 Subject: [PATCH 7/9] updated README --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7d50fa7..aac4314 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,8 @@ A Rust utility to display pride flags in the terminal. **This project is under heavy construction! It is subject to major structural and -architectural changes. There are no issues with functionality, but I am not -satisfied with the current state of the project. The software is usable, but I will -continue to refer to it as pre-release until I am happy with it.** +architectural changes. There are no issues with functionality, but I will continue +to make major changes and refactors until the main roadmap is complete.** Currently supports a variety of stripe flags. From de5aa01dafc3ef3bc409d588aa94432bd7bd23ff Mon Sep 17 00:00:00 2001 From: Valerie Date: Mon, 19 Jun 2023 20:51:45 -0400 Subject: [PATCH 8/9] added version flag --- Cargo.toml | 2 +- src/main.rs | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9d7fe7c..390af44 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pride" -version = "0.1.1" +version = "0.1.2" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/main.rs b/src/main.rs index 37aed81..6a36119 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,21 +8,30 @@ mod flag; use crate::color::Colors; +static VERSION = env!("CARGO_PKG_VERSION"); + fn main() { let mut args = Arguments::from_env(); - let help = args.contains(["-h", "--help"]); - if help { + // handle help flag + if args.contains(["-h", "--help"]) { help_text(); return; } - let list = args.contains(["-l", "--list"]); - if list { + // handle list flag + if args.contains(["-l", "--list"]) { list_text(); return; } - + + // handle version flag + if args.contains("--version") { + println!("pride v{VERSION}"); + return; + } + + // get small flag let small = args.contains(["-s", "--small"]); let subcommand = args.subcommand().unwrap(); @@ -80,7 +89,7 @@ fn main() { } fn help_text() { - println!("pride v{}", env!("CARGO_PKG_VERSION")); + println!("pride v{VERSION}"); println!("Valerie Wolfe "); println!("Show pride flags in the terminal.\n"); @@ -91,6 +100,7 @@ fn help_text() { println!("flags:"); println!(" -h, --help Shows this help text"); + println!(" --version Show version information"); println!(" -l, --list Prints a list of printable flags"); println!(" -s, --small Prints a small version without holding"); From 3e86e4f05328497e59d98d808bef071b2984f73f Mon Sep 17 00:00:00 2001 From: Valerie Date: Mon, 19 Jun 2023 20:52:22 -0400 Subject: [PATCH 9/9] added missing type annotation --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 6a36119..8a83e55 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,7 @@ mod flag; use crate::color::Colors; -static VERSION = env!("CARGO_PKG_VERSION"); +static VERSION: &str = env!("CARGO_PKG_VERSION"); fn main() { let mut args = Arguments::from_env();