This blog is under construction

Wednesday 11 September 2013

getfillsettings example in c

Header file:
    graphics.h

Synopsis:
      void getfillsettings(struct fillsettingstype * fillinfo);
     struct fillsettingstype {
          int pattern;  /* current fill pattern */
          int color;     /* current fill color */
     };
     
Description:
     getfillsettings() gets the current fill pattern and current fill color.



getfillsettings function in c graphics



  #include <graphics.h>
  #include <stdlib.h>
  #include <stdio.h>
  #include <conio.h>
  #include <dos.h>

  /* the names of the fill styles supported */
  char *fillStyle[] = { "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" };

  int main(void) {
        /* request auto detection */
        int gdriver = DETECT, gmode, errorcode;
        struct fillsettingstype data;
        int midx, midy, i;
        char pattern[40], color[40];

        /* initialize graphics and local variables */
        initgraph(&gdriver, &gmode, "C:/TURBOC3/BGI");

        /* read result of initialization */
        errorcode = graphresult();

        if (errorcode != grOk)  {
                /* an error occurred */
                printf("Graphics error: %s\n",
                                grapherrormsg(errorcode));
                getch();
                return 0;
        }

        /* mid position in x and y-axis */
        midx = getmaxx() / 2;
        midy = getmaxy() / 2;

        for (i = 0; i <= 15; i++) {
                setcolor(i);
                setfillstyle(i % 12, i);
                circle(midx, midy, 100);
                floodfill(midx, midy, i);
                /* get information about current fill pattern and color */
                getfillsettings(&data);

                /* convert fill information into strings */
                sprintf(pattern, "Fill Style is %s.", fillStyle[data.pattern]);
                sprintf(color, "color code for fill color is %d.", data.color);

                /* display the information */
                outtextxy(100, midy / 2, pattern);
                outtextxy(100, midy / 2 - 30, color);

                /* sleep for 600 milliseconds */
                delay(600);

                /* clears the graphic screen */
                cleardevice();
        }

        /* clean up */
        getch();
        closegraph();
        return 0;
  }





Output: (getfillsettings built-in function in c graphics.h)


No comments:

Post a Comment