Let the user move the center point of an elliptical gradient in C#

The example Fill an area with an elliptical gradient in C# explains how to make a brush that fills an area with an elliptical gradient. This example just moves the gradient's center point.

When you move the mouse, the following code saves the mouse's current position in the variable CenterPoint and then refreshes the form.

// Select the ellipse's center point.
private PointF CenterPoint;
private void Form1_MouseMove(
object sender, MouseEventArgs e)
{
CenterPoint = e.Location;
this.Refresh();
}

The form's Paint event handler is the same as in the previous example except it uses the following line of code to set the PathGradientBrush's center to the current center point.

br.CenterPoint = CenterPoint;

See the previous example for further details.

   

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this post.
Comments
  • No comments exist for this post.
Leave a comment

Submitted comments are subject to moderation before being displayed.

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.