Struct ruscii::gui::FPSCounter
source · pub struct FPSCounter { /* private fields */ }
Expand description
A struct that provides access to the application’s framerate.
This FPS counter does not update automatically. FPSCounter::update
should be called
to update the FPS for every frame, i.e., in the frame_action
function parameter of
App::run
.
The FPS value can be obtained by calling FPSCounter::count
.
Example
let mut app = App::default();
let mut fps_counter = FPSCounter::default();
app.run(|app_state: &mut State, window: &mut Window| {
fps_counter.update(); // Updates the FPS
let mut pencil = Pencil::new(window.canvas_mut());
pencil.draw_text(
&format!("FPS: {}", fps_counter.count()), // Draws the FPS
Vec2::xy(1, 0)
);
});
Implementations§
source§impl FPSCounter
impl FPSCounter
Trait Implementations§
source§impl Default for FPSCounter
impl Default for FPSCounter
source§fn default() -> FPSCounter
fn default() -> FPSCounter
Returns the “default value” for a type. Read more