<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Tue, 07 Jul 1998 13:22:21 -0700 (PDT)
From   : Angus Duggan <angus@...>
Subject: Re: Circle routines in Basic

Richard Harker writes:
>Here's a routine to draw a few circles that I copied from one of my programs.
>Hope it helps.

Yuck! Too many transcendentals. The easiest way to do it is to get the
advanced graphics ROM, which provides extra VDU codes for circles, ellipses,
pattern fills, flood fills, and quite a bit more. Of course, this means your
program won't work on a standard Beeb, and the AGR uses some public claimed
memory.

If you want to roll your own, I suggest looking at just about any graphics
textbook, or some of the vast amount of literature on DDA techniques. There
are many variants on the Bresenham/DDA algorithms for drawing circles, from
the relatively simple to the more complex, like mirrored double-step DDAs.

If you don't need speed, then you can use something like Richard's technique.
This itself can be speeded up considerably by storing the sin/cos results in
an array (note you only need one quadrant worth of results for sin, since the
other quadrants are mirrorings and cos is a phase shift). Mirroring the lines
will also speed it up; the same point calculations can be used to draw
segments in all four quadrants, from (cx + x0, cy + y0) to (cx + x1, cy + y1),
(cx + x0, cy - y0) to (cx + x0, cy - y1), (cx - x0, cy - y0) to
(cx - x0, cy - y1), and (cx - x0, cy + y0) to (cx - x0, cy + y1).

a.
--
Harlequin Inc., 301 Ravenswood Ave.,	| http://www.dcs.ed.ac.uk/home/ajcd/
Suite 100, Menlo Park, CA 94025, U.S.A.	| http://www.tardis.ed.ac.uk/~ajcd/

If e-mail to me bounces, your mail system is probably mis-configured. Add the
string "af8Gg01zXrl3k6yy32OtE9Q11v" to the message subject to get through my
spam-blocks. This string will change periodically.


<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>