# What is the difference between pixelDensity() and displayDensity()?

**URL:** https://discourse.processing.org/t/what-is-the-difference-between-pixeldensity-and-displaydensity/12381
**Category:** Beginners
**Created:** [June 29, 2019, 1:59pm UTC](https://discourse.processing.org/t/what-is-the-difference-between-pixeldensity-and-displaydensity/12381 "2019-06-29T13:59:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![matias.silva](https://avatars.discourse-cdn.com/v4/letter/m/8dc957/32.png) [@matias.silva](https://discourse.processing.org/u/matias.silva)
#### Post date: [June 29, 2019, 1:59pm UTC](https://discourse.processing.org/t/what-is-the-difference-between-pixeldensity-and-displaydensity/12381/1 "2019-06-29T13:59:23Z")

</div>

Hey!

I’ve started to use p5.Graphics in my sketches and ran into a problem with pixel densities. I’m familiar with p5 and Processing but can’t quite grasp the meaning of these two functions and how they differ. Also, what’s the best way to solve a problem involving different pixel densities and p5.Graphics objects?

Thanks!

---

<div class="post-metadata">

### Author: ![jb4x](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jb4x/32/789_2.png) [@jb4x](https://discourse.processing.org/u/jb4x)
#### Post date: [June 29, 2019, 2:11pm UTC](https://discourse.processing.org/t/what-is-the-difference-between-pixeldensity-and-displaydensity/12381/2 "2019-06-29T14:11:05Z")

</div>

Hi,

One is used to set the pixel density and the other one to get it:  
[https://p5js.org/reference/#/p5/pixelDensity](https://p5js.org/reference/#/p5/pixelDensity)  
[https://p5js.org/reference/#/p5/displayDensity](https://p5js.org/reference/#/p5/displayDensity)

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [June 29, 2019, 2:31pm UTC](https://discourse.processing.org/t/what-is-the-difference-between-pixeldensity-and-displaydensity/12381/3 "2019-06-29T14:31:36Z")

</div>

> [@jb4x](#):
>
> One is used to set the pixel density and the other one to get it:

- **pixelDensity()** is both a setter & a getter for the sketch’s current pixel scaling!
- **displayDensity()** is a getter only. It grabs the monitor’s pixel scaling AFAIK.
