Set the dither pattern and colors for fills
void PgSetFillDither( PgColor_t c1, PgColor_t c0, PgPattern_t pat );
This function combines two colors according to the pattern defined by pat and applies the pattern to fills.
The c1 argument represents the color used for "on" bits in the dither pattern and c0 represents the color used for "off" bits. The driver always selects the colors closest to c1 and c0.
The dither pattern is an array of 8 bytes, aligned with the upper-left corner of the application's region. This pattern repeats itself every 8 pixels horizontally and every 8 pixels vertically.
This function overrides the color defined by the appropriate PgSetFillColor() function. For basic colors, see PgColor_t.
At least the following patterns are defined in <photon/Pg.h>:
Predefined dither patterns.
// Set the fill to be black with every 8th // vertical line being white PgSetFillDither( Pg_WHITE, Pg_BLACK, Pg_PAT_VERT8 ); // Set the fill to be red bricks with dark gray mortar PgSetFillDither(Pg_DGRAY, Pg_RED, "\x20\x20\xFF\x02\x02\x02\xFF\x20" );
Here's the code that produced the sample of predefined dither patterns:
typedef struct { char *name; PgPattern_t p; } DithersListStruct; DithersListStruct DithersList[] = { "Pg_PAT_DEFAULT", Pg_PAT_DEFAULT, "Pg_PAT_HALF", Pg_PAT_HALF, "Pg_PAT_BACK_HALF", Pg_PAT_BACK_HALF, "Pg_PAT_CHECKB8", Pg_PAT_CHECKB8, "Pg_PAT_CHECKB4", Pg_PAT_CHECKB4, "Pg_PAT_DIAMOND", Pg_PAT_DIAMOND, "Pg_PAT_HORIZ8", Pg_PAT_HORIZ8, "Pg_PAT_HORIZ4", Pg_PAT_HORIZ4, "Pg_PAT_HORIZ2", Pg_PAT_HORIZ2, "Pg_PAT_VERT8", Pg_PAT_VERT8, "Pg_PAT_VERT4", Pg_PAT_VERT4, "Pg_PAT_VERT2", Pg_PAT_VERT2, "Pg_PAT_DIAGF8", Pg_PAT_DIAGF8, "Pg_PAT_DIAGF4", Pg_PAT_DIAGF4, "Pg_PAT_DIAGB8", Pg_PAT_DIAGB8, "Pg_PAT_DIAGB4", Pg_PAT_DIAGB4, "Pg_PAT_BRICK", Pg_PAT_BRICK, "Pg_PAT_WEAVE", Pg_PAT_WEAVE, "Pg_PAT_RXHATCH8", Pg_PAT_RXHATCH8, "Pg_PAT_RXHATCH4", Pg_PAT_RXHATCH4, "Pg_PAT_RXHATCH2", Pg_PAT_RXHATCH2, "Pg_PAT_DXHATCH8", Pg_PAT_DXHATCH8, "Pg_PAT_DXHATCH4", Pg_PAT_DXHATCH4, }; #define DithersListNum \ (sizeof( DithersList ) / sizeof( DithersListStruct ) ) #define DithersListCHeight 20 #define DithersListWinY (DithersListNum*DithersListCHeight) Dithers() { DithersListStruct *DLPtr = DithersList; PhPoint_t p; PhRect_t r; int i, y; PgSetFont( "helv14b" ); PgSetTextColor( Pg_BLACK ); PgSetStrokeColor( Pg_BLACK ); for (y=i=0; i<DithersListNum; i++, y+=DithersListCHeight, DLPtr++) { p.x = 2; p.y = y+14; PgDrawText( DLPtr->name, strlen( DLPtr->name ), &p, 0 ); PgSetFillDither( Pg_WHITE, Pg_DBLUE, DLPtr->p ); r.ul.x = 160; r.lr.x = 320; r.ul.y = y; r.lr.y = y+DithersListCHeight; PgDrawRect( &r, Pg_DRAW_FILL_STROKE ); } }
Photon
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |
PgCMY(), PgColor_t, PgGray(), PgHSV(), PgRGB(), PgSetFillColor(), PgSetFillTransPat(), PgSetStrokeColor(), PgSetStrokeDither(), PgSetStrokeTransPat(), PgSetTextColor(), PgSetTextDither(), PgSetTextTransPat()