Git Product home page Git Product logo

braille's Introduction

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.

braille's People

Contributors

mklein994 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.