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

Add an example for the windowRatio() method #14

Open
SableRaf opened this issue Sep 24, 2022 · 1 comment
Open

Add an example for the windowRatio() method #14

SableRaf opened this issue Sep 24, 2022 · 1 comment

Comments

@SableRaf
Copy link
Collaborator

SableRaf commented Sep 24, 2022

The windowRatio() method and its associated variables rwidth, rheight, rmouseX, rmouseY are demonstrated in the release notes for Processing 4.0 beta 7 with the code below but we don't yet have an example built-in.

void setup() {
  windowResizable(true);
  windowRatio(1280, 720);

  cursor(CROSS);
  strokeWeight(10);
}

void draw() {
  background(240);
  fill(255);
  rect(0, 0, rwidth, rheight);

  fill(0);
  textAlign(CENTER, CENTER);
  textSize(200);
  text(rmouseX + ", " + rmouseY, rwidth/2, rheight/2);
}
@benfry
Copy link
Contributor

benfry commented Sep 25, 2022

Yeah, and that one is more of a “testing” thing that I was using to demonstrate what was going on.

Also need to note in the (eventual) documentation that it works for most things or at least lots of things, but there are definitely exceptions.

For instance, the sketch that Dan was using on Coding Train this week was like a perfect example of the worst kind of code to adapt this way. :) Not only is it 3D, which can be funky to get right, it also sets up its own camera/project using ortho(), which would need special care as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants