# Background color not changing

**URL:** <https://discourse.processing.org/t/background-color-not-changing/39953>\
**Category:** Beginners\
**Created:** [December 1, 2022, 12:20am UTC](https://discourse.processing.org/t/background-color-not-changing/39953 "2022-12-01T00:20:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![appas](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/appas/32/18810_2.png) [@appas](https://discourse.processing.org/u/appas)\
**Post date:** [December 1, 2022, 12:20am UTC](https://discourse.processing.org/t/background-color-not-changing/39953/1 "2022-12-01T00:20:47Z")

</div>

Hello,  
I am having the problem that calls to `background` do nothing.  
Eg. this minimal code:

```auto
void setup()
{
  background(51); 
}

void draw()
{
  clear(); 
}

```

Is, according to the reference, supposed to produce this:  
 ![background_0](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/3/7/37999c16bf0f096bcecdb88c8508a2ed491ad1ba.webp)  
but, instead, I get a black window. This is current as of Processing 4.1.1.

I am using Windows 10 x64, with Intel UHD 620 graphics.

---

<div class="post-metadata">

**Author:** ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)\
**Post date:** [December 1, 2022, 12:32am UTC](https://discourse.processing.org/t/background-color-not-changing/39953/2 "2022-12-01T00:32:58Z")

</div>

Hi @appas 🙂

According to the reference:

“This function only works on **PGraphics** objects created with the **createGraphics()** function.”

> **[clear() / Reference](https://processing.org/reference/clear_.html)**
>
> Clears the pixels within a buffer. This function only works on PGraphics objects created with the createGraphics() function. Unlike the main graphics context (the display window), pixels…

🤓

---

<div class="post-metadata">

**Author:** ![appas](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/appas/32/18810_2.png) [@appas](https://discourse.processing.org/u/appas)\
**Post date:** [December 1, 2022, 12:42am UTC](https://discourse.processing.org/t/background-color-not-changing/39953/3 "2022-12-01T00:42:38Z")

</div>

Thanks for the reply. I have to admit that I missed this part of the documentation. I just read in the `background` reference that:

> The **background()** function sets the color used for the background of the Processing window. The default background is light gray. This function is typically used within **draw()** to clear the display window at the beginning of each frame

The word “clear” threw me off. Without the call to `clear`, it works.

---

<div class="post-metadata">

**Author:** ![Mikey83](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mikey83/32/17956_2.png) [@Mikey83](https://discourse.processing.org/u/Mikey83)\
**Post date:** [December 1, 2022, 11:33am UTC](https://discourse.processing.org/t/background-color-not-changing/39953/4 "2022-12-01T11:33:48Z")

</div>

You set the background in setup, if you put it in draw it will work, will essentially fill the screen with the color you want and override all else already drawn, dont worry about the clear()
