setfillstyle

王朝百科·作者佚名  2010-05-14
窄屏简体版  字體: |||超大  

函数名:setfillstyle

功 能: 设置填充模式和颜色

用 法:void far setfillstyle(int pattern, int color);

程序例:

#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 auto detection */

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 != grOk) /* an error occurred */

{

printf("Graphics error: %s

", grapherrormsg(errorcode));

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

getch();

exit(1); /* 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 */

strcpy(stylestr, fname[style]);

/* fill a bar */

bar3d(0, 0, midx-10, midy, 0, 0);

/* output a message */

outtextxy(midx, midy, stylestr);

/* wait for a key */

getch();

cleardevice();

}

/* clean up */

getch();

closegraph();

return 0;

}

颜色填充:

1)SOLID_FILL 单色实填充

2)LINE_FILL 用“-”填充

3)HATCH_FILL 用方网格填充

4)XHATCH_FILL 用斜方格填充

5)WIDE_DOT_FILL用稀疏点填充

6)CLOSE_DOT_FILL用密集点填充

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航