示例#1
0
        private static void NormalizeFirstStopOffset(IList <GradientColorStop> result)
        {
            // assert that all stops has no absolute on vector offsets and hints
            GradientColorStop firstStop = result[0];

            if (firstStop.GetOffsetType() != GradientColorStop.OffsetType.AUTO)
            {
                return;
            }
            double firstStopOffset = 0;

            foreach (GradientColorStop stopColor in result)
            {
                if (stopColor.GetOffsetType() == GradientColorStop.OffsetType.RELATIVE)
                {
                    firstStopOffset = stopColor.GetOffset();
                    break;
                }
                else
                {
                    if (stopColor.GetHintOffsetType() == GradientColorStop.HintOffsetType.RELATIVE_ON_GRADIENT)
                    {
                        firstStopOffset = stopColor.GetHintOffset();
                        break;
                    }
                }
            }
            firstStopOffset = Math.Min(0, firstStopOffset);
            firstStop.SetOffset(firstStopOffset, GradientColorStop.OffsetType.RELATIVE);
        }
示例#2
0
        private static void NormalizeAutoStops(IList <GradientColorStop> toNormalizeList, int fromIndex, int toIndex
                                               , double prevOffset, double nextOffset)
        {
            System.Diagnostics.Debug.Assert(toIndex >= fromIndex);
            int    intervalsCount = Math.Min(toIndex, toNormalizeList.Count - 1) - fromIndex + 1;
            double offsetShift    = (nextOffset - prevOffset) / intervalsCount;
            double currentOffset  = prevOffset;

            for (int i = fromIndex; i < toIndex; ++i)
            {
                currentOffset += offsetShift;
                GradientColorStop currentAutoStop = toNormalizeList[i];
                System.Diagnostics.Debug.Assert(currentAutoStop.GetOffsetType() == GradientColorStop.OffsetType.AUTO);
                currentAutoStop.SetOffset(currentOffset, GradientColorStop.OffsetType.RELATIVE);
            }
        }