moved Flag enum to flag module, added first iteration of aroace flag
This commit is contained in:
parent
b0678542ef
commit
b318c96734
5 changed files with 49 additions and 66 deletions
|
@ -6,9 +6,11 @@ use termion::{
|
||||||
color::{ Bg, Rgb }
|
color::{ Bg, Rgb }
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::color::*;
|
use crate::{
|
||||||
use crate::draw::{ self, Flag };
|
color::*,
|
||||||
use crate::flag;
|
draw,
|
||||||
|
flag::{ self, Flag }
|
||||||
|
};
|
||||||
|
|
||||||
/// vertically stacking eighths
|
/// vertically stacking eighths
|
||||||
pub static V_EIGHTH: [char; 7] = ['▁', '▂', '▃', '▄', '▅', '▆', '▇'];
|
pub static V_EIGHTH: [char; 7] = ['▁', '▂', '▃', '▄', '▅', '▆', '▇'];
|
||||||
|
@ -39,7 +41,7 @@ pub fn progress(small: bool) -> Flag {
|
||||||
let pink: u32 = 0xEAACB8;
|
let pink: u32 = 0xEAACB8;
|
||||||
let white: u32 = 0xFFFFFF;
|
let white: u32 = 0xFFFFFF;
|
||||||
|
|
||||||
let (height, width) = if small { (6, 18) } else { terminal_size().unwrap() };
|
let (width, height) = if small { (18, 6) } else { terminal_size().unwrap() };
|
||||||
|
|
||||||
// create color slices and line buffer
|
// create color slices and line buffer
|
||||||
let stripes = [red, orange, yellow, green, blue, purple];
|
let stripes = [red, orange, yellow, green, blue, purple];
|
||||||
|
@ -77,6 +79,7 @@ pub fn progress(small: bool) -> Flag {
|
||||||
|
|
||||||
// get this line's depth?
|
// get this line's depth?
|
||||||
// get chevron start: (full_depth - line_depth) / chevron_width = chevron_start
|
// get chevron start: (full_depth - line_depth) / chevron_width = chevron_start
|
||||||
|
let start: i16 = 2 - (n as i16);
|
||||||
|
|
||||||
// for chevron_index in chevron_start..5
|
// for chevron_index in chevron_start..5
|
||||||
// if chevron_index = 4, draw stripe after (stripe width = width - line_depth - 1)
|
// if chevron_index = 4, draw stripe after (stripe width = width - line_depth - 1)
|
||||||
|
@ -107,10 +110,34 @@ pub fn progress(small: bool) -> Flag {
|
||||||
|
|
||||||
// everything below this point is in alphabetical order
|
// everything below this point is in alphabetical order
|
||||||
|
|
||||||
pub fn aroace() {
|
pub fn aroace(small: bool) -> Flag {
|
||||||
let aro = flag::aromantic();
|
// pull colors from aro & ace stripe flags
|
||||||
let ace = flag::asexual();
|
let Flag::Stripes(aro) = flag::aromantic() else { panic!() };
|
||||||
|
let Flag::Stripes(ace) = flag::asexual() else { panic!() };
|
||||||
|
|
||||||
|
let (width, height) = if small { (60, 20) } else { terminal_size().unwrap() };
|
||||||
|
|
||||||
|
let mut lines: Vec<String> = Vec::new();
|
||||||
|
|
||||||
|
// set up constraints
|
||||||
|
let linecount = height - (height % 20);
|
||||||
|
let aro_thresh = linecount / 5; // threshold for aromantic colors
|
||||||
|
let ace_thresh = linecount / 4; // threshold for asexual colors
|
||||||
|
let stripe = draw::BLOCK.repeat((width / 2) as usize);
|
||||||
|
|
||||||
|
let mut aro_index = 0;
|
||||||
|
let mut ace_index = 0;
|
||||||
|
for n in 0..linecount {
|
||||||
|
// switch colors on thresholds
|
||||||
|
if n != 0 {
|
||||||
|
if n % aro_thresh == 0 { aro_index += 1; }
|
||||||
|
if n % ace_thresh == 0 { ace_index += 1; }
|
||||||
|
}
|
||||||
|
let line = format!("{}{stripe}{}{stripe}", aro[aro_index], ace[ace_index]);
|
||||||
|
lines.push(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
Flag::Lines(lines)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn demi_orientation_render(middle: Bg<Rgb>, bottom: Bg<Rgb>, width: u16, height: u16) -> Vec<String> {
|
fn demi_orientation_render(middle: Bg<Rgb>, bottom: Bg<Rgb>, width: u16, height: u16) -> Vec<String> {
|
||||||
|
|
56
src/draw.rs
56
src/draw.rs
|
@ -10,58 +10,14 @@ use termion::{
|
||||||
raw::IntoRawMode
|
raw::IntoRawMode
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::color::{ RESET, RESET_BG, Colors };
|
use crate::{
|
||||||
|
color::{ RESET, RESET_BG },
|
||||||
|
flag::Flag
|
||||||
|
};
|
||||||
|
|
||||||
pub static BLOCK: &str = "█";
|
pub static BLOCK: &str = "█";
|
||||||
pub static UHALF: &str = "▀";
|
pub static UHALF: &str = "▀";
|
||||||
|
|
||||||
pub fn full(colors: Colors) {
|
|
||||||
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 mut index = 0;
|
|
||||||
for n in 0..(height as usize) {
|
|
||||||
if n != 0 && n % thresh == 0 {
|
|
||||||
index += 1;
|
|
||||||
if index >= count { break; }
|
|
||||||
}
|
|
||||||
write!(
|
|
||||||
stdout,
|
|
||||||
"{color}{stripe}{RESET}",
|
|
||||||
color = colors[index]
|
|
||||||
).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();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn draw_lines(lines: Vec<String>, hold: bool) {
|
pub fn draw_lines(lines: Vec<String>, hold: bool) {
|
||||||
let mut stdout = io::stdout().into_raw_mode().unwrap();
|
let mut stdout = io::stdout().into_raw_mode().unwrap();
|
||||||
|
|
||||||
|
@ -133,10 +89,6 @@ pub fn bg_stripes(colors: Vec<Bg<Rgb>>, width: u16, height: u16) -> Vec<String>
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Flag {
|
|
||||||
Stripes(Colors),
|
|
||||||
Lines(Vec<String>)
|
|
||||||
}
|
|
||||||
impl Flag {
|
impl Flag {
|
||||||
pub fn draw(self, hold: bool) {
|
pub fn draw(self, hold: bool) {
|
||||||
let lines = match self {
|
let lines = match self {
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
|
|
||||||
use crate::color::*;
|
use crate::color::*;
|
||||||
use crate::draw::Flag;
|
|
||||||
|
pub enum Flag {
|
||||||
|
Stripes(Colors),
|
||||||
|
Lines(Vec<String>)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn pride() -> Flag {
|
pub fn pride() -> Flag {
|
||||||
let red = rgb(0xE50000);
|
let red = rgb(0xE50000);
|
||||||
|
|
|
@ -8,7 +8,7 @@ mod draw;
|
||||||
mod flag;
|
mod flag;
|
||||||
mod variant;
|
mod variant;
|
||||||
|
|
||||||
use crate::draw::Flag;
|
use crate::flag::Flag;
|
||||||
|
|
||||||
static VERSION: &str = env!("CARGO_PKG_VERSION");
|
static VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
|
@ -67,8 +67,8 @@ fn main() {
|
||||||
Some("asexual" | "ace")
|
Some("asexual" | "ace")
|
||||||
=> flag::asexual(),
|
=> flag::asexual(),
|
||||||
|
|
||||||
// Some("aroace" | "aromantic-asexual")
|
Some("aroace" | "aromantic-asexual")
|
||||||
// => complex::aroace(),
|
=> complex::aroace(small),
|
||||||
|
|
||||||
Some("bigender")
|
Some("bigender")
|
||||||
=> flag::bigender(),
|
=> flag::bigender(),
|
||||||
|
@ -145,7 +145,7 @@ fn list_text() {
|
||||||
println!(" agender agender pride flag");
|
println!(" agender agender pride flag");
|
||||||
println!(" aro, aromantic aromantic pride flag");
|
println!(" aro, aromantic aromantic pride flag");
|
||||||
println!(" ace, asexual asexual pride flag");
|
println!(" ace, asexual asexual pride flag");
|
||||||
// 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");
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
color::*,
|
color::*,
|
||||||
draw::Flag,
|
flag::{ self, Flag }
|
||||||
flag
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn gilbert_baker() -> Flag {
|
pub fn gilbert_baker() -> Flag {
|
||||||
|
|
Loading…
Reference in a new issue