# Microsoft Small Basic

Program Listing:
' Challenge of the month October 2012 Crescent area by NaochanON

gui()

While "true"
For k=0 to 9
plot()
GraphicsWindow.Title=" Lap % = "+math.Floor(XLap*100*10)/10 +" %" + " Crescent area = "+math.Round(Yarea*100*10)/10+" % "
Program.Delay(2000)
endfor
scatter()
Program.Delay(3000)
Shapes.Animate(DMoon,250,5,3000)
endwhile

Sub plot
X= 130+45*2*XLap*6
Y=100+100*(1-Yarea)*4
GraphicsWindow.BrushColor="Yellow"
GraphicsWindow.PenColor="Yellow"
Shapes.Remove(mark[k])
Shapes.Animate(mark[k],X,Y,1500)
EndSub

sub scatter
For k=0 To 9
Shapes.Animate( mark[k],600-Math.GetRandomNumber(1200),500+Math.GetRandomNumber(1200),1500)
EndFor
EndSub

sub gui
GraphicsWindow.Top=50
GraphicsWindow.Width=800
GraphicsWindow.Height=600
GraphicsWindow.BackgroundColor="darkgreen"
GraphicsWindow.BrushColor="Black"
GraphicsWindow.PenColor="Black"
GraphicsWindow.FillRectangle(100,100,600,400)
GraphicsWindow.BrushColor="Yellow"
GraphicsWindow.PenColor="Yellow"
' ---------------- show message ------------------------------------
LF= Text.GetCharacter(10)
msg=" s=( Πr^2/2*θ/Π - rcos(θ)*rsin(θ)/2 )"+LF
msg=msg+" CS=Πr^2 - 4*s"+LF+LF
msg=msg+" =r^2*( Π - 2*(θ-cos(θ)*sin(θ)) )"+LF
msg=msg+" Crescent %= CS/Πr^2 *100"+LF
msg=msg+" = ( Π-2*(θ-cos(θ)*sin(θ)) ) /Π*100"+LF
msg=msg+" = ( 1- 2*(θ-cos(θ)*sin(θ)) /Π )*100"+LF+LF
msg=msg+" X Lap = r*(1-cos(θ))*2/2r*100"+LF
msg=msg+" = (1-cos(θ))*100"
Shapes.Move(smsg,450,120)
' ---------------- graph ------------------------------------
GraphicsWindow.FontSize=20
For i=0 To 5
GraphicsWindow.DrawText(50,90+i*80,100-i*20)
GraphicsWindow.fillRectangle(100,100+i*80,10,4)
EndFor
GraphicsWindow.DrawText(50,60," (%)")
For J=0 To 10
GraphicsWindow.DrawText(120+j*60*90/100,500,j*10)
GraphicsWindow.fillRectangle(130+j*60*90/100,490,4,10)
EndFor
GraphicsWindow.DrawText(250,530," Lap (%) ")
' ---------------- Light Moon and Dark Moon --------------------------