Page 1 of 1
Trying to draw circles in basic.
Posted: 05 Mar 2019, 04:53
by Gigadave
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
Re: Trying to draw circles in basic.
Posted: 05 Mar 2019, 22:28
by marcelk
This is based on Bresenham's algorithm:
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
I wonder how fast a Commodore 64 can do this in BASIC...
- Screenshot
- Disc.png (56.78 KiB) Viewed 3485 times
Re: Trying to draw circles in basic.
Posted: 06 Mar 2019, 06:44
by Gigadave
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
Re: Trying to draw circles in basic.
Posted: 14 Mar 2019, 07:07
by marcelk
Thanks for sharing
Gigadave wrote: ↑06 Mar 2019, 06:44
Is there a way of drawing an empty circle ?
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