aboutsummaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/graph.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/ui/graph.rs b/src/ui/graph.rs
index d02b587..198c020 100644
--- a/src/ui/graph.rs
+++ b/src/ui/graph.rs
@@ -36,7 +36,8 @@ impl GraphCanvas {
pub fn push(&mut self, f: &str) {
if let Ok(f) = ExpressionFunction::from_string(f.to_string(), self.ctx.operations()) {
- self.ctx.set_function(f.name(), std::sync::Arc::new(f.clone()));
+ self.ctx
+ .set_function(f.name(), std::sync::Arc::new(f.clone()));
self.funcs.lock().unwrap().push(Some(FunctionCache::new(f)));
} else {
self.funcs.lock().unwrap().push(None);
@@ -50,12 +51,12 @@ impl GraphCanvas {
}
if let Ok(f) = ExpressionFunction::from_string(f.to_string(), self.ctx.operations()) {
- self.ctx.set_function(f.name(), std::sync::Arc::new(f.clone()));
+ self.ctx
+ .set_function(f.name(), std::sync::Arc::new(f.clone()));
vf[i] = Some(FunctionCache::new(f));
} else {
vf[i] = None;
}
-
}
}
@@ -80,12 +81,12 @@ pub struct GraphState {
impl GraphState {
fn view_rectangle(&self, frame: &Frame, step: usize) -> Rectangle {
let s = Size::new(
- self.map_to_step((frame.width() / self.scale) * step as f32 + 10.0, step),
- self.map_to_step((frame.height() / self.scale) * step as f32 + 10.0, step),
+ self.map_to_step((frame.width() / self.scale) + 2.0 * step as f32, step),
+ self.map_to_step((frame.height() / self.scale) + 2.0 * step as f32, step),
);
let p = Point::new(
- self.map_to_step(-self.center.x / self.scale - s.width / 2.0, step),
- self.map_to_step(-self.center.y / self.scale - s.height / 2.0, step),
+ self.map_to_step(-self.center.x / self.scale - s.width / 2.0 - step as f32, step),
+ self.map_to_step(-self.center.y / self.scale - s.height / 2.0 - step as f32, step),
);
Rectangle::new(p, s)
}
@@ -191,7 +192,7 @@ impl canvas::Program<Message, Renderer> for GraphCanvas {
);
frame.with_save(|frame| {
- for x in (rect.x as i64..x_end).step_by(step) {
+ for x in (rect.x as i64 + 2 * step as i64..x_end).step_by(step) {
let p = Point::new(x as f32, 0.0);
frame.fill(&Path::circle(p, 10.0 / state.scale), zcolor);
frame.fill_text(Text {