display_density()#

This function returns the number “2” if the screen is a high-density screen (called a Retina display on OSX or high-dpi on Windows and Linux) and a “1” if not.

Examples#

1def setup():
2    py5.pixel_density(py5.display_density())
3    py5.no_stroke()
4
5
6def draw():
7    py5.background(0)
8    py5.ellipse(30, 48, 36, 36)
9    py5.ellipse(70, 48, 36, 36)

Description#

This function returns the number “2” if the screen is a high-density screen (called a Retina display on OSX or high-dpi on Windows and Linux) and a “1” if not. This information is useful for a program to adapt to run at double the pixel density on a screen that supports it.

Underlying Processing method: displayDensity

Syntax#

display_density() -> int
display_density(display: int, /) -> int

Parameters#

  • display: int - the display number to check (1-indexed to match the Preferences dialog box)

Updated on November 12, 2021 11:30:58am UTC