pixels holds a color value for every pixel currently drawn in the system display window. It can be read and modified to change the display. To use this array to modify the display:
loadPixels()to populate the array (otherwise it will be null).
updatePixels()to commit the changes. This will redraw the screen.
By default, the color values stored in
pixels are made up of Red, Green and Blue (RGB) values. This is called RGB mode. Each of the Red, Green, and Blue values are 8-bit numbers from 0 to 255:
color c = color(125,125,125);
You can read these values back with the red(), green() and blue() functions. To modify a pixel, you would use something like:
pixels[x] = color(125, green(pixels[x]), blue(pixels[x]));
Note: a common error is to treat a color value as an object. Color values are just 32-bit integers (8 bits for each RGB value plus alpha channel information stored in the extra 8 bits - we'll talk about alpha channels later on), so any code which treats a color as an object will cause a syntax error. Treat color values as the type color in Processing code, and as type
int in Java code.