From f57d384eb828324cc7747117403911800ca89210 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Fri, 25 Feb 2022 18:56:14 -0500 Subject: [PATCH] stuff + set margins of Plot (made a PR to egui for that) --- Cargo.toml | 4 ++-- src/egui_app.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e45a450..a839dda 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,8 +15,8 @@ strip = true [dependencies] meval = { git = "https://github.com/Titaniumtown/meval-rs.git" } -egui = "0.17.0" -eframe = "0.17.0" +egui = { git = "https://github.com/Titaniumtown/egui", branch = "patch-1" } +eframe = { git = "https://github.com/Titaniumtown/egui", branch = "patch-1" } instant = { version = "0.1.12", features = ["wasm-bindgen"] } git-version = "0.3.5" diff --git a/src/egui_app.rs b/src/egui_app.rs index a4a6078..980b7b2 100644 --- a/src/egui_app.rs +++ b/src/egui_app.rs @@ -6,7 +6,7 @@ use eframe::{egui, epi}; use egui::plot::{Line, Plot, Values}; use egui::widgets::plot::BarChart; use egui::widgets::Button; -use egui::Color32; +use egui::{Color32, Vec2}; use git_version::git_version; // Grabs git version on compile time @@ -18,7 +18,6 @@ const MIN_X_TOTAL: f64 = -1000.0; const MAX_X_TOTAL: f64 = 1000.0; const X_RANGE: RangeInclusive = MIN_X_TOTAL..=MAX_X_TOTAL; const DEFAULT_FUNCION: &str = "x^2"; -const MARGINS: f64 = 0.9; pub struct MathApp { functions: Vec, @@ -156,7 +155,7 @@ impl epi::App for MathApp { function.is_integral() }; - if !func_strs[i].is_empty() { + if func_strs[i] != "" { let func_test_output = test_func(func_strs[i].clone()); if !func_test_output.is_empty() { parse_error += &func_test_output; @@ -203,6 +202,7 @@ impl epi::App for MathApp { let step = self.get_step(); let mut area_list: Vec = Vec::new(); Plot::new("plot") + .set_margin_fraction(Vec2::ZERO) .view_aspect(1.0) .data_aspect(1.0) .include_y(0) @@ -213,7 +213,7 @@ impl epi::App for MathApp { // println!("({}, {})", minx_bounds, maxx_bounds); for (i, function) in self.functions.iter_mut().enumerate() { - function.update_bounds(minx_bounds * MARGINS, maxx_bounds * MARGINS); + function.update_bounds(minx_bounds, maxx_bounds); if self.func_strs[i].is_empty() { continue; }