Microsoft Small Basic

Program Listing: CPZ043
' Triangle Clock 0.1
' Copyright (c) 2013 Nonki Takahashi. All rights reserved.
'
' History:
' 0.1 2013/02/11 Created.
'
GraphicsWindow.BackgroundColor = "Black"
x0 = GraphicsWindow.Width / 2
y0 = GraphicsWindow.Height / 2
hLen = 50
mLen = 100
sLen = 150
For m2 = 1 To 60
If Math.Remainder(m2, 2) = 0 Then
GraphicsWindow.BrushColor = "Gray"
Else
GraphicsWindow.BrushColor = "Black"
EndIf
m1 = m2 - 1
angle = m1 / 60 * 360
x1 = mLen * Math.Sin(Math.GetRadians(angle)) + x0
y1 = -mLen * Math.Cos(Math.GetRadians(angle)) + y0
angle = m2 / 60 * 360
x2 = mLen * Math.Sin(Math.GetRadians(angle)) + x0
y2 = -mLen * Math.Cos(Math.GetRadians(angle)) + y0
GraphicsWindow.FillTriangle(x0, y0, x1, y1, x2, y2)
EndFor
For h2 = 1 To 12
If Math.Remainder(h2, 2) = 0 Then
GraphicsWindow.BrushColor = "Gray"
Else
GraphicsWindow.BrushColor = "Black"
EndIf
h1 = h2 - 1
angle = h1 / 12 * 360
x1 = hLen * Math.Sin(Math.GetRadians(angle)) + x0
y1 = -hLen * Math.Cos(Math.GetRadians(angle)) + y0
angle = h2 / 12 * 360
x2 = hLen * Math.Sin(Math.GetRadians(angle)) + x0
y2 = -hLen * Math.Cos(Math.GetRadians(angle)) + y0
GraphicsWindow.FillTriangle(x0, y0, x1, y1, x2, y2)
EndFor
Timer.Interval = 1000
Timer.Tick = OnTick
Sub OnTick
hour = Clock.Hour
If hour > 12 Then
hour = hour - 12
EndIf
minute = Clock.Minute
second = Clock.Second
angle = (hour / 12 + minute / 720 + second / 43200) * 360
x1 = hLen * Math.Sin(Math.GetRadians(angle)) + x0
y1 = -hLen * Math.Cos(Math.GetRadians(angle)) + y0
angle = (minute / 60 + second / 3600) * 360
x2 = mLen * Math.Sin(Math.GetRadians(angle)) + x0
y2 = -mLen * Math.Cos(Math.GetRadians(angle)) + y0
angle = second / 60 * 360
x3 = sLen * Math.Sin(Math.GetRadians(angle)) + x0
y3 = -sLen * Math.Cos(Math.GetRadians(angle)) + y0
GraphicsWindow.PenWidth = 0
GraphicsWindow.BrushColor = "White"
If tri <> "" Then
Shapes.Remove(tri)
EndIf
tri = Shapes.AddTriangle(x1, y1, x2, y2, x3, y3)
Shapes.SetOpacity(tri, 70)
GraphicsWindow.Title = hour + ":" + minute + ":" + second
EndSub