Beispiel #1
0
        public static GradientStopCollection FillGradients(GradientStopCollection stops)
        {
            GradientStopCollection result = new GradientStopCollection();

            result.Add(stops[0]);

            for (int i = 1; i < stops.Count; i++)
            {
                GradientStop stop     = stops[i];
                GradientStop previous = stops[i - 1];

                double progress = 0.5;
                double offset   = previous.Offset + (stop.Offset - previous.Offset) * progress;
                Color  color    = HslConversion.Blend(previous.Color, stop.Color, progress);

                result.Add(new GradientStop(color, offset));

                //if (Math.Abs(previous.Offset - stop.Offset) > float.Epsilon)
                //{
                //    for (int j = 1; j < 10; j++)
                //    {
                //        double progress = j / 10.0;
                //        double offset = previous.Offset + (stop.Offset - previous.Offset) * progress;
                //        Color color = HslConversion.Blend(previous.Color, stop.Color, progress);

                //        result.Add(new GradientStop(color, offset));
                //    }
                //}

                result.Add(stop);
            }
            return(result);
        }
Beispiel #2
0
        public static GradientStopCollection FillGradients(List <HeatMapEntry> stops)
        {
            GradientStopCollection result = new GradientStopCollection();

            result.Add(stops[0].ToGradientStop());

            for (int i = 1; i < stops.Count; i++)
            {
                GradientStop stop     = stops[i].ToGradientStop();
                GradientStop previous = stops[i - 1].ToGradientStop();

                double progress = 0.5;
                double offset   = previous.Offset + (stop.Offset - previous.Offset) * progress;
                Color  color    = HslConversion.Blend(previous.Color, stop.Color, progress);

                result.Add(new GradientStop(color, offset));
                result.Add(stop);
            }
            return(result);
        }