• Please review our updated Terms and Rules here

Drawing a Solid Circle in Degrees (GWBASIC program)

CP/M User

Veteran Member
Joined
May 2, 2003
Messages
2,986
Location
Back of Burke (Guday!), Australia
Code:
1 ' Draw Circle in Degrees (GWBASIC)
2 ' Public Domain
10 CLS:KEY OFF:SCREEN 2:FOR A=1 TO 360
20 GOSUB 1000
30 XPOS = 160*COS(COSDEG) : YPOS = 80*SIN(SINDEG)
40 LINE (320,100)-(320+XPOS,100+YPOS)
50 NEXT A:WHILE INKEY$<>" ":WEND:SCREEN 0:KEY 
   ON:END
1000 PI=3.141592:COSDEG=A*PI/180 : SINDEG=A*PI/180 : 
     RETURN

---- Notes ----

Okay, so we're drawing a circle in 640x200 screen mode &
this was about as round as I could get it in this resolution
(if it was 640x400 I might of been able to do more with it
in terms of how big & round I could have got it, but this
will do! ;-)

In this program, I've started up a loop & created a subroutine
(line 1000) which calculates the degrees of the Cosine & 
Sine, returns & calculates the SIN & COS of that (which 
obviously gives it it a result in Degrees - even though it's 
still in radians - thanks to the conversion formula, the result
comes out very well! :-)

I've made this program a little bit friendlier (to that of the other 
two I posted a little while ago) - in that at the end of the 
drawning cycle, the program pauses - this is when you can 
press space & it will take the user back to text mode 80x25
(well I hope no-one protests about the 80x25 screen mode,
some of you might be into the 80x50, but if you're using 
GWBASIC which supports 80x50 (mine doesn't - it's so ol'
that it doesn't do EGA! ;-) feel free to change the SCREEN 0
at the end to whatever gets you into 80x50 (or 80x43).

Cheers,
CP/M User.
 
Back
Top