merged in changes from main

This commit is contained in:
Valerie Wolfe 2023-09-03 16:04:47 -04:00
commit f94bbcb042
6 changed files with 162 additions and 36 deletions

View file

@ -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

View file

@ -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

View file

@ -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<String> = 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)
}

View file

@ -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])
}

View file

@ -1,7 +1,6 @@
use crate::VERSION;
pub fn help_text() {
println!("pride v{VERSION}
Valerie Wolfe <sleeplessval@gmail.com>
@ -33,6 +32,8 @@ flag list:
asexual asexual pride flag
bigender bigender pride flag
bisexual bisexual pride flag
demiromantic demiromantic pride flag
demisexual demisexual pride flag
gay gay men pride flag
genderfluid genderfluid pride flag
gender-nonconforming gender nonconforming pride flag
@ -82,11 +83,16 @@ names:
=> { println!("The asexual pride flag.\n\nnames:\n 'asexual', 'ace'"); }
"aroace" | "aromantic-asexual"
=> {
println!("The aromantic-asexual pride flag.
println!("The aromantic-asexual pride flag designed by aroaesflags on tumblr.
names:
'aroace', 'aromantic-asexual'
variants:
halves The side-by-side aromantic and asexual aroace flag
side-by-side
sbs
notes:
Currently only displays in terminals 20 lines or taller.");
},

View file

@ -1,4 +1,7 @@
use std::process::exit;
use std::{
io::{ stdout, IsTerminal },
process::exit
};
use pico_args::Arguments;
@ -38,17 +41,22 @@ 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"]);
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(),
@ -61,8 +69,8 @@ fn main() {
}
},
Some("transgender" | "trans")
=> flag::transgender(),
Some("progress")
=> complex::progress(small),
Some("agender")
@ -75,7 +83,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(),
@ -107,8 +122,8 @@ fn main() {
Some("gendervoid")
=> flag::gendervoid(),
Some("intersex")
=> complex::intersex(),
// Some("intersex")
// => complex::intersex(),
Some("lesbian")
=> {
@ -130,11 +145,16 @@ fn main() {
Some("pansexual" | "pan")
=> flag::pansexual(),
// Some("poly" | "polyamorous" | "polyamory")
// => complex::polyamorous(),
Some("polyamory" | "polyamorous" | "poly")
=> complex::polyamory(small),
<<<<<<< HEAD
Some("progress")
=> complex::progress(small),
=======
Some("transgender" | "trans")
=> flag::transgender(),
>>>>>>> main
_ => { help::help_text(); exit(1) }
};
@ -143,3 +163,54 @@ fn main() {
}
<<<<<<< HEAD
=======
fn help_text() {
println!("pride v{VERSION}");
println!("Valerie Wolfe <sleeplessval@gmail.com>");
println!("Show pride flags in the terminal.\n");
println!("usage: pride [flags] [name]\n");
println!("args:");
println!(" <name> The pride flag to display\n");
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");
println!("\nUse 'pride --list' to see a list of printable flags");
println!("\n~ You're loved and you matter ♥");
}
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!(" aroace aromantic/asexual pride flag");
println!(" bigender bigender pride flag");
println!(" bi, bisexual bisexual pride flag");
println!(" demiromantic demiromantic pride flag");
println!(" demisexual demisexual pride flag");
// println!(" disability disability pride flag");
println!(" gay, mlm gay men pride flag");
println!(" genderfluid genderfluid pride flag");
println!(" gender-nonconforming gender nonconforming pride flag");
println!(" genderqueer genderqueer pride flag");
println!(" gendervoid gendervoid pride flag");
// println!(" intersex intersex pride flag");
println!(" lesbian lesbian pride flag");
println!(" multigender multigender pride flag");
println!(" nb, nonbinary nonbinary pride flag");
println!(" pan, pansexual pansexual 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");
}
>>>>>>> main