Merge pull request #1226 from Stefterv/pixel-density-warning

Add warning for default pixelDensity behavior
This commit is contained in:
Raphaël de Courville
2025-09-12 14:43:31 +02:00
committed by GitHub
+9
View File
@@ -802,6 +802,7 @@ public class PApplet implements PConstants {
// Unlike the others above, needs to be public to support
// the pixelWidth and pixelHeight fields.
public int pixelDensity = 1;
boolean pixelDensityWarning = false;
boolean present;
@@ -1082,6 +1083,9 @@ public class PApplet implements PConstants {
*/
public void pixelDensity(int density) {
//println(density + " " + this.pixelDensity);
this.pixelDensityWarning = false;
if (density != this.pixelDensity) {
if (insideSettings("pixelDensity", density)) {
if (density != 1 && density != 2) {
@@ -2050,6 +2054,10 @@ public class PApplet implements PConstants {
if (frameCount == 0) {
setup();
if(pixelDensityWarning){
System.err.println("Warning: Processing now sets pixelDensity(2) by default on high-density screens. This may change how your sketch looks. To revert to the old behavior, set pixelDensity(1) in setup().");
}
} else { // frameCount > 0, meaning an actual draw()
// update the current frameRate
@@ -10106,6 +10114,7 @@ public class PApplet implements PConstants {
sketch.fullScreen = fullScreen;
sketch.pixelDensity = sketch.displayDensity();
sketch.pixelDensityWarning = sketch.pixelDensity > 1;
// For 3.0.1, moved this above handleSettings() so that loadImage() can be
// used inside settings(). Sets a terrible precedent, but the alternative