Пример #1
0
        public override System.Drawing.Brush CreateBrush()
        {
            if (ColorStops.Count == 0)
            {
                throw new ArgumentException();
            }

            var stops = ColorStops.OrderBy(t => t.Item1).ToArray();
            var first = stops[0];
            var last  = stops[stops.Length - 1];

            var brush = new System.Drawing.Drawing2D.LinearGradientBrush(Start, End, first.Item2.ToDrawingColor(),
                                                                         last.Item2.ToDrawingColor());

            return(brush);
        }
Пример #2
0
        public override Brush CreateBrush()
        {
            var path = new GraphicsPath();

            path.AddEllipse(new RectangleF((float)(cx0 - r0), (float)(cy0 - r0), (float)(r0 * 2), (float)(r0 * 2)));

            var brush = new PathGradientBrush(path);

            var orderedStops = ColorStops.OrderBy(t => t.Item1).ToArray();
            var colors       = orderedStops.Select(i => i.Item2.ToDrawingColor()).ToArray();
            var stops        = orderedStops.Select(i => (float)(i.Item1)).ToArray();

            brush.InterpolationColors = new ColorBlend(colors.Length)
            {
                Colors    = colors,
                Positions = stops
            };
            return(brush);
        }