getfillsettings


Syntax

#include <graphics.h>

void getfillsettings(struct fillsettingstype *fillinfo);

Description
getfillsettings fills in the fillsettingstype structure pointed to by fillinfo with information about the current fill pattern and fill color. The fillsettingstype structure is defined in graphics.h as follows:

struct fillsettingstype {

   int pattern;            /* current fill pattern */

   int color;              /* current fill color */

};

The functions bar, bar3d, fillpoly, floodfill, and pieslice all fill an area with the current fill pattern in the current fill color. There are 11 predefined fill pattern styles (such as solid, crosshatch, dotted, and so on). Symbolic names for the predefined patterns are provided by the enumerated type fill_patterns in graphics.h, as shown here:
NameValue   Description
EMPTY_FILL 0 Fill with background color
SOLID_FILL 1 Solid fill
LINE_FILL 2 Fill with ---
LTSLASH_FILL 3 Fill with ///
SLASH_FILL 4 Fill with ///, thick lines
BKSLASH_FILL 5 Fill with \\\, thick lines
LTBKSLASH_FILL 6 Fill with \\\
HATCH_FILL 7 Light hatch fill
XHATCH_FILL 8 Heavy crosshatch fill
INTERLEAVE_FILL    9 Interleaving line fill
WIDE_DOT_FILL 10 Widely spaced dot fill
CLOSE_DOT_FILL 11 Closely spaced dot fill
USER_FILL 12 User-defined fill pattern
Note: All but EMPTY_FILL fill with the current fill color; EMPTY_FILL uses the current background color. In addition, you can define your own fill pattern. If pattern equals 12 (USER_FILL), then a user-defined fill pattern is being used; otherwise, pattern gives the number of a predefined pattern.

Return Value
None.

Windows Notes [WIN]
In the winbgim version, the user might set the fill color to an RGB color. Therefore, the color in the fillsettingstype struct might be an ordinary BGI color (integer from 0 to 15) or an RGB color.

See also
getfillpattern
setfillpattern
setfillstyle

Example

/* getfillsettings example */ 



#include 

#include 

#include 

#include 



/* the names of the fill styles supported */

char *fname[] = { "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 autodetection */

   int gdriver = DETECT, gmode, errorcode;

   struct fillsettingstype fillinfo;



   int midx, midy;

   char patstr[40], colstr[40];



   /* initialize graphics and local variables */

   initgraph(&gdriver, &gmode, "");



   /* read result of initialization */

   errorcode = graphresult();

   if (errorcode != grOk) {  /* an error occurred */

      printf("Graphics error: %s\n", grapherrormsg(errorcode));

      printf("Press any key to halt:");

      getch();

      exit(1);               /* terminate with an error code */

   }



   midx = getmaxx() / 2;



   midy = getmaxy() / 2;



   /* get info about current fill pattern and color */

   getfillsettings(&fillinfo);



   /* convert fill information into strings */

   sprintf(patstr, "%s is the fill style.", fname[fillinfo.pattern]);

   sprintf(colstr, "%d is the fill color.", fillinfo.color);



   /* display the information */

   settextjustify(CENTER_TEXT, CENTER_TEXT);

   outtextxy(midx, midy, patstr);

   outtextxy(midx, midy+2*textheight("W"), colstr);



   /* clean up */



   getch();

   closegraph();

   return 0;

}


Back to index