' This program exported from BASIC Anywhere Machine (Version [5.2.3].[2023.12.16.16.28]) on 2024.05.07 at 02:51 (Coordinated Universal Time)
' Program by Charlie Veniot
' Demonstrating a recursive subroutine.  Also demonstrating the use of DRAW with angle to get point positions to draw the outline of circles (using CIRCLE to draw each point)

SCREEN _NEWIMAGE( 600, 600, 17 )
DECLARE SUB drawCircle( x%, y%, radius%, level%, dir$ )
DIM stepval%(1 TO 6) = {45,18,10,5,3,2}

DO 
  drawCircle( INT(_WIDTH/2), INT(_HEIGHT/2), INT(_WIDTH/2 - 3), 6, "L" )
  drawCircle( INT(_WIDTH/2), 100, 90, 4, "U" )
  drawCircle( INT(_WIDTH/2), YMAX - 100, 90, 4, "D" )
  SLEEP 1
LOOP


SUB drawCircle( x%, y%, radius%, level%, dir$ )
  DIM a%
COLOR INT( RND * 30 + 33 )

  FOR a% = 0 TO 359 STEP stepval%( level% )
    DRAW "B M " + x% + "," + y%
    DRAW "B TA" + a% + " " + dir$ + radius%
    CIRCLE (POINT(0),POINT(1)),2, , , , ,T
    IF a% MOD 180 = 0 AND level% > 1 THEN
      DRAW "B M " + x% + "," + y%
      DRAW "B TA" + a% + " " + dir$ + INT(radius%/2)
      CALL drawCircle( POINT(0), POINT(1), INT(radius%/2), ( level% - 1 ), (dir$) ) 
    END IF
    IF A% MOD 1 = 0 THEN SLEEP 0.05
  NEXT A%

END SUB