setfillstyle
raw OCR
Sets the fill pattern and color.
Defined in header <graphics.h>
Syntax
#include <graphics.h>
void far setfillstyle(int pattern, int color);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ |
Remarks
setfillstyle sets the current fill pattern and fill color. To set a user-defined
| fill pattern, do not give a pattern of 12 (USERFILL) | to setfillstyle; instead, |
call setfillpattern.
The enumeration filljpatterns, defined in graphics.h, gives names for the predefined fill patterns, plus an indicator for a user-defined pattern.
| Name | Value | 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 hnes | |
| 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 |
| All but EMPTY_FILL | fill with the current fill color; EMPTY_FILL | uses the |
current background color.
If invalid input is passed to setfillstyle, graphresult returns -11 (grError), and the current fill pattern and fill color remain unchanged.
Return value
None.
See also
Example
#include <graphics.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <conio.h>
/* 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;
int style, midx, midy;
char stylestr [40];
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult ();
if (errorcode 1= grOk) { /* an error occurred */
printf( "Graphics error: %s\n", grapherrormsg(errorcode)
printf ("Press any key to halt:");
getch( );
exit(l); /* terminate with an error code */
midx = getmaxx () / 2;
midy = getmaxy () / 2;
for (style = EMPTY_FILL; style < USER_FILL; style++) {
/* select the fill style */
setfillstyle (style, getmaxcolor());
/* convert style into a string ■'I
strcpy (stylestr, fname[style]);
I* fill a bar */
bar3d(0, 0, midx-10, midy, 0, 0);
/* output a message */
outtextxy (midx, midy, stylestr);
/* wait for a key */
getch ();
cleardeviceO ;
/* clean up */
getch ();
closegraph() ;
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/graphics.h/setfillstyle/
· short form /3.1/setfillstyle/