'Set color to each line:
colors = "0=Maroon;1=DarkRed;2=Red;3=SkyBlue;4=DodgerBlue;5=Blue;6=Navy;7=Indigo;"
colorsIndex = Array.GetItemCount(colors) '# of colors = # of lines to draw at each row
angStep = 360/(colorsIndex) 'angle gap for lines of each color
colorsIndex = colorsIndex - 1 '{Ajusted to For condition}
'Store all calcs in array x[ang][y][line]:
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 ruggy 'Row loop
calc = y/amp + ang 'Pre-calc
For line=0 To colorsIndex 'Coordinates to draw each line
x[ang][y][line] = Math.Round( Math.Sin(calc + angStep*line) * size ) + set
EndFor
x[ang][y][line] = x[ang][y][0] 'extra redundant line = 1st line
EndFor
EndFor
GraphicsWindow.TextInput = KeyPressed 'Turns pause & exit keys on
GraphicsWindow.MouseDown = MousePressed 'Same for mouse clicks
'Main twister routine
Twist:
For ang=0 To angMax
While isPaused
Program.Delay(150) 'Resume/Halt execution by key presses
EndWhile
GraphicsWindow.Title = "Twister --- Angle = " + ang
Program.Delay(delay) 'Delay before clearing the screen:
GraphicsWindow.Clear()
For y=0 To gh Step ruggy
xx = x[ang][y] 'Create a 1D sub-array outta 3D x[ang][y][line]
x1 = xx[0] '1st horizontal coordinate
For line=0 To colorsIndex
x2 = xx[line+1] 'Destination horizontal coordinate
If x1
GraphicsWindow.PenColor = colors[line]
GraphicsWindow.DrawLine(x1,y x2,y)
EndIf
x1 = x2 'Now 1st coordinate = last used 2nd coordinate
EndFor
EndFor
EndFor
'Do it again!:
Goto Twist
'Pause animation
Sub KeyPressed
If GraphicsWindow.LastKey = "Escape" Then
Sound.PlayClickAndWait()
Program.End()
ElseIf isPaused Then
isPaused = "False"
Else
isPaused = "True"
EndIf