Borland C++ reference

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

DOSUNIXWindowsANSI CC++ 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.

NameValueDescription
EMPTY FILL0Fill with background color
SOLID FILL1Solid fill
LINE FILL2Fill with
LTSLASH FILL3Fill with///
SLASH FILL4Fill with ///, thick lines
BKSLASH FILL5Fill with \\\, thick hnes
LTBKSLASHFILL6Fill with \\\
HATCH FILL7Light hatch fill
XHATCHFILL8Heavy Crosshatch fill
INTERLEAVEFILL9Interleaving line fill
WIDE DOT FILL10Widely spaced dot fill
CLOSE DOT FILL11Closely spaced dot fill
USER FILL12User-defined fill pattern
All but EMPTY_FILLfill with the current fill color; EMPTY_FILLuses 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.