Computers represent colours by mixing different amounts of red, green and blue.
Computers represent colours using three number - the red, green, and blue (RGB) values. Usually each value is a number between 0 and 255 (0 indicates none of the colour is present, 255 indicates that the colour is turned up to the maximum). Here are some examples of (R, G, B) values:
The reason the colour values have the range 0 to 255 is because that is the range of values which will fit into a byte. An RGB colour can be stored in 3 bytes of memory.
Sometimes it is useful to write colours as hexadecimal values rather than 3 denary values. We use this notation:
#ff3300
The first 2 digits give the red value (0xFF, or 255). The next 2 digits give the green value (0x33, or 51). The final 2 digits give the blue value (0x00, or 0). Of course, this is exactly the same colour as (255, 51, 0), just written in a different way. Hex notation is used in Cascading Style Sheets (CSS) to specify colours on web pages.
This chart shows a selection of the available colours, with their hex values:
In total, there are 256x256x256 possible RGB values, which is about 16 million colours! But the human eye can't see quite that many colours, so colours which have very similar RGB values will look identical.
CSS named colours contain 140 colour names which can be used in web pages (HTML or CSS). They are also used by the SVG format (for vector images). Some software graphics libraries also allow you to use named colours.
Named colours include all the standard colours (red, green, blue, yellow, white...) plus lots of other colours with whimsical names like powder blue or mint cream. Each colour has an RGB equivalent.
Copyright (c) Axlesoft Ltd 2021