use wasm_bindgen::prelude::*; pub type DrawResult = Result>; /// Result of screen to chart coordinates conversion. #[wasm_bindgen] pub struct Point { pub x: f32, pub y: f32, } #[wasm_bindgen] impl Point { pub fn new(x: f32, y: f32) -> Self { Self { x, y } } } #[wasm_bindgen] pub struct Chart { pub(crate) convert: Box Option<(f32, f32)>>, pub(crate) area: f32, } #[wasm_bindgen] impl Chart { pub fn get_area(&self) -> f32 { self.area } pub fn coord(&self, x: i32, y: i32) -> Option { (self.convert)((x, y)).map(|(x, y)| Point::new(x, y)) } }