Microsoft Small Basic

Program Listing: ngm188
init()
Timer.Tick=demo
Timer.Interval=1000
Timer.Resume()
DEMO()

Sub DEMO
sANGLE=360*Clock.Second/w_mAX
Move_second()
mANGLE=360*(Clock.minute+Clock.Second/w_max)/w_mAX
Move_minute()
hANGLE=5*360*(Clock.Hour+Clock.minute/w_max+Clock.Second/w_max/w_max)/w_mAX
Move_Hour()
GraphicsWindow.Title=(clock.Date+" "+Clock.Time)
If clock.second=0 Then
photo()
endif
ENDSUB

Sub Move_second
dsx=(DR/4-DR/2*0.1)*math.Cos(Math.GetRadians(sangle-90)) ' 44/2 ..... center of arrow length
dsy=(DR/4-DR/2*0.1)*math.sin(Math.GetRadians(sangle-90))
Shapes.Move(blc[4],x+DR/2+dsx-wr,y+dsy+0.1*DR/2+DR/4-wr)
Shapes.Rotate(blc[4],sangle)
EndSub

Sub Move_minute
dmx=0.75/0.8*(DR/4-DR/2*0.125)*math.Cos(Math.GetRadians(mangle-90)) ' 44/2 ..... center of arrow length
dmy=0.75/0.8*(DR/4-DR/2*0.125)*math.sin(Math.GetRadians(mangle-90))
Shapes.Move(blc[3],x+DR/2+dmx-wr,y+dmy+0.125*DR/2+DR/4-wr)
Shapes.Rotate(blc[3],mangle)
EndSub

Sub Move_hour
dhx=0.7/0.8*(DR/4-DR/2*0.15)*math.Cos(Math.GetRadians(hangle-90)) ' 44/2 ..... center of arrow length
dhy=0.7/0.8*(DR/4-DR/2*0.15)*math.sin(Math.GetRadians(hangle-90))
Shapes.Move(blc[2],x+DR/2+dhx-wr,y+dhy+0.15*DR/2+DR/4-wr)
Shapes.Rotate(blc[2],hangle)
EndSub

Sub scaling
GraphicsWindow.BrushColor="Yellow"
GraphicsWindow.FontSize=12
For j=1 To 60
angle=360/60*j
scx=DR/2*math.Cos(math.GetRadians(angle-90))
scY=DR/2*math.sin(math.GetRadians(angle-90))
scm[j]=Shapes.AddRectangle(2,5) ' narrow mark
If Math.Remainder(j,5)=0 Then ' 5 pitch
Shapes.Remove(scm[j])
scm[j]=Shapes.AddRectangle(5,5) ' wide mark
sct[j]=Shapes.AddText(math.Floor(j/5))
Shapes.Move(sct[j],X+DR/2+0.85*scx-6,Y+DR/2+0.85*scy-7)
EndIf
Shapes.Move(scm[j],X+DR/2+scx-1,Y+DR/2+scy-1)
Shapes.Rotate(scm[j],angle)
EndFor
EndSub

Sub init
X=20
Y=20
DR=208
GraphicsWindow.Hide()
GraphicsWindow.BackgroundColor="Teal"
photo()
GraphicsWindow.Width=250
GraphicsWindow.Height=250
GraphicsWindow.Top=20
GraphicsWindow.Left=50
GraphicsWindow.BrushColor="Red"
w_mAX=60 ' full scale
face() ' draw analoguebalance
scaling()
GraphicsWindow.Show()
EndSub

Sub face
wr=3
'------------------------ Hour Arrow -------------------------
GraphicsWindow.BrushColor="DarkGreen"
GraphicsWindow.PenColor="DarkGreen"
blc[2]= Shapes.AddTriangle(wr,0,0,DR/2*0.7,2*wr,DR/2*0.7) ' <----- Hour arrow
'------------------------ Minute Arrow -------------------------
GraphicsWindow.BrushColor="Navy"
GraphicsWindow.PenColor="Navy"
blc[3]= Shapes.AddTriangle(wr,0,0,DR/2*0.75,2*wr,DR/2*0.75) ' <----- Minute arrow
'------------------------ second Arrow -------------------------
GraphicsWindow.BrushColor="Red"
GraphicsWindow.PenColor="Red"
blc[4]= Shapes.AddTriangle(wr,0,0,DR/2*0.8,2*wr,DR/2*0.8) ' <----- Second arrow
blc[5]= Shapes.AddEllipse(15,15)
GraphicsWindow.BrushColor="Yellow"
'---------------------------------------------------------
Shapes.Move(blc[4],X+DR/2-wr,Y) ' arrow
Shapes.Move(blc[5],X+DR/2-7.5,Y+DR/2-7.5)
GraphicsWindow.PenColor="Yellow"
EndSub

Sub photo
a= Flickr.GetRandomPicture("cat") ' get a photo from Flickr
GraphicsWindow.DrawResizedImage(a,0,0,250,250)
EndSub