PDA

View Full Version : Drawing a solid circle the hard way (in GWBASIC)

CP/M User
January 11th, 2004, 11:22 PM
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:
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.

carlsson
January 12th, 2004, 05:52 AM
Does it really generate a perfect solid circle, i.e. not a close/tight fan of beams?

CP/M User
January 12th, 2004, 01:07 PM
"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.

CP/M User
January 16th, 2004, 09:36 PM
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.

CP/M User
January 31st, 2004, 07:08 PM
"CP/M User" wrote:

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

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