|
|
Title | Draw a filled polygon in VB .NET |
Description | This example shows how to draw a filled polygon in Visual Basic .NET. |
Keywords | polygon, fill, filled polygon, VB.NET |
Categories | Graphics, VB.NET |
|
|
To fill the polygon, the program creates a brush that defines the desired fill (a diagonal brick hatch pattern in this case). It then uses the Graphics object's FillPolygon method to fill the polygon.
To outline the polygon, the program makes a pen to define the line style and calls the Graphics object's DrawPolygon method.
|
|
Private Const MAX_POINT As Integer = 9
Private m_Points(MAX_POINT) As Point
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
System.Windows.Forms.PaintEventArgs) Handles _
MyBase.Paint
Dim the_brush As New _
System.Drawing.Drawing2D.HatchBrush( _
Drawing2D.HatchStyle.DiagonalBrick, Color.Red, _
Color.Orange)
e.Graphics.FillPolygon(the_brush, m_Points)
the_brush.Dispose()
Dim the_pen As New Pen(Color.Blue, 5)
e.Graphics.DrawPolygon(the_pen, m_Points)
the_pen.Dispose()
End Sub
|
|
|
|
|
|