Reference for Processing version 1.2. If you have a previous version, use the reference included with your software. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Javadoc.

Name

color()

Examples
example pic
color c1 = color(102, 102, 0);
fill(c1);
noStroke();
rect(30, 20, 55, 55);
Description Creates colors for storing 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. More about how colors are stored can be found in the reference for the color datatype.
Syntax
color(gray)
color(gray, alpha)
color(value1, value2, value3)
color(value1, value2, value3, alpha)
color(hex)
color(hex, alpha)
Parameters
gray int or float: number specifying value between white and black
alpha int or float: relative to current color range
value1 int or float: red or hue values relative to the current color range
value2 int or float: green or saturation values relative to the current color range
value3 int or float: blue or brightness values relative to the current color range
hex int: color value in hexadecimal notation (i.e. #FFCC00 or 0xFFFFCC00)
Returns color
Usage Web & Application
Related color_datatype
colorMode()
Updated on June 14, 2010 12:05:29pm EDT

Creative Commons License