simplegui_lib_fps — class to calculate and display Frames Per Second

(Version saved in CodeSkulptor http://www.codeskulptor.org/#user33_Bhc7VzXKbXGVQV1.py .)

Examples of use in :

simplegui_lib_fps (May 25, 2014)

A class to calculate and display FPS (Frames Per Second) in SimpleGUI of CodeSkulptor.

Piece of SimpleGUICS2Pygame. https://bitbucket.org/OPiMedia/simpleguics2pygame

GPLv3 — Copyright (C) 2013, 2014 Olivier Pirson http://www.opimedia.be/

class SimpleGUICS2Pygame.simplegui_lib_fps.FPS(x=10, y=10, font_color='Red', font_size=40)[source]

Calculate and display FPS (Frames Per Second).

How to use:

  • Create an instance of FPS: fps = FPS()
  • Start: fps.start()
  • And put the draw_fct() in the end of your canvas’ draw handler: fps.draw_fct(canvas)
__init__(x=10, y=10, font_color='Red', font_size=40)[source]

Set an instance to calculate FPS and drawing on position (x, y).

Parameters:
  • x – int or float
  • y – int or float
  • font_color – str
  • font_size – int > 0
draw_fct(canvas)[source]

Update the number of frames drawn and draw the FPS.

This method must be called from the canvas’ draw handler (the function passed as a parameter to simplegui.Frame.set_draw_handler()).

Parameters:canvas – simplegui.Canvas
is_started()[source]

If FPS is active then return True, else return False.

start()[source]

Start calculation and drawing.

See draw_fct().

stop()[source]

Stop calculation and drawing.

__weakref__

list of weak references to the object (if defined)

[source]