pub fn convert_coord(canvas: &web_sys::HtmlElement, e: &web_sys::MouseEvent) -> [f32; 2] {
    let rect = canvas.get_bounding_client_rect();

    let canvas_width: f64 = canvas
        .get_attribute("width")
        .unwrap_throw()
        .parse()
        .unwrap_throw();
    let canvas_height: f64 = canvas
        .get_attribute("height")
        .unwrap_throw()
        .parse()
        .unwrap_throw();

    let scalex = canvas_width / rect.width();
    let scaley = canvas_height / rect.height();

    let [x, y] = [e.client_x() as f64, e.client_y() as f64];

    let [x, y] = [(x - rect.left()) * scalex, (y - rect.top()) * scaley];
    [x as f32, y as f32]
}
///
/// Convert a mouse event to a coordinate for simple2d.
///
Convert a mouse event to a coordinate for simple2d.
Convert a mouse event to a coordinate for simple2d .
pub fn convert_coord(canvas: &web_sys::HtmlElement, e: &web_sys::MouseEvent) -> [f32; 2] {
    let rect = canvas.get_bounding_client_rect();
    let canvas_width: f64 = canvas
        .get_attribute("width")
        .unwrap_throw()
        .parse()
        .unwrap_throw();
    let canvas_height: f64 = canvas
        .get_attribute("height")
        .unwrap_throw()
        .parse()
        .unwrap_throw();
    let scalex = canvas_width / rect.width();
    let scaley = canvas_height / rect.height();
    let [x, y] = [e.client_x() as f64, e.client_y() as f64];
    let [x, y] = [(x - rect.left()) * scalex, (y - rect.top()) * scaley];
    [x as f32, y as f32]
}
pub fn convert_coord ( canvas : & web_sys :: HtmlElement , e : & web_sys :: MouseEvent ) -> [ f32 ; 2 ] { let rect = canvas . get_bounding_client_rect ( ) ; let canvas_width : f64 = canvas . get_attribute ( " " ) . unwrap_throw ( ) . parse ( ) . unwrap_throw ( ) ; let canvas_height : f64 = canvas . get_attribute ( " " ) . unwrap_throw ( ) . parse ( ) . unwrap_throw ( ) ; let scalex = canvas_width / rect . width ( ) ; let scaley = canvas_height / rect . height ( ) ; let [ x , y ] = [ e . client_x ( ) as f64 , e . client_y ( ) as f64 ] ; let [ x , y ] = [ ( x - rect . left ( ) ) * scalex , ( y - rect . top ( ) ) * scaley ] ; [ x as f32 , y as f32 ] }
Convert a mouse event to a coordinate for simple2d.
Convert a mouse event to a coordinate for simple2d .
canvas
&web_sys::HtmlElement
e
&web_sys::MouseEvent
canvas
&web_sys::HtmlElement
e
&web_sys::MouseEvent