Background color not changing

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

void setup()
{
  background(51); 
}

void draw()
{
  clear(); 
}

Is, according to the reference, supposed to produce this:
background_0
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.

Hi @appas :slightly_smiling_face:

According to the reference:

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

:nerd_face:

1 Like

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.

2 Likes

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()