SilverScreen Solid Modeler

Colors and RGB

Colors and RGB

Previous topic Next topic  

Colors and RGB

Previous topic Next topic JavaScript is required for the print function  



Colors and RGB





SilverScreen is RGB-based. In all drawings, colors are stored as RGB values. Some video systems support color numbers rather than RGB. When a drawing is loaded, the RGB values are converted to color numbers that are appropriate to the video display.


When a color is selected for a surface or a line, the user may express this color as an RGB value or as a color number. If a color number is selected, then this number is internally converted to an RGB value.


The advantage of this approach is clear: SilverScreen drawings are independent of any color limitations imposed by the video device on which they were created. A surface, even on a 16-color system, may be given the RGB color of r13g120b93 . On a 16-color system, this color may be interpreted as the color 3 (cyan). If the drawing is later displayed on an RGB video device, the color will be accurately portrayed as r13g120b93 .


For video systems that do not have RGB display capability, SilverScreen uses a base palette of either 16 or 256 colors, dependent on the capabilities of the video device. Each color in SilverScreen is simultaneously maintained both as an RGB value and as a color from this palette.


A special data type, RGB , defined in silver.h , is used to store this color information. The data type is an int, 32 bits in length. Eight bits are used to store the base color and 24 bits are used to store the RGB. There are several macros that are defined in silver.h that allow each of these values to be extracted:


    RED_COLOR (rgb)

    GREEN_COLOR (rgb)

    BLUE_COLOR (rgb)

    THE_COLOR (rgb)

    MAKE_RGB (color,red,green,blue)


The SilverScreen API also provides functions that convert color to RGB and RGB to color.


    color_to_rgb   for a given base color, the function returns the RGB components of the color.

    rgb_to_color   for an RGB, this function returns the base color appropriate for the current video device.