This function makes it possible to render using all the pixels on high resolutions screens like Apple Retina and Windows HiDPI. This function can only be run once within a program, and must be called right after size() in a program without a setup() function, or within setup() i
(int density)
| 1081 | * @see PApplet#pixelHeight |
| 1082 | */ |
| 1083 | public void pixelDensity(int density) { |
| 1084 | //println(density + " " + this.pixelDensity); |
| 1085 | if (density != this.pixelDensity) { |
| 1086 | if (insideSettings("pixelDensity", density)) { |
| 1087 | if (density != 1 && density != 2) { |
| 1088 | throw new RuntimeException("pixelDensity() can only be 1 or 2"); |
| 1089 | } |
| 1090 | if (!FX2D.equals(renderer) && density == 2 && displayDensity() == 1) { |
| 1091 | // FX has its own check in PSurfaceFX |
| 1092 | // Don't throw exception because the sketch should still work |
| 1093 | System.err.println("pixelDensity(2) is not available for this display"); |
| 1094 | this.pixelDensity = 1; |
| 1095 | } else { |
| 1096 | this.pixelDensity = density; |
| 1097 | } |
| 1098 | } else { |
| 1099 | System.err.println("not inside settings"); |
| 1100 | // this should only be reachable when not running in the PDE, |
| 1101 | // so saying it's a settings()--not just setup()--issue should be ok |
| 1102 | throw new RuntimeException("pixelDensity() can only be used inside settings()"); |
| 1103 | } |
| 1104 | } |
| 1105 | } |
| 1106 | |
| 1107 | |
| 1108 | /** |
nothing calls this directly
no test coverage detected