Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A command line PApplet argument that controls the size of the sketch window #4943

Closed
mistodev opened this issue Mar 5, 2017 · 4 comments
Closed

Comments

@mistodev
Copy link

mistodev commented Mar 5, 2017

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.

@JakubValtar
Copy link
Contributor

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:

void settings() {
  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 width
  if (h == 0) h = 200; // some default height
  size(w, h);
}

void setup() {
  println("started with width", width, "and height", height);
}

void draw() {
  background(0);
}

I don't know if @benfry thinks it would be a good idea to make it built-in.

@mistodev
Copy link
Author

mistodev commented Mar 7, 2017

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.

@benfry
Copy link
Contributor

benfry commented May 4, 2017

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.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants