Skip to content

Commit

Permalink
merged in flags and features from main
Browse files Browse the repository at this point in the history
  • Loading branch information
sleeplessval committed Jul 10, 2023
2 parents b238dbe + 1332a30 commit d6370da
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pride"
version = "0.1.4"
version = "0.2.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@

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.**

Currently supports a variety of stripe flags.
A list of currently implemented flags is available on the [project wiki](https://git.vwolfe.io/valerie/pride/wiki/Flags).

## Dependencies

Complex renderers often use [Powerline's slant](https://github.com/ryanoasis/powerline-extra-symbols)
symbols, and therefore require use of a Powerline font, such as [Fira Code](https://github.com/tonsky/FiraCode).
Some Complex renderers utilize [Powerline's](https://github.com/ryanoasis/powerline-extra-symbols)
slant symbols, and therefore require use of a Powerline font, such as [Fira Code](https://github.com/tonsky/FiraCode).

## Libraries

Expand Down
1 change: 1 addition & 0 deletions src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub static RESET_BG: Bg<Reset> = Bg(Reset);

/// produces a termion foreground color from the provided integer
pub fn rgb(hex: u32) -> Color {
// colors should be 0xrrggbb = 0x__rrggbb; drop the most significant byte
let [_, r, g, b] = hex.to_be_bytes();

Fg(Rgb(r, g, b))
Expand Down
2 changes: 2 additions & 0 deletions src/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ pub fn fg_stripes(colors: Vec<Fg<Rgb>>, width: u16, height: u16) -> Vec<String>
let stripe = BLOCK.repeat(width);
let mut output = Vec::new();

// create our color index
let mut index = 0;
for n in 0..height {
if n != 0 && n % thresh == 0 {
index += 1;
// and break if out of bounds
if index >= count { break; }
}
let color = colors[index];
Expand Down
21 changes: 21 additions & 0 deletions src/flag.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! stripe pride flag color functions.
//! all of these return a Vec of colors to be drawn from first to last.

use crate::color::*;

Expand Down Expand Up @@ -66,6 +68,17 @@ pub fn bisexual() -> Flag {
Flag::Stripes(vec![magenta, magenta, purple, blue, blue])
}

pub fn gay() -> Flag {
let green1 = rgb(0x00906D);
let green2 = rgb(0x00D1A7);
let green3 = rgb(0x7EEBC1);
let blue1 = rgb(0x6CAEE8);
let blue2 = rgb(0x5543D3);
let blue3 = rgb(0x461280);

Flag::Stripes(vec![green1, green2, green3, WHITE, blue1, blue2, blue3])
}

pub fn genderfluid() -> Flag {
let pink = rgb(0xFF75A2);
let violet = rgb(0xBE18D6);
Expand All @@ -74,6 +87,14 @@ pub fn genderfluid() -> Flag {
Flag::Stripes(vec![pink, WHITE, violet, BLACK, blue])
}

pub fn gender_nonconforming() -> Flag {
let purple = rgb(0x50284D);
let magenta = rgb(0x96467B);
let blue = rgb(0x5C96F7);

Flag::Stripes(vec![purple, purple, magenta, blue, WHITE, blue, magenta, purple, purple])
}

pub fn genderqueer() -> Flag {
let purple = rgb(0xB899DF);
let green = rgb(0x6B8E3B);
Expand Down
18 changes: 15 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::flag::Flag;
static VERSION: &str = env!("CARGO_PKG_VERSION");

fn main() {
// collect args
let mut args = Arguments::from_env();

// handle help flag
Expand All @@ -39,8 +40,10 @@ fn main() {

let subcommand = args.subcommand().unwrap();

// get color vec from matched flag
let flag: Flag = match subcommand.as_deref() {
Some("pride" | "gay")
Some("pride" | "rainbow")
| None
=> {
let variant = args.subcommand().unwrap_or(None);
match variant.as_deref() {
Expand Down Expand Up @@ -86,9 +89,15 @@ fn main() {
// Some("disability")
// => complex::disability();

Some("gay" | "mlm")
=> flag::gay(),

Some("genderfluid")
=> flag::genderfluid(),

Some("gender-nonconforming" | "gnc" | "gendernonconforming")
=> flag::gender_nonconforming(),

Some("genderqueer")
=> flag::genderqueer(),

Expand Down Expand Up @@ -125,7 +134,7 @@ fn help_text() {
println!("Valerie Wolfe <[email protected]>");
println!("Show pride flags in the terminal.\n");

println!("usage: pride [flags] <name>\n");
println!("usage: pride [flags] [name]\n");

println!("args:");
println!(" <name> The pride flag to display\n");
Expand All @@ -152,8 +161,9 @@ fn list_text() {
println!(" demiromantic demiromantic pride flag");
println!(" demisexual demisexual pride flag");
// println!(" disability disability pride flag");
println!(" gay, pride six-color rainbow 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");
Expand All @@ -162,6 +172,8 @@ fn list_text() {
println!(" nb, nonbinary nonbinary pride flag");
println!(" pan, pansexual pansexual pride flag");
// println!(" poly, polyamorous polyamorous pride flag");
println!(" pride, rainbow six-color rainbow flag");
println!(" progress progress arrow flag");
println!(" trans, transgender transgender pride flag");
}

2 changes: 2 additions & 0 deletions src/variant.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! variant pride flags
//! these aren't in the flag module for organizational reasons.

use crate::{
color::*,
Expand Down

0 comments on commit d6370da

Please sign in to comment.