add rustfmt.toml

This commit is contained in:
Simon Gardling
2022-02-11 14:29:43 -05:00
parent 4e99bf651e
commit 7eb4008d15
3 changed files with 9 additions and 23 deletions

View File

@@ -5,14 +5,8 @@ use plotters_canvas::CanvasBackend;
use web_sys::HtmlCanvasElement;
pub fn draw(
element: HtmlCanvasElement,
func_str: &str,
min_x: f32,
max_x: f32,
min_y: f32,
max_y: f32,
num_interval: usize,
resolution: i32,
element: HtmlCanvasElement, func_str: &str, min_x: f32, max_x: f32, min_y: f32, max_y: f32,
num_interval: usize, resolution: i32,
) -> DrawResult<(impl Fn((i32, i32)) -> Option<(f32, f32)>, f32)> {
let expr: Expr = func_str.parse().unwrap();
let func = expr.bind("x").unwrap();
@@ -61,10 +55,7 @@ pub fn draw(
// Creates and does the math for creating all the rectangles under the graph
#[inline(always)]
fn integral_rectangles(
min_x: f32,
step: f32,
num_interval: usize,
func: &dyn Fn(f64) -> f64,
min_x: f32, step: f32, num_interval: usize, func: &dyn Fn(f64) -> f64,
) -> (Vec<(f32, f32, f32)>, f32) {
let mut area: f32 = 0.0; // sum of all rectangles' areas
let mut tmp1: f32; // Top left Y value that's tested

View File

@@ -23,14 +23,8 @@ pub struct Point {
#[wasm_bindgen]
impl Chart {
pub fn draw(
canvas: HtmlCanvasElement,
func_str: &str,
min_x: f32,
max_x: f32,
min_y: f32,
max_y: f32,
num_interval: usize,
resolution: i32,
canvas: HtmlCanvasElement, func_str: &str, min_x: f32, max_x: f32, min_y: f32, max_y: f32,
num_interval: usize, resolution: i32,
) -> Result<Chart, JsValue> {
let draw_output = func_plot::draw(
canvas,
@@ -51,9 +45,7 @@ impl Chart {
});
}
pub fn get_area(&self) -> f32 {
return self.area;
}
pub fn get_area(&self) -> f32 { return self.area; }
pub fn coord(&self, x: i32, y: i32) -> Option<Point> {
(self.convert)((x, y)).map(|(x, y)| Point { x, y })