says...

Quote:>Could someone provide me with the algorithm for drawing lines.

>I have a LCD screen that is 128 x 56 and I wrote a put_pixel()

>routine, but I need a line drawing routine. The version of C that I

>have doesn't support floating point math, only integer math.

>Thanks Gary

Check out this...

void Line(int x0,int y0,int x1,int y1,int c)

{ int i,dx,ix,dy,iy,m,cx,cy;

if (x0<x1) { dx=x1-x0; ix=1; }

else { dx=x0-x1; ix=-1; }

if (y0<y1) { dy=y1-y0; iy=1; }

else { dy=y0-y1; iy=-1; }

if (dx>dy) m=dx; else m=dy;

cx=cy=m>>1;

for (i=0; i<m; i++)

{ PutPixel(x0,y0,c);

if ((cx+=dx)>=m) { cx-=m; x0+=ix; }

if ((cy+=dy)>=m) { cy-=m; y0+=iy; }

}

Quote:}

This is my personal version of an integer arithmetic DDA (as you should

see there is only a shift and additions ... :-) )

Warning: this algo don't draw the last point because I like that; if you

are wrong (i.e. don't agree with me) change the for with a "<=m" ;)

I hope this helps