frame_rate()

Specifies the number of frames to be displayed every second.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
pos = 0


def setup():
    py5.frame_rate(4)


def draw():
    py5.background(204)
    global pos
    pos += 1
    py5.line(pos, 20, pos, 80)
    if pos > py5.width:
        pos = 0

Description

Specifies the number of frames to be displayed every second. For example, the function call frame_rate(30) will attempt to refresh 30 times a second. If the processor is not fast enough to maintain the specified rate, the frame rate will not be achieved. Setting the frame rate within setup() is recommended. The default rate is 60 frames per second.

Underlying Java method: frameRate

Syntax

frame_rate(fps: float, /) -> None

Parameters

  • fps: float - number of desired frames per second

Updated on September 11, 2021 16:51:34pm UTC