' This program exported from BASIC Anywhere Machine (Version [5.2.3].[2026.04.20.03.05]) on 2026.04.26 at 02:07 (Coordinated Universal Time)
' Program by Charlie Veniot
' The result of wondering:
' What if I drew circles at each end of a piston, and that piston moved up and down a fixed point on the screen.
' And then made that piston go up and down.
' Then, what if I made the fixed point the center of a circle, and then drew similar pistons at different angles in that circle.
' And then made all the pistons go "up and down".
' And then rotated the circle of pistons around the axis of that circle.
' And all of that led to this program.'

alert("At any time, touch/click the screen, then release the touch/click, to restart the program with a new random setup.")
sD% = 521 ' screen dimension

nodePmax% = (sD% - 1) / 2 - 10
nodePmin% = 10

STRUCTURE piston
  endPos%
  direction%
  radius%
  color#
END STRUCTURE

DIM s(1 TO 360) AS piston

SCREEN _NEWIMAGE( sD%, sD%, 27 )

🏁🏁🏁AppRestart🏁🏁🏁:

  CLS

  br% = INT( RND * 51 ) + 30
  bg% = INT( RND * 51 ) + 30
  bb% = INT( RND * 51 ) + 30
  iPmax% = nodePmax%
  thisStep% = INT( RND * 14 ) + 2
  FOR i% = 1 TO 360
    badj% = INT( RND * 176 )
    s(i%).endPos% = iPmax%
    s(i%).direction% = -1
    c% = INT(RND*246) + 10
    s(i%).color# = _RGB( IFF( br% < 60, br%, br% + badj% ), _
                         IFF( bg% < 60, bg%, bg% + badj% ), _
                         IFF( bb% < 60, bb%, bb% + badj% ) )
    s(i%).radius% = INT(RND*41) + 3
  NEXT i%

  a% = 0
  swirl% = INT(RND*3)
  🔶LoopStart:
     FOR i% = 1 TO 360
       IF INT(RND * 8) = 0 THEN s(i%).endPos% = s(i%).endPos% + s(i%).direction%
       IF NOT BETWEEN( s(i%).endPos%, nodePmin%, nodePmax% ) THEN s(i%).direction% = - s(i%).direction%
     NEXT i%
     GOSUB 💠DrawEverything
     SLEEP 0.01
     a% = a% + 1
     IF swirl% > 0 THEN CLS
     IF _MOUSEBUTTON THEN WHILE _MOUSEBUTTON : WEND : GOTO 🏁🏁🏁AppRestart🏁🏁🏁
  GOTO 🔶LoopStart

END 

💠DrawEverything:

  FOR i% = 1 TO 360  STEP thisStep%
  
    COLOR s(i%).color#

    DRAW "TA" + ( i% + a% )

    DRAW "BM " + ( ( sD% - 1 ) / 2 ) + "," + ( ( sD% - 1 ) / 2 )
    DRAW "BU" + ( s(i%).endPos% )
    CIRCLE (POINT(0), POINT(1)), s(i%).radius%, , , , ,T

    DRAW "BM " + ( ( sD% - 1 ) / 2 ) + "," + ( ( sD% - 1 ) / 2 )
    DRAW "BD" + ( nodePmax% - s(i%).endPos%  )
    CIRCLE (POINT(0), POINT(1)), s(i%).radius%, , , , ,T
    
  NEXT i%

RETURN