=xmin&&xi[p]<=xmax)
p++;
}
sort(xi,p);
for(j=0;jxi[j+1])
{
float temp;
temp=xi[j];
xi[j]=xi[j+1];
xi[j+1]=temp;
}
}
}
}
void edge_fill(int ed[20],int num)
{
int i,j,k,xmax,xmin,ymax,ymin,col;
double xint;
get_y(ymin,ymax,ed,num);
get_x(xmin,xmax,ed,num);
for(k=0;k<2*num;k+=2)
{
for(i=ymin;i<=ymax;i++)
{
if(ed[k+1]==ed[k+3])
continue;
if(!check_mid(i,ed,k))
continue;
xint = ed[k]+(((double)(i-ed[k+1])/(ed[k+1]-ed[k+3]))*(ed[k]-ed[k+2]));
for(j=xmin;j<=xmax;j++)
{
if(j>xint)
{
col=getpixel(j,i);
if(col==15)
putpixel(j,i,0);
if(col==0)
putpixel(j,i,15);
}
}
}
}
}
void main()
{
clrscr();
char *mess[]={"-","=","["," ","P","o","l","y","g","o","n"," ",
"F","i","l","l","i","n","g"," ","]","=","-",};
int xx=28,xxx=51,i,j;
_setcursortype(_NOCURSOR);
for(i=0,j=22;i<13,j>=11;i++,j--)
{
gotoxy(xx,1);
cout<" Flood Fill "";
cout<<"
2:==>" Ordered Edge List Fill "";
cout<<"
3:==>" Edge Fill "";
cout<<"
4:==>" Exit "";
cout<<"
" Enter Your Choice ":=";
cin>>choice;
initgraph(&gd,&gm,"..\bgi");
clearviewport();
switch(choice)
{
case 1:
flood_fill(ed);
getch();
break;
case 2:
num=get_poly(ed);
scan_poly(ed,num);
getch();
break;
case 3:
num=get_poly(ed);
edge_fill(ed,num);
getch();
break;
case 4:
exit(0);
default:
cout<<"
a" Press A Valid Key...!!! "";
getch();
main();
break;
}
closegraph();
}
No comments: