From 906ab17264d41e279428078c6f27772424e10d76 Mon Sep 17 00:00:00 2001 From: Stef Tervelde Date: Thu, 4 Sep 2025 10:34:45 +0200 Subject: [PATCH 1/2] Add warning for default pixelDensity behavior Introduces a warning message when pixelDensity defaults to 2x to match the display's pixel density. The warning prompts users to explicitly set pixelDensity in settings() to avoid the message. --- core/src/processing/core/PApplet.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index d1297ec6fb..c977996b27 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -802,6 +802,7 @@ public PSurface getSurface() { // 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 int displayDensity(int display) { */ 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 void handleDraw() { if (frameCount == 0) { setup(); + if(pixelDensityWarning){ + System.err.println("Warning: pixelDensity() now defaults to 2x to align with your display's pixel density. To avoid this warning, please explicitly set pixelDensity() in settings()."); + } + } else { // frameCount > 0, meaning an actual draw() // update the current frameRate @@ -10106,6 +10114,7 @@ static public void runSketch(final String[] args, 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 From 38143079c1e57cd88beed50d373cd19603bc58cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20de=20Courville?= Date: Fri, 12 Sep 2025 14:42:36 +0200 Subject: [PATCH 2/2] Update the warning message for pixelDensity Made the warning message more helpful --- core/src/processing/core/PApplet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index c977996b27..4fccd1a535 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -2055,7 +2055,7 @@ public void handleDraw() { setup(); if(pixelDensityWarning){ - System.err.println("Warning: pixelDensity() now defaults to 2x to align with your display's pixel density. To avoid this warning, please explicitly set pixelDensity() in settings()."); + 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()