Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class FillPolygon
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 = e.Graphics
' Create a solid brush
Dim greenBrush As New SolidBrush(Color.Green)
' Create points for polygon.
Dim p1 As New PointF(40.0F, 50.0F)
Dim p2 As New PointF(60.0F, 70.0F)
Dim p3 As New PointF(80.0F, 34.0F)
Dim p4 As New PointF(120.0F, 180.0F)
Dim p5 As New PointF(200.0F, 150.0F)
Dim ptsArray As PointF() = {p1, p2, p3, p4, p5}
' Draw polygon
e.Graphics.FillPolygon(greenBrush, ptsArray)
' Dispose
greenBrush.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
|