Py5Surface.set_visible()#

Set the Sketch window’s visiblity.

Examples#

 1def draw():
 2    py5.rect(py5.random(py5.width), py5.random(py5.height), 10, 10)
 3    py5.println(py5.frame_count)
 4
 5py5.run_sketch(block=False)
 6surface = py5.get_surface()
 7
 8# hide the sketch.
 9surface.set_visible(False)
10# the sketch is no longer visible but there is still output
11
12# after waiting a bit, make the sketch visible again
13surface.set_visible(True)
 1# this sketch will hide itself and reappear elsewhere on your display.
 2
 3def setup():
 4    global surface
 5    global visible
 6    surface = py5.get_surface()
 7    visible = True
 8
 9
10def draw():
11    global visible
12    if py5.frame_count % 250 == 0:
13        # this negates the visible variable
14        visible = not visible
15        if visible:
16            surface.set_location(py5.random_int(py5.display_width),
17                                 py5.random_int(py5.display_height))
18        surface.set_visible(visible)

Description#

Set the Sketch window’s visiblity. The animation will continue to run but the window will not be visible.

Underlying Processing method: PSurface.setVisible

Syntax#

set_visible(visible: bool, /) -> None

Parameters#

  • visible: bool - desired surface visiblity

Updated on November 12, 2021 11:30:58am UTC