Skip to main content

cgrustplot/helper/
charset.rs

1//! Helper file for storing sets of characters used for plotting graphs
2
3pub const NULL_STR: &str = "�";
4pub const NULL_CHR: char = '�';
5
6/// Used for displaying axes on a plot.
7/// 
8/// # Characters
9/// 
10/// VERTICAL:    '│'
11/// 
12/// HORIZONTAL:  '─'
13/// 
14/// CROSS:       '┼'
15/// 
16/// CORNER:      '└'
17/// 
18pub mod axes_chars {
19    pub const VERTICAL: char = '│';
20    pub const HORIZONTAL: char = '─';
21    pub const CROSS: char = '┼';
22    pub const CORNER: char = '└';
23}
24
25/// Used for shading a charachter to a specific brightness.
26/// 
27/// # Characters
28/// 
29/// binary_chars():       " █"
30/// 
31/// shade_chars():        " ░▒▓█"
32/// 
33/// ascii_chars():        " .:-=+*#%@"
34/// 
35/// ascii_chars_large():  " .'`^",:;Il!i><~+_-?][}{1)(|\/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$"
36/// 
37/// # Notes
38/// 
39/// Contains charachter gradients of multiple sizes, of the form Vec<String>
40pub mod gradient_chars {
41    // Vec<String> instead of Vec<char> for future ideas:
42    // e.g. using ANSI escape codes for color / bold if the terminal supports it
43    // Charachter sets largely based on https://paulbourke.net/dataformats/asciiart/
44    pub fn binary_chars() -> Vec<String> {[" ", "█"].iter().map(|&s| s.into()).collect()}
45    pub fn shade_chars() -> Vec<String> {[" ", "░", "▒", "▓", "█"].iter().map(|&s| s.into()).collect()}
46    pub fn ascii_chars() -> Vec<String> {[" ", ".", ":", "-", "=", "+", "*", "#", "%", "@"].iter().map(|&s| s.into()).collect()}
47    pub fn ascii_chars_large() -> Vec<String> {[" ", ".", "'", "`", "^", "\"", ",", ":", ";", "I", "l", "!", "i", ">", "<", "~", "+", "_", "-", "?", "]", "[", "}", "{", "1", ")", "(", "|", "\\", "/", "t", "f", "j", "r", "x", "n", "u", "v", "c", "z", "X", "Y", "U", "J", "C", "L", "Q", "0", "O", "Z", "m", "w", "q", "p", "d", "b", "k", "h", "a", "o", "*", "#", "M", "W", "&", "8", "%", "B", "@", "$"].iter().map(|&s| s.into()).collect()}
48}
49
50/// Used for subdividing a single charachter into multiple individual binary pieces.
51/// 
52/// # Characters
53/// 
54/// dots_one_by_one():    " ●"
55/// 
56/// blocks_two_by_two():  " ▘▖▌▝▀▞▛▗▚▄▙▐▜▟█"
57/// 
58/// dots_two_by_foour():  "⠀⠁⠂⠃⠄⠅⠆⠇⡀⡁⡂⡃⡄⡅⡆⡇⠈⠉⠊⠋⠌⠍⠎⠏⡈⡉⡊⡋⡌⡍⡎⡏⠐⠑⠒⠓⠔⠕⠖⠗⡐⡑⡒⡓⡔⡕⡖⡗⠘⠙⠚⠛⠜⠝⠞⠟⡘⡙⡚⡛⡜⡝⡞⡟⠠⠡⠢⠣⠤⠥⠦⠧⡠⡡⡢⡣⡤⡥⡦⡧⠨⠩⠪⠫⠬⠭⠮⠯⡨⡩⡪⡫⡬⡭⡮⡯⠰⠱⠲⠳⠴⠵⠶⠷⡰⡱⡲⡳⡴⡵⡶⡷⠸⠹⠺⠻⠼⠽⠾⠿⡸⡹⡺⡻⡼⡽⡾⡿⢀⢁⢂⢃⢄⢅⢆⢇⣀⣁⣂⣃⣄⣅⣆⣇⢈⢉⢊⢋⢌⢍⢎⢏⣈⣉⣊⣋⣌⣍⣎⣏⢐⢑⢒⢓⢔⢕⢖⢗⣐⣑⣒⣓⣔⣕⣖⣗⢘⢙⢚⢛⢜⢝⢞⢟⣘⣙⣚⣛⣜⣝⣞⣟⢠⢡⢢⢣⢤⢥⢦⢧⣠⣡⣢⣣⣤⣥⣦⣧⢨⢩⢪⢫⢬⢭⢮⢯⣨⣩⣪⣫⣬⣭⣮⣯⢰⢱⢲⢳⢴⢵⢶⢷⣰⣱⣲⣳⣴⣵⣶⣷⢸⢹⢺⢻⢼⢽⢾⢿⣸⣹⣺⣻⣼⣽⣾⣿"
59/// 
60/// # Notes
61/// 
62/// Ordered in terms of binary from left to right, top to bottom
63pub mod subdiv_chars {
64    pub fn dots_one_by_one() -> Vec<char> {" ●".chars().collect()}
65    pub fn blocks_two_by_two() -> Vec<char> {" ▘▖▌▝▀▞▛▗▚▄▙▐▜▟█".chars().collect()}
66    pub fn dots_two_by_four() -> Vec<char>    {"⠀⠁⠂⠃⠄⠅⠆⠇⡀⡁⡂⡃⡄⡅⡆⡇⠈⠉⠊⠋⠌⠍⠎⠏⡈⡉⡊⡋⡌⡍⡎⡏⠐⠑⠒⠓⠔⠕⠖⠗⡐⡑⡒⡓⡔⡕⡖⡗⠘⠙⠚⠛⠜⠝⠞⠟⡘⡙⡚⡛⡜⡝⡞⡟⠠⠡⠢⠣⠤⠥⠦⠧⡠⡡⡢⡣⡤⡥⡦⡧⠨⠩⠪⠫⠬⠭⠮⠯⡨⡩⡪⡫⡬⡭⡮⡯⠰⠱⠲⠳⠴⠵⠶⠷⡰⡱⡲⡳⡴⡵⡶⡷⠸⠹⠺⠻⠼⠽⠾⠿⡸⡹⡺⡻⡼⡽⡾⡿⢀⢁⢂⢃⢄⢅⢆⢇⣀⣁⣂⣃⣄⣅⣆⣇⢈⢉⢊⢋⢌⢍⢎⢏⣈⣉⣊⣋⣌⣍⣎⣏⢐⢑⢒⢓⢔⢕⢖⢗⣐⣑⣒⣓⣔⣕⣖⣗⢘⢙⢚⢛⢜⢝⢞⢟⣘⣙⣚⣛⣜⣝⣞⣟⢠⢡⢢⢣⢤⢥⢦⢧⣠⣡⣢⣣⣤⣥⣦⣧⢨⢩⢪⢫⢬⢭⢮⢯⣨⣩⣪⣫⣬⣭⣮⣯⢰⢱⢲⢳⢴⢵⢶⢷⣰⣱⣲⣳⣴⣵⣶⣷⢸⢹⢺⢻⢼⢽⢾⢿⣸⣹⣺⣻⣼⣽⣾⣿".chars().collect()}
67    pub fn blocks_two_by_three() -> Vec<char> {" 🬀🬃🬄🬏🬐🬓▌🬁🬂🬅🬆🬑🬒🬔🬕🬇🬈🬋🬌🬖🬗🬚🬛🬉🬊🬍🬎🬘🬙🬜🬝🬞🬟🬢🬣🬭🬮🬱🬲🬠🬡🬤🬥🬯🬰🬳🬴🬦🬧🬩🬪🬵🬶🬹🬺▐🬨🬫🬬🬷🬸🬻█".chars().collect()}
68}
69
70/// Used for displaying continuous single lines. 
71/// 
72/// # Characters
73/// 
74/// `"_―‾╱/╲\|"`
75/// 
76pub mod line_chars {
77    pub const FLAT_LOW: char = '_';
78    pub const FLAT_MED: char = '―';
79    pub const FLAT_HIGH: char = '‾';
80
81    pub const UP_ONE: char = '╱';
82    pub const UP_TWO: char = '/';
83    pub const DOWN_ONE: char = '╲';
84    pub const DOWN_TWO: char = '\\';
85
86    pub const VERTICAL: char = '|';
87}
88
89pub mod vec_chars {
90    pub const ARROWS: &'static str = "→↘↓↙←↖↑↗";
91}