window_resize()

Set a new width and height for the Sketch window.

Examples

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

py5.run_sketch(block=False)

# while the sketch is running, change the window size
py5.window_resize(400, 400)

Description

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

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

This method provides the same funcationality as Py5Surface.set_size() but without the need to interact directly with the Py5Surface object.

Underlying Processing method: windowResize

Syntax

window_resize(new_width: int, new_height: int, /) -> None

Parameters

  • new_height: int - new window height

  • new_width: int - new window width

Updated on February 21, 2022 11:40:40am UTC