From 136502f371851efec48426d424115e136033c157 Mon Sep 17 00:00:00 2001 From: jakobst1n Date: Sat, 8 Jun 2024 20:15:35 +0200 Subject: Add some basic functionality --- src/main.rs | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 4cae5be..e9798c5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,31 +1,26 @@ use textgraph::graph; +use textgraph::parseopts::parseopts; fn main() { - let mut line: Vec = Vec::new(); - let mut marks: Vec = Vec::new(); - for i in 0..500 { - line.push((i as f64 * std::f64::consts::PI / 120.0).sin()); - marks.push(i as f64); - } - - // Choose one of the methods based on sample speed: - //let downsampled_data = graph::downsample(&line, 100); - let interpolated_data = graph::interpolate(&line, &marks, 100); + let opts = parseopts(); + let mut y_values: Vec = Vec::new(); + let mut x_values: Vec = Vec::new(); + for i in 0..600 { + y_values.push((i as f64 * std::f64::consts::PI / 120.0).sin()); + x_values.push(i as f64); + } - //let processed_data = if marks.windows(2).all(|w| w[1] - w[0] == w[0] - w[1]) { - // downsample(&series, options.width) - //} else { - // interpolate(&series, &marks, options.width) - //}; + //let y_values: [f64; 6] = [1.0, 10.0, 40.0, 0.0, 30.0, 15.0]; + //let x_values: [f64; 6] = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]; + let graph_options: textgraph::graph::GraphOptions = (&opts).into(); + let g = match opts.graph_type { + textgraph::parseopts::GraphType::Ascii => { + graph::ascii(&y_values, &x_values, &graph_options) + } + textgraph::parseopts::GraphType::Star => graph::star(&y_values, &x_values, &graph_options), + }; - let g = graph::ascii_trailing( - &interpolated_data, - &graph::GraphOptions { - width: 100.0, - height: 30.0, - }, - ); println!("{}", g); } -- cgit v1.2.3