Microsoft Small Basic

Program Listing: GQF135
' Kitchen Timer 0.1a
' Copyright (c) 2014 Nonki Takahashi. The MIT License.
'
gw = 598
gh = 428
GraphicsWindow.Title = "Kitchen Timer 0.1a"
DrawKitchenTimer()
AddMinuteHand()
StartTimer()
Sub DrawKitchenTimer
size = 300
GraphicsWindow.BackgroundColor = "SkyBlue"
x = (gw - size) / 2
y = (gh - size) / 2
GraphicsWindow.BrushColor = "White"
GraphicsWindow.FillRectangle(x, y, size, size)
x = (gw - size * 0.9) / 2
y = (gh - size * 0.9) / 2
GraphicsWindow.BrushColor = "SkyBlue"
GraphicsWindow.FillEllipse(x, y, size * 0.9, size * 0.9)
x = (gw - size * 0.7) / 2
y = (gh - size * 0.7) / 2
GraphicsWindow.BrushColor = "White"
GraphicsWindow.FillEllipse(x, y, size * 0.7, size * 0.7)
r2 = size * 0.9 / 2
GraphicsWindow.PenColor = "LightGray"
For m = 0 To 59
If Math.Remainder(m, 10) = 0 Then
r1 = size * 0.7 / 2
Else
r1 = size * 0.8 / 2
EndIf
_a = Math.GetRadians(m * 360 / 60)
x1 = gw / 2 + r1 * Math.Sin(_a)
y1 = gh / 2 + r1 * Math.Cos(_a)
x2 = gw / 2 + r2 * Math.Sin(_a)
y2 = gh / 2 + r2 * Math.Cos(_a)
GraphicsWindow.DrawLine(x1, y1, x2, y2)
EndFor
EndSub
Sub AddMinuteHand
x1 = 0
y1 = size * 0.9
x2 = size * 0.1
y2 = 0
x3 = size * 0.2
y3 = size * 0.9
GraphicsWindow.PenColor = "LightGray"
GraphicsWindow.BrushColor = "White"
hand = Shapes.AddTriangle(x1, y1, x2, y2, x3, y3)
Shapes.Move(hand, gw / 2 - size * 0.1, gh / 2 - size * 0.45)
EndSub
Sub StartTimer
Timer.Interval = 500
Timer.Tick = OnTick
m = 3
EndSub
Sub OnTick
If 0 < m Then
m = m - 0.5 / 60
a = m * 360 / 60
Shapes.Rotate(hand, a)
Else
Timer.Pause()
Sound.PlayBellRing()
EndIf
EndSub