# Setting canvas and background color in setup() not working

**URL:** <https://discourse.processing.org/t/setting-canvas-and-background-color-in-setup-not-working/8162>\
**Category:** Beginners\
**Created:** [February 6, 2019, 4:47pm UTC](https://discourse.processing.org/t/setting-canvas-and-background-color-in-setup-not-working/8162 "2019-02-06T16:47:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Milky](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/milky/32/4334_2.png) [@Milky](https://discourse.processing.org/u/Milky)\
**Post date:** [February 6, 2019, 4:47pm UTC](https://discourse.processing.org/t/setting-canvas-and-background-color-in-setup-not-working/8162/1 "2019-02-06T16:47:18Z")

</div>

function setup() {  
createCanvas(windowWidth, windowHeight);  
background(0, 0, 0);  
}

this is pretty much how my setup() function starts. Everything in draw() works fine, but my canvas is never set and my background color is also never set. I don’t understand why this could happen. Any ideas?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [February 7, 2019, 12:14pm UTC](https://discourse.processing.org/t/setting-canvas-and-background-color-in-setup-not-working/8162/2 "2019-02-07T12:14:27Z")

</div>

in p5.js i not see a problem.

[https://editor.p5js.org/kll/sketches/hXy\_Ij1gB](https://editor.p5js.org/kll/sketches/hXy_Ij1gB)  
for resize…  
[https://editor.p5js.org/kll/sketches/SkZFY5Qg4](https://editor.p5js.org/kll/sketches/SkZFY5Qg4)

also try Processing 3.5.3 p5.js mode OK

* * *

so you need to tell us more about your environment…

when you say draw works??  
and it starts with a background or image  
you might never see the background set from setup()

---

<div class="post-metadata">

**Author:** ![Milky](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/milky/32/4334_2.png) [@Milky](https://discourse.processing.org/u/Milky)\
**Post date:** [February 7, 2019, 4:48pm UTC](https://discourse.processing.org/t/setting-canvas-and-background-color-in-setup-not-working/8162/3 "2019-02-07T16:48:22Z")

</div>

Sorry, I had a lot of code already, I think I figured it out now, I had a line pixelDensity(1) or something that caused this, I don’t remember why I had it. Thank you for the reply
