Microsoft Small Basic

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

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

' FKF358-2

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 = 150

'Set twist
twist = 10

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

'Set angMax
angMax = 180

'Set Delay
delay = 120

'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
xx1 = Math.Sin(y/amp + ang + 45)*size + set
x2 = Math.Sin(y/amp + ang + 90)*size + set
xx2 = Math.Sin(y/amp + ang + 135)*size + set
x3 = Math.Sin(y/amp + ang + 180)*size + set
xx3 = Math.Sin(y/amp + ang + 225)*size + set
x4 = Math.Sin(y/amp + ang + 270)*size + set
xx4 = Math.Sin(y/amp + ang + 315)*size + set

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

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

If x2 GraphicsWindow.PenColor = "Tomato"
GraphicsWindow.DrawLine(x2,y xx2,y)
EndIf

If xx2 GraphicsWindow.PenColor = "Cyan"
GraphicsWindow.DrawLine(xx2,y x3,y)
EndIf

If x3 GraphicsWindow.PenColor = "Blue"
GraphicsWindow.DrawLine(x3,y xx3,y)
EndIf

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

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

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

EndFor

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

EndFor

' Do it again!
Goto Twist