aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorjakobst1n <jakob.stendahl@outlook.com>2024-06-08 20:15:35 +0200
committerjakobst1n <jakob.stendahl@outlook.com>2024-06-08 20:15:35 +0200
commit136502f371851efec48426d424115e136033c157 (patch)
treee4ec71f3dd3733503c5c284ce87fbb0ae0a36909 /src/main.rs
parent6e9628e2d20c09eaeb7eedfe2f7278de0b65a09f (diff)
downloadtextgraph-136502f371851efec48426d424115e136033c157.tar.gz
textgraph-136502f371851efec48426d424115e136033c157.zip
Add some basic functionality
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs39
1 files changed, 17 insertions, 22 deletions
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<f64> = Vec::new();
- let mut marks: Vec<f64> = 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<f64> = Vec::new();
+ let mut x_values: Vec<f64> = 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);
}