Setting the Primitive Color Attributes

To set the color attributes for one type of graphics primitive, an application uses GpiSetAttrs. To set the color attributes for each type of primitive in a presentation space, use GpiSetColor and GpiSetBackColor. The following figure shows how to use GpiSetAttrs to set the color attribute of line primitives to dark gray.

#define INCL_GPIPRIMITIVES
#include <os2.h>

void fncCOLR04(void){
    LINEBUNDLE lbnd;     /* Line-primitive attribute structure */
    HPS hps;

    lbnd.lColor = CLR_DARKGRAY;

    GpiSetAttrs(hps, PRIM_LINE, LBB_COLOR, 0, &lbnd);
} /* fncCOLR04 */

The following figure is an example of how to use GpiSetColor to set the foreground color attribute to dark gray in all of the primitives.

#include <os2.h>

void fncCOLR05(void){
    HPS hps;

    GpiSetColor(hps, CLR_DARKGRAY);
} /* fncCOLR05 */


[Back: Determining the Index Value of an RGB Value]
[Next: Creating a Palette]