From 930e26a0375e13117780a39fca87b91b889db418 Mon Sep 17 00:00:00 2001 From: Valerie Date: Mon, 10 Jul 2023 14:33:04 -0400 Subject: [PATCH 1/6] fixed a typo --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index f453cb4..4dff1d4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -123,7 +123,7 @@ fn main() { // => complex::polyamorous(), Some("progress") - => flag::progress(), + => complex::progress(small), _ => { help_text(); exit(1) } }; From 18b7b7424ade02b2ede08b4a2644ab6ca1d93ebd Mon Sep 17 00:00:00 2001 From: Valerie Date: Sun, 16 Jul 2023 13:45:13 -0400 Subject: [PATCH 2/6] updated README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8a17e47..a1a4f6b 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,6 @@ slant symbols, and therefore require use of a Powerline font, such as [Fira Code ## Libraries -- [pico-args](https://crates.io/crates/pico-args) -- [termion](https://crates.io/crates/termion) +- [pico-args](https://crates.io/crates/pico-args) — argument parsing +- [termion](https://crates.io/crates/termion) — ANSI formatting From 2617c192275a2eb23e4035fa1b62b4aabb12e902 Mon Sep 17 00:00:00 2001 From: Valerie Date: Sun, 16 Jul 2023 13:46:55 -0400 Subject: [PATCH 3/6] partial implementation for polyamory flag; blank cutin and stripes --- src/complex.rs | 67 +++++++++++++++++++++++++++++++++++++++----------- src/main.rs | 6 ++--- 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/src/complex.rs b/src/complex.rs index c3355cd..29a1deb 100644 --- a/src/complex.rs +++ b/src/complex.rs @@ -52,16 +52,6 @@ pub fn progress(small: bool) -> Flag { // set up stripe index let mut index = 0; - /* ok, coming up with procedure: - * - can't rely on bg_stripes; line count, threshold, etc., will need to happen here - * - line count will always be the largest multiple of 6 smaller than height; c = h - (h % 6) - * - chevrons may have larger widths: TODO calc - * - depth will be funky; line depth will need to use "full" depth; (Df - Dl) / Wc = Ic (TODO verify?) - * - switch stripe index on *absolute* line number rather than n - * - chevron building will be BLOCK.repeat(width) + TRIANGLE_21[0] (fg Ic, bg Ic + 1) - * - chevrons[len - 1] will need unique handling to draw stripes - */ - // set up constraints let linecount = height - (height % 6); // largest multiple of 6 smaller than height let full_depth = width / 3; @@ -280,13 +270,62 @@ pub fn intersex() -> Flag { Flag::Lines(lines) } -pub fn polyamorous() { +pub fn polyamory(small: bool) -> Flag { let blue = rgb(0x019FE3); let magenta = rgb(0xE50051); let purple = rgb(0x340C46); - let yellow = rgb(0x00FCBF); + let yellow = rgb(0xFCBF00); + let white = bg(0xFFFFFF); - // blue / magenta / purple vert - // WHITE isosceles cutin with yellow heart pointed right + // special characters + let semicircle = '\u{E0B6}'; + let separators = ['\u{E0BE}', '\u{E0BA}']; + + let (width, height) = if small { (18, 6) } else { terminal_size().unwrap() }; + + // create stripe array and line buffer + let stripes = [magenta, purple]; // only stripes 2 and 3 need tracked + let mut lines: Vec = Vec::new(); + + // constraints + let linecount = height - (height % 3); // largest multiple of 3 smaller than height + let full_depth = width / 3; + let thresh = linecount / 3; // stripe & direction thresh + let start = width / 6; + + // piecewise function: ascent -> descent + let mut separator = separators[0]; + for n in 0..thresh { + let size = start + n; + + let line = format!( + "{white}{yellow}{cutin}{blue}{separator}{stripe}", + cutin = " ".repeat(size as usize), + stripe = draw::BLOCK.repeat((width - (size + 1)) as usize) + ); + + lines.push(line); + } + // first piece goes until the end of stripes[0] + let mut index = 0; // stripe index + separator = separators[1]; + for n in thresh..linecount { + // advance index at threshold + if n == (thresh * 2) { index = 1; } + + let rel = (n - thresh) + 2; + let size = full_depth - rel; + let color = stripes[index]; + + let line = format!( + "{white}{yellow}{cutin}{color}{separator}{stripe}", + cutin = " ".repeat(size as usize), + stripe = draw::BLOCK.repeat((width - (size + 1)) as usize) + ); + + lines.push(line); + } + + Flag::Lines(lines) } diff --git a/src/main.rs b/src/main.rs index 4dff1d4..8135099 100644 --- a/src/main.rs +++ b/src/main.rs @@ -119,8 +119,8 @@ fn main() { Some("pansexual" | "pan") => flag::pansexual(), -// Some("poly" | "polyamorous" | "polyamory") -// => complex::polyamorous(), + Some("polyamory" | "polyamorous" | "poly") + => complex::polyamory(small), Some("progress") => complex::progress(small), @@ -174,7 +174,7 @@ fn list_text() { println!(" multigender multigender pride flag"); println!(" nb, nonbinary nonbinary pride flag"); println!(" pan, pansexual pansexual pride flag"); -// println!(" poly, polyamorous polyamorous pride flag"); + println!(" polyamory polyamorous pride flag"); println!(" pride, rainbow six-color rainbow flag"); println!(" progress progress arrow flag"); println!(" trans, transgender transgender pride flag"); From 02d06b68efd23a609cae91a1673c58c1108a7c86 Mon Sep 17 00:00:00 2001 From: Valerie Date: Mon, 14 Aug 2023 11:51:13 -0400 Subject: [PATCH 4/6] added terminal check --- src/main.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 8135099..1d8f59c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,7 @@ -use std::process::exit; +use std::{ + io::{ stdout, IsTerminal }, + process::exit +}; use pico_args::Arguments; @@ -35,6 +38,11 @@ fn main() { return; } + if !stdout().is_terminal() { + println!("pride: output must be a terminal"); + exit(2); + } + // get small flag let small = args.contains(["-s", "--small"]); From 515f6da05cffeae28fc1656ba8e18c4fa69c6a85 Mon Sep 17 00:00:00 2001 From: Valerie Date: Mon, 14 Aug 2023 11:51:29 -0400 Subject: [PATCH 5/6] version bump --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 83d9966..a8d1643 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pride" -version = "0.2.1" +version = "0.2.2" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html From 992b07edcc194dac5080e23bb0529cc3fa55f953 Mon Sep 17 00:00:00 2001 From: Valerie Date: Sun, 3 Sep 2023 15:58:48 -0400 Subject: [PATCH 6/6] minor structure changes and added a variant of the aroace flag --- src/flag.rs | 24 +++++++++++++++++------- src/main.rs | 25 ++++++++++++++++--------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/flag.rs b/src/flag.rs index d20247d..864876c 100644 --- a/src/flag.rs +++ b/src/flag.rs @@ -20,13 +20,6 @@ pub fn pride() -> Flag { Flag::Stripes(vec![red, orange, yellow, green, blue, purple]) } -pub fn transgender() -> Flag { - let pink = rgb(0x7ACBF5); - let blue = rgb(0xEAACB8); - - Flag::Stripes(vec![pink, blue, WHITE, blue, pink]) -} - // everything below here is alphabetical pub fn agender() -> Flag { @@ -51,6 +44,15 @@ pub fn asexual() -> Flag { Flag::Stripes(vec![BLACK, grey, WHITE, purple]) } +pub fn aroace() -> Flag { + let orange = rgb(0xE28D00); + let yellow = rgb(0xEBE200); + let blue = rgb(0x67B7E8); + let navy = rgb(0x203756); + + Flag::Stripes(vec![orange, yellow, WHITE, blue, navy]) +} + pub fn bigender() -> Flag { let pink = rgb(0xE676A6); let yellow = rgb(0xF9F04C); @@ -141,3 +143,11 @@ pub fn pansexual() -> Flag { Flag::Stripes(vec![magenta, yellow, cyan]) } +pub fn transgender() -> Flag { + let pink = rgb(0x7ACBF5); + let blue = rgb(0xEAACB8); + + Flag::Stripes(vec![pink, blue, WHITE, blue, pink]) +} + + diff --git a/src/main.rs b/src/main.rs index 1d8f59c..545da60 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,14 +46,14 @@ fn main() { // get small flag let small = args.contains(["-s", "--small"]); - let subcommand = args.subcommand().unwrap(); + let subcommand = args.subcommand().unwrap(); + let variant = args.subcommand().unwrap_or(None); // get color vec from matched flag let flag: Flag = match subcommand.as_deref() { Some("pride" | "rainbow") | None => { - let variant = args.subcommand().unwrap_or(None); match variant.as_deref() { Some("8-color" | "gilbert-baker" | "sex-and-magic") => variant::gilbert_baker(), @@ -66,8 +66,8 @@ fn main() { } }, - Some("transgender" | "trans") - => flag::transgender(), + Some("progress") + => complex::progress(small), Some("agender") @@ -80,7 +80,14 @@ fn main() { => flag::asexual(), Some("aroace" | "aromantic-asexual") - => complex::aroace(small), + => { + match variant.as_deref() { + Some("halves" | "side-by-side" | "sbs") + => complex::aroace(small), + _ + => flag::aroace() + } + }, Some("bigender") => flag::bigender(), @@ -112,8 +119,8 @@ fn main() { Some("gendervoid") => flag::gendervoid(), - Some("intersex") - => complex::intersex(), +// Some("intersex") +// => complex::intersex(), Some("lesbian") => flag::lesbian(), @@ -130,8 +137,8 @@ fn main() { Some("polyamory" | "polyamorous" | "poly") => complex::polyamory(small), - Some("progress") - => complex::progress(small), + Some("transgender" | "trans") + => flag::transgender(), _ => { help_text(); exit(1) } };