From d084cf8fc7d2bf35fcf387eac3bf4b9f17cdbc9a Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 10 May 2021 14:49:54 +0100 Subject: [PATCH] dont break api. --- src/Avalonia.Animation/AnimationInstance`1.cs | 2 +- .../Animators/Animator`1.cs | 2 +- .../Animators/SolidColorBrushAnimator.cs | 21 ++++++++++++------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/Avalonia.Animation/AnimationInstance`1.cs b/src/Avalonia.Animation/AnimationInstance`1.cs index 6f601a3e13..77547451bb 100644 --- a/src/Avalonia.Animation/AnimationInstance`1.cs +++ b/src/Avalonia.Animation/AnimationInstance`1.cs @@ -12,7 +12,7 @@ namespace Avalonia.Animation /// Handles interpolation and time-related functions /// for keyframe animations. /// - internal class AnimationInstance : SingleSubscriberObservableBase + internal class AnimationInstance : SingleSubscriberObservableBase { private T _lastInterpValue; private T _firstKFValue; diff --git a/src/Avalonia.Animation/Animators/Animator`1.cs b/src/Avalonia.Animation/Animators/Animator`1.cs index 0660440e30..679c879935 100644 --- a/src/Avalonia.Animation/Animators/Animator`1.cs +++ b/src/Avalonia.Animation/Animators/Animator`1.cs @@ -116,7 +116,7 @@ namespace Avalonia.Animation.Animators clock ?? control.Clock ?? Clock.GlobalClock, onComplete, InterpolationHandler); - return control.Bind((AvaloniaProperty)Property, instance, BindingPriority.Animation); + return control.Bind(Property, instance, BindingPriority.Animation); } /// diff --git a/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs b/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs index 9077ef2e6c..dd1580e3b3 100644 --- a/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs +++ b/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs @@ -1,4 +1,5 @@ -using Avalonia.Media; +using System; +using Avalonia.Media; using Avalonia.Media.Immutable; namespace Avalonia.Animation.Animators @@ -6,14 +7,20 @@ namespace Avalonia.Animation.Animators /// /// Animator that handles values. /// - public class SolidColorBrushAnimator : Animator + public class ISolidColorBrushAnimator : Animator { - public override IBrush Interpolate(double progress, IBrush oldValue, IBrush newValue) + public override ISolidColorBrush Interpolate(double progress, ISolidColorBrush oldValue, ISolidColorBrush newValue) { - if (!(oldValue is ISolidColorBrush oldSCB) || !(newValue is ISolidColorBrush newSCB)) - return Brushes.Transparent; - - return new ImmutableSolidColorBrush(ColorAnimator.InterpolateCore(progress, oldSCB.Color, newSCB.Color)); + return new ImmutableSolidColorBrush(ColorAnimator.InterpolateCore(progress, oldValue.Color, newValue.Color)); + } + } + + [Obsolete] + public class SolidColorBrushAnimator : Animator + { + public override SolidColorBrush Interpolate(double progress, SolidColorBrush oldValue, SolidColorBrush newValue) + { + return new SolidColorBrush(ColorAnimator.InterpolateCore(progress, oldValue.Color, newValue.Color)); } } }