Basic's of how to draw a line in TurboC.... #include<iostream.h> #include<conio.h> #include<stdio.h> #include<dos.h> #include<graphics.h> #include<math.h> void main() { clrscr(); float x,y,x1,x2,y1,y2,dx,dy,lenght; int i,gd,gm; cout<<"enter x1 and y1"<<endl; cin>>x1>>y2; cout<<"enter x2 and y2"<<endl; cin>>x2>>y2; detectgraph(&gd,&gm); initgraph(&gd,&gm,"C:\\TC\\BGI"); dx=abs(x2-x1); dy=abs(y2-y1); if(dx>=dy) { lenght=dx;} else {lenght=dy;} dx=(x2-x1)/lenght; dy=(y2-y1)/lenght; x=x1+0.5 ; y=y1+0.5; i=1; while(i<=lenght) { putpixel(x,y,15); x=x+dx; y=y+dy; i++; } delay(100); getch(); closegraph(); } Second basic's ...
Comments
Post a Comment