stuff + set margins of Plot (made a PR to egui for that)

This commit is contained in:
Simon Gardling 2022-02-25 18:56:14 -05:00
parent a2d2a7a551
commit f57d384eb8
2 changed files with 6 additions and 6 deletions

View File

@ -15,8 +15,8 @@ strip = true
[dependencies] [dependencies]
meval = { git = "https://github.com/Titaniumtown/meval-rs.git" } meval = { git = "https://github.com/Titaniumtown/meval-rs.git" }
egui = "0.17.0" egui = { git = "https://github.com/Titaniumtown/egui", branch = "patch-1" }
eframe = "0.17.0" eframe = { git = "https://github.com/Titaniumtown/egui", branch = "patch-1" }
instant = { version = "0.1.12", features = ["wasm-bindgen"] } instant = { version = "0.1.12", features = ["wasm-bindgen"] }
git-version = "0.3.5" git-version = "0.3.5"

View File

@ -6,7 +6,7 @@ use eframe::{egui, epi};
use egui::plot::{Line, Plot, Values}; use egui::plot::{Line, Plot, Values};
use egui::widgets::plot::BarChart; use egui::widgets::plot::BarChart;
use egui::widgets::Button; use egui::widgets::Button;
use egui::Color32; use egui::{Color32, Vec2};
use git_version::git_version; use git_version::git_version;
// Grabs git version on compile time // 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 MAX_X_TOTAL: f64 = 1000.0;
const X_RANGE: RangeInclusive<f64> = MIN_X_TOTAL..=MAX_X_TOTAL; const X_RANGE: RangeInclusive<f64> = MIN_X_TOTAL..=MAX_X_TOTAL;
const DEFAULT_FUNCION: &str = "x^2"; const DEFAULT_FUNCION: &str = "x^2";
const MARGINS: f64 = 0.9;
pub struct MathApp { pub struct MathApp {
functions: Vec<Function>, functions: Vec<Function>,
@ -156,7 +155,7 @@ impl epi::App for MathApp {
function.is_integral() function.is_integral()
}; };
if !func_strs[i].is_empty() { if func_strs[i] != "" {
let func_test_output = test_func(func_strs[i].clone()); let func_test_output = test_func(func_strs[i].clone());
if !func_test_output.is_empty() { if !func_test_output.is_empty() {
parse_error += &func_test_output; parse_error += &func_test_output;
@ -203,6 +202,7 @@ impl epi::App for MathApp {
let step = self.get_step(); let step = self.get_step();
let mut area_list: Vec<f64> = Vec::new(); let mut area_list: Vec<f64> = Vec::new();
Plot::new("plot") Plot::new("plot")
.set_margin_fraction(Vec2::ZERO)
.view_aspect(1.0) .view_aspect(1.0)
.data_aspect(1.0) .data_aspect(1.0)
.include_y(0) .include_y(0)
@ -213,7 +213,7 @@ impl epi::App for MathApp {
// println!("({}, {})", minx_bounds, maxx_bounds); // println!("({}, {})", minx_bounds, maxx_bounds);
for (i, function) in self.functions.iter_mut().enumerate() { 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() { if self.func_strs[i].is_empty() {
continue; continue;
} }