Trapezoid : Polygon « 2D Graphics « VB.Net Tutorial






Trapezoid
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms

public class DrawPolygon
   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 points(3) As System.Drawing.Point
        points(0) = New Point(120, 60) 'Top Left of Trapezoid
        points(1) = New Point(180, 60) 'Top Right of Trapezoid
        points(2) = New Point(240, 120) 'Bottom Right of Trapezoid
        points(3) = New Point(60, 120) 'Bottom Left of Trapezoid
        e.Graphics.DrawPolygon(New Pen(Color.Blue), points)
  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








17.6.Polygon
17.6.1.Draw a PolygonDraw a Polygon
17.6.2.Use mouse to draw a polygonUse mouse to draw a polygon
17.6.3.TrapezoidTrapezoid