弧形緩動就是其緩動曲線為一段圓弧, 如何我們假設圓弧上的點的斜率為速度的話,那麼可以想像其速度的變化多麼具有戲劇性, 其加速或減速來得很突然, 與5次緩動差不多.
參考以下代碼:
//圓形緩動
protected override double GetCurrentValueCore(double defaultOriginValue, double defaultDestinationValue, AnimationClock animationClock)
{
double from = (this.From==null?defaultDestinationValue:(double)this.From);
double to = (this.To==null?defaultOriginValue:(double)this.To);
double delta = to - from;
double value = animationClock.CurrentProgress.Value;
double t = value * this.Duration.TimeSpan.Ticks;
double d = this.Duration.TimeSpan.Ticks;
//加速
//return delta * (1-Math.Sqrt(1-(t/=d)*t)) + from;
//減速
//return delta * Math.Sqrt(1 - (t = t / d - 1) * t) + from;
//先加速,後減速
if ((t /= (d / 2)) < 1)
{
return delta / 2 * (1 - Math.Sqrt(1 - t * t)) + from;
}
return delta / 2 * (Math.Sqrt(1 - (t -= 2) * t) + 1) + from;
}
本文配套源碼