Compare commits
7 commits
f8e02e06fb
...
73f8137c5b
Author | SHA1 | Date | |
---|---|---|---|
73f8137c5b | |||
76fa83fd45 | |||
4f1952f6c0 | |||
1c71bd1ce1 | |||
cadb1949a7 | |||
a74f2e5acc | |||
a003aaa797 |
10 changed files with 301 additions and 306 deletions
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "pride"
|
||||
version = "0.1.4"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
|
16
README.md
16
README.md
|
@ -4,11 +4,19 @@
|
|||
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 will continue
|
||||
to make major changes and refactors until the main roadmap is complete.**
|
||||
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.**
|
||||
|
||||
Currently supports a variety of stripe flags.
|
||||
|
||||
Under Construction features:
|
||||
- ["Complex" Flags](https://git.vwolfe.io/valerie/pride/src/branch/complex)
|
||||
## "Complex" Flag Branch
|
||||
|
||||
This branch adds "complex" flags that require a little more effort to render than
|
||||
iterating over an array of colors. Currently, the branch aims to add the following
|
||||
flags:
|
||||
- Progress: 2018 rainbow pride flag with black and brown and transgender flag chevrons
|
||||
- Aro/Ace: side-by-side aromantic and asexual combination flag
|
||||
- Intersex: a yellow flag with a purple circle
|
||||
- Polyamorous: three-stripe flag with an isosceles triangle cut-in and a heart
|
||||
|
||||
|
|
17
src/color.rs
17
src/color.rs
|
@ -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))
|
||||
}
|
||||
|
148
src/complex.rs
148
src/complex.rs
|
@ -1,63 +1,103 @@
|
|||
use std::process::exit;
|
||||
use std::io::{
|
||||
stdin, stdout,
|
||||
|
||||
use crate::color::*;
|
||||
use crate::draw;
|
||||
use crate::flag;
|
||||
use crate::variant;
|
||||
Write
|
||||
};
|
||||
|
||||
pub fn progress() {
|
||||
let philadelphia = variant::philadelphia();
|
||||
let trans = flag::transgender();
|
||||
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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// everything below this point is in alphabetical order
|
||||
|
||||
pub fn aroace() {
|
||||
let aro = flag::aromantic();
|
||||
let ace = flag::asexual();
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
pub fn demiromantic() {
|
||||
let green = rgb(0x3DA542);
|
||||
let gray = rgb(0xD2D2D2);
|
||||
|
||||
// WHITE×2 / green / gray×2 vert
|
||||
// BLACK triangle cutin
|
||||
}
|
||||
|
||||
pub fn demisexual() {
|
||||
let purple = rgb(0x832FA8);
|
||||
let grey = rgb(0x7B868C);
|
||||
|
||||
// WHITE×2 / green / grey×2 vert
|
||||
// BLACK triangle cutin
|
||||
}
|
||||
|
||||
pub fn intersex() -> Colors {
|
||||
let yellow = rgb(0xFFDA00);
|
||||
let purple = rgb(0x7A00AC);
|
||||
|
||||
let stripe = draw::BLOCK.repeat(9);
|
||||
let part = draw::BLOCK.repeat(4);
|
||||
|
||||
println!(
|
||||
"{yellow}{stripe}\n{part}{purple}{}O{}{yellow}{part}\n{stripe}{RESET}",
|
||||
yellow.0.bg_string(),
|
||||
RESET.0.bg_str()
|
||||
);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
pub fn polyamorous() {
|
||||
let blue = rgb(0x019FE3);
|
||||
let magenta = rgb(0xE50051);
|
||||
let purple = rgb(0x340C46);
|
||||
let yellow = rgb(0x00FCBF);
|
||||
|
||||
// blue / magenta / purple vert
|
||||
// WHITE isosceles cutin with yellow heart pointed right
|
||||
let white = color::Rgb(0xFF, 0xFF, 0xFF);
|
||||
let yellow = color::Rgb(0x00, 0xFC, 0xBF);
|
||||
}
|
||||
|
||||
|
|
72
src/draw.rs
72
src/draw.rs
|
@ -1,63 +1,69 @@
|
|||
use std::io::{ self, Write };
|
||||
use std::{
|
||||
io,
|
||||
io::Write
|
||||
};
|
||||
|
||||
use termion::{
|
||||
terminal_size,
|
||||
|
||||
clear,
|
||||
color::{ Fg, Rgb },
|
||||
cursor,
|
||||
input::TermRead,
|
||||
raw::IntoRawMode
|
||||
};
|
||||
|
||||
use crate::color::{ RESET, Colors };
|
||||
use crate::flag::BLOCK;
|
||||
|
||||
pub static BLOCK: &str = "█";
|
||||
pub static UHALF: &str = "▀";
|
||||
pub fn wait(stdin: io::Stdin) { for _ in stdin.keys() { return; } }
|
||||
|
||||
pub fn full(colors: Colors) {
|
||||
|
||||
pub fn simple(colors: &[Fg<Rgb>]) {
|
||||
let mut stdout = io::stdout().into_raw_mode().unwrap();
|
||||
let stdin = io::stdin();
|
||||
|
||||
let count = colors.len();
|
||||
let (width, height) = terminal_size().unwrap();
|
||||
let thresh = height as usize / count;
|
||||
|
||||
write!(stdout, "{}{}", cursor::Hide, clear::All).ok();
|
||||
stdout.flush().ok();
|
||||
|
||||
let stripe = BLOCK.repeat(width as usize);
|
||||
let (width, height) = terminal_size().unwrap();
|
||||
stripes(&mut stdout, colors, (width as usize, height as usize));
|
||||
|
||||
wait(stdin);
|
||||
write!(stdout, "{}{}", cursor::Show, clear::All).ok();
|
||||
stdout.flush().ok();
|
||||
}
|
||||
|
||||
pub fn small(colors: &[Fg<Rgb>]) {
|
||||
let mut stdout = io::stdout().into_raw_mode().unwrap();
|
||||
|
||||
let height = colors.len();
|
||||
let width = height * 3;
|
||||
|
||||
stripes(&mut stdout, colors, (width, height));
|
||||
}
|
||||
|
||||
|
||||
pub fn stripes(stdout: &mut io::Stdout, colors: &[Fg<Rgb>], size: (usize, usize)) {
|
||||
let mut stdout = stdout.into_raw_mode().unwrap();
|
||||
let count = colors.len();
|
||||
let (width, height) = size;
|
||||
let thresh = height / count;
|
||||
|
||||
let stripe = BLOCK.repeat(width);
|
||||
let mut index = 0;
|
||||
for n in 0..(height as usize) {
|
||||
if n != 0 && n % thresh == 0 {
|
||||
for n in 0..height {
|
||||
if n!= 0 && n % thresh == 0 {
|
||||
index += 1;
|
||||
if index >= count { break; }
|
||||
}
|
||||
write!(
|
||||
stdout,
|
||||
"{color}{stripe}{RESET}",
|
||||
color = colors[index]
|
||||
"{color}{stripe}\n{repos}",
|
||||
color = colors[index],
|
||||
repos = cursor::Left(width as u16)
|
||||
).ok();
|
||||
stdout.flush().ok();
|
||||
}
|
||||
stdout.flush().ok();
|
||||
|
||||
for _ in stdin.keys() { break; }
|
||||
write!(stdout, "{}{}", cursor::Show, clear::All).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();
|
||||
}
|
||||
|
||||
|
|
8
src/error.rs
Normal file
8
src/error.rs
Normal 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);
|
||||
}
|
||||
|
171
src/flag.rs
171
src/flag.rs
|
@ -1,116 +1,129 @@
|
|||
|
||||
use crate::color::*;
|
||||
use termion::color::{ Fg, Rgb };
|
||||
|
||||
pub fn pride() -> Colors {
|
||||
let red = rgb(0xE50000);
|
||||
let orange = rgb(0xFF8D00);
|
||||
let yellow = rgb(0xFFEE00);
|
||||
let green = rgb(0x028121);
|
||||
let blue = rgb(0x004CFF);
|
||||
let purple = rgb(0x770088);
|
||||
use crate::draw;
|
||||
|
||||
vec![red, orange, yellow, green, blue, purple]
|
||||
pub static BLOCK: &str = "█";
|
||||
|
||||
pub fn pride(small: bool) {
|
||||
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); }
|
||||
else { draw::simple(stripes); }
|
||||
}
|
||||
|
||||
pub fn transgender() -> Colors {
|
||||
let pink = rgb(0x7ACBF5);
|
||||
let blue = rgb(0xEAACB8);
|
||||
pub fn transgender(small: bool) {
|
||||
let pink = Fg(Rgb(0x7A, 0xCB, 0xF5));
|
||||
let blue = Fg(Rgb(0xEA, 0xAC, 0xB8));
|
||||
let white = Fg(Rgb(0xFF, 0xFF, 0xFF));
|
||||
|
||||
vec![pink, blue, WHITE, blue, pink]
|
||||
let stripes = &[pink, blue, white, blue, pink];
|
||||
if small { draw::small(stripes); }
|
||||
else { draw::simple(stripes); }
|
||||
}
|
||||
|
||||
// everything below here is alphabetical
|
||||
|
||||
pub fn agender() -> Colors {
|
||||
let gray = rgb(0xB9B9B9);
|
||||
let green = rgb(0xB8F483);
|
||||
pub fn aromantic(small: bool) {
|
||||
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));
|
||||
|
||||
vec![BLACK, gray, WHITE, green, WHITE, gray, BLACK]
|
||||
let stripes = &[green, lime, white, grey, black];
|
||||
if small { }
|
||||
else { draw::simple(stripes); }
|
||||
}
|
||||
|
||||
pub fn aromantic() -> Colors {
|
||||
let green = rgb(0x3BA740);
|
||||
let lime = rgb(0xA8D47A);
|
||||
let grey = rgb(0xABABAB);
|
||||
pub fn asexual(small: bool) {
|
||||
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));
|
||||
|
||||
vec![green, lime, WHITE, grey, BLACK]
|
||||
let stripes = &[black, grey, white, purple];
|
||||
if small { draw::small(stripes); }
|
||||
else { draw::simple(stripes); }
|
||||
}
|
||||
|
||||
pub fn asexual() -> Colors {
|
||||
let grey = rgb(0xA4A4A4);
|
||||
let purple = rgb(0x810081);
|
||||
pub fn bigender(small: bool) {
|
||||
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));
|
||||
|
||||
vec![BLACK, grey, WHITE, purple]
|
||||
let stripes = &[pink, yellow, white, purple, blue];
|
||||
if small { draw::small(stripes); }
|
||||
else { draw::simple(stripes); }
|
||||
}
|
||||
|
||||
pub fn bigender() -> Colors {
|
||||
let pink = rgb(0xE676A6);
|
||||
let yellow = rgb(0xF9F04C);
|
||||
let purple = rgb(0xAB6BBB);
|
||||
let blue = rgb(0x6D96DC);
|
||||
pub fn bisexual(small: bool) {
|
||||
let magenta = Fg(Rgb(0xC4, 0x2A, 0x6F));
|
||||
let purple = Fg(Rgb(0x91, 0x53, 0x92));
|
||||
let blue = Fg(Rgb(0x14, 0x37, 0xA2));
|
||||
|
||||
vec![pink, yellow, WHITE, purple, blue]
|
||||
let stripes = &[magenta, magenta, purple, blue, blue];
|
||||
if small { draw::small(stripes); }
|
||||
else { draw::simple(stripes); }
|
||||
}
|
||||
|
||||
pub fn bisexual() -> Colors {
|
||||
let magenta = rgb(0xC42A6F);
|
||||
let purple = rgb(0x915392);
|
||||
let blue = rgb(0x1437A2);
|
||||
pub fn gendervoid(small: bool) {
|
||||
let navy = Fg(Rgb(0x08, 0x11, 0x4A));
|
||||
let gray = Fg(Rgb(0x4A, 0x48, 0x4B));
|
||||
let black = Fg(Rgb(0x00, 0x00, 0x00));
|
||||
|
||||
vec![magenta, magenta, purple, blue, blue]
|
||||
let stripes = &[navy, gray, black, gray, navy];
|
||||
if small { draw::small(stripes); }
|
||||
else { draw::simple(stripes); }
|
||||
}
|
||||
|
||||
pub fn genderfluid() -> Colors {
|
||||
let pink = rgb(0xFF75A2);
|
||||
let violet = rgb(0xBE18D6);
|
||||
let blue = rgb(0x333EBD);
|
||||
pub fn lesbian(small: bool) {
|
||||
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));
|
||||
|
||||
vec![pink, WHITE, violet, BLACK, blue]
|
||||
let stripes = &[red, orange, white, pink, magenta];
|
||||
if small { draw::small(stripes); }
|
||||
else { draw::simple(stripes); }
|
||||
}
|
||||
|
||||
pub fn genderqueer() -> Colors {
|
||||
let purple = rgb(0xB899DF);
|
||||
let green = rgb(0x6B8E3B);
|
||||
pub fn multigender(small: bool) {
|
||||
let blue = Fg(Rgb(0x3F, 0x47, 0xCC));
|
||||
let ltblue = Fg(Rgb(0x01, 0xA4, 0xE9));
|
||||
let orange = Fg(Rgb(0xFB, 0x7F, 0x27));
|
||||
|
||||
vec![purple, WHITE, green]
|
||||
let stripes = &[blue, ltblue, orange, ltblue, blue];
|
||||
if small { draw::small(stripes); }
|
||||
else { draw::simple(stripes); }
|
||||
}
|
||||
|
||||
pub fn gendervoid() -> Colors {
|
||||
let navy = rgb(0x08114A);
|
||||
let gray = rgb(0x4A484B);
|
||||
pub fn nonbinary(small: bool) {
|
||||
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));
|
||||
|
||||
vec![navy, gray, BLACK, gray, navy]
|
||||
let stripes = &[yellow, white, purple, black];
|
||||
if small { draw::small(stripes); }
|
||||
else { draw::simple(stripes); }
|
||||
}
|
||||
|
||||
pub fn lesbian() -> Colors {
|
||||
let red = rgb(0xD62800);
|
||||
let orange = rgb(0xFF9B56);
|
||||
let pink = rgb(0xD462A6);
|
||||
let magenta = rgb(0xA40062);
|
||||
pub fn pansexual(small: bool) {
|
||||
let magenta = Fg(Rgb(0xFF, 0x1B, 0x8D));
|
||||
let yellow = Fg(Rgb(0xFF, 0xDA, 0x00));
|
||||
let cyan = Fg(Rgb(0x1B, 0xB3, 0xFF));
|
||||
|
||||
vec![red, orange, WHITE, pink, magenta]
|
||||
}
|
||||
|
||||
pub fn multigender() -> Colors {
|
||||
let blue = rgb(0x3F47CC);
|
||||
let ltblue = rgb(0x01A4E9);
|
||||
let orange = rgb(0xFB7F27);
|
||||
|
||||
vec![blue, ltblue, orange, ltblue, blue]
|
||||
}
|
||||
|
||||
pub fn nonbinary() -> Colors {
|
||||
let yellow = rgb(0xFFF433);
|
||||
let purple = rgb(0x9B59D0);
|
||||
|
||||
vec![yellow, WHITE, purple, BLACK]
|
||||
}
|
||||
|
||||
pub fn pansexual() -> Colors {
|
||||
let magenta = rgb(0xFF1B8D);
|
||||
let yellow = rgb(0xFFDA00);
|
||||
let cyan = rgb(0x1BB3FF);
|
||||
|
||||
vec![magenta, yellow, cyan]
|
||||
if small { draw::small(&[magenta, magenta, yellow, yellow, cyan, cyan]); }
|
||||
else { draw::simple(&[magenta, yellow, cyan]); }
|
||||
}
|
||||
|
||||
|
|
129
src/main.rs
129
src/main.rs
|
@ -2,123 +2,79 @@ use std::process::exit;
|
|||
|
||||
use pico_args::Arguments;
|
||||
|
||||
mod color;
|
||||
mod complex;
|
||||
mod draw;
|
||||
mod error;
|
||||
mod flag;
|
||||
mod variant;
|
||||
|
||||
use crate::color::Colors;
|
||||
|
||||
static VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
mod util;
|
||||
|
||||
fn main() {
|
||||
let mut args = Arguments::from_env();
|
||||
|
||||
// handle help flag
|
||||
if args.contains(["-h", "--help"]) {
|
||||
let help = args.contains(["-h", "--help"]);
|
||||
if help {
|
||||
help_text();
|
||||
return;
|
||||
}
|
||||
|
||||
// handle list flag
|
||||
if args.contains(["-l", "--list"]) {
|
||||
let list = args.contains(["-l", "--list"]);
|
||||
if 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();
|
||||
|
||||
let colors: Colors = match subcommand.as_deref() {
|
||||
Some("pride" | "gay")
|
||||
=> {
|
||||
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(),
|
||||
// Some("progress")
|
||||
// => complex::progress(),
|
||||
_
|
||||
=> flag::pride()
|
||||
}
|
||||
},
|
||||
match subcommand.as_deref() {
|
||||
Some("progress") => complex::progress(small),
|
||||
|
||||
Some("transgender" | "trans")
|
||||
=> flag::transgender(),
|
||||
Some("pride") |
|
||||
Some("gay") => flag::pride(small),
|
||||
|
||||
Some("trans") |
|
||||
Some("transgender") => flag::transgender(small),
|
||||
|
||||
|
||||
Some("agender")
|
||||
=> flag::agender(),
|
||||
Some("aroace") => complex::aroace(small),
|
||||
|
||||
Some("aromantic" | "aro")
|
||||
=> flag::aromantic(),
|
||||
Some("aro") |
|
||||
Some("aromantic") => flag::aromantic(small),
|
||||
|
||||
Some("asexual" | "ace")
|
||||
=> flag::asexual(),
|
||||
Some("ace") |
|
||||
Some("asexual") => flag::asexual(small),
|
||||
|
||||
// Some("aroace" | "aromantic-asexual")
|
||||
// => complex::aroace(),
|
||||
Some("bigender") => flag::bigender(small),
|
||||
|
||||
Some("bigender")
|
||||
=> flag::bigender(),
|
||||
Some("bi") |
|
||||
Some("bisexual") => flag::bisexual(small),
|
||||
|
||||
Some("bisexual" | "bi")
|
||||
=> flag::bisexual(),
|
||||
Some("gendervoid") => flag::gendervoid(small),
|
||||
|
||||
// Some("demiromantic")
|
||||
// => flag::demiromantic(),
|
||||
Some("intersex") => complex::intersex(small),
|
||||
|
||||
// Some("demisexual")
|
||||
// => flag::demisexual(),
|
||||
Some("lesbian") => flag::lesbian(small),
|
||||
|
||||
Some("genderfluid")
|
||||
=> flag::genderfluid(),
|
||||
Some("multigender") => flag::multigender(small),
|
||||
|
||||
Some("genderqueer")
|
||||
=> flag::genderqueer(),
|
||||
Some("nb") |
|
||||
Some("nonbinary") => flag::nonbinary(small),
|
||||
|
||||
Some("gendervoid")
|
||||
=> flag::gendervoid(),
|
||||
Some("pan") |
|
||||
Some("pansexual") => flag::pansexual(small),
|
||||
|
||||
Some("intersex")
|
||||
=> complex::intersex(),
|
||||
|
||||
Some("lesbian")
|
||||
=> flag::lesbian(),
|
||||
|
||||
Some("multigender")
|
||||
=> flag::multigender(),
|
||||
|
||||
Some("nonbinary" | "nb")
|
||||
=> flag::nonbinary(),
|
||||
|
||||
Some("pansexual" | "pan")
|
||||
=> flag::pansexual(),
|
||||
|
||||
// Some("poly" | "polyamorous" | "polyamory")
|
||||
// => complex::polyamorous(),
|
||||
Some("poly") |
|
||||
Some("polyam") |
|
||||
Some("polyamory") |
|
||||
Some("polyamorous") => complex::polyamorous(small),
|
||||
|
||||
_ => { help_text(); exit(1) }
|
||||
};
|
||||
|
||||
if small { draw::small(colors); }
|
||||
else { draw::full(colors); }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fn help_text() {
|
||||
println!("pride v{VERSION}");
|
||||
println!("pride v{}", env!("CARGO_PKG_VERSION"));
|
||||
println!("Valerie Wolfe <sleeplessval@gmail.com>");
|
||||
println!("Show pride flags in the terminal.\n");
|
||||
|
||||
|
@ -129,7 +85,6 @@ 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");
|
||||
|
||||
|
@ -140,24 +95,20 @@ fn help_text() {
|
|||
fn list_text() {
|
||||
println!("pride v{}", env!("CARGO_PKG_VERSION"));
|
||||
println!("\nFlag list:");
|
||||
println!(" agender agender pride flag");
|
||||
println!(" aroace aromantic asexual 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!(" gay, pride six-color rainbow flag");
|
||||
println!(" genderfluid genderfluid pride flag");
|
||||
println!(" genderqueer genderqueer pride flag");
|
||||
println!(" gendervoid gendervoid pride flag");
|
||||
// println!(" intersex intersex 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!(" poly, polyamorous polyamorous pride flag");
|
||||
println!(" poly, polyamory polyamorous pride flag");
|
||||
println!(" progress progress arrow flag");
|
||||
println!(" trans, transgender transgender pride flag");
|
||||
}
|
||||
|
||||
|
|
15
src/util.rs
Normal file
15
src/util.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
|
||||
pub fn gcd(a: usize, b: usize) -> usize {
|
||||
if a == 0 || b == 0 { return 0; }
|
||||
let min = usize::min(a, b);
|
||||
let max = usize::max(a, b);
|
||||
|
||||
let remainder = max % min;
|
||||
if remainder == 0 { return min; }
|
||||
else { return gcd(min, remainder); }
|
||||
}
|
||||
|
||||
pub fn lcm(a: usize, b: usize) -> usize {
|
||||
return ( a * b ) / gcd(a, b);
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
|
||||
use crate::{
|
||||
color::*,
|
||||
flag
|
||||
};
|
||||
|
||||
pub fn gilbert_baker() -> Colors {
|
||||
let pink = rgb(0xFF69B4); // sex
|
||||
let red = rgb(0xFF0000); // life
|
||||
let orange = rgb(0xFF8F00); // healing
|
||||
let yellow = rgb(0xFFFF00); // sunlight
|
||||
let green = rgb(0x008F00); // nature
|
||||
let cyan = rgb(0x00C0C0); // magic
|
||||
let indigo = rgb(0x3E0099); // serenity
|
||||
let purple = rgb(0x8F008F); // spirit
|
||||
|
||||
vec![pink, red, orange, yellow, green, cyan, indigo, purple]
|
||||
}
|
||||
|
||||
pub fn philadelphia() -> Colors {
|
||||
let brown = rgb(0x784F17);
|
||||
|
||||
let mut output = flag::pride();
|
||||
output.insert(0, BLACK);
|
||||
output.insert(1, brown);
|
||||
|
||||
output
|
||||
}
|
||||
|
Loading…
Reference in a new issue