Defining the Current Color

The value of each pixel in a virtual buffer determines the color in which that pixel is displayed. Recall that 256-color virtual buffers are said to be palette-based because the pixel value is actually an index into a larger color space, and high color and true color virtual buffers are termed direct color because the pixel value itself represents the actual color displayed.

Fastgraph's fg_setcolorrgb() and fg_setcolor() functions define the color in which many graphics operations are performed (this is called the current color). For fg_setcolorrgb(), we define the current color in terms of its red, green, and blue color components. As usual, each RGB component is a value between 0 and 255, with increasing values producing more intense colors. For fg_setcolor(), we define the current color as a logical palette index for 256-color virtual buffers, or as an encoded RGB value for direct color virtual buffers. In the next two sections, we'll discuss these and other color-related functions as they apply to 256-color and direct color virtual buffers.

One feature worth noting is that color 0 defaults to black in 256-color and direct color virtual buffers, and the highest-numbered color defaults to white. In the highest-numbered color, all relevant bits are 1, which is also true for the integer value -1. This means we can call fg_setcolor(-1) to make white the current color in both 256-color and direct color virtual buffers.

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.