Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add draw_fps helper function #852

Merged
merged 1 commit into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
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::{get_context, text::draw_text};

/// Draws the current FPS on the screen. For extra customization, please use `draw_text` instead.
pub fn draw_fps() {
draw_text(&format!("FPS: {}", get_fps()), 0., 16., 32., crate::WHITE);
}

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