Re: A86: Drawing circles


[Prev][Next][Index][Thread]

Re: A86: Drawing circles



Grams Family wrote:
At 09:14 AM 11/3/97 -0500, you wrote:
>On Sun, 2 Nov 1997, MrManson wrote:
>
>> Robby Gutmann wrote:
>> >
>> > Is there an easier way to draw circles than using sprites?  if not,
>>
>> yeah use sine and cosine, gonna have to manipulate the values in the OPs
>
>Don't use sine and cos functions to draw circles.  It's slow, and not well
>suited to a bitmapped display.  Do a net search for "Bresenham" and
>"circle" and you will find lots of info on drawing circles on bitmapped
>displays.
>
As I recall, the Bresenham circle algorithm uses some multiplication, so it
might be a pain to write. _Definitely_ worth it though. If you do it right,
it can do ellipses too.

--Joshua

  here is a QuickBasic version of it sorry i am too lazy to write the ASM version i think almost everything can be multiplied using the sll thing i think

;RADIUS=r
;centr of circle=(cx,cy)
;

Cldrw
0×x
(radius)×y
3-(2*r)×d
While x÷Y
PtOn(xc+x,yc+y)
PtOn(xc+x,yc-y)    ;you might want to put this all on one line for fun using colon
PtOn(xc-x,yc+y)
PtOn(xc-x,yc-y)
PtOn(yc+y,xc+x)
PtOn(yc+y,xc-x)
PtOn(yc-y,xc+x)
PtOn(yc-y,xc-x)
If d<0
Then
d+4*x+6×d
Else
d+4*(x-y)+10×d
End
x+1×x
End

Thanks Dan for telling people about this.  This is probably the fastest algorithm for circles i have seen  even better than TI's version that draws the circles for the graph. A circle with a radius of 20 drawn using the TI command Circl(0,0,20 was 4.5 seconds while the same circle was drawn using my Circle program using Bressenham's alg in TI-Basic is 5 seconds so hopefully it would be instantaneous or appear instaneous if it were written in ASM.  Tomorrow i'll try to write it in ASM but right now i am so tired i can barely type or fix grammar or spellnig error sorry about them and sorry if ur mail cant read the enhanced mail netscape uses.

Patrick


Follow-Ups: References: