Set size() from calculations within the sketch

Hi!
I searched the forum but didn’t really find an answer…

I have a sketch that generates a list of lists of integers(it’s what the apply_rule function in the screenshot does). Some calculations are performed and I want to set the size of the sketch window to the values derived from the output of the function.
Now I might be mistaken but it seems that size() has to be the first thing set in a sketch even for sketches that don’t use setup() (which I don’t here). My problem is that I have to run the calculations before I can tell the sketch what size I want for the sketch. But of course, running the sketch pops up a window right away, at the default size of 100,100, before the calculations are finished(it’s potentially a lot of values and the calculation for a factor of 1000 takes about a minute for example). Is there any way or workaround for this?
Note: In this case my output is deterministic so I actually could calculate them externally and then just use the values but I would also be interested in seeing how this can be done for future projects that involve non-deterministic values. Hope this makes sense, thanks a lot!

Have a look at these surface options:
https://processing.org/reference/setResizable_.html
Also with surface.setSize(); you can change it afterwards.

You can call size() anywhere within callback settings(): :bulb:

Here’s a link for an example on how to it on Processing’s Python Mode: :snake:

3 Likes

thanks a lot that did it for me! Wasn’t aware of settings()…

Indeed some Processing functions, even important 1s, aren’t listed in Python Mode’s reference: :expressionless:
Py.Processing.org/reference/