diff --git a/Cargo.toml b/Cargo.toml index a8d1643..0a04b6f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pride" -version = "0.2.2" +version = "0.2.3" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/color.rs b/src/color.rs index 55a7c9e..ca58981 100644 --- a/src/color.rs +++ b/src/color.rs @@ -1,3 +1,4 @@ +//! utility types and functions for color operations use termion::color::{ Bg, Fg, Rgb, Reset }; diff --git a/src/complex.rs b/src/complex.rs index 29a1deb..0eb0c01 100644 --- a/src/complex.rs +++ b/src/complex.rs @@ -181,6 +181,7 @@ pub fn aroace(small: bool) -> Flag { Flag::Lines(lines) } + fn demi_orientation_render(middle: Bg, bottom: Bg, width: u16, height: u16) -> Vec { let white = bg(0xFFFFFF); @@ -238,6 +239,7 @@ pub fn demisexual(small: bool) -> Flag { Flag::Lines(lines) } + pub fn disability() { let gray = bg(0x575757); @@ -253,6 +255,7 @@ pub fn disability() { } + pub fn intersex() -> Flag { let yellow = bg(0xFFDA00); let purple = rgb(0x7A00AC); @@ -270,6 +273,7 @@ pub fn intersex() -> Flag { Flag::Lines(lines) } + pub fn polyamory(small: bool) -> Flag { let blue = rgb(0x019FE3); let magenta = rgb(0xE50051); @@ -289,9 +293,9 @@ pub fn polyamory(small: bool) -> Flag { // constraints let linecount = height - (height % 3); // largest multiple of 3 smaller than height - let full_depth = width / 3; + let full_depth = linecount; let thresh = linecount / 3; // stripe & direction thresh - let start = width / 6; + let start = 2 * full_depth / 3; // piecewise function: ascent -> descent let mut separator = separators[0]; @@ -313,8 +317,7 @@ pub fn polyamory(small: bool) -> Flag { // advance index at threshold if n == (thresh * 2) { index = 1; } - let rel = (n - thresh) + 2; - let size = full_depth - rel; + let size = (2 * start) - n - 1; let color = stripes[index]; let line = format!( diff --git a/src/draw.rs b/src/draw.rs index 7ae7ff6..3ebf02f 100644 --- a/src/draw.rs +++ b/src/draw.rs @@ -1,3 +1,5 @@ +//! render handling code + use std::io::{ self, Write }; use termion::{ @@ -18,6 +20,7 @@ use crate::{ pub static BLOCK: &str = "█"; pub static UHALF: &str = "▀"; +/// prints a provided vec of lines to stdout pub fn draw_lines(lines: Vec, hold: bool) { let mut stdout = io::stdout().into_raw_mode().unwrap(); @@ -44,6 +47,7 @@ pub fn draw_lines(lines: Vec, hold: bool) { stdout.flush().ok(); } +/// generates lines for foreground colors provided as a vec of strings for the draw_lines method pub fn fg_stripes(colors: Vec>, width: u16, height: u16) -> Vec { let width = width as usize; let height = height as usize; @@ -68,6 +72,7 @@ pub fn fg_stripes(colors: Vec>, width: u16, height: u16) -> Vec output } +/// generates lines for background colors provided as a vec of strings for the draw_lines method pub fn bg_stripes(colors: Vec>, width: u16, height: u16) -> Vec { let width = width as usize; let height = height as usize; @@ -92,6 +97,7 @@ pub fn bg_stripes(colors: Vec>, width: u16, height: u16) -> Vec } impl Flag { + /// renders a flag to stdout pub fn draw(self, hold: bool) { let lines = match self { Flag::Stripes(colors) diff --git a/src/flag.rs b/src/flag.rs index 864876c..6db07aa 100644 --- a/src/flag.rs +++ b/src/flag.rs @@ -53,6 +53,7 @@ pub fn aroace() -> Flag { Flag::Stripes(vec![orange, yellow, WHITE, blue, navy]) } + pub fn bigender() -> Flag { let pink = rgb(0xE676A6); let yellow = rgb(0xF9F04C); @@ -70,6 +71,31 @@ pub fn bisexual() -> Flag { Flag::Stripes(vec![magenta, magenta, purple, blue, blue]) } + +fn demigender_base(color: Color) -> Colors { + let grey = rgb(0x7F7F7F); + let gray = rgb(0xC3C3C3); + + + vec![grey, gray, color, WHITE, color, gray, grey] +} + +pub fn demiboy() -> Flag { + let blue = rgb(0x7ACBF5); + Flag::Stripes(demigender_base(blue)) +} + +pub fn demigender() -> Flag { + let yellow = rgb(0xFBFF74); + Flag::Stripes(demigender_base(yellow)) +} + +pub fn demigirl() -> Flag { + let pink = rgb(0xEAACB8); + Flag::Stripes(demigender_base(pink)) +} + + pub fn gay() -> Flag { let green1 = rgb(0x00906D); let green2 = rgb(0x00D1A7); @@ -111,6 +137,7 @@ pub fn gendervoid() -> Flag { Flag::Stripes(vec![navy, gray, BLACK, gray, navy]) } + pub fn lesbian() -> Flag { let red = rgb(0xD62800); let orange = rgb(0xFF9B56); @@ -120,6 +147,7 @@ pub fn lesbian() -> Flag { Flag::Stripes(vec![red, orange, WHITE, pink, magenta]) } + pub fn multigender() -> Flag { let blue = rgb(0x3F47CC); let ltblue = rgb(0x01A4E9); @@ -128,6 +156,15 @@ pub fn multigender() -> Flag { Flag::Stripes(vec![blue, ltblue, orange, ltblue, blue]) } +pub fn multisexual() -> Flag { + let purple = rgb(0x724DC9); + let blue = rgb(0xFF3D9B); + let pink = rgb(0xFF3D9B); + + Flag::Stripes(vec![purple, WHITE, blue, pink]) +} + + pub fn nonbinary() -> Flag { let yellow = rgb(0xFFF433); let purple = rgb(0x9B59D0); @@ -135,6 +172,7 @@ pub fn nonbinary() -> Flag { Flag::Stripes(vec![yellow, WHITE, purple, BLACK]) } + pub fn pansexual() -> Flag { let magenta = rgb(0xFF1B8D); let yellow = rgb(0xFFDA00); @@ -143,6 +181,15 @@ pub fn pansexual() -> Flag { Flag::Stripes(vec![magenta, yellow, cyan]) } +pub fn polysexual() -> Flag { + let pink = rgb(0xF61CB9); + let green = rgb(0x07D569); + let blue = rgb(0x1C92F6); + + Flag::Stripes(vec![pink, green, blue]) +} + + pub fn transgender() -> Flag { let pink = rgb(0x7ACBF5); let blue = rgb(0xEAACB8); diff --git a/src/help.rs b/src/help.rs index 427f02f..a9f5650 100644 --- a/src/help.rs +++ b/src/help.rs @@ -32,6 +32,9 @@ flag list: asexual asexual pride flag bigender bigender pride flag bisexual bisexual pride flag + demiboy demiboy pride flag + demigender demigender pride flag + demigirl demigirl pride flag demiromantic demiromantic pride flag demisexual demisexual pride flag gay gay men pride flag diff --git a/src/main.rs b/src/main.rs index f687c3d..69793f4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +//! main method module + use std::{ io::{ stdout, IsTerminal }, process::exit @@ -98,6 +100,14 @@ fn main() { Some("bisexual" | "bi") => flag::bisexual(), + + Some("demiboy") + => flag::demiboy(), + Some("demigender") + => flag::demigender(), + Some("demigirl") + => flag::demigirl(), + Some("demiromantic") => complex::demiromantic(small), @@ -136,6 +146,9 @@ fn main() { } } + Some("multisexual" | "m-spec" | "mspec") + => flag::multisexual(), + Some("multigender") => flag::multigender(), @@ -148,6 +161,9 @@ fn main() { Some("polyamory" | "polyamorous" | "poly") => complex::polyamory(small), + Some("polysexual") + => flag::polysexual(), + Some("transgender" | "trans") => flag::transgender(), @@ -155,6 +171,7 @@ fn main() { _ => { help::help_text(); exit(1) } }; + // draw flag flag.draw(!small); } diff --git a/src/util.rs b/src/util.rs index cd198d9..533e327 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,3 +1,4 @@ +//! utility functions for working with ansi strings /// gets the substring of displayed characters of an ANSI formatted string pub fn ansi_substr(source: &str, start: usize, end: usize) -> String {