Built in constant: displayWidth and displayHeight

Is somehow possible to get the display width and height?

I was reading an old forum topic (from 5 years ago) and it said that displayWidth/Height is deprecated.

Is there any method I can use to extract those constants with code?

Thank you

1 Like

Just use width and height. Not joking.

Var a = width gives you canvas width.

This was covered a while back in Setting size of display window to a percentage of screen size. If it’s deprecated then there’s a reason for it. During runtime width and height are you friends, you don’t have any use for displayWidth

2 Likes

Differences:

import java.awt.*;

void setup() {
  size(500, 500);
  background(255);
  Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  int screenHeight = screenSize.height;
  int screenWidth = screenSize.width;
  println(screenWidth);
  println(screenHeight);
  println(width);
  println(height);
}
3 Likes