Microsoft Small Basic

Program Listing: RBN002-0
' Turtle Flash - RBN002-0
' Copyright (c) 2014 Nonki Takahashi. MIT License.
'
GraphicsWindow.Title = "Turtle Flash"
gw = 598
gh = 428
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
dw = Desktop.Width
dh = Desktop.Height
GraphicsWindow.Left = (dw - gw) / 2
GraphicsWindow.Top = (dh - gh) / 2
Turtle.Show()
Turtle.PenUp()
x1 = gw / 2
y1 = gh / 2
Turtle.MoveTo(x1, y1)
For i = 1 To 10
Turtle.Angle = Turtle.Angle / 2
Program.Delay(100)
EndFor
bg = "Gray"
GraphicsWindow.BrushColor = "White"
GraphicsWindow.PenWidth = 0
rect = Shapes.AddRectangle(gw, gh)
Shapes.SetOpacity(rect, 0)
corner = "1= 0, 0;2= 0,428;3=598,428;4=598, 0;"
GraphicsWindow.BackgroundColor = bg
GraphicsWindow.PenColor = "White"
GraphicsWindow.PenWidth = 1
GraphicsWindow.BrushColor = bg
While "True"
For i = 1 To 100
For j = 1 To 5
DrawLine()
EndFor
Shapes.SetOpacity(rect, i)
Program.Delay(10)
EndFor
Program.Delay(1000)
GraphicsWindow.FillRectangle(0, 0, gw, gh)
For i = 100 To 0 Step -1
Shapes.SetOpacity(rect, i)
Program.Delay(10)
EndFor
Program.Delay(4000)
EndWhile
Sub DrawLine
r = 128
g = Math.GetRandomNumber(127) + 128
b = Math.GetRandomNumber(127) + 128
GraphicsWindow.PenColor = GraphicsWindow.GetColorFromRGB(r, g, b)
i3 = Math.GetRandomNumber(4)
i4 = i3 + (Math.GetRandomNumber(2) * 2 - 3)
If i4 < 1 Then
i4 = 4
ElseIf 4 i4 = 1
EndIf
x3 = Text.GetSubText(corner[i3], 1, 3)
y3 = Text.GetSubTextToEnd(corner[i3], 5)
x4 = Text.GetSubText(corner[i4], 1, 3)
y4 = Text.GetSubTextToEnd(corner[i4], 5)
f = (Math.GetRandomNumber(1001) - 1) / 1000
x2 = x3 * f + x4 * (1 - f)
y2 = y3 * f + y4 * (1 - f)
GraphicsWindow.DrawLine(x1, y1, x2, y2)
EndSub