GDI+ Shapes: Polygons |
|
Description |
A polygon is a series of connected lines with the whole shape being closed. In other words, a polygon is defined a group of lines so that, except for the first line of the group, the starting point of each line is the same as the end point of the previous line and the end point of the last line is connected to the start point of the first line. |
To draw a polygon, you can use the Graphics.Polygon() method. It is overloaded with two versions as follows: Public Sub DrawPolygon(pen As Pen, points As Point()) Public Sub DrawPolygon(pen As Pen, points As PointF()) To use this method, you can first declare a Point or PointF array and pass it as the second argument to the method. Here is an example: Private Sub FormPaint(ByVal sender As Object, _ ByVal e As PaintEventArgs) _ Handles MyBase.Paint Dim pt As Point() = { _ New Point(20, 50), _ New Point(180, 50), _ New Point(180, 20), _ New Point(230, 70), _ New Point(180, 120), _ New Point(180, 90), _ New Point(20, 90)} Dim penCurrent As Pen = New Pen(Color.Red) e.Graphics.DrawPolygon(penCurrent, pt) End Sub This would produce:
|
|
||
Home | Copyright © 2008-2016, FunctionX, Inc. | Home |
|