Skip to content

Conversation

Stefterv
Copy link
Collaborator

Fixes #950

Changes the default sketch density to reflect the current display in use.

@Stefterv Stefterv added this to the 4.4.3 milestone Apr 15, 2025
@SableRaf SableRaf moved this to In progress in Processing Roadmap Apr 19, 2025
@SableRaf SableRaf merged commit 732b20c into processing:main Apr 25, 2025
11 of 12 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in Processing Roadmap Apr 25, 2025
@Stefterv Stefterv deleted the default-display-density branch May 15, 2025 11:55
golanlevin added a commit to CreativeInquiry/PEmbroider that referenced this pull request Jun 12, 2025
In processing/processing4#1038, Processing modified the default display density, which changes how sketches allocate pixels and breaks many PEmbroider examples. The temporary fix is to use `pixelDensity(1)`.
golanlevin added a commit to CreativeInquiry/PEmbroider that referenced this pull request Jun 12, 2025
@@ -10105,6 +10105,8 @@ static public void runSketch(final String[] args,
sketch.present = present;
sketch.fullScreen = fullScreen;

sketch.pixelDensity = sketch.displayDensity();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I stumbled across this just now while helping a new CS teacher come up to speed on one of my former class projects. The project uses a nested loop and the width and height system variables to change the color of each pixel in the pixels array (as described in chapter 15 of Shiffman's "Learning Processing"). As of this change, that same loop only modifies the pixels in a small portion of the display window on my high DPI laptop. It's a nasty little bug if you haven't faithfully kept up with the Processing release notes. Perhaps you could display a warning message to ease folks into it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @agreyson Thanks for your comment! We made this change because sketches looked blurry on high-DPI displays, but as you found out, it can break older code that works with pixels directly. This happens because different pixelDensity values introduce inconsistencies in per-pixel operations. @catilac and @tychedelia are exploring solutions here: #1145, and suggestions are welcome on the issue thread: #1131. Since the fix is more complex than expected, adding a warning message could be a helpful interim step to prevent the headaches you ran into. Thanks for your suggestion.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @SableRaf. I appreciate the speedy response! Given that this breaks a substantial chunk of @shiffman instructional materials, my recommendation would be to revert #1038 for now, and leave it to knowledgable developers to call pixelDensity explicitly until you've found a solution (easier said than done, judging by the commentary). Thank you for your work on Processing, and best of luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

Set default pixel density to the display's density
3 participants