'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()