While working on juicy-draw, I thought it would be nice to look at drawing nicely antialiased lines. I thought I’d have a go at implementing Xiaolin Wu’s algorithm and post it up at Rosetta Code while I was at it:

You can also check out the GitHub project.

I have a couple of remaining issues that I may or may not get to at some point in the future:

Should it use Double instead of Int for coordinates?

instead of for coordinates? Attempting to draw a line covering the full extent of the image will crash the program due to out-of-range indices: the current code fudges the issue by deliberately drawing the line with two pixels of padding from the edges

Sometimes coordinates will wrap around

An industrial-strength implementation would need to address these questions.