2000年左右的流行歌曲:·用C语言编多变的填充多边形

来源:百度文库 编辑:高考问答 时间:2024/05/09 10:09:34
原程序

#include Conio.h
#include graphics.h
#define closegr closegraph

void initgr(void) /* BGI初始化 */
{int gd=DETECT,gm=0; /* 和gd=VGA,gm=VGAHI是同样效果 */
registerbgidriver(EGAVGA_driver);/* 注册BGI驱动后可以不需要.BGI文件的支持运行 */
initgraph(&gd,&gm,);
}
void seedfilling(x,y,fill_color,boundary_color)

int x,y,fill_color,boundary_color;

{

int c;

c=getpixel(x,y); /*获取当前点的颜色*/

if((c!=boundary_color)&&(c!=fill_color)) /*如果颜色为边界色则不填充*/

{

putpixel(x, y, fill_color); /*画点*/
getch(); /*加上这条语句可以显示填充状态 */

seedfilling(x+1,y, fill_color, boundary_color);

seedfilling(x-1,y, fill_color, boundary_color);

seedfilling(x, y+1, fill_color, boundary_color);

seedfilling(x, y-1, fill_color, boundary_color);

}

}

void main()
{
int a,b,color;

int gd=DETECT , gm;
int poly[10];
a=150 ;
b=140;
color=4;
initgraph(&gd , &gm , );

poly[0] = 110; /* 第一个点的x坐标以及y坐标 */
poly[1] = 110;

poly[2] = 200; /* 第二点 */
poly[3] = 105;

poly[4] = 170; /* 第三点 */
poly[5] = 120;

poly[6]=150; /*第四点*/
poly[7]=170;

poly[8]=110; /*多边形的起点与终点一样*/
poly[9]=110;
drawpoly(5,poly);/* 显示各点连接起来的多边形 */
seedfilling(a,b,color,15); /*种子填充多边形*/

getch();
closegraph();
}

TC环境或者Win-TC下的啊

凶.