MCPcopy Create free account
hub / github.com/benfry/processing4 / displayDensity

Method displayDensity

core/src/processing/core/PApplet.java:1005–1025  ·  view source on GitHub ↗

This function returns the number "2" if the screen is a high-density screen (called a Retina display on OS X or high-dpi on Windows and Linux) and a "1" if not. This information is useful for a program to adapt to run at double the pixel density on a screen that supports it. @webref environment @we

()

Source from the content-addressed store, hash-verified

1003 * @see PApplet#size(int,int)
1004 */
1005 public int displayDensity() {
1006 if (display != SPAN && (fullScreen || present)) {
1007 return displayDensity(display);
1008 }
1009
1010 int displayCount = 0;
1011 if (!disableAWT) {
1012 displayCount = ShimAWT.getDisplayCount();
1013 } else {
1014 // https://github.com/processing/processing4/issues/57
1015 System.err.println("display count needs to be implemented for non-AWT");
1016 }
1017 // walk through all displays, use 2 if any display is 2
1018 for (int i = 0; i < displayCount; i++) {
1019 if (displayDensity(i+1) == 2) {
1020 return 2;
1021 }
1022 }
1023 // If nobody's density is 2 then everyone is 1
1024 return 1;
1025 }
1026
1027
1028 /**

Callers 1

pixelDensityMethod · 0.95

Calls 3

getDisplayCountMethod · 0.95
getDisplayDensityMethod · 0.95
printlnMethod · 0.45

Tested by

no test coverage detected