Beispiel #1
0
        private static ColorBlend ToGDIClampColorBlend(this UGGradientStop[] ugStops)
        {
            var  count  = ugStops.Length;
            bool addEnd = false;

            if (ugStops[count - 1].Offset < 1F - EPSILON)
            {
                addEnd = true;
            }

            var outCount = count + 1;

            if (addEnd)
            {
                ++outCount;
            }

            var gdiStops = new ColorBlend(outCount);
            var outIdx   = 0;

            ugStops[0].AddColorblend(ref gdiStops, ref outIdx, 0F);
            ugStops.AddColorBlend(ref gdiStops, ref outIdx, .5F, .5F);
            if (addEnd)
            {
                ugStops[count - 1].AddColorblend(ref gdiStops, ref outIdx, 1F);
            }
            return(gdiStops);
        }
Beispiel #2
0
        public static ColorBlend ToGDIColorBlend(this UGGradientStop[] ugStops)
        {
            var  count = ugStops.Length;
            bool addStart = false, addEnd = false;

            if (ugStops[0].Offset > EPSILON)
            {
                addStart = true;
            }
            if (ugStops[count - 1].Offset < 1F - EPSILON)
            {
                addEnd = true;
            }

            var outCount = count;

            if (addStart)
            {
                ++outCount;
            }
            if (addEnd)
            {
                ++outCount;
            }

            var gdiStops = new ColorBlend(outCount);
            var outIdx   = 0;

            if (addStart)
            {
                ugStops[0].AddColorblend(ref gdiStops, ref outIdx, 0F);
            }
            ugStops.AddColorBlend(ref gdiStops, ref outIdx);
            if (addEnd)
            {
                ugStops[count - 1].AddColorblend(ref gdiStops, ref outIdx, 1F);
            }
            return(gdiStops);
        }