width#

System variable that stores the width of the display window.

Examples#

example picture for width
1def setup():
2    py5.no_stroke()
3    py5.background(0)
4    py5.rect(0, 40, py5.width, 20)
5    py5.rect(0, 60, py5.width//2, 20)

Description#

System variable that stores the width of the display window. This value is set by the first parameter of the size() function. For example, the function call size(320, 240) sets the width variable to the value 320. The value of width defaults to 100 if size() is not used in a program.

Underlying Processing field: width

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