Skip to content

Commit f7cc29a

Browse files
committed
Add draw_fps function
1 parent 455f3fb commit f7cc29a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

examples/rustaceanmark.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async fn main() {
5555
);
5656
}
5757

58-
draw_text(format!("FPS: {}", get_fps()).as_str(), 0., 16., 32., WHITE);
58+
draw_fps();
5959
draw_text(
6060
format!("Rustaceanes: {}", rustaceanes.len()).as_str(),
6161
0.,

src/time.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
//! Cross platform system time access and FPS counters.
22
3-
use crate::get_context;
3+
use crate::{color::Color, get_context, text::draw_text};
4+
5+
/// Draws the current FPS on the screen. For extra customization, please use `draw_text` instead.
6+
pub fn draw_fps() {
7+
draw_text(&format!("FPS: {}", get_fps()), 0., 16., 32., crate::WHITE);
8+
}
49

510
/// Returns current FPS
611
pub fn get_fps() -> i32 {

0 commit comments

Comments
 (0)