Py5Surface.set_size()

Set a new width and height for the Sketch window.

Examples

1
2
3
4
5
6
7
8
def draw():
    py5.square(py5.random(py5.width), py5.random(py5.height), 10)

py5.run_sketch(block=False)

# while the sketch is running, get the surface and change the size
surface = py5.get_surface()
surface.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 your Sketch uses this, the width and height variables will change.

Underlying Java method: PSurface.setSize

Syntax

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

Parameters

  • height: int - new window height

  • width: int - new window width

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