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