From ed90143e738f1181df2fcee1a1e2e164c6b596ef Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Sat, 8 Dec 2018 16:44:51 +0800 Subject: [PATCH] Add `Point` animator. --- .../Animation/Animators/PointAnimator.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/Avalonia.Visuals/Animation/Animators/PointAnimator.cs diff --git a/src/Avalonia.Visuals/Animation/Animators/PointAnimator.cs b/src/Avalonia.Visuals/Animation/Animators/PointAnimator.cs new file mode 100644 index 0000000000..a11481c924 --- /dev/null +++ b/src/Avalonia.Visuals/Animation/Animators/PointAnimator.cs @@ -0,0 +1,22 @@ +using System; +using Avalonia.Logging; +using Avalonia.Media; + +namespace Avalonia.Animation.Animators +{ + /// + /// Animator that handles properties. + /// + public class PointAnimator : Animator + { + public override Point Interpolate(double progress, Point oldValue, Point newValue) + { + var deltaX = newValue.X - oldValue.Y; + var deltaY = newValue.X - oldValue.Y; + + var nX = progress * deltaX + oldValue.X; + var nY = progress * deltaY + oldValue.Y; + return new Point(nX, nY); + } + } +} \ No newline at end of file