Sample program to illustrate fill patterns.

#include <graphics.h>

int main(void)
{
int gd, gm = DETECT, x, y, fst;
unsigned char arr[] = { 0x88, 0xAA, 0xCD, 0x24, 0x85, 0xAA, 0x62, 0xBD };
// unsigned char arr[] = { 0x18, 0x24, 0x5A, 0xA5, 0x42, 0x81, 0x3C, 0x00 };

char *pattern[] = { "EMPTY_FILL", "SOLID_FILL",
"LINE_FILL", "LTSLASH_FILL",
"SLASH_FILL", "BKSLASH_FILL",
"LTBKSLASH_FILL", "HATCH_FILL",
"XHATCH_FILL", "INTERLEAVE_FILL",
"WIDEDOT_FILL", "CLOSEDOT_FILL",
"USER_FILL" };

initgraph( &gm, &gd, "C:\\TC\\BGI" );

x = getmaxx();
y = getmaxy();

/* Display pre-defined fill styles */
for( fst = 0; fst < 12; fst++ )
{
setfillstyle( fst, GREEN ); /* GREEN */
setcolor( YELLOW ); /* WHITE */

bar3d( x/4+10, y/15, x/2+10, y/4, 18, 1);
outtextxy( x/4+10, y/4+10, pattern[fst] );
getch();
getch();
/* Erase the image */
setcolor( BLACK );
setfillstyle( fst, BLACK );
bar3d( x/4+10, y/15, x/2+10, y/4, 18, 1 );
outtextxy( x/4+10, y/4+10, pattern[fst] );
// getch();
// getch();

} /* End of for loop */
/* Display user defined fill pattern */
setcolor( WHITE );
setfillpattern( arr, WHITE );
bar3d( x/4+10, y/15, x/2+10, y/4, 18, 1 );
outtextxy( x/4+10, y/4+10, pattern[fst] );
getch();
getch();
closegraph();
restorecrtmode();

return 0;
} /* End of main */

No comments:

Post a Comment

kiss on google ads if you are anonymous because your ip is trackable.thank you.

......from.admin