256-Color Virtual BuffersIn 256-color virtual buffers, fg_setcolor() takes a single integer parameter that specifies the color as a logical palette index. This means we can pass fg_setcolor() a value between 0 and 255. For instance, in our first Fastgraph example program we called
C/C++:
Delphi:
Visual Basic:
Because entry 19 in the default logical palette is blue, fg_fillpage() filled the virtual buffer with blue pixels. If we pass fg_setcolor() a value greater than 255, it treats it as value modulo 256. We can also use fg_setcolorrgb() to define the current color in terms of its RGB components. If the specified color is in the active logical palette, fg_setcolorrgb() makes that color's logical palette index the current color. If it is not in the logical palette, fg_setcolorrgb() uses the closest matching color. The following statement finds the color closest to half-intensity pure green and makes it the current color:
C/C++ and Delphi:
Visual Basic:
The fg_getcolor() function returns the current color, as defined in the most recent call to fg_setcolorrgb() or fg_setcolor(). It has no parameters and returns the current color as its function value. The fg_maprgb() function searches for a color in the active logical palette. Its three parameters define the target color in terms of its red, green, and blue color components (each between 0 and 255). If the target color is in the active logical palette, fg_maprgb() returns its color number (that is, its index within the logical palette). If not, it returns the color number of the closest matching color. Passing the fg_maprgb() return value to fg_setcolor() is functionally equivalent to calling fg_setcolorrgb() with the three fg_maprgb() parameters.
|
 
copyright 2001 Ted Gruber Software, Inc.