' This program exported from BASIC Anywhere Machine (Version [5.2.3].[2026.05.16.03.15]) on 2026.06.28 at 05:45 (Coordinated Universal Time)
' This program by Charlie Veniot
' creates random geometric mandalas in an infinte loop
' using DRAW statements to get plot points for drawing regular polygons that define the mandalas

ALERT( "Pause the program by clicking/touching (and holding that click/touch of) the screen.  Release the click/touch to resume the program.")

DIM iA%, d% = 300, iA_step%, A_step%

NewGraph:

DO
iA_step% = INT(RND * 36) + 6
LOOP UNTIL 360 MOD iA_step% = 0

DO
A_step% = INT(RND * 91) + 10
LOOP UNTIL 360 MOD A_step% = 0

SUB DrawRegularPolygon(cx%,cy%)
    DIM A%, xnow%, ynow%, xlast%, ylast%
    FOR A% = 0 TO 360 STEP A_step%
        DRAW "BM" + cx% + "," + cy%
        DRAW "TA" + ( A% + iA% )
        DRAW "BD" + (INT(d%/2))
        xnow% = POINT(0) : ynow% = POINT(1)
        IF A% > 0 THEN LINE (xnow%,ynow%) TO (xlast%, ylast%)
        xlast% = xnow% : ylast% = ynow%

    NEXT A%
END SUB


screen _newimage(d%*2 + 1,d%*2 + 1,17 )

FOR iA% = 0 TO 359 STEP iA_step%
    DRAW "BM" + d% + "," + d%
    DRAW "TA" + iA%
    DRAW "BU" + (INT(d%/2))
    CALL DrawRegularPolygon(POINT(0),POINT(1))
        SLEEP 0.05
NEXT iA%

c% = INT(RND*62) + 1
FOR n% =  d% * 2 TO 10 STEP -21
c% = INT(RND*62) + 1
FOR A# = 0 TO 359 STEP 0.25
    DRAW "BM" + d% + "," + d%
    DRAW "TA" + A#
    DRAW "BU" + (n%)
    IF POINT(POINT(0),POINT(1)) = 0 THEN PAINT(POINT(0),POINT(1)), c%,63
NEXT A%
    SLEEP 0.01
NEXT n%
SLEEP 5
WHILE _MOUSEBUTTON : WEND
GOTO NewGraph