Color

Updated: 03/05/2023 by Computer Hope
Examples of colors

Color may refer to any of the following:

1. In general, color or colour (non-American) is the interaction between the eye and a spectrum of light that creates the perception of shades and hues, such as red, blue, yellow, and green. The picture shows a custom color picker in Adobe Photoshop.

How do computers handle colors?

With today's computers, colors are often 24-bit or 32-bit, usually stored in a 32-bit integer (e.g., BGR or ABGR would be: 00000000 00000000 00000000 00000000).

Note

24-bit colors are often stored as a 32-bit integer because it's faster to process a standard 32-bit integer than a nonstandard 24-bit integer. When working with 24-bit colors, the first 8-bit can be left empty or used as an alpha (transparency) value.

For example, red in the 32-bit BGR is 00000000 00000000 00000000 11111111. Having all bits turned on gives red its maximum value of 255, and because there are no blue or green bits turned on, the red color is not changed to another color. Because working with a 32-bit binary number is tedious, the binary number is converted to hexadecimal, which makes it easier to read and write. That number converted to hexadecimal is 0x000000FF.

In this example, the "0x" lets the reader know the number shown is a hexadecimal number. Each hexadecimal "F" is "1111" in binary. To make the full 8 bits, two F's are used.

To make colors other than blue, green, or red, the quantity (value) of each color is increased. For example, mixing all red and green makes yellow, and mixing all red and half green makes orange.

A more complex color (e.g., the blue on the Computer Hope website), has a blue value of 226, a green value of 120, and a red value of 3. In a binary 32-bit integer, that'd be 00000000 11100010 01111000 00000011, or converted to hexadecimal as 0x00E27803.

Remember that the example above is how a Windows API (application programming interface) might handle colors. When dealing with HTML and colors on the Internet, you work with an RGB value, not a BGR value. In other words, you switch the red and green values to get the correct color. So, the HTML color code for the blue mentioned above would be #0378e2 (the "#" (hash) represents an HTML color code).

2. When dealing with a command or command line, color is a command that changes the default color of the Windows command line background or text. See the color command page for further information about the MS-DOS and Windows command line command.

Color-coded, Color terms, Grayscale, Hue, Neon, Palette, Pastel, Primary color, Web safe colors