## Trying to draw circles in basic.

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice.
Posts: 10
Joined: 03 Mar 2019, 10:50

### Trying to draw circles in basic.

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

marcelk
Posts: 251
Joined: 13 May 2018, 08:26

### Re: Trying to draw circles in basic.

This is based on Bresenham's algorithm:

Code: Select all

``````'Draw filled circle with
'LINE statements
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 221 times

Posts: 10
Joined: 03 Mar 2019, 10:50

### 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

marcelk
Posts: 251
Joined: 13 May 2018, 08:26

### Re: Trying to draw circles in basic.

Thanks for sharing