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
red value if color mode is RGB or hue value if color mode is HSB.
green value if color mode is RGB or saturation value if color mode is HSB.
blue value if color mode is RGB or brightness value if color mode is HSB.
a color string.
a grayscale value.
an array containing the red, green, blue & and alpha components of the color.
the fill color.