コード例 #1
0
        public override SolidColorBrush?Interpolate(double progress, SolidColorBrush?oldValue, SolidColorBrush?newValue)
        {
            if (oldValue is null || newValue is null)
            {
                return(progress >= 0.5 ? newValue : oldValue);
            }

            return(new SolidColorBrush(ColorAnimator.InterpolateCore(progress, oldValue.Color, newValue.Color)));
        }
コード例 #2
0
        public override ISolidColorBrush Interpolate(double progress, ISolidColorBrush oldValue, ISolidColorBrush newValue)
        {
            if (oldValue is null || newValue is null)
            {
                return(oldValue);
            }

            return(new ImmutableSolidColorBrush(ColorAnimator.InterpolateCore(progress, oldValue.Color, newValue.Color)));
        }
コード例 #3
0
        void InitializeColorAnimator()
        {
            _colorAnimator = new ColorAnimator();

            foreach (AnimatorKeyFrame keyframe in this)
            {
                _colorAnimator.Add(keyframe);
            }

            _colorAnimator.Property = SolidColorBrush.ColorProperty;
        }
コード例 #4
0
        public override ISolidColorBrush?Interpolate(double progress, ISolidColorBrush?oldValue, ISolidColorBrush?newValue)
        {
            if (oldValue is null || newValue is null)
            {
                return(progress >= 0.5 ? newValue : oldValue);
            }

            return(new ImmutableSolidColorBrush(
                       ColorAnimator.InterpolateCore(progress, oldValue.Color, newValue.Color),
                       s_doubleAnimator.Interpolate(progress, oldValue.Opacity, newValue.Opacity)));
        }
コード例 #5
0
        private IReadOnlyList <ImmutableGradientStop> InterpolateStops(double progress, IReadOnlyList <IGradientStop> oldValue, IReadOnlyList <IGradientStop> newValue)
        {
            var resultCount = Math.Max(oldValue.Count, newValue.Count);
            var stops       = new ImmutableGradientStop[resultCount];

            for (int index = 0, oldIndex = 0, newIndex = 0; index < resultCount; index++)
            {
                stops[index] = new ImmutableGradientStop(
                    s_doubleAnimator.Interpolate(progress, oldValue[oldIndex].Offset, newValue[newIndex].Offset),
                    ColorAnimator.InterpolateCore(progress, oldValue[oldIndex].Color, newValue[newIndex].Color));

                if (oldIndex < oldValue.Count - 1)
                {
                    oldIndex++;
                }

                if (newIndex < newValue.Count - 1)
                {
                    newIndex++;
                }
            }

            return(stops);
        }
コード例 #6
0
 public override SolidColorBrush Interpolate(double progress, SolidColorBrush oldValue, SolidColorBrush newValue)
 {
     return(new SolidColorBrush(ColorAnimator.InterpolateCore(progress, oldValue.Color, newValue.Color)));
 }