diff options
author | metamuffin <metamuffin@disroot.org> | 2024-07-25 17:37:49 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-07-25 17:37:49 +0200 |
commit | 5bf5a200ada9ba03ca2a12c1503318a97166d7c7 (patch) | |
tree | 0936ea088efd11eaee00a88dcb368e7271fb985b /pixel-client/src/render/font.rs | |
parent | 3403fc2d55f510c29bf7e74d85433801cd99cbbc (diff) | |
download | hurrycurry-5bf5a200ada9ba03ca2a12c1503318a97166d7c7.tar hurrycurry-5bf5a200ada9ba03ca2a12c1503318a97166d7c7.tar.bz2 hurrycurry-5bf5a200ada9ba03ca2a12c1503318a97166d7c7.tar.zst |
pc: show fps
Diffstat (limited to 'pixel-client/src/render/font.rs')
-rw-r--r-- | pixel-client/src/render/font.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/pixel-client/src/render/font.rs b/pixel-client/src/render/font.rs index 43df9ca7..95cb3fab 100644 --- a/pixel-client/src/render/font.rs +++ b/pixel-client/src/render/font.rs @@ -42,20 +42,22 @@ impl FontTextures { } impl<'a> Renderer<'a> { - pub fn draw_text(&mut self, position: Vec2, text: &str) -> Vec2 { + pub fn draw_text( + &mut self, + position: Vec2, + text: &str, + scale: f32, + tint: Option<[u8; 4]>, + ) -> Vec2 { let mut cursor = position; let mut line_height = 0f32; for c in text.chars() { if (c as u32) < 128 { let r = self.font_textures.glyphs[c as usize]; - self.draw_ui(SpriteDraw::overlay( - r, - cursor, - Vec2::new(r.width() as f32, r.height() as f32), - None, - )); - cursor.x += r.width() as f32; - line_height = line_height.max(r.height() as f32) + let size = Vec2::new(r.width() as f32, r.height() as f32) * scale; + self.draw_ui(SpriteDraw::overlay(r, cursor, size, tint)); + cursor.x += size.x; + line_height = line_height.max(size.y) } } (cursor - position.y) + Vec2::Y * line_height |