How to obtain pixel dimensions of screen in Processing 3

edited September 2015 in How To...

Since displayWidth and displayHeight are deprecated in Processing 3, what is the easy way to obtain the pixel dimensions (raw or retina/doubled) of the screen? (Not the window/sketch size, the display size.)

Answers

  • They were added to the language to run at full screen with size(displayWidth, displayHeight). Now you can use fullScreen() and then get the full display with width and height. They are deprecated, but they still work in 3.0.

  • edited September 2015

    Yes, but there should be a way to obtain the pixel dimensions of the physical screen decoupled from the size of the sketch. This isn't (conveniently) possible if displayWidth and displayHeight are no longer available.

    In other words, one should be able to run a sketch at any size; and regardless of the sketch size, be able to obtain the physical screen dimensions easily. For example, I might want to have a window that is 50% the size of the screen, but draw a shape that is some ratio of the screen dimensions.

    (I am trying to make a case for not deprecating those two variables.) :)

  • edited September 2015

    I don't understand why the issue of deprecating useful features which got no real substitute.
    Fields displayWidth & displayHeight are important environment information.
    There are times we want a resolution which is 3/4 of desktop's dimensions for example:
    size(displayWidth*3>>2, displayHeight*3>>2);

    Threatening removing features is counter productive. Folks want more not less features.
    Moreover, it creates a chasm of insecurity about how much time a feature is gonna keep working or what's the next cutoff "deprecated" victim's gonna be!

    Heck, Processing doesn't even provide a version constant so a code can check out the environment version it's currently running under.
    Also Processing has lost many deployment capabilities since Processing 2 had started!

    And to compound for it all, Processing 3 is spreading private everywhere, making things more difficult or even impossible to tame for our custom needs or patch some bug on-the-fly! X(

Sign In or Register to comment.