#graph #ascii #term #closures #terminal #github #started

term_graph

A library to graph functions in the command line. For a tutorial on getting started, check out the CaspianA1/term-graph repository on Github.

1 unstable release

0.1.0 Sep 11, 2020

#22 in #started

GPL-3.0 license

6KB
84 lines

Graph Rust closures in the terminal.

  • Note: the closures used are floating-point.

Here's an example of how to use term-graph:

use term_graph::*;

fn main() {
  let screen = init_screen();
  let graph_spot = make_plot_area(&screen, GraphPlacement::_TopMiddle);
  let graph_spot_2 = make_plot_area(&screen, GraphPlacement::_TopRight);

  let small_wave = |theta: f32| 8.0 * theta.sin();
  let big_wave = |theta: f32| 17.0 * theta.tan() + 17.0 * theta.atan();

  draw_function(graph_spot, small_wave);
  draw_function(graph_spot_2, big_wave);

  screen.deinit();
}

Here's what that looks like:

ASCII-graph

Dependencies

~0.4–1MB
~19K SLoC