Browse Source

Remove animator

pull/6344/head
Wiesław Šoltés 5 years ago
parent
commit
a887a412b3
  1. 13
      src/Avalonia.Visuals/Animation/Animators/GradientBrushAnimator.cs
  2. 20
      src/Avalonia.Visuals/Animation/Animators/MatrixAnimator.cs
  3. 11
      src/Avalonia.Visuals/Animation/Transitions/MatrixTransition.cs
  4. 7
      src/Avalonia.Visuals/Matrix.cs

13
src/Avalonia.Visuals/Animation/Animators/GradientBrushAnimator.cs

@ -16,8 +16,6 @@ namespace Avalonia.Animation.Animators
{
private static readonly RelativePointAnimator s_relativePointAnimator = new RelativePointAnimator();
private static readonly DoubleAnimator s_doubleAnimator = new DoubleAnimator();
private static readonly TransformAnimator s_transformAnimator = new TransformAnimator();
private static readonly MatrixAnimator _matrixAnimator = new MatrixAnimator();
public override IGradientBrush? Interpolate(double progress, IGradientBrush? oldValue, IGradientBrush? newValue)
{
@ -32,7 +30,7 @@ namespace Avalonia.Animation.Animators
return new ImmutableRadialGradientBrush(
InterpolateStops(progress, oldValue.GradientStops, newValue.GradientStops),
s_doubleAnimator.Interpolate(progress, oldValue.Opacity, newValue.Opacity),
oldValue.Transform is { } && newValue.Transform is { } ? InterpolateTransform(progress, oldValue.Transform, newValue.Transform) : null,
oldValue.Transform is { } ? new ImmutableTransform(oldValue.Transform.Value) : null,
oldValue.SpreadMethod,
s_relativePointAnimator.Interpolate(progress, oldRadial.Center, newRadial.Center),
s_relativePointAnimator.Interpolate(progress, oldRadial.GradientOrigin, newRadial.GradientOrigin),
@ -42,7 +40,7 @@ namespace Avalonia.Animation.Animators
return new ImmutableConicGradientBrush(
InterpolateStops(progress, oldValue.GradientStops, newValue.GradientStops),
s_doubleAnimator.Interpolate(progress, oldValue.Opacity, newValue.Opacity),
oldValue.Transform is { } && newValue.Transform is { } ? InterpolateTransform(progress, oldValue.Transform, newValue.Transform) : null,
oldValue.Transform is { } ? new ImmutableTransform(oldValue.Transform.Value) : null,
oldValue.SpreadMethod,
s_relativePointAnimator.Interpolate(progress, oldConic.Center, newConic.Center),
s_doubleAnimator.Interpolate(progress, oldConic.Angle, newConic.Angle));
@ -51,7 +49,7 @@ namespace Avalonia.Animation.Animators
return new ImmutableLinearGradientBrush(
InterpolateStops(progress, oldValue.GradientStops, newValue.GradientStops),
s_doubleAnimator.Interpolate(progress, oldValue.Opacity, newValue.Opacity),
oldValue.Transform is { } && newValue.Transform is { } ? InterpolateTransform(progress, oldValue.Transform, newValue.Transform) : null,
oldValue.Transform is { } ? new ImmutableTransform(oldValue.Transform.Value) : null,
oldValue.SpreadMethod,
s_relativePointAnimator.Interpolate(progress, oldLinear.StartPoint, newLinear.StartPoint),
s_relativePointAnimator.Interpolate(progress, oldLinear.EndPoint, newLinear.EndPoint));
@ -91,11 +89,6 @@ namespace Avalonia.Animation.Animators
return stops;
}
private ImmutableTransform InterpolateTransform(double progress, ITransform oldValue, ITransform newValue)
{
return new ImmutableTransform(_matrixAnimator.Interpolate(progress, oldValue.Value, newValue.Value));
}
internal static IGradientBrush ConvertSolidColorBrushToGradient(IGradientBrush gradientBrush, ISolidColorBrush solidColorBrush)
{
switch (gradientBrush)

20
src/Avalonia.Visuals/Animation/Animators/MatrixAnimator.cs

@ -1,20 +0,0 @@
namespace Avalonia.Animation.Animators
{
/// <summary>
/// Animator that handles <see cref="Matrix"/> properties.
/// </summary>
public class MatrixAnimator : Animator<Matrix>
{
/// <inheritdocs/>
public override Matrix Interpolate(double progress, Matrix oldValue, Matrix newValue)
{
return new Matrix(
((newValue.M11 - oldValue.M11) * progress) + oldValue.M11,
((newValue.M12 - oldValue.M12) * progress) + oldValue.M12,
((newValue.M21 - oldValue.M21) * progress) + oldValue.M21,
((newValue.M22 - oldValue.M22) * progress) + oldValue.M22,
((newValue.M31 - oldValue.M31) * progress) + oldValue.M31,
((newValue.M32 - oldValue.M32) * progress) + oldValue.M32);
}
}
}

11
src/Avalonia.Visuals/Animation/Transitions/MatrixTransition.cs

@ -1,11 +0,0 @@
using Avalonia.Animation.Animators;
namespace Avalonia.Animation
{
/// <summary>
/// Transition class that handles <see cref="AvaloniaProperty"/> with <see cref="Matrix"/> type.
/// </summary>
public class MatrixTransition : AnimatorDrivenTransition<Matrix, MatrixAnimator>
{
}
}

7
src/Avalonia.Visuals/Matrix.cs

@ -15,13 +15,6 @@ namespace Avalonia
#endif
readonly struct Matrix : IEquatable<Matrix>
{
static Matrix()
{
#if !BUILDTASK
Animation.Animation.RegisterAnimator<MatrixAnimator>(prop => typeof(Matrix).IsAssignableFrom(prop.PropertyType));
#endif
}
private readonly double _m11;
private readonly double _m12;
private readonly double _m21;

Loading…
Cancel
Save