@webref environment @param density 1 or 2 @see PApplet#pixelWidth @see PApplet#pixelHeight
(int density)
| 1217 | * @see PApplet#pixelHeight |
| 1218 | */ |
| 1219 | public void pixelDensity(int density) { |
| 1220 | //println(density + " " + this.pixelDensity); |
| 1221 | if (density != this.pixelDensity) { |
| 1222 | if (insideSettings("pixelDensity", density)) { |
| 1223 | if (density != 1 && density != 2) { |
| 1224 | throw new RuntimeException("pixelDensity() can only be 1 or 2"); |
| 1225 | } |
| 1226 | if (!FX2D.equals(renderer) && density == 2 && displayDensity() == 1) { |
| 1227 | // FX has its own check in PSurfaceFX |
| 1228 | // Don't throw exception because the sketch should still work |
| 1229 | System.err.println("pixelDensity(2) is not available for this display"); |
| 1230 | this.pixelDensity = 1; |
| 1231 | } else { |
| 1232 | this.pixelDensity = density; |
| 1233 | } |
| 1234 | } else { |
| 1235 | System.err.println("not inside settings"); |
| 1236 | // this should only be reachable when not running in the PDE, |
| 1237 | // so saying it's a settings()--not just setup()--issue should be ok |
| 1238 | throw new RuntimeException("pixelDensity() can only be used inside settings()"); |
| 1239 | } |
| 1240 | } |
| 1241 | } |
| 1242 | |
| 1243 | |
| 1244 | /** |
nothing calls this directly
no test coverage detected