diff --git a/src/lib.rs b/src/lib.rs index 2c0e03e..6e21056 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,7 +5,7 @@ use std::panic; use wasm_bindgen::prelude::*; use web_sys::HtmlCanvasElement; mod misc; -use crate::misc::{Chart, DrawResult, Cache}; +use crate::misc::{ChartOutput, DrawResult, Cache}; #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; @@ -118,7 +118,7 @@ impl ChartManager { pub fn update( &mut self, canvas: HtmlCanvasElement, func_str: &str, min_x: f32, max_x: f32, min_y: f32, max_y: f32, num_interval: usize, resolution: i32, - ) -> Result { + ) -> Result { let underlying_update = (*func_str != self.func_str) | (min_x != self.min_x) | (max_x != self.max_x) @@ -158,12 +158,12 @@ impl ChartManager { let draw_output = self.draw(canvas).map_err(|err| err.to_string())?; let map_coord = draw_output.0; - let chart = Chart { + let chart_output = ChartOutput { convert: Box::new(move |coord| map_coord(coord).map(|(x, y)| (x, y))), area: draw_output.1, }; - Ok(chart) + Ok(chart_output) } // Creates and does the math for creating all the rectangles under the graph diff --git a/src/misc.rs b/src/misc.rs index 77b7a62..41d8f02 100644 --- a/src/misc.rs +++ b/src/misc.rs @@ -16,13 +16,13 @@ impl Point { } #[wasm_bindgen] -pub struct Chart { +pub struct ChartOutput { pub(crate) convert: Box Option<(f32, f32)>>, pub(crate) area: f32, } #[wasm_bindgen] -impl Chart { +impl ChartOutput { pub fn get_area(&self) -> f32 { self.area } pub fn coord(&self, x: i32, y: i32) -> Option {