Hi,
I have been trying to draw circles in Tiny Basic using the line command.
Can someone please share a small basic program I can use as a reference ?
Thanks
Trying to draw circles in basic.
Forum rules
Be nice. No drama.
Be nice. No drama.
Re: Trying to draw circles in basic.
This is based on Bresenham's algorithm:
I wonder how fast a Commodore 64 can do this in BASIC...
Code: Select all
'Draw filled circle with
'LINE statements
10 x=80:y=60:u=45:'Radius
20 cls:v=0:w=0
30 at x-u,y-v:line u+u,0
40 at x-u,y+v:line u+u,0
50 w=w+v+v+1:v=v+1
60 if w<0 goto 30
70 w=w-u-u+1:u=u-1
80 if u>0 goto 60
Re: Trying to draw circles in basic.
Thanks, thats great.
I have made a colourful pattern.
5 poke 42,0:cls
6 a=61
7 a=a-1
8 poke 43,a
10 x=80:y=60:u=a
20 v=0:w=0
30 at x-u,y-v:line u+u,0
40 at x-u,y+v:line u+u,0
50 w=w+v+v+1:v=v+1
60 if w<0 goto 30
70 w=w-u-u+1:u=u-1
80 if u>0 goto 60
85 if a<2 goto 85
90 goto 7
Is there a way of drawing an empty circle ?
Thanks
I have made a colourful pattern.
5 poke 42,0:cls
6 a=61
7 a=a-1
8 poke 43,a
10 x=80:y=60:u=a
20 v=0:w=0
30 at x-u,y-v:line u+u,0
40 at x-u,y+v:line u+u,0
50 w=w+v+v+1:v=v+1
60 if w<0 goto 30
70 w=w-u-u+1:u=u-1
80 if u>0 goto 60
85 if a<2 goto 85
90 goto 7
Is there a way of drawing an empty circle ?
Thanks
Re: Trying to draw circles in basic.
Thanks for sharing
Wikipedia has a lot of background: https://en.wikipedia.org/wiki/Midpoint_circle_algorithm
You can use the same algorithm and plot pixels instead of drawing lines, I suppose. I haven't tried.
Wikipedia has a lot of background: https://en.wikipedia.org/wiki/Midpoint_circle_algorithm