points
Point 结构数组,这些结构表示多边形的顶点。
数组中的每对相邻的两个点指定多边形的一条边。另外,如果数组的最后一个点和第一个点不重合,则这两个点指定多边形的最后一条边。
下面的代码示例设计用于 Windows 窗体,它需要 PaintEventArgse(这是 Paint 事件处理程序的参数)。代码执行下列操作:
创建黑色钢笔。
创建一个数组,该数组由表示多边形顶点的七个点组成。
将该多边形绘制到屏幕。
public void DrawPolygonPoint(PaintEventArgs e)
{
// Create pen.
Pen blackPen = new Pen(Color.Black, 3);
// Create points that define polygon.
Point point1 = new Point(50, 50);
Point point2 = new Point(100, 25);
Point point3 = new Point(200, 5);
Point point4 = new Point(250, 50);
Point point5 = new Point(300, 100);
Point point6 = new Point(350, 200);
Point point7 = new Point(250, 250);
Point[] curvePoints =
{
point1,
point2,
point3,
point4,
point5,
point6,
point7
};
// Draw polygon to screen.
e.Graphics.DrawPolygon(blackPen, curvePoints);
}