' This program exported from BASIC Anywhere Machine (Version [5.2.3].[2023.12.16.16.28]) on 2024.04.07 at 19:55 (Coordinated Universal Time)
' Program by Charlie Veniot
' Demonstration of DRAW for creating interesting graphs that have a "spirograph" kind of feel

SCREEN _NEWIMAGE(401,401,17)

aend% =  2880 

DO

  FOR u1% = 0 TO 60 STEP 20

    COLOR INT (RND * 62 + 1)

    afstep# = 0.125
    FOR af# = 0.125 TO 7 STEP afstep#

      FOR spiro_loop_direction% = 1 TO 2 ' 1 = inward, 2 = outward

        u2start% = 5 : u2end% = 75 : u2step% = 5
        FOR u2% = u2start% TO u2end% STEP u2step%
          GOSUB DrawLoop
          IF u2% = 75 AND u2step% = 5 THEN u2start% = 75 : u2end% = 5 : u2step% = - u2step%
          CLS
        NEXT u2%

      NEXT spiro_loop_direction%

      IF af# = 1 AND afstep# = 0.125 THEN afstep# = 0.5
    NEXT af#

  NEXT u1%

LOOP

END

DrawLoop:
  FOR angle# = 0 TO aend% STEP 0.25
    DRAW "B M 200,200"
    DRAW "B TA" + angle# + " U" + ( 119 - u1% )
    spiro_angle# = IFF( spiro_loop_direction% = 1, angle# * af#, aend% - angle# * af# )
    DRAW "B TA" + spiro_angle# + "D " + ( u2% + u1% )
    CIRCLE ( POINT(0), POINT(1) ), 2, , , , , T
  NEXT angle#
  SLEEP 0.05
RETURN