aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs
index 34adc14..534d634 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -47,11 +47,12 @@ impl Application for Graph {
type Flags = ();
fn new(_flags: ()) -> (Self, Command<Message>) {
+ let ctx = Context::commonsense();
(
Graph {
input_state: "f(x) = x^2".to_string(),
- func: ExpressionFunction::from_string("f(x) = x^2".to_string()),
- ctx: Context::commonsense(),
+ func: ExpressionFunction::from_string("f(x) = x^2".to_string(), ctx.operations()),
+ ctx,
..Default::default()
},
Command::none(),
@@ -68,7 +69,7 @@ impl Application for Graph {
self.input_state = s;
}
Message::UpdateScreen => {
- self.func = ExpressionFunction::from_string(self.input_state.clone());
+ self.func = ExpressionFunction::from_string(self.input_state.clone(), self.ctx.operations());
self.graph.clear();
}
}
@@ -137,26 +138,26 @@ impl canvas::Program<Message, Renderer> for Graph {
let unitline = Stroke {
width: 2.0,
style: stroke::Style::Solid(Color::new(0.0, 0.0, 0.0, 1.0)),
- line_cap: LineCap::Square,
+ line_cap: LineCap::Round,
..Stroke::default()
};
let unitline_whole = Stroke {
width: 1.0,
style: stroke::Style::Solid(Color::new(0.5, 0.5, 0.5, 1.0)),
- line_cap: LineCap::Square,
+ line_cap: LineCap::Round,
..Stroke::default()
};
let zeroline = Stroke {
width: 3.0,
style: stroke::Style::Solid(Color::new(0.0, 0.0, 0.8, 1.0)),
- line_cap: LineCap::Square,
+ line_cap: LineCap::Round,
..Stroke::default()
};
let graphline = Stroke {
width: 3.0,
style: stroke::Style::Solid(Color::new(0.8, 0.0, 0.0, 1.0)),
- line_cap: LineCap::Square,
+ line_cap: LineCap::Round,
..Stroke::default()
};
@@ -230,7 +231,7 @@ impl canvas::Program<Message, Renderer> for Graph {
let mut y1 = self
.func
.eval(
- FunctionArgument::new(vec![Complex::new(start_x as f64, 0.0)]),
+ &FunctionArgument::from_values(vec![Complex::new(start_x as f64, 0.0)]),
&self.ctx,
)
.unwrap()
@@ -243,7 +244,7 @@ impl canvas::Program<Message, Renderer> for Graph {
let y2 = self
.func
.eval(
- FunctionArgument::new(vec![Complex::new(x2 as f64, 0.0)]),
+ &FunctionArgument::from_values(vec![Complex::new(x2 as f64, 0.0)]),
&self.ctx,
)
.unwrap()