绘制多边形

实现效果

  

知识运用:

  Graphics类的DrawPolygon (Pen pen,Point[] points)  //绘制由一组Point结构定义的多边形

实现代码:

        private void button1_Click(object sender, EventArgs e)
        {
            Graphics graphics = this.CreateGraphics();
            Pen myPen = new Pen(Color.Black,3);
            Point pt1 = new Point(80,150);
            Point pt2 = new Point(120, 20);
            Point pt3 = new Point(240, 20);
            Point pt4 = new Point(280,150);
            Point pt5 = new Point(140,240);
            Point[] myPoints = { pt1,pt2,pt3,pt4,pt5};
            graphics.DrawPolygon(myPen,myPoints);
        }

  

猜你喜欢

转载自www.cnblogs.com/feiyucha/p/10257654.html