background()

Sets the background color of the canvas

Example

background('hotpink')

Syntax

background('NAME')

or

background(a,b,c)

or

background(VALUE)

or

background(IMAGE)
InputDescription

NAME

the name of any HTML color, for example: blue, green, lightgrey, skyblue, etc...

a,b,c

RGB or HSB values - see Description below

VALUE

a number from 0 - 255, greyscale with 0 being black and 255 being white

IMAGE

variable name of a loaded image (see loadImage()) to be used as an entire background across the canvas

Description

Changes the color of the background of the entire canvas. Input can either be the name of an HTML color, a value 0 - 255 for greyscale values with 0 being black and 255 being white. Input can also be three numbers for the RGB or HSB color scale - see colorMode(). Finally, input can be the name of a loaded image, which will be stretched to cover the entire canvs.

Find these documents helpful? Let the people who made them help your child learn to code at Strivemath!

We'd love to hear your Feedback/Comments here.

Last updated