Skip to content

Commit

Permalink
Add draw_fps function
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohq committed Oct 27, 2024
1 parent 455f3fb commit 0f20cbb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/rustaceanmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async fn main() {
);
}

draw_text(format!("FPS: {}", get_fps()).as_str(), 0., 16., 32., WHITE);
draw_fps(0., 16., 32., WHITE);
draw_text(
format!("Rustaceanes: {}", rustaceanes.len()).as_str(),
0.,
Expand Down
7 changes: 6 additions & 1 deletion src/time.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
//! Cross platform system time access and FPS counters.
use crate::get_context;
use crate::{color::Color, get_context, text::draw_text};

/// Draws the current FPS on the screen. For extra customization, please use `draw_text` instead.
pub fn draw_fps(x: f32, y: f32, font_size: f32, color: Color) {
draw_text(&format!("FPS: {}", get_fps()), x, y, font_size, color);
}

/// Returns current FPS
pub fn get_fps() -> i32 {
Expand Down

0 comments on commit 0f20cbb

Please sign in to comment.