Reference for Processing (BETA) version 0135+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.

Name

color

Examples
example pic
color c1 = color(204, 153, 0);
color c2 = #FFCC00;
noStroke();
fill(c1);
rect(0, 0, 25, 100);
fill(c2);
rect(25, 0, 25, 100);
color c3 = get(10, 50);
fill(c3);
rect(50, 0, 50, 100);
Description Datatype for storing color values. Colors may be assigned with get() and color() or they may be specified directly using hexadecimal notation such as #FFCC00.

Using print() or println() on a color will produce strange results (usually negative numbers) because of the way colors are stored in memory. A better method is to use the hex() function to format the color data, or use the red(), green(), and blue() functions to get individual values and print those.

From a technical standpoint, colors are 32 bits of information ordered as AAAAAAAARRRRRRRRGGGGGGGGBBBBBBBB where the A's contain the alpha value, the R's are the red/hue value, G's are green/saturation, and B's are blue/brightness.
Syntax
color var
color var = colorvalue
Parameters
var variable name referencing the value
colorvalue any color value
Usage Web & Application
Related colorMode()
color()
hex()
red()
green()
blue()
Updated on February 09, 2008 04:38:52pm PST

Creative Commons License