VB.Net Tutorial/2D Graphics/PathGradientBrush

Материал из VB Эксперт
Перейти к: навигация, поиск

Create PathGradientBrush

Imports System
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Collections
Imports System.ruponentModel
Imports System.Windows.Forms
Imports System.Data
public class PathGradientBrushCreate
   public Shared Sub Main
        Application.Run(New BrushesForm)
   End Sub
End class
Public Class BrushesForm
    Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
    Public Sub New()
        MyBase.New()
        "This call is required by the Windows Form Designer.
        InitializeComponent()
        "Add any initialization after the InitializeComponent() call
    End Sub
    "Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    "Required by the Windows Form Designer
    Private components As System.ruponentModel.IContainer
    "NOTE: The following procedure is required by the Windows Form Designer
    "It can be modified using the Windows Form Designer.  
    "Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        "
        "BrushesForm
        "
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 266)
        Me.Name = "BrushesForm"
        Me.Text = "Form1"
    End Sub
#End Region

    Enum LinearGradientMode
        BackwardDiagonal
        ForwardDiagonal
        Horizontal
        Vertical
    End Enum
    Private Sub BrushesForm_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
        Dim g As Graphics = e.Graphics
        Dim width As Integer = Me.ClientRectangle.Width
        Dim height As Integer = Me.ClientRectangle.Height / 5
        Dim whiteBrush As Brush = System.Drawing.Brushes.White
        Dim blackBrush As Brush = System.Drawing.Brushes.Black
        Dim b As Brush
        Dim points As Point() = New Point() {New Point(0,0), New Point(width, 0), New Point(width, height), New Point(0, height)}
        b = New PathGradientBrush(points)
        g.FillRectangle(b, 0, 0, width, height)
        g.DrawString(b.ToString(), Me.Font, whiteBrush, 0, 0)
    End Sub
End Class

Diamond PathGradientBrush

Imports System.Drawing.Text
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class PathGradientBrushDiamondPoints
   public Shared Sub Main
        Application.Run(New PathGradientBrushesForm)
   End Sub
End class
Public Class PathGradientBrushesForm
    Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
    Public Sub New()
        MyBase.New()
        "This call is required by the Windows Form Designer.
        InitializeComponent()
        "Add any initialization after the InitializeComponent() call
    End Sub
    "Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    "Required by the Windows Form Designer
    Private components As System.ruponentModel.IContainer
    "NOTE: The following procedure is required by the Windows Form Designer
    "It can be modified using the Windows Form Designer.  
    "Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        components = New System.ruponentModel.Container()
        Me.Text = "PathGradientBrushesForm"
    End Sub
#End Region

    Private Sub PathGradientBrushesForm_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
        Dim g As Graphics = e.Graphics
        Dim width As Integer = Me.ClientRectangle.Width / 2
        Dim height As Integer = Me.ClientRectangle.Height / 2
        Dim b As PathGradientBrush
        Dim x As Integer = 0
        Dim y As Integer = 0
        Dim diamondPoints As Point() = New Point() {New Point(width / 2, 0), New Point(width, height / 2), New Point(width / 2, height), New Point(0, height / 2)}
        b = New PathGradientBrush(diamondPoints)
        b.WrapMode = WrapMode.Tile
        b.CenterPoint = New PointF(0, height / 2)
        g.FillRectangle(b, x, y, width, height)
    End Sub
End Class

Fill an ellipse setting CenterColor and SurroundColors

Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.Math
public class PathGradientBrushesCenterColorSurroundColors
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class
public class Form1
  Inherits System.Windows.Forms.Form
  Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        Dim x As Integer = 10
        Dim y As Integer = 10
        Dim wid As Integer = 100
        Dim hgt As Integer = 50
        Dim rect_pts() As Point = { _
            New Point(x, y), _
            New Point(x + wid, y), _
            New Point(x + wid, y + hgt), _
            New Point(x, y + hgt) _
        }
        Dim path_brush As New PathGradientBrush(rect_pts)
        Dim ellipse_path As New GraphicsPath
        ellipse_path.AddEllipse(x, y, wid, hgt)
        path_brush = New PathGradientBrush(ellipse_path)
        path_brush.CenterColor = Color.White
        path_brush.SurroundColors = New Color() {Color.Black}
        e.Graphics.FillEllipse(path_brush, x, y, wid, hgt)
    End Sub

  Public Sub New()
   
    MyBase.New()
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(292, 273)
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
  End Sub
End Class

Fill an ellipse using SetBlendTriangularShape

Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.Math
public class PathGradientBrushesSetBlendTriangularShape
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class
public class Form1
  Inherits System.Windows.Forms.Form
  Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        Dim x As Integer = 10
        Dim y As Integer = 10
        Dim wid As Integer = 100
        Dim hgt As Integer = 50
        Dim rect_pts() As Point = { _
            New Point(x, y), _
            New Point(x + wid, y), _
            New Point(x + wid, y + hgt), _
            New Point(x, y + hgt) _
        }
        Dim path_brush As New PathGradientBrush(rect_pts)
        Dim ellipse_path As New GraphicsPath
        ellipse_path = New GraphicsPath
        ellipse_path.AddEllipse(x, y, wid, hgt)
        path_brush = New PathGradientBrush(ellipse_path)
        path_brush.CenterColor = Color.White
        path_brush.SurroundColors = New Color() {Color.Black}
        path_brush.SetBlendTriangularShape(0.5)
        e.Graphics.FillEllipse(path_brush, x, y, wid, hgt)
    End Sub

  Public Sub New()
   
    MyBase.New()
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(292, 273)
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
  End Sub
End Class

Fill an ellipse using SetSigmaBellShape

Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.Math
public class PathGradientBrushesSetSigmaBellShape
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class
public class Form1
  Inherits System.Windows.Forms.Form
  Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        Dim x As Integer = 10
        Dim y As Integer = 10
        Dim wid As Integer = 100
        Dim hgt As Integer = 50
        Dim rect_pts() As Point = { _
            New Point(x, y), _
            New Point(x + wid, y), _
            New Point(x + wid, y + hgt), _
            New Point(x, y + hgt) _
        }
        Dim path_brush As New PathGradientBrush(rect_pts)
        Dim ellipse_path As New GraphicsPath
        ellipse_path = New GraphicsPath
        ellipse_path.AddEllipse(x, y, wid, hgt)
        path_brush = New PathGradientBrush(ellipse_path)
        path_brush.CenterColor = Color.White
        path_brush.SurroundColors = New Color() {Color.Black}
        path_brush.SetSigmaBellShape(0.5, 1)
        e.Graphics.FillEllipse(path_brush, x, y, wid, hgt)
    End Sub

  Public Sub New()
   
    MyBase.New()
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(292, 273)
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
  End Sub
End Class

Fill a rectangle with PathGradientBrush

Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.Math
public class PathGradientBrushes
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class
public class Form1
  Inherits System.Windows.Forms.Form
  Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        Dim x As Integer = 10
        Dim y As Integer = 10
        Dim wid As Integer = 100
        Dim hgt As Integer = 50
        " Fill a rectangle.
        Dim rect_pts() As Point = { _
            New Point(x, y), _
            New Point(x + wid, y), _
            New Point(x + wid, y + hgt), _
            New Point(x, y + hgt) _
        }
        Dim path_brush As New PathGradientBrush(rect_pts)
        e.Graphics.FillPolygon(path_brush, rect_pts)

    End Sub

  Public Sub New()
   
    MyBase.New()
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(292, 273)
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
  End Sub
End Class

PathGradientBrush and its SurroundColors

Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class PathGradientBrushSurroundColors
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class
Public Class Form1
    Private MouseX As Integer
    Private MouseY As Integer
    Private Sub Form1_MouseMove(ByVal sender As Object, _
          ByVal e As System.Windows.Forms.MouseEventArgs) _
          Handles Me.MouseMove
        MouseX = e.X
        MouseY = e.Y
        Me.Refresh()
    End Sub
    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim thePath As New GraphicsPath
        thePath.AddRectangle(Me.ClientRectangle)
        Dim smoothBrush As PathGradientBrush = New PathGradientBrush(thePath)
        smoothBrush.CenterPoint = New PointF(MouseX, MouseY)
        smoothBrush.CenterColor = Color.White
        Dim colorArray() As Color = {Color.Red, Color.Yellow, Color.Blue, Color.Green}
        smoothBrush.SurroundColors = colorArray
        e.Graphics.FillRectangle(smoothBrush, Me.ClientRectangle)
    End Sub
End Class

<Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _
Partial Class Form1
    Inherits System.Windows.Forms.Form
    "Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
        MyBase.Dispose(disposing)
    End Sub
    "Required by the Windows Form Designer
    Private components As System.ruponentModel.IContainer
    "NOTE: The following procedure is required by the Windows Form Designer
    "It can be modified using the Windows Form Designer.  
    "Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.SuspendLayout()
        "
        "Form1
        "
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(396, 357)
        Me.DoubleBuffered = True
        Me.Name = "Form1"
        Me.Text = "Using Gradients for Smooth Color Changes"
        Me.ResumeLayout(False)
    End Sub
End Class

PathGradientBrush.Blend

Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class PathGBBlend
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class
public class Form1
  Inherits System.Windows.Forms.Form
  Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        Dim g As Graphics = Me.CreateGraphics()
        g.Clear(Me.BackColor)
        Dim blend As New Blend
        Dim factArray As Single() = {0.0F, 0.3F, 0.5F, 1.0F}
        Dim posArray As Single() = {0.0F, 0.2F, 0.6F, 1.0F}
        blend.Factors = factArray
        blend.Positions = posArray
        g.SmoothingMode = SmoothingMode.AntiAlias
        Dim path As New GraphicsPath
        Dim rect As New Rectangle(10, 20, 200, 200)
        path.AddRectangle(rect)
        Dim rgBrush As New PathGradientBrush(path)
        rgBrush.Blend = blend
        rgBrush.FocusScales = New PointF(0.6F, 0.2F)
        Dim colors() As Color = {Color.Green}
        rgBrush.CenterColor = Color.Red
        rgBrush.SurroundColors = colors
        g.FillEllipse(rgBrush, rect)
        " Dispose
        g.Dispose()
  End Sub
  Public Sub New()
   
    MyBase.New()
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(292, 273)
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
  End Sub
End Class

PathGradientBrush by GraphicsPath

Imports System.Drawing.Text
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class PathGradientBrushGraphicsPath
   public Shared Sub Main
        Application.Run(New PathGradientBrushesForm)
   End Sub
End class
Public Class PathGradientBrushesForm
    Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
    Public Sub New()
        MyBase.New()
        "This call is required by the Windows Form Designer.
        InitializeComponent()
        "Add any initialization after the InitializeComponent() call
    End Sub
    "Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    "Required by the Windows Form Designer
    Private components As System.ruponentModel.IContainer
    "NOTE: The following procedure is required by the Windows Form Designer
    "It can be modified using the Windows Form Designer.  
    "Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        components = New System.ruponentModel.Container()
        Me.Text = "PathGradientBrushesForm"
    End Sub
#End Region

    Private Sub PathGradientBrushesForm_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
        Dim g As Graphics = e.Graphics
        Dim width As Integer = Me.ClientRectangle.Width / 2
        Dim height As Integer = Me.ClientRectangle.Height / 2
        Dim b As PathGradientBrush
        Dim x As Integer = 0
        Dim y As Integer = 0
        Dim circle As GraphicsPath = New GraphicsPath()
        circle.AddEllipse(0, 0, width, height)
        b = New PathGradientBrush(circle)
        b.WrapMode = WrapMode.Tile
        b.SurroundColors = New Color() {Color.White}
        b.CenterColor = Color.Black
        g.FillRectangle(b, x, y, width, height)
    End Sub
End Class

PathGradientBrush.InterpolationColors

Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class PathGBInterPol
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class
public class Form1
  Inherits System.Windows.Forms.Form
  Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        Dim g As Graphics = Me.CreateGraphics()
        g.Clear(Me.BackColor)
        Dim clrArray As Color() = {Color.Red, Color.Blue, Color.Green, Color.Pink, Color.Yellow, Color.DarkTurquoise}
        Dim posArray As Single() = {0.0F, 0.2F, 0.4F, 0.6F, 0.8F, 1.0F}
        Dim colorBlend As New ColorBlend
        colorBlend.Colors = clrArray
        colorBlend.Positions = posArray
        g.SmoothingMode = SmoothingMode.AntiAlias
        Dim path As New GraphicsPath
        Dim rect As New Rectangle(10, 20, 200, 200)
        path.AddRectangle(rect)
        Dim rgBrush As New PathGradientBrush(path)
        rgBrush.InterpolationColors = colorBlend
        rgBrush.FocusScales = New PointF(0.6F, 0.2F)
        Dim colors() As Color = {Color.Green}
        rgBrush.CenterColor = Color.Red
        rgBrush.SurroundColors = colors
        g.FillEllipse(rgBrush, rect)
        g.Dispose()
  End Sub
  Public Sub New()
   
    MyBase.New()
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(292, 273)
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
  End Sub
End Class

PathGradientBrush.SurroundColors

Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class PathGradientPros
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class
public class Form1
  Inherits System.Windows.Forms.Form
  Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        Dim g As Graphics = Me.CreateGraphics()
        g.Clear(Me.BackColor)
        g.SmoothingMode = SmoothingMode.AntiAlias
        Dim path As New GraphicsPath
        Dim rect As New Rectangle(10, 20, 200, 200)
        path.AddRectangle(rect)
        Dim rgBrush As New PathGradientBrush(path)
        rgBrush.CenterColor = Color.Red
        rgBrush.FocusScales = New PointF(0.6F, 0.2F)
        Dim colors As Color() = {Color.Green, Color.Blue, Color.Red, Color.Yellow}
        rgBrush.SurroundColors = colors
        g.FillEllipse(rgBrush, rect)
        g.Dispose()
  End Sub
  Public Sub New()
   
    MyBase.New()
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(292, 273)
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
  End Sub
End Class

Quad PathGradientBrush

Imports System.Drawing.Text
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class PathGradientBrushQuadPoints
   public Shared Sub Main
        Application.Run(New PathGradientBrushesForm)
   End Sub
End class
Public Class PathGradientBrushesForm
    Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
    Public Sub New()
        MyBase.New()
        "This call is required by the Windows Form Designer.
        InitializeComponent()
        "Add any initialization after the InitializeComponent() call
    End Sub
    "Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    "Required by the Windows Form Designer
    Private components As System.ruponentModel.IContainer
    "NOTE: The following procedure is required by the Windows Form Designer
    "It can be modified using the Windows Form Designer.  
    "Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        components = New System.ruponentModel.Container()
        Me.Text = "PathGradientBrushesForm"
    End Sub
#End Region

    Private Sub PathGradientBrushesForm_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
        Dim g As Graphics = e.Graphics
        Dim width As Integer = Me.ClientRectangle.Width / 2
        Dim height As Integer = Me.ClientRectangle.Height / 2
        Dim b As PathGradientBrush
        Dim x As Integer = 0
        Dim y As Integer = 0
        Dim quadPoints As Point() = New Point() {New Point(0, 0), New Point(width, 0), New Point(width, height), New Point(0, height)}
        b = New PathGradientBrush(quadPoints)
        b.WrapMode = WrapMode.Tile
        g.FillRectangle(b, x, y, width, height)
    End Sub
End Class

Transform PathGradientBrush

Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class TransformPathGradientBrush
   public Shared Sub Main
        Application.Run(New Form1)
   End Sub
End class
public class Form1
  Inherits System.Windows.Forms.Form
  Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
        Dim g As Graphics = Me.CreateGraphics()
        g.Clear(Me.BackColor)
        " Create a GraphicsPath object
        Dim path As New GraphicsPath
        " Create a rectangle and add it to path
        Dim rect As New Rectangle(20, 20, 200, 200)
        path.AddRectangle(rect)
        " Create a path gradient brush
        Dim pgBrush As New PathGradientBrush(path.PathPoints)
        " Set its center and surrounding colors
        pgBrush.CenterColor = Color.Green
        pgBrush.SurroundColors = New Color() {Color.Blue}
        " Create matrix
        Dim M As New Matrix
        " Translate
        M.Translate(20.0F, 10.0F, MatrixOrder.Prepend)
        " Rotate
        M.Rotate(10.0F, MatrixOrder.Prepend)
        " Scale
        M.Scale(2, 1, MatrixOrder.Prepend)
        " shear
        M.Shear(0.05F, 0.03F, MatrixOrder.Prepend)
        " Apply matrix to the brush
        pgBrush.MultiplyTransform(M)
        " Use brush after transformation
        " to fill a rectangle
        g.FillRectangle(pgBrush, 20, 100, 400, 400)
        " Dispose
        pgBrush.Dispose()
        g.Dispose()

  End Sub
  Public Sub New()
   
    MyBase.New()
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(292, 273)
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
  End Sub
End Class

Triangular PathGradientBrush

Imports System.Drawing.Text
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class PathGradientBrushTriangularPoints
   public Shared Sub Main
        Application.Run(New PathGradientBrushesForm)
   End Sub
End class
Public Class PathGradientBrushesForm
    Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
    Public Sub New()
        MyBase.New()
        "This call is required by the Windows Form Designer.
        InitializeComponent()
        "Add any initialization after the InitializeComponent() call
    End Sub
    "Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    "Required by the Windows Form Designer
    Private components As System.ruponentModel.IContainer
    "NOTE: The following procedure is required by the Windows Form Designer
    "It can be modified using the Windows Form Designer.  
    "Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        components = New System.ruponentModel.Container()
        Me.Text = "PathGradientBrushesForm"
    End Sub
#End Region

    Private Sub PathGradientBrushesForm_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
        Dim g As Graphics = e.Graphics
        Dim width As Integer = Me.ClientRectangle.Width / 2
        Dim height As Integer = Me.ClientRectangle.Height / 2
        Dim triPoints As Point() = New Point() {New Point(width / 2, 0), New Point(0, height), New Point(width, height)}
        Dim b As PathGradientBrush = New PathGradientBrush(triPoints)
        b.SurroundColors = New Color() {Color.Red, Color.Blue}
        Dim x As Integer = 0
        Dim y As Integer = 0
        g.FillRectangle(b, x, y, width, height)
    End Sub
End Class