Name

displayDensity()

Description

This function returns the number "2" if the screen is a high-density screen (called a Retina display on OS X 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.

Examples

  • void setup() {
      size(100, 100);
      pixelDensity(displayDensity());
      noStroke();
    }
    
    void draw() {
      background(0);
      ellipse(30, 48, 36, 36);
      ellipse(70, 48, 36, 36);
    }
    

Syntax

  • displayDensity()
  • displayDensity(display)

Parameters

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

Return

  • int