Microsoft Small Basic

Program Listing: QJL661
GraphicsWindow.Title="Analog Clock with Ticks"
GraphicsWindow.Width=220
GraphicsWindow.Height=220
GraphicsWindow.BrushColor="Green"
GraphicsWindow.FillEllipse(10,10,200,200)
GraphicsWindow.BrushColor="Black"
GraphicsWindow.DrawEllipse(10,10,200,200)
GraphicsWindow.PenWidth=5
While 1=1
LenS = Math.Max(87, 92-15*Math.Remainder(Clock.Second, 5))
AngleS = Math.Pi*Clock.Second/30
AngleM = Math.Pi*Clock.Minute/30 + AngleS/60
AngleH = Math.Pi*Clock.Hour/6 + AngleM/60
GraphicsWindow.BrushColor="Green"
GraphicsWindow.FillEllipse(25,25,170,170)
GraphicsWindow.PenColor="LightGreen"
GraphicsWindow.DrawLine(110,110,110+LenS*Math.Sin(AngleS),110-LenS*Math.Cos(AngleS))
GraphicsWindow.PenColor="Black"
GraphicsWindow.DrawLine(110,110,110+75*Math.Sin(AngleM),110-75*Math.Cos(AngleM))
GraphicsWindow.DrawLine(110,110,110+60*Math.Sin(AngleH),110-60*Math.Cos(AngleH))
Program.Delay(500)
EndWhile

'Title: An analog clock.
'Special Feature: after one minute, has Hour Ticks on the face
'Most code is for presentation purposes only
'Can be functionally reproduced in 6 lines

'The Tick Trick:
'LenS (the length of the Second Hand) changes based on the
'current Second, and the program only erases MOST of the
'clock face each redraw. Any part of the second hand outside
'of the erase area stays behind and forms the tick marks.