demiromantic and demisexual flags now have proper, scalable rendering
This commit is contained in:
parent
f7afc30f2e
commit
bd00a2813f
3 changed files with 132 additions and 30 deletions
100
src/complex.rs
100
src/complex.rs
|
@ -1,9 +1,14 @@
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
||||||
|
use termion::{
|
||||||
|
terminal_size,
|
||||||
|
|
||||||
|
color::{ Bg, Rgb }
|
||||||
|
};
|
||||||
|
|
||||||
use crate::color::*;
|
use crate::color::*;
|
||||||
use crate::draw;
|
use crate::draw;
|
||||||
use crate::flag;
|
use crate::flag;
|
||||||
use crate::variant;
|
|
||||||
|
|
||||||
/// vertically stacking eighths
|
/// vertically stacking eighths
|
||||||
pub static V_EIGHTH: [char; 7] = ['▁', '▂', '▃', '▄', '▅', '▆', '▇'];
|
pub static V_EIGHTH: [char; 7] = ['▁', '▂', '▃', '▄', '▅', '▆', '▇'];
|
||||||
|
@ -13,10 +18,13 @@ pub static H_EIGHTH: [char; 7] = ['▏', '▎', '▍', '▌', '▋', '▊', '▉
|
||||||
/// shading by intensity
|
/// shading by intensity
|
||||||
pub static SHADING: [char; 3] = ['░', '▒', '▓'];
|
pub static SHADING: [char; 3] = ['░', '▒', '▓'];
|
||||||
|
|
||||||
|
/// 2/1 slope triangle cut in
|
||||||
|
pub static TRIANGLE_21: [char; 3] = ['', '🭬', ''];
|
||||||
|
|
||||||
/// 2/3 slope slant
|
/// 2/3 slope slant
|
||||||
pub static SLANT_23: [char; 2] = ['🭒', '🭏'];
|
pub static SLANT_23: [char; 2] = ['🭒', '🭏'];
|
||||||
|
|
||||||
pub fn progress() -> Colors {
|
pub fn progress(small: bool) -> Colors {
|
||||||
let red = bg(0xE50000);
|
let red = bg(0xE50000);
|
||||||
let orange = bg(0xFF8D00);
|
let orange = bg(0xFF8D00);
|
||||||
let yellow = bg(0xFFEE00);
|
let yellow = bg(0xFFEE00);
|
||||||
|
@ -25,11 +33,17 @@ pub fn progress() -> Colors {
|
||||||
let purple = bg(0x770088);
|
let purple = bg(0x770088);
|
||||||
|
|
||||||
// we need these colors in both fg & bg; just hold the integers for now
|
// we need these colors in both fg & bg; just hold the integers for now
|
||||||
let black: u16 = 0;
|
let black: u32 = 0;
|
||||||
let brown: u16 = 0x784F17;
|
let brown: u32 = 0x784F17;
|
||||||
let pink: u16 = 0xEAACB8;
|
let pink: u32 = 0xEAACB8;
|
||||||
let white: u16 = 0xFFFFFF;
|
let white: u32 = 0xFFFFFF;
|
||||||
|
|
||||||
|
let (width, height) = if small { (6, 18) } else { terminal_size().unwrap() };
|
||||||
|
|
||||||
|
let stripes = vec![red, orange, yellow, green, blue, purple];
|
||||||
|
let mut lines = draw::bg_stripes(stripes, width, height);
|
||||||
|
|
||||||
|
draw::lines(lines, !small);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,32 +55,74 @@ pub fn aroace() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn demiromantic() {
|
fn demi_orientation_render(middle: Bg<Rgb>, bottom: Bg<Rgb>, width: u16, height: u16) -> Vec<String> {
|
||||||
let green = rgb(0x3DA542);
|
let white = bg(0xFFFFFF);
|
||||||
let gray = rgb(0xD2D2D2);
|
|
||||||
|
|
||||||
// WHITE×2 / green / gray×2 vert
|
let stripes = vec![white, white, middle, bottom, bottom];
|
||||||
// BLACK triangle cutin
|
|
||||||
|
// initial stripe output buffer
|
||||||
|
let mut lines: Vec<String> = draw::bg_stripes(stripes, width, height);
|
||||||
|
|
||||||
|
// assemble triangle cut-in
|
||||||
|
let linecount = lines.len();
|
||||||
|
let depth = linecount / 2;
|
||||||
|
let corner = linecount % 2 == 1;
|
||||||
|
for n in 0..depth {
|
||||||
|
let line = lines[n].clone();
|
||||||
|
|
||||||
|
let replacement = format!("{BLACK}{}{}", draw::BLOCK.repeat(n), TRIANGLE_21[0]);
|
||||||
|
lines[n] = line.replacen(&" ".repeat(n + 1), &replacement, 1);
|
||||||
|
}
|
||||||
|
if corner {
|
||||||
|
let line = lines[depth].clone();
|
||||||
|
|
||||||
|
let replacement = format!("{BLACK}{}{}", draw::BLOCK.repeat(depth), TRIANGLE_21[1]);
|
||||||
|
lines[depth] = line.replacen(&" ".repeat(depth + 1), &replacement, 1);
|
||||||
|
}
|
||||||
|
let start = depth + (linecount % 2);
|
||||||
|
for n in 0..depth {
|
||||||
|
let line = lines[start + n].clone();
|
||||||
|
|
||||||
|
let size = depth - n - 1;
|
||||||
|
let replacement = format!("{BLACK}{}{}", draw::BLOCK.repeat(size), TRIANGLE_21[2]);
|
||||||
|
lines[start + n] = line.replacen(&" ".repeat(size + 1), &replacement, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
lines
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn demisexual() {
|
pub fn demiromantic(small: bool) -> Colors {
|
||||||
let purple = rgb(0x832FA8);
|
let green = bg(0x3DA542);
|
||||||
let grey = rgb(0x7B868C);
|
let gray = bg(0xD2D2D2);
|
||||||
|
|
||||||
// WHITE×2 / green / grey×2 vert
|
let (width, height) = if small { (15, 5) } else { terminal_size().unwrap() };
|
||||||
// BLACK triangle cutin
|
let lines = demi_orientation_render(green, gray, width, height);
|
||||||
|
|
||||||
|
draw::lines(lines, !small);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn demisexual(small: bool) -> Colors {
|
||||||
|
let purple = bg(0x832FA8);
|
||||||
|
let grey = bg(0x7B868C);
|
||||||
|
|
||||||
|
let (width, height) = if small { (15, 5) } else { terminal_size().unwrap() };
|
||||||
|
let lines = demi_orientation_render(purple, grey, width, height);
|
||||||
|
|
||||||
|
draw::lines(lines, !small);
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn disability() {
|
pub fn disability() {
|
||||||
let gray = bg(0x575757);
|
let gray = bg(0x575757);
|
||||||
|
|
||||||
let green = rgb(0x3AAD7D);
|
let green: u32 = 0x3AAD7D;
|
||||||
let blue = rgb(0x79BFE0);
|
let blue: u32 = 0x79BFE0;
|
||||||
let white = rgb(0xE8E8E8);
|
let white: u32 = 0xE8E8E8;
|
||||||
let yellow = rgb(0xEDDB76);
|
let yellow: u32 = 0xEDDB76;
|
||||||
let red = rgb(0xCD7281);
|
let red: u32 = 0xCD7281;
|
||||||
|
|
||||||
let stripe = [red, yellow, white, blue, green];
|
let stripes = [red, yellow, white, blue, green];
|
||||||
|
|
||||||
// 2/3 slant stripes with gray background
|
// 2/3 slant stripes with gray background
|
||||||
}
|
}
|
||||||
|
|
46
src/draw.rs
46
src/draw.rs
|
@ -4,6 +4,7 @@ use termion::{
|
||||||
terminal_size,
|
terminal_size,
|
||||||
|
|
||||||
clear,
|
clear,
|
||||||
|
color::{ Bg, Fg, Rgb },
|
||||||
cursor,
|
cursor,
|
||||||
input::TermRead,
|
input::TermRead,
|
||||||
raw::IntoRawMode
|
raw::IntoRawMode
|
||||||
|
@ -87,3 +88,48 @@ pub fn lines(lines: Vec<String>, hold: bool) {
|
||||||
stdout.flush().ok();
|
stdout.flush().ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn fg_stripes(colors: Vec<Fg<Rgb>>, width: u16, height: u16) -> Vec<String> {
|
||||||
|
let width = width as usize;
|
||||||
|
let height = height as usize;
|
||||||
|
let count = colors.len();
|
||||||
|
|
||||||
|
let thresh = height / count;
|
||||||
|
|
||||||
|
let stripe = BLOCK.repeat(width);
|
||||||
|
let mut output = Vec::new();
|
||||||
|
|
||||||
|
let mut index = 0;
|
||||||
|
for n in 0..height {
|
||||||
|
if n != 0 && n % thresh == 0 {
|
||||||
|
index += 1;
|
||||||
|
if index >= count { break; }
|
||||||
|
}
|
||||||
|
let color = colors[index];
|
||||||
|
output.push(format!("{color}{stripe}"));
|
||||||
|
}
|
||||||
|
|
||||||
|
output
|
||||||
|
}
|
||||||
|
pub fn bg_stripes(colors: Vec<Bg<Rgb>>, width: u16, height: u16) -> Vec<String> {
|
||||||
|
let width = width as usize;
|
||||||
|
let height = height as usize;
|
||||||
|
let count = colors.len();
|
||||||
|
|
||||||
|
let thresh = height / count;
|
||||||
|
|
||||||
|
let stripe = " ".repeat(width);
|
||||||
|
let mut output = Vec::new();
|
||||||
|
|
||||||
|
let mut index = 0;
|
||||||
|
for n in 0..height {
|
||||||
|
if n != 0 && n % thresh == 0 {
|
||||||
|
index += 1;
|
||||||
|
if index >= count { break; }
|
||||||
|
}
|
||||||
|
let color = colors[index];
|
||||||
|
output.push(format!("{color}{stripe}"));
|
||||||
|
}
|
||||||
|
|
||||||
|
output
|
||||||
|
}
|
||||||
|
|
||||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -47,8 +47,8 @@ fn main() {
|
||||||
=> variant::gilbert_baker(),
|
=> variant::gilbert_baker(),
|
||||||
Some("philadelphia")
|
Some("philadelphia")
|
||||||
=> variant::philadelphia(),
|
=> variant::philadelphia(),
|
||||||
// Some("progress")
|
Some("progress")
|
||||||
// => complex::progress(),
|
=> complex::progress(small),
|
||||||
_
|
_
|
||||||
=> flag::pride()
|
=> flag::pride()
|
||||||
}
|
}
|
||||||
|
@ -76,11 +76,11 @@ fn main() {
|
||||||
Some("bisexual" | "bi")
|
Some("bisexual" | "bi")
|
||||||
=> flag::bisexual(),
|
=> flag::bisexual(),
|
||||||
|
|
||||||
// Some("demiromantic")
|
Some("demiromantic")
|
||||||
// => complex::demiromantic(),
|
=> complex::demiromantic(small),
|
||||||
|
|
||||||
// Some("demisexual")
|
Some("demisexual")
|
||||||
// => complex::demisexual(),
|
=> complex::demisexual(small),
|
||||||
|
|
||||||
// Some("disability")
|
// Some("disability")
|
||||||
// => complex::disability();
|
// => complex::disability();
|
||||||
|
@ -149,8 +149,8 @@ fn list_text() {
|
||||||
// println!(" aroace aromantic/asexual pride flag");
|
// println!(" aroace aromantic/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!(" demiromantic demiromantic pride flag");
|
println!(" demiromantic demiromantic pride flag");
|
||||||
// println!(" demisexual demisexual pride flag");
|
println!(" demisexual demisexual pride flag");
|
||||||
// println!(" disability disability pride flag");
|
// println!(" disability disability pride flag");
|
||||||
println!(" gay, pride six-color rainbow flag");
|
println!(" gay, pride six-color rainbow flag");
|
||||||
println!(" genderfluid genderfluid pride flag");
|
println!(" genderfluid genderfluid pride flag");
|
||||||
|
|
Loading…
Reference in a new issue