Compare commits

..

No commits in common. "18af36ddeba9a97789bade785b8c623a407dbe4f" and "e4f056a8d4a7c8e7920dee37ea5a9d2f356116e5" have entirely different histories.

7 changed files with 240 additions and 207 deletions

View file

@ -1,6 +1,6 @@
[package] [package]
name = "pride" name = "pride"
version = "0.1.2" version = "0.0.1"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -4,8 +4,9 @@
A Rust utility to display pride flags in the terminal. A Rust utility to display pride flags in the terminal.
**This project is under heavy construction! It is subject to major structural and **This project is under heavy construction! It is subject to major structural and
architectural changes. There are no issues with functionality, but I will continue architectural changes. There are no issues with functionality, but I am not
to make major changes and refactors until the main roadmap is complete.** 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.**
Currently supports a variety of stripe flags. Currently supports a variety of stripe flags.

View file

@ -1,17 +0,0 @@
use termion::color::{ Fg, Rgb, Reset };
pub type Color = Fg<Rgb>;
pub type Colors = Vec<Fg<Rgb>>;
pub static BLACK: Color = Fg(Rgb(0x00, 0x00, 0x00));
pub static WHITE: Color = Fg(Rgb(0xFF, 0xFF, 0xFF));
pub static RESET: Fg<Reset> = Fg(Reset);
pub fn rgb(hex: u32) -> Color {
let [_, r, g, b] = hex.to_be_bytes();
Fg(Rgb(r, g, b))
}

View file

@ -1,18 +1,22 @@
use std::io::{ self, Write }; use std::{
io,
io::Write
};
use termion::{ use termion::{
terminal_size, terminal_size,
clear, clear,
color::{ Fg, Rgb },
cursor, cursor,
input::TermRead, input::TermRead,
raw::IntoRawMode raw::IntoRawMode,
style
}; };
use crate::color::{ RESET, Colors };
use crate::flag::BLOCK; use crate::flag::BLOCK;
pub fn full(colors: Colors) { pub fn draw(colors: &[Fg<Rgb>]) {
let mut stdout = io::stdout().into_raw_mode().unwrap(); let mut stdout = io::stdout().into_raw_mode().unwrap();
let stdin = io::stdin(); let stdin = io::stdin();
@ -24,6 +28,7 @@ pub fn full(colors: Colors) {
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) {
@ -33,7 +38,7 @@ pub fn full(colors: Colors) {
} }
write!( write!(
stdout, stdout,
"{color}{stripe}{RESET}", "{color}{stripe}{reset}",
color = colors[index] color = colors[index]
).ok(); ).ok();
} }
@ -44,18 +49,4 @@ pub fn full(colors: Colors) {
stdout.flush().ok(); 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();
}

View file

@ -1,118 +1,239 @@
use crate::color::*; use termion::color;
use crate::draw::draw;
pub static BLOCK: &str = ""; pub static BLOCK: &str = "";
pub fn pride() -> Colors { pub fn pride(small: bool) {
let red = rgb(0xE50000); let red = color::Fg(color::Rgb(0xE5, 0x00, 0x00));
let orange = rgb(0xFF8D00); let orange = color::Fg(color::Rgb(0xFF, 0x8D, 0x00));
let yellow = rgb(0xFFEE00); let yellow = color::Fg(color::Rgb(0xFF, 0xEE, 0x00));
let green = rgb(0x028121); let green = color::Fg(color::Rgb(0x02, 0x81, 0x21));
let blue = rgb(0x004CFF); let blue = color::Fg(color::Rgb(0x00, 0x4C, 0xFF));
let purple = rgb(0x770088); let purple = color::Fg(color::Rgb(0x77, 0x00, 0x88));
vec![red, orange, yellow, green, blue, purple] 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}",
reset = color::Fg(color::Reset),
stripe = BLOCK.repeat(width)
);
} else { draw(&[red, orange, yellow, green, blue, purple]); }
} }
pub fn transgender() -> Colors { pub fn transgender(small: bool) {
let pink = rgb(0x7ACBF5); let pink = color::Fg(color::Rgb(0x7A, 0xCB, 0xF5));
let blue = rgb(0xEAACB8); let blue = color::Fg(color::Rgb(0xEA, 0xAC, 0xB8));
let white = color::Fg(color::Rgb(0xFF, 0xFF, 0xFF));
vec![pink, blue, WHITE, blue, pink] 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),
stripe = BLOCK.repeat(width)
);
} else { draw(&[pink, blue, white, blue, pink]); }
} }
// everything below here is alphabetical // everything below here is alphabetical
pub fn agender() -> Colors { pub fn aromantic(small: bool) {
let gray = rgb(0xB9B9B9); let green = color::Fg(color::Rgb(0x3B, 0xA7, 0x40));
let green = rgb(0xB8F483); 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));
vec![BLACK, gray, WHITE, green, WHITE, gray, BLACK] 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),
stripe = BLOCK.repeat(width)
);
} else { draw(&[green, lime, white, grey, black]); }
} }
pub fn aromantic() -> Colors { pub fn asexual(small: bool) {
let green = rgb(0x3BA740); let black = color::Fg(color::Rgb(0x00, 0x00, 0x00));
let lime = rgb(0xA8D47A); let grey = color::Fg(color::Rgb(0xA4, 0xA4, 0xA4));
let grey = rgb(0xABABAB); let white = color::Fg(color::Rgb(0xFF, 0xFF, 0xFF));
let purple = color::Fg(color::Rgb(0x81, 0x00, 0x81));
vec![green, lime, WHITE, grey, BLACK] if small {
let width = 12;
println!(
"{black}{stripe}\n{grey}{stripe}\n{white}{stripe}\n{purple}{stripe}{reset}",
reset = color::Fg(color::Reset),
stripe = BLOCK.repeat(width)
);
} else { draw(&[black, grey, white, purple]); }
} }
pub fn asexual() -> Colors { pub fn bigender(small: bool) {
let grey = rgb(0xA4A4A4); let pink = color::Fg(color::Rgb(0xE6, 0x76, 0xA6));
let purple = rgb(0x810081); 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));
vec![BLACK, grey, WHITE, purple] if small {
let width = 15;
println!(
"{pink}{stripe}\n{yellow}{stripe}\n{white}{stripe}\n{purple}{stripe}\n{blue}{stripe}{reset}",
reset = color::Fg(color::Reset),
stripe = BLOCK.repeat(width)
);
} else { draw(&[pink, yellow, white, purple, blue]); }
} }
pub fn bigender() -> Colors { pub fn bisexual(small: bool) {
let pink = rgb(0xE676A6); let magenta = color::Fg(color::Rgb(0xC4, 0x2A, 0x6F));
let yellow = rgb(0xF9F04C); let purple = color::Fg(color::Rgb(0x91, 0x53, 0x92));
let purple = rgb(0xAB6BBB); let blue = color::Fg(color::Rgb(0x14, 0x37, 0xA2));
let blue = rgb(0x6D96DC);
vec![pink, yellow, WHITE, purple, blue] if small {
let width = 15;
println!(
"{magenta}{stripe}\n{stripe}\n{purple}{stripe}\n{blue}{stripe}\n{stripe}{reset}",
reset = color::Fg(color::Reset),
stripe = BLOCK.repeat(width)
);
} else { draw(&[magenta, magenta, purple, blue, blue]); }
} }
pub fn bisexual() -> Colors { pub fn gendervoid(small: bool) {
let magenta = rgb(0xC42A6F); let navy = color::Fg(color::Rgb(0x08, 0x11, 0x4A));
let purple = rgb(0x915392); let gray = color::Fg(color::Rgb(0x4A, 0x48, 0x4B));
let blue = rgb(0x1437A2); let black = color::Fg(color::Rgb(0x00, 0x00, 0x00));
vec![magenta, magenta, purple, blue, blue] 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),
stripe = BLOCK.repeat(width)
);
} else { draw(&[navy, gray, black, gray, navy]); }
} }
pub fn genderfluid() -> Colors { pub fn lesbian(small: bool) {
let pink = rgb(0xFF75A2); let red = color::Fg(color::Rgb(0xD6, 0x28, 0x00));
let violet = rgb(0xBE18D6); let orange = color::Fg(color::Rgb(0xFF, 0x9B, 0x56));
let blue = rgb(0x333EBD); 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));
vec![pink, WHITE, violet, BLACK, blue] if small {
let width = 15;
println!(
"{red}{stripe}\n{orange}{stripe}\n{white}{stripe}\n{pink}{stripe}\n{magenta}{stripe}{reset}",
reset = color::Fg(color::Reset),
stripe = BLOCK.repeat(width)
);
} else { draw(&[red, orange, white, pink, magenta]); }
} }
pub fn genderqueer() -> Colors { pub fn multigender(small: bool) {
let purple = rgb(0xB899DF); let blue = color::Fg(color::Rgb(0x3F, 0x47, 0xCC));
let green = rgb(0x6B8E3B); let ltblue = color::Fg(color::Rgb(0x01, 0xA4, 0xE9));
let orange = color::Fg(color::Rgb(0xFB, 0x7F, 0x27));
vec![purple, WHITE, green] if small {
let width = 15;
println!(
"{blue}{stripe}\n{ltblue}{stripe}\n{orange}{stripe}\n{ltblue}{stripe}\n{blue}{stripe}{reset}",
reset = color::Fg(color::Reset),
stripe = BLOCK.repeat(width)
);
} else { draw(&[blue, ltblue, orange, ltblue, blue]); }
} }
pub fn gendervoid() -> Colors { pub fn nonbinary(small: bool) {
let navy = rgb(0x08114A); let yellow = color::Fg(color::Rgb(0xFF, 0xF4, 0x33));
let gray = rgb(0x4A484B); 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));
vec![navy, gray, BLACK, gray, navy] if small {
let width = 12;
println!(
"{yellow}{stripe}\n{white}{stripe}\n{purple}{stripe}\n{black}{stripe}{reset}",
reset = color::Fg(color::Reset),
stripe = BLOCK.repeat(width)
);
} else { draw(&[yellow, white, purple, black]); }
} }
pub fn lesbian() -> Colors { pub fn pansexual(small: bool) {
let red = rgb(0xD62800); let magenta = color::Fg(color::Rgb(0xFF, 0x1B, 0x8D));
let orange = rgb(0xFF9B56); let yellow = color::Fg(color::Rgb(0xFF, 0xDA, 0x00));
let pink = rgb(0xD462A6); let cyan = color::Fg(color::Rgb(0x1B, 0xB3, 0xFF));
let magenta = rgb(0xA40062);
vec![red, orange, WHITE, pink, magenta] if small {
let width = 18;
println!(
"{magenta}{stripe}\n{stripe}\n{yellow}{stripe}\n{stripe}\n{cyan}{stripe}\n{stripe}{reset}",
reset = color::Fg(color::Reset),
stripe = BLOCK.repeat(width)
);
} else { draw(&[magenta, yellow, cyan]); }
} }
pub fn multigender() -> Colors { // misc variants
let blue = rgb(0x3F47CC);
let ltblue = rgb(0x01A4E9);
let orange = rgb(0xFB7F27);
vec![blue, ltblue, orange, ltblue, blue] pub fn gilbert(small: bool) {
let pink = color::Fg(color::Rgb(0xFF, 0x69, 0xB4));
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 cyan = color::Fg(color::Rgb(0x00, 0xC0, 0xC0));
let blue = color::Fg(color::Rgb(0x00, 0x4C, 0xFF));
let purple = color::Fg(color::Rgb(0x77, 0x00, 0x88));
if small {
let width = 24;
println!(
"{pink}{stripe}\n{red}{stripe}\n{orange}{stripe}\n{yellow}{stripe}\n{green}{stripe}\n{cyan}{stripe}\n{blue}{stripe}\n{purple}{stripe}{reset}",
reset = color::Fg(color::Reset),
stripe = BLOCK.repeat(24)
);
} else { draw(&[pink, red, orange, yellow, green, cyan, blue, purple]); }
} }
pub fn nonbinary() -> Colors { pub fn philadelphia(small: bool) {
let yellow = rgb(0xFFF433); let black = color::Fg(color::Rgb(0x00, 0x00, 0x00));
let purple = rgb(0x9B59D0); let brown = color::Fg(color::Rgb(0x78, 0x4F, 0x17));
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));
vec![yellow, WHITE, purple, BLACK] if small {
let width = 24;
println!(
"{black}{stripe}\n{brown}{stripe}\n{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)
);
} else { draw(&[black, brown, red, orange, yellow, green, blue, purple]); }
} }
pub fn pansexual() -> Colors {
let magenta = rgb(0xFF1B8D);
let yellow = rgb(0xFFDA00);
let cyan = rgb(0x1BB3FF);
vec![magenta, yellow, cyan]
}

View file

@ -2,105 +2,73 @@ use std::process::exit;
use pico_args::Arguments; use pico_args::Arguments;
mod color;
mod draw; mod draw;
mod flag; mod flag;
mod variant;
use crate::color::Colors;
static VERSION: &str = env!("CARGO_PKG_VERSION");
fn main() { fn main() {
let mut args = Arguments::from_env(); let mut args = Arguments::from_env();
// handle help flag let help = args.contains(["-h", "--help"]);
if args.contains(["-h", "--help"]) { if help {
help_text(); help_text();
return; return;
} }
// handle list flag let list = args.contains(["-l", "--list"]);
if args.contains(["-l", "--list"]) { if list {
list_text(); list_text();
return; return;
} }
// handle version flag
if args.contains("--version") {
println!("pride v{VERSION}");
return;
}
// get small flag
let small = args.contains(["-s", "--small"]); let small = args.contains(["-s", "--small"]);
let subcommand = args.subcommand().unwrap(); let subcommand = args.subcommand().unwrap();
let colors: Colors = match subcommand.as_deref() { match subcommand.as_deref() {
Some("pride" | "gay") Some("pride") |
=> { Some("gay") => flag::pride(small),
let variant = args.subcommand().unwrap_or(None);
match variant.as_deref() {
Some("8-color" | "gilbert-baker" | "sex-and-magic")
=> variant::gilbert_baker(),
Some("philadelphia")
=> variant::philadelphia(),
_
=> flag::pride()
}
},
Some("transgender" | "trans") Some("trans") |
=> flag::transgender(), Some("transgender") => flag::transgender(small),
Some("agender") Some("aro") |
=> flag::agender(), Some("aromantic") => flag::aromantic(small),
Some("aromantic" | "aro") Some("ace") |
=> flag::aromantic(), Some("asexual") => flag::asexual(small),
Some("asexual" | "ace") Some("bigender") => flag::bigender(small),
=> flag::asexual(),
Some("bigender") Some("bi") |
=> flag::bigender(), Some("bisexual") => flag::bisexual(small),
Some("bisexual" | "bi") Some("gendervoid") => flag::gendervoid(small),
=> flag::bisexual(),
Some("genderfluid") Some("lesbian") => flag::lesbian(small),
=> flag::genderfluid(),
Some("genderqueer") Some("multigender") => flag::multigender(small),
=> flag::genderqueer(),
Some("gendervoid") Some("nb") |
=> flag::gendervoid(), Some("nonbinary") => flag::nonbinary(small),
Some("lesbian") Some("pan") |
=> flag::lesbian(), Some("pansexual") => flag::pansexual(small),
Some("multigender")
=> flag::multigender(),
Some("nonbinary" | "nb") Some("sex-and-magic")|
=> flag::nonbinary(), Some("baker") |
Some("gilbert") => flag::gilbert(small),
Some("pansexual" | "pan") Some("philly") |
=> flag::pansexual(), Some("philadelphia")=> flag::philadelphia(small),
_ => { help_text(); exit(1) } _ => { help_text(); exit(1) }
}; }
if small { draw::small(colors); }
else { draw::full(colors); }
} }
fn help_text() { fn help_text() {
println!("pride v{VERSION}"); println!("pride v{}", env!("CARGO_PKG_VERSION"));
println!("Valerie Wolfe <sleeplessval@gmail.com>"); println!("Valerie Wolfe <sleeplessval@gmail.com>");
println!("Show pride flags in the terminal.\n"); println!("Show pride flags in the terminal.\n");
@ -111,7 +79,6 @@ fn help_text() {
println!("flags:"); println!("flags:");
println!(" -h, --help Shows this help text"); println!(" -h, --help Shows this help text");
println!(" --version Show version information");
println!(" -l, --list Prints a list of printable flags"); println!(" -l, --list Prints a list of printable flags");
println!(" -s, --small Prints a small version without holding"); println!(" -s, --small Prints a small version without holding");
@ -122,14 +89,11 @@ fn help_text() {
fn list_text() { fn list_text() {
println!("pride v{}", env!("CARGO_PKG_VERSION")); println!("pride v{}", env!("CARGO_PKG_VERSION"));
println!("\nFlag list:"); println!("\nFlag list:");
println!(" agender agender pride flag");
println!(" aro, aromantic aromantic pride flag"); println!(" aro, aromantic aromantic pride flag");
println!(" ace, asexual asexual pride flag"); println!(" ace, asexual asexual pride flag");
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!(" genderfluid genderfluid pride 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");

View file

@ -1,27 +0,0 @@
use crate::{
color::*,
flag
};
pub fn gilbert_baker() -> Colors {
let pink = rgb(0xFF69B4); // sex
let cyan = rgb(0x00C0C0); // magic
let mut output = flag::pride();
output.insert(0, pink);
output.insert(5, cyan);
output
}
pub fn philadelphia() -> Colors {
let brown = rgb(0x784F17);
let mut output = flag::pride();
output.insert(0, BLACK);
output.insert(1, brown);
output
}