Py5Surface.set_size()#

Set a new width and height for the Sketch window.

Examples#

1def draw():
2    py5.square(py5.random(py5.width), py5.random(py5.height), 10)
3
4py5.run_sketch(block=False)
5
6# while the sketch is running, get the surface and change the size
7surface = py5.get_surface()
8surface.set_size(400, 400)

Description#

Set a new width and height for the Sketch window. You do not need to call Py5Surface.set_resizable() before calling this.

Changing the window size will clear the drawing canvas. If you do this, the width and height variables will change.

Underlying Processing method: PSurface.setSize

Syntax#

set_size(width: int, height: int, /) -> None

Parameters#

  • height: int - new window height

  • width: int - new window width

Updated on February 10, 2022 17:53:01pm UTC