UInt32Animator.cs 631 B

123456789101112131415161718192021
  1. using System;
  2. namespace Avalonia.Animation.Animators
  3. {
  4. /// <summary>
  5. /// Animator that handles <see cref="UInt32"/> properties.
  6. /// </summary>
  7. public class UInt32Animator : Animator<UInt32>
  8. {
  9. const double maxVal = (double)UInt32.MaxValue;
  10. /// <inheritdocs/>
  11. public override UInt32 Interpolate(double progress, UInt32 oldValue, UInt32 newValue)
  12. {
  13. var normOV = oldValue / maxVal;
  14. var normNV = newValue / maxVal;
  15. var deltaV = normNV - normOV;
  16. return (UInt32)Math.Round(maxVal * ((deltaV * progress) + normOV));
  17. }
  18. }
  19. }