Esempio n. 1
0
        /// <summary>
        /// Add a color stop to the renderer.
        /// </summary>
        /// <param name="ratio">Position of the color in the renderer from 0 (start) to 1 (end).</param>
        /// <param name="color">Color for the stop.</param>
        public void AddColorStop(double ratio, Color color)
        {
            if (ratio > 1.0 || ratio < 0.0)
            {
                throw new Exception("Argument 'ratio' must be a value between 0 and 1.");
            }
            ;

            ColorStop stop = new ColorStop(ratio, color);

            ColorStops.Add(stop);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
 public void Serializing(StreamingContext context)
 {
     colorStopsInternal = ColorStops.ToArray();
 }
Esempio n. 5
0
 /// <summary>
 /// Remove all color stops from the renderer.
 /// </summary>
 public void ClearColorStops()
 {
     ColorStops.Clear();
 }