Private Sub AnimateHeart
Dim SmallSize As Int = 100dip
Dim LargeSize As Int = 130dip
Dim cx = imgHeart.Left + imgHeart.Width / 2, cy = imgHeart.Top + imgHeart.Height / 2 As Int
Dim StartTime As Long = DateTime.Now
Do While True
Dim PulseIntervalMs As Int = 60000 / RatePerMinute
Dim x As Float = ((DateTime.Now - StartTime) Mod PulseIntervalMs) / PulseIntervalMs
Dim size As Float
If x <= 0.5 Then
size = SmallSize + (LargeSize - SmallSize) * x * 2 'growing
Else
size = LargeSize - (LargeSize - SmallSize) * (x - 0.5) * 2 'shrinking
End If
imgHeart.SetLayoutAnimated(0, cx - size / 2, cy - size / 2, size, size)
Sleep(10)
Loop
End Sub