typedef unsigned long rgb;
rgb rgb(int red, int green, int blue); /* create rgb value */ byte getalpha(rgb col); /* return alpha byte */ byte getred(rgb col); /* return red byte */ byte getgreen(rgb col); /* return green byte */ byte getblue(rgb col); /* return blue byte */
#define Transparent 0xFFFFFFFFL #define Black 0x00000000L #define White 0x00FFFFFFL #define Blue 0x000000FFL #define Yellow 0x00FFFF00L #define Green 0x0000FF00L #define Magenta 0x00FF00FFL #define Red 0x00FF0000L #define Cyan 0x0000FFFFL #define Grey 0x00808080L #define Gray 0x00808080L #define LightGrey 0x00C0C0C0L #define LightGray 0x00C0C0C0L #define DarkGrey 0x00404040L #define DarkGray 0x00404040L #define DarkBlue 0x00000080L #define DarkGreen 0x00008000L #define DarkRed 0x00800000L #define LightBlue 0x0080C0FFL #define LightGreen 0x0080FF80L #define LightRed 0x00FFC0FFL #define Pink 0x00FFAFAFL #define Brown 0x00603000L #define Orange 0x00FF8000L #define Purple 0x00C000FFL #define Lime 0x0080FF00L
An rgb value is an unsigned long integer used to represent a colour.
The rgb function constructs an rgb value, given the required intensity of red, green and blue light. The values of red, green and blue can range from zero (no intensity) to 255 (maximum intensity). The rgb function is implemented as a macro.
Pre-defined colours are available, such as Black, White, Grey, Blue, Red, Green, etc. These are simply pre-defined long integers representing logical colours. The bit-patterns they become when inside a bitmap are not generally defined. (Note that both American and British English spellings are supported, both for colour-names and functions which employ the word 'colour' or 'color'. Thus Grey and Gray are quite legal, and interchangeable.)
The top-most byte of an rgb value is used to represent an 'alpha' value, which records transparency information. If this byte is equal to 255, that rgb value is fully transparent. If the alpha value is zero, the rgb is fully opaque. In theory, an alpha value between zero and 255 can be used to perform 'colour blending', however currently only fully transparent and fully opaque rgb values are supported. The special constant Transparent can be used to represent fully transparent rgb values in images, and so forth.
The getalpha function returns the alpha byte from an rgb value. The various red, green and blue components of an rgb value can be found by using getred, getgreen, and getblue respectively.