rustfmt
This commit is contained in:
25
src/lib.rs
25
src/lib.rs
@@ -11,7 +11,7 @@ pub type DrawResult<T> = Result<T, Box<dyn std::error::Error>>;
|
||||
#[wasm_bindgen]
|
||||
pub struct Chart {
|
||||
convert: Box<dyn Fn((i32, i32)) -> Option<(f32, f32)>>,
|
||||
area: f32
|
||||
area: f32,
|
||||
}
|
||||
|
||||
/// Result of screen to chart coordinates conversion.
|
||||
@@ -23,8 +23,27 @@ pub struct Point {
|
||||
|
||||
#[wasm_bindgen]
|
||||
impl Chart {
|
||||
pub fn draw(canvas: HtmlCanvasElement, func: &str, min_x: f32, max_x: f32, min_y: f32, max_y: f32, num_interval: usize, resolution: i32) -> Result<Chart, JsValue> {
|
||||
let output = func_plot::draw(canvas, func, min_x, max_x, min_y, max_y, num_interval, resolution).map_err(|err| err.to_string())?;
|
||||
pub fn draw(
|
||||
canvas: HtmlCanvasElement,
|
||||
func: &str,
|
||||
min_x: f32,
|
||||
max_x: f32,
|
||||
min_y: f32,
|
||||
max_y: f32,
|
||||
num_interval: usize,
|
||||
resolution: i32,
|
||||
) -> Result<Chart, JsValue> {
|
||||
let output = func_plot::draw(
|
||||
canvas,
|
||||
func,
|
||||
min_x,
|
||||
max_x,
|
||||
min_y,
|
||||
max_y,
|
||||
num_interval,
|
||||
resolution,
|
||||
)
|
||||
.map_err(|err| err.to_string())?;
|
||||
let map_coord = output.0;
|
||||
Ok(Chart {
|
||||
convert: Box::new(move |coord| map_coord(coord).map(|(x, y)| (x.into(), y.into()))),
|
||||
|
||||
Reference in New Issue
Block a user