|
|
|
@ -1,6 +1,8 @@ |
|
|
|
using System; |
|
|
|
using System.Reactive.Linq; |
|
|
|
|
|
|
|
using Avalonia.Animation.Animators; |
|
|
|
|
|
|
|
namespace Avalonia.Animation |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
@ -8,26 +10,13 @@ namespace Avalonia.Animation |
|
|
|
/// </summary>
|
|
|
|
public class CornerRadiusTransition : Transition<CornerRadius> |
|
|
|
{ |
|
|
|
private static readonly CornerRadiusAnimator s_animator = new CornerRadiusAnimator(); |
|
|
|
|
|
|
|
/// <inheritdocs/>
|
|
|
|
public override IObservable<CornerRadius> DoTransition(IObservable<double> progress, CornerRadius oldValue, CornerRadius newValue) |
|
|
|
{ |
|
|
|
return progress |
|
|
|
.Select(p => |
|
|
|
{ |
|
|
|
var f = Easing.Ease(p); |
|
|
|
|
|
|
|
var deltaTL = newValue.TopLeft - oldValue.TopLeft; |
|
|
|
var deltaTR = newValue.TopRight - oldValue.TopRight; |
|
|
|
var deltaBR = newValue.BottomRight - oldValue.BottomRight; |
|
|
|
var deltaBL = newValue.BottomLeft - oldValue.BottomLeft; |
|
|
|
|
|
|
|
var nTL = f * deltaTL + oldValue.TopLeft; |
|
|
|
var nTR = f * deltaTR + oldValue.TopRight; |
|
|
|
var nBR = f * deltaBR + oldValue.BottomRight; |
|
|
|
var nBL = f * deltaBL + oldValue.BottomLeft; |
|
|
|
|
|
|
|
return new CornerRadius(nTL, nTR, nBR, nBL); |
|
|
|
}); |
|
|
|
.Select(progress => s_animator.Interpolate(Easing.Ease(progress), oldValue, newValue)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|