width

System variable that stores the width of the display window.

Examples

example picture for width
1
2
3
4
5
def setup():
    py5.no_stroke()
    py5.background(0)
    py5.rect(0, 40, py5.width, 20)
    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 Java field: width

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