' This program exported from BASIC Anywhere Machine (Version [5.2.3].[2023.12.16.16.28]) on 2024.04.20 at 18:22 (Coordinated Universal Time)
' This port and mod by Charlie Veniot
' of an sVB (aka Small Visual Basic) program by "Small Visual Basic is An Educational Programming Language
' as posted at https://www.facebook.com/groups/2057165187928233/posts/3618985041746232/?comment_id=3619152395062830&reply_comment_id=3619159728395430)

r# = _PI / 180
DECLARE SUB DrawShape( ox, oy )
DEF FN rndrgb(v%) = _RGB( INT( RND * v% ), INT( RND * v% ), INT( RND * v% ) )

SCREEN _NEWIMAGE( 1240, 620, 27)

_ALERT( "At any time, pause the program by clicking/touching the screen.\n\n" _
        + "At completion of a drawing cycle, the next new drawing cycle begins after 5 seconds." )

➔DrawCycleStart:
  COLOR , rndrgb( 55 )
  r1step% = 1 + INT( RND * 23 )
  r1start% = 1 + INT( RND * 49 )
  CLS
  imax% = 3 + INT(RND*18)
  FOR i = 1 TO imax%
    COLOR rndrgb( 256 )
    CALL DrawShape( 190  + INT( RND * ( 1239 - 380 ) ) , 10 + INT( RND * 231 ) )
  NEXT i
  FOR i = 0 TO 5
    CIRCLE (12,12),12-(i*2), IFF(i MOD 2 = 0, &hffffff, &hff0000), , , ,T
    CIRCLE (12,12),11-(i*2), IFF(i MOD 2 = 0, &hffffff, &hff0000), , , ,T
    IF _MOUSEBUTTON THEN WHILE _MOUSEBUTTON : WEND  
    SLEEP 1
  NEXT i
  IF _MOUSEBUTTON THEN WHILE _MOUSEBUTTON : WEND  
GOTO ➔DrawCycleStart

Sub DrawShape( ox, oy )
  DIM c%
  oy = oy + 180
  FOR r1 = r1start% TO 50 STEP r1step%
    c% = 0
    FOR a = -_PI TO _PI STEP r#
      x = a / r#
      y = r1 * SIN( a ) * COS( 3 * a )
      PLOT( ox + x, oy - y)
      PLOT( ox + x, oy + y)
      PLOT( ox - y, oy + x)
      PLOT( ox + y, oy + x)
      PLOT( ox - x, oy - y)
      PLOT( ox - x, oy + y)
      PLOT( ox - y, oy - x)
      PLOT( ox + y, oy - x)
      c% = c% + 1
      IF c% MOD INT(125/r1step%) = 0 THEN SLEEP 0.001
      IF _MOUSEBUTTON THEN WHILE _MOUSEBUTTON : WEND  
    NEXT a
  NEXT r1
END SUB