Creates a p5.Color object.
By default, the parameters are interpreted as RGB values. Calling color(255, 204, 0)
will return a bright yellow color. The way these parameters are interpreted may be changed with the colorMode() function.
The version of color()
with one parameter interprets the value one of two 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.
The version of color()
with two parameters interprets the first one as a grayscale value. The second parameter sets the alpha (transparency) value.
The version of color()
with three parameters interprets them as RGB, HSB, or HSL colors, depending on the current colorMode()
.
The version of color()
with four parameters interprets them as RGBA, HSBA, or HSLA colors, depending on the current colorMode()
. The last parameter sets the alpha (transparency) value.
Examples
Syntax
color(gray, [alpha])
color(v1, v2, v3, [alpha])
color(value)
color(values)
color(color)