Title | Fill an ellipse with a color gradient |
Description | This example shows how to fill an ellipse with a color gradient in Visual Basic .NET. |
Keywords | ellipse, color, color gradient, LinearGradientBrush, fill, VB.NET |
Categories | Graphics, VB.NET |
|
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
System.Windows.Forms.PaintEventArgs) Handles Me.Paint
e.Graphics.Clear(Me.BackColor)
Dim rect As New Rectangle(20, 20, Me.ClientSize.Width - _
40, Me.ClientSize.Height - 40)
' Make a gradient brush.
Dim pt1 As New Point(rect.Left + rect.Width \ 2, _
rect.Top)
Dim pt2 As New Point(pt1.X, rect.Bottom)
Using br As New LinearGradientBrush(pt1, pt2, _
Color.Red, Color.Blue)
e.Graphics.FillEllipse(br, rect)
End Using
e.Graphics.DrawEllipse(Pens.Black, rect)
End Sub
|