Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
entities: rendering hud with semi transparent background
- Loading branch information
Showing
4 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use sdl2::pixels::Color; | ||
use sdl2::rect::{Point, Rect}; | ||
use sdl2::render::WindowCanvas; | ||
|
||
pub struct DiagHud { | ||
position: Point, | ||
background_color: Color, | ||
height: u32, | ||
} | ||
|
||
impl DiagHud { | ||
pub fn new(position: Point) -> DiagHud { | ||
let background_color = Color::RGBA(0, 0, 0, 0xaa); | ||
let height = 40; | ||
DiagHud { | ||
position, | ||
background_color, | ||
height, | ||
} | ||
} | ||
|
||
pub fn render(&self, canvas: &mut WindowCanvas) -> Result<(), String> { | ||
let (width, _) = canvas.window().size(); | ||
let rect = Rect::new(self.position.x, self.position.y, width, self.height); | ||
|
||
canvas.set_draw_color(self.background_color); | ||
canvas.fill_rect(rect)?; | ||
|
||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod diag_hud; | ||
pub mod floor; | ||
pub mod grid; | ||
pub mod text; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters