Skip to content

Show a graph on the terminal using block (▁▃▆█) or braille (⡶⠚) characters

Notifications You must be signed in to change notification settings

mklein994/braille

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

braille

Show a graph on the terminal using block or braille characters.

Example

Fancy Graph

Command

awk -f fancy_graph.awk | braille -r -1:1 -c 5
# fancy_graph.awk
BEGIN {
    pi = atan2(0, -1);
    for (i = (-20 * pi); i < (20 * pi); i++) {
        print 100 * sin(i / 4) / i;
    }
}

$$100*\frac{\sin(\frac{x}{4})}{x}$$

Output

⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣿⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⣿⣿⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⣿⣿⣿⣿⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⣿⣿⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⣀⣤⣤⣤⣀⠀⠀⠀⠀⠀⠀⠀⣠⣴⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠀⠀⠀⠀⠀⠀⢀⣴⣿⣿⣶⣄⠀⠀⠀⠀⠀⠀⠀⣀⣤⣤⣤⣄⡀
⠉⠉⠉⠉⠉⠉⠉⠻⢿⣿⣿⠿⠋⠉⠉⠉⠉⠉⠉⠹⣿⣿⣿⣿⣿⠋⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⢿⣿⣿⣿⣿⡟⠉⠉⠉⠉⠉⠉⠉⠻⢿⣿⡿⠟⠋⠉⠉⠉⠉⠉⠉
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣿⡿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠻⣿⡿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

Fancy Graph (Small)

Command

awk -f fancy_graph_small.awk | braille -c 10
# fancy_graph_small.awk
BEGIN {
    pi = atan2(0, -1);
    for (i = -8 * pi; i < 8 * pi; i++) {
        if (i != 0) {
            print sin(i) / i;
        }
    }
}

$$\frac{\sin(x)}{x}$$

Output

⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⣀⠀⠀⣠⡀⠀⣰⡆⠀⢸⣿⣿⡆⠀⣼⡄⠀⢠⡀⠀⢀⡀⠀⠀
⠹⠟⠉⠹⠟⠉⠹⡿⠉⠙⣿⠉⠉⠉⢹⣿⠉⠹⡿⠉⠙⠿⠉⠉⠻⠃
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⠀⠀⠀⠸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

Curve

Command

jq -nrf curve.jq | braille \
    --style auto \
    --per 2 \
    --kind braille-columns \
    10
# curve.jq
(-1 | acos) as $pi
| range(-8 * $pi; 8 * $pi)
| [
  (. / 5 | cos),
  (. / 4 | sin)
] | @tsv

Output

⠀⠀⣰⣿⡄⠀⠀⠀⠀⠀⠀⠠⠉⠑⣀⣾⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⢠⣿⣿⣿⠀⠀⠀⠀⠀⠠⠁⠀⠀⡸⣿⣿⣇⠀⠀⠀⠀⠀⠀⠀⠀
⠀⣼⣿⣿⣿⡇⠀⠀⠀⠀⠂⠀⠀⢀⠀⢻⣿⣿⡀⠀⠀⠀⠀⠀⠀⠀
⢂⣿⣿⣿⣿⣿⠀⠀⠀⠐⠀⠀⠀⡀⠀⠈⣿⣿⡇⠀⠀⠀⠀⠀⠀⠄
⡘⣿⣿⣿⣿⣿⡆⠀⠀⠂⠀⠀⠀⠀⠀⠀⢹⣿⣿⠀⠀⠀⠀⠀⠠⠀
⠀⢻⣿⣿⣿⣿⣧⠀⠐⠀⠀⠀⠈⠀⠀⠀⠈⣿⣿⡆⠀⠀⠀⠀⠄⠂
⠀⠘⣿⣿⣿⣿⣿⡄⠁⠀⠀⠀⠂⠀⠀⠀⠀⢸⣿⣧⠀⠀⠀⠠⠠⠀
⠀⠀⢻⣿⣿⣿⣿⣏⠀⠀⠀⠐⠀⠀⠀⠀⠀⠀⣿⣿⡄⠀⠀⠄⠄⠀
⠀⠀⠈⣿⣿⣿⡿⠀⠄⠀⠀⠂⠀⠀⠀⠀⠀⠀⠸⣿⣧⠀⡐⠠⠀⠀
⠀⠀⠀⠘⢿⡿⠁⠀⠐⣀⠌⠀⠀⠀⠀⠀⠀⠀⠀⠹⣿⠶⡠⠂⠀⠀

Installation

After installing rust:

cargo install --git https://github.com/mklein994/braille.git

For help on the various options, see braille --help or run cargo doc on the local clone and browse the API docs.

The --modeline option pairs nicely with jq-repl.

About

Show a graph on the terminal using block (▁▃▆█) or braille (⡶⠚) characters

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published