Lines and Lines and Lines

The SVN version of the Woopsi sourcecode (hosted by SourceForge) now has line and circle drawing in the SuperBitmap gadget. I stole both functions from Wikipedia.

During one of the long waits between flights that comprised the only dull portion of my jaunt to the other side of the world, abject boredom drove me to look up line drawing algorithms on the internets. I discovered Bresenham’s line drawing algorithm. This was apparently developed for ye olde plotting devices, but worked just as well with raster displays. It’s been around for nearly 50 years, so I decided not to bother re-inventing a circular device for transportation this time and just use the existing algorithm.

The circle routine came from the same page. It appears to be another of Bresenham’s inventions, but the Wiki article falls apart at this stage and desperately needs tidying up. I can’t say that the algorithm is definitely his work because the article isn’t clear enough. It does work, though, which is the main thing.

Now I just need an ellipse function, and all of the primitive drawing routines are done.


Jeff on 2007-10-18 at 00:10 said: