Reference for Processing version 1.2. If you have a previous version, use the reference included with your software. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Javadoc.



example pic
example pic
background(255, 204, 0);
example pic
PImage b;
b = loadImage("laDefense.jpg");
Description The background() function sets the color used for the background of the Processing window. The default background is light gray. In the draw() function, the background color is used to clear the display window at the beginning of each frame.

An image can also be used as the background for a sketch, however its width and height must be the same size as the sketch window. To resize an image 'b' to the size of the sketch window, use b.resize(width, height).

Images used as background will ignore the current tint() setting.

It is not possible to use transparency (alpha) in background colors with the main drawing surface, however they will work properly with createGraphics.
background(gray, alpha)
background(value1, value2, value3)
background(value1, value2, value3, alpha)
background(color, alpha)
background(hex, alpha)
gray int or float: specifies a value between white and black
alpha int or float: opacity of the background
value1 int or float: red or hue value (depending on the current color mode)
value2 int or float: green or saturation value (depending on the current color mode)
value3 int or float: blue or brightness value (depending on the current color mode)
color color: any value of the color datatype
hex int: color value in hexadecimal notation (i.e. #FFCC00 or 0xFFFFCC00)
Returns None
Usage Web & Application
Related stroke()
Updated on June 14, 2010 12:05:29pm EDT

Creative Commons License