DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Changing colors

The RGB and HSV color models

Most color monitors on the market today are based on the RGB color model. Each pixel on the screen is made up of three phosphors, or colors: Red, Green, and Blue. When all three of these colors are illuminated, the pixel appears white. When all three are dark, the pixel appears black. Various combinations of the three phosphors result in a large number of distinct colors and shades. For example, equal portions of red and green, without any blue, result in a shade of yellow.

The intensity of each of the phosphors is controlled by a three-part digital value. As noted in the previous section, the rgb.txt file consists of lines such as:

   127 255 212     aquamarine
On each line, the three numeric fields represent the RGB components that comprise the color. These components are decimal values and must be within the range of 0 to 255, where 255 sets the color to full intensity. In the preceding example, the aquamarine color is created from 127/255ths of maximum red, 255/255ths of maximum green, and 212/255ths of maximum blue.

In most cases, using the color names defined in the color database should be adequate for customizing colors for the Graphical Environment. However, if you want to specify a more precise color or use a color that is not defined in the database, you can use a hexadecimal RGB value instead of a name to set a resource or a command line option.


NOTE: If you are unfamiliar with hexadecimal numbering, see a basic computer textbook for more information.

Hexadecimal RGB values are somewhat different from the RGB definitions in the rgb.txt file. When you specify a hexadecimal value, follow these rules:


Using these rules, you can choose from one of the following hexadecimal formats:
   #RGB
   #RRGGBB
   #RRRGGGBBB
   #RRRRGGGGBBBB
When fewer than four digits are used, they represent the most significant bits of the value. For example, ``#8E4'' is the same as ``#8000E0004000''. In addition, while #RGB and #RRRGGGBBB have the same relative intensities of the three color components, the second value results in a much brighter color than the first.

You can specify hexadecimal RGB values exactly as you would a color name:

client*resource_name: #RRRGGGBBB


NOTE: Because the precision of different adapters and monitors varies, the exact same color values may not produce the exact same shade of color on different displays.

The scocolor client is also based on the RGB color model. However, it allows you to switch to the HSV color model to provide greater flexibility in choosing colors.

Unlike the RGB color model, which is hardware-oriented, the HSV model is user-oriented, based on the more intuitive appeal of combining hue, saturation, and value elements to create a color.

However, the scocolor client automatically translates any colors that are selected or created using the HSV model to corresponding RGB values. The HSV option is provided only as an alternative interface for selecting colors.


Next topic: The scocolor client
Previous topic: The color database

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003