PathGradientBrush.CenterPoint : PathGradientBrush « System.Drawing.Drawing2D « C# / C Sharp by API






PathGradientBrush.CenterPoint

  

using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

class BouncingGradientBrushBall : Form {
    public static void Main() {
        Application.Run(new BouncingGradientBrushBall());
    }
    public BouncingGradientBrushBall() {
        ResizeRedraw = true;
    }
    protected override void OnPaint(PaintEventArgs pea) {
        GraphicsPath path = new GraphicsPath();
        Rectangle rect = new Rectangle(10, 10, 30, 30);
        path.AddEllipse(rect);

        PathGradientBrush pgbrush = new PathGradientBrush(path);
        pgbrush.CenterPoint = new PointF((rect.Left + rect.Right) / 3,
                                         (rect.Top + rect.Bottom) / 3);
        pgbrush.CenterColor = Color.White;
        pgbrush.SurroundColors = new Color[] { Color.Red };

        pea.Graphics.FillRectangle(pgbrush, rect);
    }
}

   
    
  








Related examples in the same category

1.new PathGradientBrush(GraphicsPath path)
2.new PathGradientBrush(Path.PathPoints, WrapMode.Tile);
3.PathGradientBrush.CenterColor
4.PathGradientBrush.SurroundColors