pub fn draw(
        &self,
        ctx: &CanvasRenderingContext2d,
        sprites: &HashMap<String, HtmlImageElement>,
    ) -> Result<(), JsValue> {
        ctx.translate(self.rect.center_x(), self.rect.center_y())?;
        ctx.rotate(self.rotation)?;
        ctx.draw_image_with_html_image_element_and_dw_and_dh(
            sprites.get(&self.img).unwrap(),
            (-self.rect.w() * 0.5).floor(),
            (-self.rect.h() * 0.5).floor(),
            self.rect.w().floor(),
            self.rect.h().floor(),
        )?;
        self.draw_hp_bar(ctx)?;
        ctx.set_transform(1.0, 0.0, 0.0, 1.0, 0.0, 0.0)?;

        Ok(())
    }
/// Draw the Plane on the referenced Context
Draw the Plane on the referenced Context
Draw the Plane on the referenced Context
pub fn draw(
        &self,
        ctx: &CanvasRenderingContext2d,
        sprites: &HashMap<String, HtmlImageElement>,
    ) -> Result<(), JsValue> {
        ctx.translate(self.rect.center_x(), self.rect.center_y())?;
        ctx.rotate(self.rotation)?;
        ctx.draw_image_with_html_image_element_and_dw_and_dh(
            sprites.get(&self.img).unwrap(),
            (-self.rect.w() * 0.5).floor(),
            (-self.rect.h() * 0.5).floor(),
            self.rect.w().floor(),
            self.rect.h().floor(),
        )?;
        self.draw_hp_bar(ctx)?;
        ctx.set_transform(1.0, 0.0, 0.0, 1.0, 0.0, 0.0)?;
        Ok(())
    }
pub fn draw ( & self , ctx : & CanvasRenderingContext2d , sprites : & HashMap < String , HtmlImageElement > , ) -> Result < ( ) , JsValue > { ctx . translate ( self . rect . center_x ( ) , self . rect . center_y ( ) ) ? ; ctx . rotate ( self . rotation ) ? ; ctx . draw_image_with_html_image_element_and_dw_and_dh ( sprites . get ( & self . img ) . unwrap ( ) , ( - self . rect . w ( ) * 0.5 ) . floor ( ) , ( - self . rect . h ( ) * 0.5 ) . floor ( ) , self . rect . w ( ) . floor ( ) , self . rect . h ( ) . floor ( ) , ) ? ; self . draw_hp_bar ( ctx ) ? ; ctx . set_transform ( 1.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 ) ? ; Ok ( ( ) ) }
Draw the Plane on the referenced Context
Draw the Plane on the referenced Context
&self
ctx
&CanvasRenderingContext2d
sprites
&HashMap<String, HtmlImageElement>
&self
ctx
&CanvasRenderingContext2d
sprites
&HashMap<String, HtmlImageElement>