I've implimented Bresenham line drawing in lisp and added an optional feature for dashed lines.The dashed line option is used when an array of t and nil values are provided.You must provide your own plot function, making this highly portable as it separates the algorithm from the graphics lib.

The problem comes when using expressions such as (random number) for both x2 and y2 at the same time along with a dash pattern.If just the pattern is provided with x2 and y2 being both numeric constants and a dash pattern it works.

On the other hand, you can seem to be able to use (random number) on x2 and y2 without a dash pattern and it works....

For example this line will fail:Assume *pixel-buffer* is a 2d array of 0's or 1's.

Once again you come to the rescue!Thanks for the help Edgar it is working now.It was a silly mistake. This is actually for the graphics viewer we were working on. It might be cool if the forum had a code snippit section since this function is not bound to any library and could be extended by the user.I might also add an option for filled arrow ends. I didn't use your mod method because it is a costly operation compared to a second if check.

I'm now considering adding a few more functions like polygons (with stipple patterns defined by 2d arrays of t and nil values) Then you could combine the polygon function and the line function to get an arrow function (line with polygon arrow tips) I also have a spline drawing function for bezier curves which could also be paired with a polygon function to get curvy leader arrows like you see in drafting blueprints.

All in all, this working function opens up some doors.Thank you very much for finding and spotting my error.This was sent from my 80x24 command terminal hopefully the formatting is OK.

Question: What exactly is the difference between your pattern code above and the Tk canvas dash and stipple options? Wouldn't it make sense to write a function that converts e.g. a CL bit-vector into a X bitmap string and then use the XBM pattern to draw stippled lines? Of course I don't want to stop you to explore Bresenham's graphics algorithms but why re-inventing the wheel if dashed and stippled lines are already part of the Tk canvas?