Gradient Brush Ball : PathGradientBrush : Graphics C# Source Code


Custom Search

C# Source Code » Graphics » PathGradientBrush »

 

Gradient Brush Ball








    
 

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);
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Graphics
» PathGradientBrush