From 57d05ac5dca32e167caed9e56680ba744fe567ca Mon Sep 17 00:00:00 2001 From: Trym Lund Flogard Date: Sun, 20 Feb 2022 14:53:53 +0100 Subject: [PATCH] fix opacity not interpolated in animated brush --- .../Animation/Animators/SolidColorBrushAnimator.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs b/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs index 57f9f3c1a5..b87b2681d6 100644 --- a/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs +++ b/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs @@ -12,6 +12,8 @@ namespace Avalonia.Animation.Animators /// public class ISolidColorBrushAnimator : Animator { + private static readonly DoubleAnimator s_doubleAnimator = new DoubleAnimator(); + public override ISolidColorBrush? Interpolate(double progress, ISolidColorBrush? oldValue, ISolidColorBrush? newValue) { if (oldValue is null || newValue is null) @@ -19,7 +21,9 @@ namespace Avalonia.Animation.Animators return progress >= 0.5 ? newValue : oldValue; } - return new ImmutableSolidColorBrush(ColorAnimator.InterpolateCore(progress, oldValue.Color, newValue.Color)); + return new ImmutableSolidColorBrush( + ColorAnimator.InterpolateCore(progress, oldValue.Color, newValue.Color), + s_doubleAnimator.Interpolate(progress, oldValue.Opacity, newValue.Opacity)); } public override IDisposable BindAnimation(Animatable control, IObservable instance)