You are on page 1of 8

CAD ASSIGNMENT-2

G.SANGEETHA

BT16MEC024

PROGRAMME:

# include <stdio.h>

# include <graphics.h>

# include <math.h>

# include <dos.h>

Void main()

int gd;

int gm;

int x,y,x1,y1,x2,y2,yend,dx,dy, g, n ;

float p,c1,c2;

gd = DETECT;

initgraph (&gd,&gm,"C:\\TC\\BGI") ;

n= getmaxy();

printf("enter start point of the line\n");

scanf ("%d%d",&x1, &y1 ) ;

printf ("enter end point of the line\n");


scanf("%d%d", &x2 ,&y2);

dx=abs(x1-x2);

dy=abs(y1-y2);

p= 2*dx-dy;

c1=2*dx;

c2= 2*(dx-dy);

if(x1>x2)

x=x2;

y = y2;

yend= y1;

else

x=x1;

y=y1;

yend= y2;

putpixel(x,n-y,4);

delay (200);
while(y<yend)

y= y+1;

if(p<0)

p= p+c1;

else

x=x+1;

p=p+c2;

putpixel(x,n-y,4);

delay(200);

scanf("%d",&g);

closegraph();

}
Result of given points (1,1)&(7,10)

Zoomed view of line having points (1,1) and (7,10)


Result of points (zoomed)(10,10)&(70,100) for clarity of line:
Verification of pixel points by programme:
GRAPH:

You might also like