Int32Animator.cs 789 B

123456789101112131415161718192021222324
  1. // Copyright (c) The Avalonia Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using System;
  4. namespace Avalonia.Animation.Animators
  5. {
  6. /// <summary>
  7. /// Animator that handles <see cref="Int32"/> properties.
  8. /// </summary>
  9. public class Int32Animator : Animator<Int32>
  10. {
  11. const double maxVal = (double)Int32.MaxValue;
  12. /// <inheritdocs/>
  13. public override Int32 Interpolate(double progress, Int32 oldValue, Int32 newValue)
  14. {
  15. var normOV = oldValue / maxVal;
  16. var normNV = newValue / maxVal;
  17. var deltaV = normNV - normOV;
  18. return (Int32)Math.Round(maxVal * ((deltaV * progress) + normOV));
  19. }
  20. }
  21. }