color()ColorCreating & ReadingWeb & Applicationcolor_.gif
color c1 = color(102, 102, 0);
fill(c1);
noStroke();
rect(30, 20, 55, 55);
Creates colors which may be stored in variables of the color datatype. The parameters are interpreted as RGB or HSB values depending on the current colorMode(). The default mode is RGB values from 0 to 255 and therefore, the function call color(255, 204, 0) will return a bright yellow color. The color() function packs the information input through its parameters into a 32 bit number in the following order AAAAAAAARRRRRRRRGGGGGGGGBBBBBBBB where R is the red/hue value, G is green/saturation, and B is blue/brightness.
color(gray)
color(gray, alpha)
color(value1, value2, value3)
color(value1, value2, value3, alpha)
int or float: number specifying value between white and blackint or float: relative to current color rangeint or float: red or hue values relative to the current color rangeint or float: green or saturation values relative to the current color rangeint or float: blue or brightness values relative to the current color rangecolor
color
colorMode()
1.0FunctionCore