UI improvements
This commit is contained in:
@@ -241,8 +241,8 @@ impl epi::App for MathApp {
|
||||
|
||||
Plot::new("plot")
|
||||
.set_margin_fraction(Vec2::ZERO)
|
||||
.view_aspect(1.0)
|
||||
.data_aspect(1.0)
|
||||
// .view_aspect(1.0)
|
||||
// .data_aspect(1.0)
|
||||
.include_y(0)
|
||||
.show(ui, |plot_ui| {
|
||||
let bounds = plot_ui.plot_bounds();
|
||||
|
||||
@@ -23,26 +23,6 @@ pub struct Function {
|
||||
integral_num: usize,
|
||||
}
|
||||
|
||||
impl Clone for Function {
|
||||
fn clone(&self) -> Self {
|
||||
let expr: Expr = self.func_str.parse().unwrap();
|
||||
let func = expr.bind("x").unwrap();
|
||||
Self {
|
||||
function: Box::new(func),
|
||||
func_str: self.func_str.clone(),
|
||||
min_x: self.min_x,
|
||||
max_x: self.max_x,
|
||||
pixel_width: self.pixel_width,
|
||||
back_cache: self.back_cache.clone(),
|
||||
front_cache: self.front_cache.clone(),
|
||||
integral: self.integral,
|
||||
integral_min_x: self.integral_min_x,
|
||||
integral_max_x: self.integral_max_x,
|
||||
integral_num: self.integral_num,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Function {
|
||||
pub fn new(
|
||||
func_str: String, min_x: f64, max_x: f64, pixel_width: usize, integral: bool,
|
||||
|
||||
13
src/lib.rs
13
src/lib.rs
@@ -35,9 +35,16 @@ pub fn start(canvas_id: &str) -> Result<(), wasm_bindgen::JsValue> {
|
||||
init_tracing_wasm();
|
||||
|
||||
// Used in order to hook into `panic!()` to log in the browser's console
|
||||
log_helper("Initializing console_error_panic_hook...");
|
||||
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
|
||||
log_helper("Initialized console_error_panic_hook!");
|
||||
log_helper("Initializing panic hooks...");
|
||||
std::panic::set_hook(Box::new(|panic_info| {
|
||||
web_sys::window()
|
||||
.and_then(|window| window.document())
|
||||
.and_then(|document| document.body())
|
||||
.and_then(|element| element.set_attribute("data-panicked", "true").ok());
|
||||
|
||||
console_error_panic_hook::hook(panic_info);
|
||||
}));
|
||||
log_helper("Initialized panic hooks!");
|
||||
|
||||
log_helper("Finished initializing!");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user