www.pudn.com > tuxingxue.rar > ZHIXIAN3.C


#include 
Bresenham_Line(x0,y0,x1,y1,color) 
int x0,y0,x1,y1,color; 
{ 
  int x,y,dx,dy,i; 
  float k,e; 
  dx=x1-x0; 
  dy=y1-y0; 
  k=dy/dx; 
  e=-0.5; x=x0; y=y0; 
  for(i=0;i<=dy;i++) 
  {putpixel(x,y,color); 
  y=y+1; 
  e=e+k; 
  if(e>=0) 
  { 
    x=x+1; 
    e=e-1; 
   } 
   } 
} 
main() 
{ 
  int x0,y0,x1,y1,color; 
  int gdriver=DETECT,gmode; 
  initgraph(&gdriver,&gmode,"c:\\tc"); 
  cleardevice(); 
  Bresenham_Line(10,10,100,100,YELLOW); 
  getch(); 
}