Py5Surface.is_stopped()

Determine if the surface is currently running an animation.

Examples

1
2
3
4
5
6
7
def draw():
    py5.rect(py5.mouse_x, py5.mouse_y, 10, 10)

py5.run_sketch(block=False)
surface = py5.get_surface()
# this will print False
py5.println(surface.is_stopped())
1
2
3
4
5
6
7
8
def setup():
    py5.fill(255, 0, 0)
    py5.rect(50, 50, 10, 10)

py5.run_sketch(block=False)
surface = py5.get_surface()
# this will print True
py5.println(surface.is_stopped())
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
def draw():
    py5.rect(py5.mouse_x, py5.mouse_y, 10, 10)

py5.run_sketch(block=False)
surface = py5.get_surface()
# this will print False
py5.println(surface.is_stopped())

surface.stop_thread()
# now it will print True
py5.println(surface.is_stopped())

Description

Determine if the surface is currently running an animation. A Sketch that has called no_loop() or has no draw() function is not animating, and will result in this method returning True. If there is a draw() function and no_loop() has not been called, this will return False. Calling Py5Surface’s Py5Surface.stop_thread() will make all future calls to is_stopped() return True.

The output of this method is independent of Py5Surface.pause_thread() and Py5Surface.resume_thread().

Underlying Java method: PSurface.isStopped

Syntax

is_stopped() -> bool

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