Graph plotting in the terminal using braille characters
I recently made a program named tplot, short for terminal plotter.
It uses braille characters as software-based "subpixels", each character is a grid of 2x8 dots, making an average 80x24 terminal have 160x192 available dots for graphing.
It takes into in two input forms;
$ echo 1 1 | tplot
Which will draw a dot at position 1x1 on the grid.
It utilizes Bresenham's line algorithm to acceept input in form of ;
$ echo 1 1 to 25 25 | tplot
Which will draw a line from 1x1 to 25x25.
More advanced use
Lines and dots are fine and all, but you can advance upon it a lot with a small awk
script.
$ awk -f - << EOF | tplot
BEGIN {
pi = 3.14159;
c = 50;
r = 45;
for (i=0; i < pi * 2; i += pi/10) {
x = cos(i) * r;
y = sin(i) * r;
printf("%d %d to %d %d\n", c + x, c + y, c, c);
}
}
EOF
Which will output something like; depending on your font, this might be borked.
⢠ ⡇ ⡄
⢇ ⡇ ⡸
⠱⡀ ⠘⡄ ⡇ ⢀⠇ ⢀⠎
⠈⢆ ⢱ ⡇ ⡜ ⡰⠁
⢄⡀ ⠱⡀ ⢇ ⡇ ⢰⠁ ⢀⠜ ⢀⡠
⠈⠢⢄ ⠘⢄ ⠘⡄ ⢇ ⡎ ⡠⠊ ⡠⠔⠁
⠑⠢⣀ ⠣⡀ ⢣ ⢸ ⡸ ⡔⠁ ⢀⠔⠊
⣀ ⠑⠤⡀ ⠘⢄ ⠈⡆ ⢸ ⢀⠇ ⢀⠎ ⢀⡠⠊⠁ ⣀
⠉⠑⠒⠤⢄⣀ ⠈⠒⢄ ⠣⡀⠸⡀⢸ ⡜ ⡰⠁ ⡠⠔⠁ ⣀⡠⠤⠒⠊⠉
⠉⠑⠒⠤⠤⣀⡀ ⠉⠢⢄⠑⢄⢣⢸⢰⢁⠜⢀⠔⠊ ⣀⡠⠤⠒⠊⠉
⠈⠉⠒⠢⠤⣑⡪⡪⣾⣮⡪⣊⡡⠤⠒⠊⠉
⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⢒⣒⡺⣿⣿⡿⡿⣒⣒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠂
⣀⡠⠤⠔⠒⠉⣁⠔⡪⢪⢻⢫⢪⠒⢄⠉⠑⠒⠤⢄⣀
⢀⣀⠤⠔⠒⠊⠉ ⢀⠔⠊⢀⠔⠁⡎⢸⠘⡄⠑⡄⠉⠢⢄ ⠉⠉⠒⠢⠤⣀⡀
⠤⠒⠊⠉⠁ ⢀⠤⠊⠁ ⡠⠊ ⡸ ⢸ ⢱ ⠈⢆ ⠑⠢⣀ ⠈⠉⠑⠒⠤
⢀⡠⠊⠁ ⢀⠔⠁ ⢠⠃ ⢸ ⢇ ⠱⡀ ⠑⠤⡀
⢀⡠⠒⠁ ⡠⠊ ⡎ ⢸ ⠘⡄ ⠘⢄ ⠈⠒⢄⡀
⡠⠔⠁ ⢀⠔⠁ ⡸ ⢸ ⢣ ⠣⡀ ⠈⠢⢄
⡠⠊ ⢠⠃ ⢸ ⠈⡆ ⠘⢄
⢀⠔⠁ ⡎ ⢸ ⠸⡀ ⠈⠢⡀
⠊ ⡸ ⢸ ⢇ ⠑
⢠⠃ ⢸ ⠘⡄
⠘
If you're interested, you can take a look at the source on github.don't worry it's only ~120 lines