Archive

Posts Tagged ‘scanline algorithm’

>Program for scanline algorithm

January 11, 2011 2 comments

>/*program for scanline algorithm*/

#include stdio.h
#include conio.h
#include graphics.h
#include dos.h
#include math.h

struct edge
{
int x1;
int y1;
int x2;
int y2;
int flag;
};

void main()
{
int gd=DETECT,gm,n,i,j,k;
struct edge ed[10],temped;
float dx,dy,m[10],x_int[10],inter_x[10];
int x[10],y[10],max_y=0,min_y=480,yy,temp;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,”c:\\tc\\bgi”);
printf(“Enter the number of vertices\t”);
scanf(“%d”,&n);
printf(“\nEnter the vertices\t”);
for(i=0;imax_y)
{
max_y=y[i];
}
if(y[i]min_y)
{
for(i=0;ied[i].y2 && yy<=ed[i].y1 && ed[i].y1!=ed[i].y2) ed[i].flag=1; else ed[i].flag=0; } j=0; for(i=0;ix_int[k+1])
{
temp=x_int[k];
x_int[k]=x_int[k+1];
x_int[k+1]=temp;
}
}
}
for(i=0;i
{
line(x_int[i],yy,x_int[i+1],yy);
}
yy–;
delay(50);
}
getch();

}