diff --git a/src/Avalonia.Animation/AnimationsEngine`1.cs b/src/Avalonia.Animation/AnimationsEngine`1.cs index 156056d765..e724fe52d5 100644 --- a/src/Avalonia.Animation/AnimationsEngine`1.cs +++ b/src/Avalonia.Animation/AnimationsEngine`1.cs @@ -39,10 +39,10 @@ namespace Avalonia.Animation public AnimationsEngine(Animation animation, Animatable control, Animator animator, Action OnComplete, Func Interpolator) { - if (animation.SpeedRatio <= 0 || DoubleUtils.AboutEqual(animation.SpeedRatio, 0)) + if (animation.SpeedRatio <= 0) throw new InvalidOperationException("Speed ratio cannot be negative or zero."); - if (animation.Duration.TotalSeconds <= 0 || DoubleUtils.AboutEqual(animation.Duration.TotalSeconds, 0)) + if (animation.Duration.TotalSeconds <= 0) throw new InvalidOperationException("Duration cannot be negative or zero."); _parent = animator; diff --git a/src/Avalonia.Animation/Animator`1.cs b/src/Avalonia.Animation/Animator`1.cs index 77d761ce4c..2c95571dc8 100644 --- a/src/Avalonia.Animation/Animator`1.cs +++ b/src/Avalonia.Animation/Animator`1.cs @@ -59,12 +59,12 @@ namespace Avalonia.Animation int kvCount = _convertedKeyframes.Count; if (kvCount > 2) { - if (DoubleUtils.AboutEqual(t, 0.0) || t < 0.0) + if (t <= 0.0) { firstCue = _convertedKeyframes[0]; lastCue = _convertedKeyframes[1]; } - else if (DoubleUtils.AboutEqual(t, 1.0) || t > 1.0) + else if (t >= 1.0) { firstCue = _convertedKeyframes[_convertedKeyframes.Count - 2]; lastCue = _convertedKeyframes[_convertedKeyframes.Count - 1]; @@ -143,11 +143,11 @@ namespace Avalonia.Animation // Check if there's start and end keyframes. foreach (var frame in _convertedKeyframes) { - if (DoubleUtils.AboutEqual(frame.Cue.CueValue, 0.0)) + if (frame.Cue.CueValue == 0.0d) { hasStartKey = true; } - else if (DoubleUtils.AboutEqual(frame.Cue.CueValue, 1.0)) + else if (frame.Cue.CueValue == 1.0d) { hasEndKey = true; } diff --git a/src/Avalonia.Animation/Utils/DoubleUtils.cs b/src/Avalonia.Animation/Utils/DoubleUtils.cs deleted file mode 100644 index d2e74376a3..0000000000 --- a/src/Avalonia.Animation/Utils/DoubleUtils.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) The Avalonia Project. All rights reserved. -// Licensed under the MIT license. See licence.md file in the project root for full license information. - -using System; - -namespace Avalonia.Animation.Utils -{ - internal static class DoubleUtils - { - internal static bool AboutEqual(double x, double y) - { - double epsilon = Math.Max(Math.Abs(x), Math.Abs(y)) * 1E-15; - return Math.Abs(x - y) <= epsilon; - } - } -} diff --git a/src/Avalonia.Animation/Utils/EasingUtils.cs b/src/Avalonia.Animation/Utils/EasingUtils.cs index d07ec3cdf4..1a7688cace 100644 --- a/src/Avalonia.Animation/Utils/EasingUtils.cs +++ b/src/Avalonia.Animation/Utils/EasingUtils.cs @@ -13,6 +13,6 @@ namespace Avalonia.Animation.Utils /// /// Half of /// - internal static double HALFPI = Math.PI / 2d; + internal const double HALFPI = Math.PI / 2d; } }