
Animation is integral to many parts of GUIs, including both the fancy effects when things change used in window managers, and of course games.   The core of any animation system is a scheme for periodically changing the display while still remaining responsive to the user.   This task demonstrates this.



Task

Create a window containing the string "Hello World! " (the trailing space is significant).

Make the text appear to be rotating right by periodically removing one letter from the end of the string and attaching it to the front.

When the user clicks on the (windowed) text, it should reverse its direction.




 
Module UseBlink { 
      Def boolean direction=True
      rotating$ =lambda$ a$="Hello World! " (direction as boolean)->{
            =a$
            a$=if$(direction->right$(a$,1)+mid$(a$,1, len(a$)-1), mid$(a$,2)+left$(a$,1))
      }
      Declare MyForm Form
      Declare MyButton Button  Form MyForm
      With MyButton, "Caption" as MyButtonCaption$, "Blink", 200
      Method MyForm,"Move", 1000,1000,6000,4000
      Method MyButton,"Move", 1000,1700,4000,600
      Function MyButton.Blink {
            Rem Stack : Refresh  ' to refresh the console window
            MyButtonCaption$=rotating$(direction)
      }
      Function MyButton.Click {
            direction~
      }
      Function MyForm.Click {
            direction~
      }
      With MyForm, "Title", "Animation"
      Method MyForm, "Show", 1
      Threads Erase
}
UseBlink
 
 