Microsoft Small Basic

Program Listing: FKF358-3
' Twister (v1.5)
' program by tonyrocks
' modded by GoToLoop

' http://social.msdn.microsoft.com/Forums/en-US/smallbasic
'/thread/abc69be0-b2a9-4bb2-b5aa-c652f4258308

' FKF358-3

GraphicsWindow.Title = "Twister"
GraphicsWindow.BackgroundColor = "Black"

GraphicsWindow.Width = 640
GraphicsWindow.Height = 480
gw = GraphicsWindow.Width
gh = GraphicsWindow.Height

set = gw/2 'Set screen offset
size = 170 'Set size
twist = 10 'Set twist
angMax = 180 'Set max angle
delay = 100 'Set Delay

sharp = 10 'Set For y's Step
GraphicsWindow.PenWidth = sharp + 1

'Set color to each line:
colors = "0=DarkRed;1=Red;2=Tomato;3=Cyan;4=DodgerBlue;5=Blue;6=Navy;7=DarkRed;"
colorsIndex = Array.GetItemCount(colors) - 1 '# of colors = # of lines to draw at each row
angleStep = 360/(colorsIndex+1) 'Set angle step diff. for all lines

'Main twister routine
Twist:

For ang=0 To angMax 'Angle loop
amp = Math.Sin(ang)*gh + twist 'Set the amplitude and change it based on gh & ang

For y=0 To gh Step sharp 'Row loop
calc = y/amp + ang 'Pre-calc
For line=0 To colorsIndex 'Line loop

x1 = Math.Sin(calc + angleStep*line )*size + set 'Set coordinates to draw each line
x2 = Math.Sin(calc + angleStep*(line+1))*size + set

If x1 GraphicsWindow.PenColor = colors[line]
GraphicsWindow.DrawLine(x1,y x2,y)
EndIf

EndFor
EndFor

'Delay before clearing the screen:
Program.Delay(delay)
GraphicsWindow.Clear()
EndFor

'Do it again!:
Goto Twist