#include "Conio.h"
#include "graphics.h"
#define closegr closegraph
void initgr(void)
{
int gd=DETECT,gm=0;
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=9;
initgraph(&gd , &gm , "");
poly[0] = 110;
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;
printf("Enter fill_color: ");
scanf("%d",&color);
while(color>=15)
{
printf("Enter error ! please reinput color !\n");
printf("Enter fill_color: ");
scanf("%d",&color);
}
printf("Enter a and b: ");
scanf("%d%d",&a,&b);
while(a>155 || a<145)
{
printf("Out range ! please reinput a between 145-155 !\n");
printf("Enter a: ");
scanf("%d",&a);
}
while(b>155 || b<120)
{
printf("Out range ! please reinput b between 120-155 !\n");
printf("Enter b: ");
scanf("%d",&b);
}
drawpoly(5,poly);
seedfilling(a,b,color,15);
getch();
closegraph();
}
阅读(3133) | 评论(1) | 转发(0) |