setfillstyle function is used to set the current fill pattern and color.
General syntax of setfillstyle function is :
setfillstyle( int pattern, int color );
In setfillstyle we can choose any pattern and color by its name as its corresponding intger values.
There are following patterns in available with setfillstyle function with its corresponding integer value.
There are following color is available with setfillstyle function with its corresponding integer value.
#include <graphics.h>
#include <stdio.h>
int main( )
{
int gd=DETECT, gm;
int points[]={100,150,300,150,300,400,250,400,100,150};
initgraph(&gd,&gm,"C:\\tc\\bgi");
setfillstyle(6,1);
fillpoly(5,points);
getch();
closegraph();
return 0;
}
General syntax of setfillstyle function is :
setfillstyle( int pattern, int color );
In setfillstyle we can choose any pattern and color by its name as its corresponding intger values.
There are following patterns in available with setfillstyle function with its corresponding integer value.
Fill Style Name | int value |
---|---|
EMPTY_FILL | 1 |
SOLID_FILL | 2 |
LINE_FILL | 3 |
LTSLASH_FILL | 4 |
SLASH_FILL | 5 |
BKSLASH_FILL | 6 |
LTBKSLASH_FILL | 7 |
HATCH_FILL | 8 |
XHATCH_FILL | 9 |
INTERLEAVE_FILL | 10 |
WIDE_DOT_FILL | 11 |
CLOSE_DOT_FILL | 12 |
USER_FILL | 13 |
There are following color is available with setfillstyle function with its corresponding integer value.
Color | int value |
---|---|
BLACK | 0 |
BLUE | 1 |
GREEN | 2 |
CYAN | 3 |
RED | 4 |
MAGENTA | 5 |
BROWN | 6 |
LIGHTGRAY | 7 |
DARKGRAY | 8 |
LIGHTBLUE | 9 |
LIGHTGREEN | 10 |
LIGHTCYAN | 11 |
LIGHTRED | 12 |
LIGHTMAGENTA | 13 |
YELLOW | 14 |
WHITE | 15 |
C graphic program to demonstrate setfillstyle function
#include <graphics.h>
#include <stdio.h>
int main( )
{
int gd=DETECT, gm;
int points[]={100,150,300,150,300,400,250,400,100,150};
initgraph(&gd,&gm,"C:\\tc\\bgi");
setfillstyle(6,1);
fillpoly(5,points);
getch();
closegraph();
return 0;
}
Download |
---|
0 comments:
Post a Comment
Click to see the code!
To insert emoticon you must added at least one space before the code.