We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I wan't to get the ppi (pixels per inch) of the screen but where is that variable stored?
And if there's no such variable is there one for the inch-size of screen?
I made a ctrl+F for ppi and inch in PApplet reference and found nothing so if it's there it's hiding from me...
processing.github.io/processing-javadocs/core/processing/core/PApplet.html
I did find displayHeight and displayWidth though which is usefull if I want to know those without having to do fullscreen.
float ppi,inch,ratio,inch_width,inch_height;
void setup() {
inch=23.0; // <- how to set this number automatically?
println(" Screen Size = " + inch +"\"");
ratio=1.0*displayWidth/displayHeight; // 1.0* to force float result
inch_height=(inch*displayHeight)/sqrt(sq(displayWidth)+sq(displayHeight));
inch_width=ratio*inch_height;
ppi=displayWidth/inch_width; // <- how to set this number automatically?
println(" width = " + str(inch_width) +"\"");
println(" height = " + str(inch_height)+"\"");
println(" ppi = " + ppi + " pixels per 1\"");
}
void draw(){}
Answers
I found an example on for eclipse
java2s.com/Code/JavaAPI/org.eclipse.swt.graphics/DevicegetDPI.htm
But in processing though it seems just able to distinguish between regular display or retina display, and no gray-area in between?
I found a forum post regarding android though...
https://forum.processing.org/one/topic/screen-size-in-inch-cm
Maybe this is very hard to solve for different platforms, but there has to be an "api" that handles that behind the scenes for whatever screen is used.
For example if you go on a website they don't ask you what kind of device or browser you're using.
Likewise an app or program shouldn't ask the user for the details of their screen, it should just ask the screen.
Sorry if I'm nitpicking or ranting but I think you can never underestimate the value of convenience.