Demo - Simulation of Leap Year Calculation: PLFS370.000
GraphicsWindow.Title = "Leap Year Simulation" ' PLFS370.000'
GraphicsWindow.Height = 800
GraphicsWindow.Width = 800
year = 2022
center = 392
radius = 291
pin = 310
daystep = 2 * Math.Pi / 365.24219
uni =LDShapes.BrushGradient("1=gold;2=Yellow;3=black;4=black;5=black;6=black;7=black;8=black;9=navy;10=black;11=black;12=black" , "")
earth=LDShapes.BrushGradient("1=white;2=white;3=lime;4=green;5=brown;6=saddlebrown;7=blue;8=blue;9=white;10=white" , "DD")
bullet=LDShapes.BrushGradient("3=white;1=white;2=blue" , "DD")
LDGraphicsWindow.BackgroundBrush(uni)
board = Shapes.AddText(year)
Shapes.Move(board,center-7,66)
planet = Shapes.AddEllipse(18,18)
ball = Shapes.AddEllipse(16,16)
LDShapes.BrushShape(planet,earth)
LDShapes.BrushShape(ball,bullet)
LDShapes.Move(planet,center,center-pin)
x=center + Math.Sin(Math.Pi*1.999)*radius
y=center - Math.Cos(Math.Pi*1.999)*radius
LDShapes.Move(ball,x,y)
Program.Delay(1000)
x=392
y=101
LDShapes.Move(ball,x,y)
Position = 2 * Math.Pi
While 1=1
For i = 1 to 365
Position = Position + daystep
x=center + Math.Sin(Position)*radius
y=center - Math.Cos(Position)*radius
LDShapes.Move(ball,x,y)
Program.Delay(1)
EndFor
dby4 = Math.Remainder(year, 4)
dby100 = Math.Remainder(year, 100)
dby400 = Math.Remainder(year, 400)
If (dby4 = 0) AND (dby100 <> 0 OR dby400 = 0 ) Then
Position = Position + daystep
x=center + Math.Sin(Position)*radius
y=center - Math.Cos(Position)*radius
LDShapes.Move(ball,x,y)
EndIf
xpin = center + Math.Sin(Position)*pin
ypin = center - Math.Cos(Position)*pin
LDShapes.Move(planet,xpin,ypin)
Program.Delay(1)
year = year + 1
Shapes.SetText(board,year)
EndWhile