52. Drawing circles and discs
~~~~~~~~~~~~~~~~~~~~~~~~~
This is a Procedure for drawing circles or solid discs of any size, anywhere
on the screen. You call the Procedure by specifying the X co-ordinate,
(0-1279), and the Y co-ordinate, (0-1023), of the centre, plus the radius,
and lastly a "C" for circle or "D" for disc. The graphics origin is set back
to 0,0 after the circle is drawn, but you can stop this by omitting the VDU29
statement in line 150, if you wish. The example uses Mode 4, but any graphic
Mode is suitable.
10 MODE4:PROCcircle(639,511,400,"C"):PROCcircle(639,511,300,"D")
20 END
100 DEFPROCcircle(X%,Y%,R%,T$):LOCAL Q
110 VDU29,X%;Y%;:FORQ=0 TO PI*41/20 STEP PI/20
120 X%=R%*COS(Q):Y%=R%*SIN(Q)
130 IF Q=0 THEN MOVE X%,Y% ELSE IF T$="C" THEN DRAW X%,Y%
ELSE MOVE 0,0:PLOT 85,X%,Y%
140 NEXT:VDU29,0;0;:ENDPROC
(NB: The Master/Compact have ready-made circle/disc routines)