Size() not working with variables arguments

Hi everyone,

The below code is not working with Processing.py (instead of the passed arguments the default values for width and height applies, that are 100x100 pixels: same results as size() statement, with no arguments):

square_size   = 10
square_x_nb   = 50
square_y_nb   = 100

size(square_x_nb * square_size, square_y_nb * square_size)

It works fine with absolute values arguments but not with variables arguments, that is:

size(1000, 500)

Any idea?

1 Like

Processing.org/reference/settings_.html

3 Likes

When you need to define the parameters of the size of the display window with a variable, you must use the settings() function and define size() in it. :slight_smile:

1 Like

Thanks GoToLoop and hsron for your quick and clear answer!

For the above code, the solution would be:

square_size   = 10
square_x_nb   = 50
square_y_nb   = 100

def settings():

  size(square_x_nb * square_size, square_y_nb * square_size)

Just noting that the Python Mode reference has an entry for setup(), but no equivalent documentation for settings().

https://py.processing.org/reference/setup.html

This might be worth opening as an issue for documentation on the python mode docs site:

1 Like

That settings() issue strikes again: :bowling: