• Please review our updated Terms and Rules here

Drawing a solid circle the hard way (in GWBASIC)

CP/M User

Veteran Member
Joined
May 2, 2003
Messages
2,986
Location
Back of Burke (Guday!), Australia
Code:
10 CLS:SCREEN 2:FOR A=1 TO 360
20 X=50*COS(A):Y=50*SIN(A)
30 LINE(125,115)-(150+X,140+Y)
40 NEXT A

Some Notes:
Code:
Line 10 : Clear Screen
         Set Video Mode (2 : 640x200 mono)
         Begin FOR loop
Line 20 : Calculate X 
         (50 = Circumference of Circle * COS of 1 to 360)
         Calculate Y 
         (50 = Circumference of Circle * SIN of 1 to 360)
Line 30 : Draw Line
         Syntax :- Line(x1,y1)-(x2,y2)
         - divided 50 / 2, since 150 is where our circle 
           starts the centre is around 125 for X1, same
           with Y1 to get 115. 
         - Added 150 to draw complete Circle on Screen 
           for X2
         - Added 140 to draw complete Circle on Screen 
           for Y2.
Line 40 : Go back & add one to FOR loop

BTW, in case you're wonderning, this program has any l
ittle point, except it does some calculations in order to
produce a circle. Well I'd thought it'd be nice to get some
more arrays! :)

Cheers,
CP/M User.
 
Last edited:
"carlsson" wrote:

> Does it really generate a perfect solid circle, i.e.
> not a close/tight fan of beams?

No, not a perfect solid circle, otherwise I would have
titled this thread Drawning a perfect solid circle the
Hard Way (in GWBASIC).

Cheers,
CP/M User.
 
Re: Drawing a solid circle the hard way (in GWBASIC)

Code:
10 CLS:SCREEN 2:FOR A=1 TO 360
20 X=100*COS(A):Y=50*SIN(A)
30 LINE(200,75)-(250+X,100+Y)
40 NEXT A

Suprisingly, no-one asked how to get a rounder circle,
since the others were kinda ovalish. Oh well I guess
it's pretty straightfoward, but here's the code! :)

Cheers,
CP/M User.
 
Last edited:
Re: Drawing a solid circle the hard way (in GWBASIC)

"CP/M User" wrote:

Oh dear, I've got the centre of the circle all stuffed up,
this is the offending line:

Code:
30 LINE(200,75)-(250+X,100+Y)

which should read:

Code:
30 LINE(250,100)-(250+X,100+Y)

it looks a bit better now! :)

Cheers,
CP/M User.
 
Last edited:
Back
Top