void line(int left,int top,int right,int bottom,unsigned char color)
{
register t;
int distance;
int x=0,y=0,delta_x,delta_y,incx,incy;
delta_x=right-left;
delta_y=bottom-top;
if(delta_x>0)incx=1;
else
if(delta_x==0)incx=0;
else
{
delta_x=-delta_x;
incx=-1;
}
if(delta_y>0)incy=1;
else
if(delta_y==0)incy=0;
else
{
delta_y=-delta_y;
incy=-1;
}
if(delta_x>delta_y)
distance=delta_x;
else
distance=delta_y;
for(t=0;t<distance+2;t++)
{
putpixel(left,top,color);/* TURBO C 2.0的图形函数,请换成你的画点函数*/
x+=delta_x;
y+=delta_y;
if(x>distance)
{
x-=distance;
left+=incx;
}
if(y>distance)
{
y-=distance;
top+=incy;
}
}
}