setfillstyle function in c/c++ graphics


setfillstyle function in c/c++ graphics


setfillstyle() :

It sets the current fill pattern and fill color.

Syntax :

setfillstyle(int pattern,int color);


setfillstyle() patterns
:


setfillstyle() sets the current fill pattern and fill color.

Just like color has values from 0 t0 15,similarly there are fill style patterns are there:


"EMPTY_FILL",

"SOLID_FILL",

"LINE_FILL",

"LTSLASH_FILL",

"SLASH_FILL",

"BKSLASH_FILL",

"LTBKSLASH_FILL",

"HATCH_FILL",

"XHATCH_FILL",

"INTERLEAVE_FILL",

"WIDE_DOT_FILL",

"CLOSE_DOT_FILL",

"USER_FILL"


Note : These can have values two from 0 to 12..like..:

"EMPTY_FILL", value=0

"SOLID_FILL", value=1

"LINE_FILL", value=2


and so on...

Remeber syntax of this function is :

setfillstyle(int pattern,int color);

That is first parameter is one of the above pattern or values..
For eg:

setfillstyle(EMPTYFILL,BLUE)

setfillstyle(0,1)

Both represents same pattern and color as we can use values to in place of names.


Example :


#include <graphics.h>
#include <conio.h>

void main()
{
int d,m;
int midx,midy;

d=DETECT;
initgraph(&d,&m,"c:\\tc\\bgi");

midx=getmaxx()/2;
midy=getmaxy()/2;

setfillstyle(6,2);
circle(midx,midy,50);
floodfill(midx,midy,15);

getch();
closegraph();
}

Output :




0 comments:

Post a Comment