merge changes from main
This commit is contained in:
commit
7f9a8aad97
8 changed files with 83 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
//! utility types and functions for color operations
|
||||
|
||||
use termion::color::{ Bg, Fg, Rgb, Reset };
|
||||
|
||||
|
|
|
@ -181,6 +181,7 @@ pub fn aroace(small: bool) -> Flag {
|
|||
Flag::Lines(lines)
|
||||
}
|
||||
|
||||
|
||||
fn demi_orientation_render(middle: Bg<Rgb>, bottom: Bg<Rgb>, width: u16, height: u16) -> Vec<String> {
|
||||
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!(
|
||||
|
|
|
@ -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<String>, hold: bool) {
|
||||
let mut stdout = io::stdout().into_raw_mode().unwrap();
|
||||
|
||||
|
@ -44,6 +47,7 @@ pub fn draw_lines(lines: Vec<String>, 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<Fg<Rgb>>, width: u16, height: u16) -> Vec<String> {
|
||||
let width = width as usize;
|
||||
let height = height as usize;
|
||||
|
@ -68,6 +72,7 @@ pub fn fg_stripes(colors: Vec<Fg<Rgb>>, width: u16, height: u16) -> Vec<String>
|
|||
|
||||
output
|
||||
}
|
||||
/// generates lines for background colors provided as a vec of strings for the draw_lines method
|
||||
pub fn bg_stripes(colors: Vec<Bg<Rgb>>, width: u16, height: u16) -> Vec<String> {
|
||||
let width = width as usize;
|
||||
let height = height as usize;
|
||||
|
@ -92,6 +97,7 @@ pub fn bg_stripes(colors: Vec<Bg<Rgb>>, width: u16, height: u16) -> Vec<String>
|
|||
}
|
||||
|
||||
impl Flag {
|
||||
/// renders a flag to stdout
|
||||
pub fn draw(self, hold: bool) {
|
||||
let lines = match self {
|
||||
Flag::Stripes(colors)
|
||||
|
|
47
src/flag.rs
47
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);
|
||||
|
|
|
@ -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
|
||||
|
|
17
src/main.rs
17
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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue