Skip to content

Commit 906ab17

Browse files
committed
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.
1 parent 198f593 commit 906ab17

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

core/src/processing/core/PApplet.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,7 @@ public PSurface getSurface() {
802802
// Unlike the others above, needs to be public to support
803803
// the pixelWidth and pixelHeight fields.
804804
public int pixelDensity = 1;
805+
boolean pixelDensityWarning = false;
805806

806807
boolean present;
807808

@@ -1082,6 +1083,9 @@ public int displayDensity(int display) {
10821083
*/
10831084
public void pixelDensity(int density) {
10841085
//println(density + " " + this.pixelDensity);
1086+
1087+
1088+
this.pixelDensityWarning = false;
10851089
if (density != this.pixelDensity) {
10861090
if (insideSettings("pixelDensity", density)) {
10871091
if (density != 1 && density != 2) {
@@ -2050,6 +2054,10 @@ public void handleDraw() {
20502054
if (frameCount == 0) {
20512055
setup();
20522056

2057+
if(pixelDensityWarning){
2058+
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().");
2059+
}
2060+
20532061
} else { // frameCount > 0, meaning an actual draw()
20542062
// update the current frameRate
20552063

@@ -10106,6 +10114,7 @@ static public void runSketch(final String[] args,
1010610114
sketch.fullScreen = fullScreen;
1010710115

1010810116
sketch.pixelDensity = sketch.displayDensity();
10117+
sketch.pixelDensityWarning = sketch.pixelDensity > 1;
1010910118

1011010119
// For 3.0.1, moved this above handleSettings() so that loadImage() can be
1011110120
// used inside settings(). Sets a terrible precedent, but the alternative

0 commit comments

Comments
 (0)