Skip to content

Commit 0f20cbb

Browse files
committed
Add draw_fps function
1 parent 455f3fb commit 0f20cbb

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(0., 16., 32., WHITE);
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(x: f32, y: f32, font_size: f32, color: Color) {
7+
draw_text(&format!("FPS: {}", get_fps()), x, y, font_size, color);
8+
}
49

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

0 commit comments

Comments
 (0)