Reference fill()

fill()

Sets the color used to fill shapes.

Calling fill(255, 165, 0) or fill('orange') means all shapes drawn after the fill command will be filled with the color orange.

The version of fill() with one parameter interprets the value one of three ways. If the parameter is a Number, it's interpreted as a grayscale value. If the parameter is a String, it's interpreted as a CSS color string. A p5.Color object can also be provided to set the fill color.

The version of fill() with three parameters interprets them as RGB, HSB, or HSL colors, depending on the current colorMode(). The default color space is RGB, with each value in the range from 0 to 255.

Examples

Syntax

fill(v1, v2, v3, [alpha])
fill(value)
fill(gray, [alpha])
fill(values)
fill(color)

Parameters

v1
Number:

red value if color mode is RGB or hue value if color mode is HSB.

v2
Number:

green value if color mode is RGB or saturation value if color mode is HSB.

v3
Number:

blue value if color mode is RGB or brightness value if color mode is HSB.

alpha
Number:
value
String:

a color string.

gray
Number:

a grayscale value.

values
Number[]:

an array containing the red, green, blue & and alpha components of the color.

color
p5.Color:

the fill color.

Notice any errors or typos? Please let us know. Please feel free to edit src/color/setting.js and open a pull request!

Related References