a port of the Processing Visualization Language
Name

background()

Examples
example pic
background(51);
example pic
background(255, 204, 0);
example pic

// @pjs preload must be used to preload the image

/* @pjs preload="laDefense.jpg"; */

PImage b;

b = loadImage("laDefense.jpg");

background(b);
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.

Unlike Processing, it is possible to use transparency (alpha) in background colors with the main drawing surface.
Syntax
background(gray)

background(gray, alpha)

background(value1, value2, value3)

background(value1, value2, value3, alpha)

background(color)

background(color, alpha)

background(hex)

background(hex, alpha)
Parameters
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)
Usage Web & Application
Related stroke()
fill()
tint()
colorMode()

This reference is licensed under the CC BY-NC-SA 2.0 license:

Creative Commons License
Fork me on GitHub