Friday 27 September 2013

BRESENHAM'S LINE DRAWING ALGORITHM - Computer Graphics - Lab Experiment - IT Department - Final Year




#include
#include
#include
#include
int x,y;
void linebres(int x1,int x2,int y1,int y2)
{
int dx,dy,xend,p;
dx=abs(x2-x1);
dy=abs(y2-y1);
p=(2*dy)-dx;
if(x1>x2)
{
x=x2;y=y2;
xend=x1;
}
else
{
x=x1;y=y1;
xend=x2;
}
while(x {
putpixel(x,y,15);
x++;
if(p<0 p=""> p=p+2*(dy);
else
{
y++;
p=p+2*(dy-dx);
}
}
}
void main()
{
int gd=DETECT,gm,x1,x2,y1,y2;
initgraph(&gd,&gm,"c:\\tc\\bgi");
printf("\n BRESENHAM'S LINE DRAWING ALGORITHM");
printf("Enter the starting point\n");
scanf("%d%d",&x1,&y1);
printf("Enter the ending point");
scanf("%d%d",&x2,&y2);
cleardevice();
linebres(x1,y1,x2,y2);
getch();
closegraph();
}




No comments:

Don't You Think this Awesome Post should be shared ??
| BRESENHAM'S LINE DRAWING ALGORITHM - Computer Graphics - Lab Experiment - IT Department - Final Year |
Back To Top Related Posts Plugin for WordPress, Blogger...