Caution: This version of this document is no longer maintained. For the latest documentation, see

PgSetFillXORColor(), PgSetFillXORColorCx()

Set the fill color for XOR drawing


void PgSetFillXORColor( PgColor_t frgd,
                        PgColor_t bkgd );

void PgSetFillXORColorCx( PhGC_t *gc,
                          PgColor_t frgd,
                          PgColor_t bkgd );




These functions set the draw color for fills. When an application XORs this color with the color bkgd, the result is the color frgd.

Since XOR is a reflexive function, frgd and bkgd may be reversed.

PgSetFillXORColor() works on the current graphics context, while you can specify the graphics context gc for PgSetFillXORColorCx().


DrawXOR() {
    char *s = "Hello World!";
    PhPoint_t p = { 8, 30 };
    PhRect_t    r;
    char Helvetica18[MAX_FONT_TAG];

    if(PfGenerateFontName("Helvetica", 0, 18,
                          Helvetica18) == NULL) {
        perror ("Unable to find font");
    } else {
        PgSetFont( Helvetica18 );
        PgSetTextColor( Pg_YELLOW );
        PgSetFillColor( Pg_PURPLE );
        PgDrawText( s, strlen( s ), &p, Pg_BACK_FILL );

        PgExtentText( &r, &p, Helvetica18, s, strlen( s ) ); -= ( - r.ul.x) / 2;
        PgSetDrawMode( Pg_DRAWMODE_XOR );
        PgSetFillXORColor( Pg_YELLOW, Pg_PURPLE );
        PgDrawRect( &r, Pg_DRAW_FILL );
        PgSetDrawMode( Pg_DRAWMODE_OPAQUE );

The above code draws:




Interrupt handler No
Signal handler No
Thread No

See also:

PgColor_t, PgDefaultFill*(), PgSetDrawMode*(), PgSetFillColor*(), PgSetFillDither*(), PgSetFillTransPat*(), PgSetStrokeXORColor*(), PgSetTextXORColor*()

Drawing attributes and Arcs, ellipses, polygons, and rectangles in the Raw Drawing and Animation chapter of the Photon Programmer's Guide