fn draw_hp_bar(&self, ctx: &CanvasRenderingContext2d) -> Result<(), JsValue> {
        ctx.begin_path();
        ctx.set_fill_style(&JsValue::from_str("#00ff00"));
        ctx.fill_rect(
            (-self.rect.w() * 0.5).floor(),
            (-self.rect.h() * 0.5).floor(),
            (self.rect.w() * self.hp().percent()).floor(),
            (self.rect.h() * 0.1).floor(),
        );
        ctx.close_path();

        Ok(())
    }
/// Draw the HP indicator of the Plane
Draw the HP indicator of the Plane
Draw the HP indicator of the Plane
fn draw_hp_bar(&self, ctx: &CanvasRenderingContext2d) -> Result<(), JsValue> {
        ctx.begin_path();
        ctx.set_fill_style(&JsValue::from_str("#00ff00"));
        ctx.fill_rect(
            (-self.rect.w() * 0.5).floor(),
            (-self.rect.h() * 0.5).floor(),
            (self.rect.w() * self.hp().percent()).floor(),
            (self.rect.h() * 0.1).floor(),
        );
        ctx.close_path();
        Ok(())
    }
fn draw_hp_bar ( & self , ctx : & CanvasRenderingContext2d ) -> Result < ( ) , JsValue > { ctx . begin_path ( ) ; ctx . set_fill_style ( & JsValue :: from_str ( " " ) ) ; ctx . fill_rect ( ( - self . rect . w ( ) * 0.5 ) . floor ( ) , ( - self . rect . h ( ) * 0.5 ) . floor ( ) , ( self . rect . w ( ) * self . hp ( ) . percent ( ) ) . floor ( ) , ( self . rect . h ( ) * 0.1 ) . floor ( ) , ) ; ctx . close_path ( ) ; Ok ( ( ) ) }
Draw the HP indicator of the Plane
Draw the HP indicator of the Plane
&self
ctx
&CanvasRenderingContext2d
&self
ctx
&CanvasRenderingContext2d