Exemplo n.º 1
0
            static IReadOnlyList <ImmutableGradientStop> CreateStopsFromSolidColorBrush(ISolidColorBrush solidColorBrush, IReadOnlyList <IGradientStop> baseStops)
            {
                var stops = new ImmutableGradientStop[baseStops.Count];

                for (int index = 0; index < baseStops.Count; index++)
                {
                    stops[index] = new ImmutableGradientStop(baseStops[index].Offset, solidColorBrush.Color);
                }
                return(stops);
            }
Exemplo n.º 2
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);
        }