UNKNOWN //************************************** // Name: DDA Line Drawing Algorithm // Description:This is a simple program to implement DDA line drawing algorithm in C program. // By: Rekha Ram Chaudhary // // // Inputs:None // // Returns:None // //Assumes:None // //Side Effects:None //This code is copyrighted and has limited warranties. //Please see http://www.Planet-Source-Code.com/xq/ASP/txtCodeId.13842/lngWId.3/qx/vb/scripts/ShowCode.htm //for details. //************************************** #include "stdio.h" #include "conio.h" #include "math.h" #include "graphics.h" main() { int gd=DETECT,gm; int xa,xb,ya,yb; int dx,dy,steps,k,xinc,yinc,x,y; initgraph(&gd,&gm,"c:\\tc\\bgi"); printf("Enter the two left end pixel points(xa,ya):\n"); scanf("%d%d",&xa,&ya); printf("Enter the two Right end pixel points(xb,yb):\n"); scanf("%d%d",&xb,&yb); dx=xb-xa; dy=yb-ya; if(abs(dx)>abs(dy)) steps=abs(dx); else steps=abs(dy); xinc=dx/steps; yinc=dy/steps; x=xa; y=ya; putpixel(x,y,6); for(k=1;k<=steps;k++) { x=x+xinc; y=y+yinc; putpixel(x,y,6); } getch(); return(0); }