// PILLSPIN demo

logo animation
set backcolor = "black"
message "Pillspin." "Line color|Background color|Stop"
set rot = 0
set size = 150
set growing = yes
// logo circarc -90 90
set shadowcolor = "gray(0.8)"

// this loop runs once per animation "frame" 
repeat untilbreak [
  logo linecolor = :shadowcolor
  logo circrotate (calc :rot - 3)
  ellipse :size 80
 
  logo circrotate :rot
  logo linecolor = "red"
  ellipse :size 80
 
  if keypress = 1 [    // handle user button selections..

    if whichkey = "Stop" [ break ]

    elseif whichkey = "Line color" [
      set shadowcolor = (colorchoice "Select a line color")
      say :shadowcolor
      samemessage
      ]

    elseif whichkey = "Background color" [
      logo backcolor = (colorchoice "Select a background color")
      samemessage
      ]
    ]
 
  // wait 5/100th sec then erase the red ellipse
  wait 5      
  eraseshape 

  // go to next ellipse position and size...
  incr rot by 5  
  if :rot >= 360 [ decr rot by 360 ]  
  if :growing = yes [ 
    incr size by 1
    if :size > 500 [ clear  set growing = no ]
    ]
  else [ 
    decr size by 1 
    if :size < 150 [ clear  set growing = yes ]
    ]
]
