Processing for Android


The logical density of the display from getDisplayMetrics().density. According to Android's documentation: This is a scaling factor for the Density Independent Pixel unit, where one DIP is one pixel on an approximately 160 dpi screen (for example a 240x320, 1.5"x2" screen), providing the baseline of the system's display. Thus on a 160dpi screen this density value will be 1; on a 120 dpi screen it would be .75; etc.

It can be used to scale the graphical element in a sketch, like text and shapes, to present approximately the same size independently of the screen's dpi:

void setup() {
  PFont font = createFont("SansSerif", 24 * displayDensity);