Bresenham Line Algorithm

``` BBS: Inland Empire Archive
Date: 07-29-92 (05:27)             Number: 184
From: RICHARD VANHOUTEN            Refer#: NONE
To: BRIAN DESSENT                 Recvd: NO
Subj: Bresenham Line Algorithm       Conf: (1) 80xxx

>  BD> I also have source for an all-integer math circle drawing routine...

> YES!  I want it too!  I have sort of made my own, except I can't
> seem to make it work the proper dots per size etc..  THANKS!

BD> Okay, again, this isn't asm, so I apologize for being off topic, but
BD> maybe someone can translate this into ASM and post it :-)

BD> int x, y, d

BD> x = 0
BD> d = 2 * (1 - radius)
BD> while y > x
BD> plot dot at (xc + x, yc + y)  ; I think there's only 4, but
BD> plot dot at (xc - x, yc + y)  ; there may be 8 plotdot routines
BD> plot dot at (xc + x, yc - y)
BD> plot dot at (xc - x, yc - y)
plot dot at (xc + y, yc + x)
plot dot at (xc - y, yc + x)
plot dot at (xc + y, yc - x)
plot dot at (xc - y, yc - x)
BD> if d + y > 0 then
BD> y = y + 1
BD> d = d - 2 * y + 1
BD> endif
BD> if x > d then
BD> x = x + 1
BD> d = d + 2 * x + 1
BD> endif
BD> endwhile
BD> done

I believe the above algorithm is also credited to Bresenham.  It works with
square pixels.  If your pixels aren't square, you'll need to use a different
algorithm.

... The first rule of intelligent tinkering is to save all the parts.
--- Blue Wave/Max v2.10 [NR]
* Origin: <<PRISM (914)344-0350 HST/DS - (914)343-7540 HST (1:272/38.0)
```

Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET