Is there an equivalent of p5’s on-demand global mode …
new p5(); // in global space
… but for regular (Java) Processing? I want to be able to use all Processing functions / methods outside of setup() and draw(). Searched, didn’t find anything relevant.
If you use processing ide then processing functions and constants are always available. In processing ide all code is within processing scope.
If you are using external IDE then you need to pass instance of processing as a parameter in a method and you can call processing methods with that parameter
Well then, maybe my syntax is wrong. Say I want to be able to, for example, create a global PFont var and assign it at the same time, without having to assign it in setup(). In Processing, this sample code doesn’t work:
Are you saying I can assign the var in global space by placing it after either settings() or setup()? Just tried different combinations of both, it still threw up an error. E.g.:
OK, I looked up info on sketchPath(), and I invoked the function directly in my sketch. It returns the sketch’s correct path only when the invocation is within either settings() or setup(), but not in global space. So, that’s why the PFont assignment can’t be done in global? Is there some voodoo workaround that can be done to make the correct sketch path accessible in global, or no?
Also, does something like createShape rely on the sketch path too? The following example doesn’t work in Java Processing either, but … why not? Is createShape writing to / reading from the sketch path?