Beispiel #1
0
        protected override Color GetCurrentValueCore(Color defaultOriginValue, Color defaultDestinationValue, AnimationClock animationClock)
        {
            System.Diagnostics.Debug.Assert(animationClock.CurrentState != ClockState.Stopped);
            if (!_isAnimationFunctionValid)
            {
                ValidateAnimationFunction();
            }
            double          progress       = animationClock.CurrentProgress.Value;
            IEasingFunction easingFunction = EasingFunction;

            if (easingFunction != null)
            {
                progress = easingFunction.Ease(progress);
            }
            double fromVal = _keyvalues[0];
            double toVal   = _keyvalues[1];
            double target;

            if (fromVal > toVal)
            {
                target = (1 - progress) * (fromVal - toVal) + toVal;
            }
            else
            {
                target = (toVal - fromVal) * progress + fromVal;
            }
            Color originColor = OriginColor;

            if (target == 0)
            {
                return(originColor);
            }
            return(ColorEx.ChangeColorBrightness(originColor, target));
        }