Microsoft Small Basic

Program Listing: TGT557
' Write a new year greeting animation program
' Coyright © 2017 Nonki Takahashi. The MIT Licnese.
' Last update 2017-12-01

GraphicsWindow.Title = "I wish you A HAPPY NEW YEAR 2018!"
gw = 598
gh = 428
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.BackgroundColor = "Black"
GraphicsWindow.BrushColor = "#001122"
GraphicsWindow.FontBold = "False"
GraphicsWindow.FontName = "Trebuchet MS"
GraphicsWindow.FontSize = 200
GraphicsWindow.DrawText(80, -20, 2018)
GraphicsWindow.BrushColor = "#111111"
GraphicsWindow.FillRectangle(0, gh - 40, gw, 40)
GraphicsWindow.PenWidth = 0
For k = 1 To 8
If Math.Remainder(k, 2) = 0 Then
GraphicsWindow.BrushColor = "#999999"
Else
GraphicsWindow.BrushColor = "#996600"
EndIf
j = 0
For y = gh / 3 To gh - 40 Step 15
j = j + 1
x = 6 * (4.5-k) * Math.SquareRoot(gh - y) + 0.7 * gh - 101.5 * (4.5-k)
AddStar()
EndFor
EndFor
GraphicsWindow.BrushColor = "#55FFFFFF"
size = 4
max = 150
For i = 1 To max
obj[i] = Shapes.AddEllipse(size, size)
x = Math.GetRandomNumber(gw - size)
y = Math.GetRandomNumber(gh - size)
Shapes.Move(obj[i], x, y)
EndFor
Timer.Interval = 200
Timer.Tick = OnTick
While "True"
a = a + 10
If 360 <= a Then
a = a - 360
EndIf
For k = 1 To 8
_a = Math.GetRadians(a + (k - 1) * 77)
op = 40 * Math.Sin(_a) + 50
For j = 1 To 17
For i = 1 To 5
Shapes.SetOpacity(t[k*108+j*6+i], op)
EndFor
EndFor
EndFor
EndWhile

Sub AddStar
a = Math.GetRandomNumber(360)
e = 3
For i = 1 To 5
t[k*108+j*6+i] = Shapes.AddTriangle(-e, -e, e, 0, 0, e)
Shapes.Move(t[k*108+j*6+i], x, y)
Shapes.Rotate(t[k*108+j*6+i], (i - 1) * 72 + a)
EndFor
EndSub

Sub OnTick
For _i = 1 To max
x = Shapes.GetLeft(obj[_i])
y = Shapes.GetTop(obj[_i])
y = y + Math.GetRandomNumber(5)
x = x + Math.GetRandomNumber(7) - 4
If gh < y Then
x = Math.GetRandomNumber(gw - size)
y = y - gh - size
EndIf
Shapes.Move(obj[_i], x, y)
EndFor
EndSub