You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would it be possible to introduce a CLI PApplet argument that influences the size of the sketch window at runtime, without needing to invoke the PApplet#size() method from the sketch class? It would work similar to how one can go fullscreen by specifying the --presentation argument or set the sketch window location with --location.
The text was updated successfully, but these errors were encountered:
You should be able to do that by passing custom arguments on the command line and then reading them from args array in settings()like this:
voidsettings() {
int w =0;
int h =0;
if (args !=null&& args.length >=2) {
w = parseInt(args[0]);
h = parseInt(args[1]);
}
if (w ==0) w =200; // some default widthif (h ==0) h =200; // some default heightsize(w, h);
}
voidsetup() {
println("started with width", width, "and height", height);
}
voiddraw() {
background(0);
}
I don't know if @benfry thinks it would be a good idea to make it built-in.
Thanks Jakub for your response. I should clarify why I ask. When writing a sketch, one typically specifies a size for a sketch. Working outside of the PDE, this means that the settings method must always be overridden. With it as an argument, it would be possible to conveniently control the size of sketches from run configurations in IDEs. Otherwise, you are forced to hardcode or introduce handling logic yourself, as you demonstrated.
This seems like something best handled in code (@JakubValtar's example is right on)… This hasn't been a frequent enough request that it should be a default feature. We really support two cases: sketches that are specified for a particular size, or those that run full screen.
Would it be possible to introduce a CLI
PApplet
argument that influences the size of the sketch window at runtime, without needing to invoke thePApplet#size()
method from the sketch class? It would work similar to how one can go fullscreen by specifying the--presentation
argument or set the sketch window location with--location
.The text was updated successfully, but these errors were encountered: