setfillstyle function in c graphic

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.
Fill Style Nameint value
EMPTY_FILL1
SOLID_FILL2
LINE_FILL3
LTSLASH_FILL4
SLASH_FILL5
BKSLASH_FILL6
LTBKSLASH_FILL7
HATCH_FILL8
XHATCH_FILL9
INTERLEAVE_FILL10
WIDE_DOT_FILL11
CLOSE_DOT_FILL12
USER_FILL13

                                                    There are following color is available with setfillstyle function with its corresponding integer value.
Colorint value
BLACK0
BLUE1
GREEN2
CYAN3
RED4
MAGENTA5
BROWN6
LIGHTGRAY7
DARKGRAY8
LIGHTBLUE9
LIGHTGREEN10
LIGHTCYAN11
LIGHTRED12
LIGHTMAGENTA13
YELLOW14
WHITE15


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;
}



setfillstyle function of c graphics

Download


0 comments:

Post a Comment