Microsoft Small Basic

Program Listing: FKF358-1
' Twister (v1.2)
' by tonyrocks
' remixed by GoToLoop

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

' FKF358-1

GraphicsWindow.Title = "Twister"
GraphicsWindow.BackgroundColor = "Black"
GraphicsWindow.Width = 640
GraphicsWindow.Height = 480
gw = GraphicsWindow.Width
gh = GraphicsWindow.Height

'Set the screen offset
set = gw/2

'Set size
size = 180

'Set twist
twist = 30

'Set Y step
sharpness = 8
GraphicsWindow.PenWidth = sharpness + 1

'Set angMax
angMax = 180

'Set Delay
delay = 150

'Main twister routine
Twist:

For ang = 0 To angMax

'Set the Amplitude and change it based on gh and Ang
amp = Math.Sin(ang)*gh + twist

'Calculate for each row
For y=0 To gh Step sharpness

'Set the coordinates
x1 = Math.Sin(y/amp + ang )*size + set
x2 = Math.Sin(y/amp + ang + 90)*size + set
x3 = Math.Sin(y/amp + ang + 180)*size + set
x4 = Math.Sin(y/amp + ang + 270)*size + set

'Draw each line
If x1 GraphicsWindow.PenColor = "DarkRed"
GraphicsWindow.DrawLine(x1,y x2,y)
EndIf

If x2 GraphicsWindow.PenColor = "Red"
GraphicsWindow.DrawLine(x2,y x3,y)
EndIf

If x3 GraphicsWindow.PenColor = "DarkBlue"
GraphicsWindow.DrawLine(x3,y x4,y)
EndIf

If x4 GraphicsWindow.PenColor = "DarkRed"
GraphicsWindow.DrawLine(x4,y x1,y)
EndIf
EndFor

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

'Increase the Angle
EndFor

' Do it again!
Goto Twist