mirror of
https://gitee.com/handyorg/HandyControl.git
synced 2024-11-30 10:57:51 +08:00
Update GeometryAnimation.cs
This commit is contained in:
parent
814bfc2d64
commit
646f983228
@ -20,10 +20,6 @@ namespace HandyControl.Media.Animation
|
||||
|
||||
private double[] _numbersAccumulator;
|
||||
|
||||
private double[][] _keyValues;
|
||||
|
||||
private bool _isAnimationFunctionValid;
|
||||
|
||||
public GeometryAnimation()
|
||||
{
|
||||
|
||||
@ -99,11 +95,26 @@ namespace HandyControl.Media.Animation
|
||||
|
||||
protected override Geometry GetCurrentValueCore(Geometry defaultOriginValue, Geometry defaultDestinationValue, AnimationClock animationClock)
|
||||
{
|
||||
if (!_isAnimationFunctionValid)
|
||||
if (_numbersAccumulator == null)
|
||||
{
|
||||
ValidateAnimationFunction();
|
||||
if (_numbersFrom == null)
|
||||
{
|
||||
var geometryStr = defaultOriginValue.ToString();
|
||||
DecomposeValue(geometryStr, out _numbersFrom);
|
||||
}
|
||||
|
||||
if (_numbersTo == null)
|
||||
{
|
||||
var geometryStr = defaultDestinationValue.ToString();
|
||||
DecomposeValue(geometryStr, out _numbersTo);
|
||||
_strings = Regex.Split(geometryStr, Rgx);
|
||||
}
|
||||
|
||||
UpdateValue();
|
||||
}
|
||||
|
||||
if (_numbersAccumulator == null) return defaultOriginValue;
|
||||
|
||||
var progress = animationClock.CurrentProgress.Value;
|
||||
|
||||
var easingFunction = EasingFunction;
|
||||
@ -113,16 +124,7 @@ namespace HandyControl.Media.Animation
|
||||
}
|
||||
|
||||
var accumulated = new double[_numbersAccumulator.Length];
|
||||
var foundation = new double[_numbersAccumulator.Length];
|
||||
|
||||
var from = _keyValues[0];
|
||||
|
||||
if (IsAdditive)
|
||||
{
|
||||
foundation = new double[_numbersAccumulator.Length];
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (IsCumulative)
|
||||
{
|
||||
var currentRepeat = (double)(animationClock.CurrentIteration - 1);
|
||||
@ -141,23 +143,12 @@ namespace HandyControl.Media.Animation
|
||||
|
||||
for (var i = 0; i < _numbersAccumulator.Length; i++)
|
||||
{
|
||||
numbers[i] = foundation[i] + accumulated[i] + from[i] + _numbersAccumulator[i] * progress;
|
||||
numbers[i] = accumulated[i] + _numbersFrom[i] + _numbersAccumulator[i] * progress;
|
||||
}
|
||||
|
||||
return ConvertToGeometry(numbers);
|
||||
}
|
||||
|
||||
private void ValidateAnimationFunction()
|
||||
{
|
||||
_keyValues = null;
|
||||
|
||||
_keyValues = new double[2][];
|
||||
_keyValues[0] = _numbersFrom;
|
||||
_keyValues[1] = _numbersTo;
|
||||
|
||||
_isAnimationFunctionValid = true;
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty FromProperty = DependencyProperty.Register(
|
||||
"From", typeof(Geometry), typeof(GeometryAnimation), new PropertyMetadata(default(Geometry), OnFromChanged));
|
||||
|
||||
@ -207,12 +198,6 @@ namespace HandyControl.Media.Animation
|
||||
set => SetValue(EasingFunctionProperty, value);
|
||||
}
|
||||
|
||||
public bool IsAdditive
|
||||
{
|
||||
get => (bool)GetValue(IsAdditiveProperty);
|
||||
set => SetValue(IsAdditiveProperty, value);
|
||||
}
|
||||
|
||||
public bool IsCumulative
|
||||
{
|
||||
get => (bool)GetValue(IsCumulativeProperty);
|
||||
|
Loading…
Reference in New Issue
Block a user