天天看點

C#程式設計-131:DrawPolygon繪制多邊形

C#程式設計-131:DrawPolygon繪制多邊形
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace PolygonTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            Pen pen = new Pen(Color.Orange,3);
            //繪制三角形
            Point[] points={
                           new Point(220,176),
                           new Point(320,76),
                           new Point(220,76)
                           };
            g.DrawPolygon(pen,points);
            //繪制五角星
            Point[] ps ={
                       new Point(0,76),
                       new Point(80,76),
                       new Point(106,0),
                       new Point(130,76),
                       new Point(210,76),
                       new Point(146,124),
                       new Point(170,200),
                       new Point(106,152),
                       new Point(40,200),
                       new Point(66,124),
                        
                       };
            g.DrawPolygon(pen,ps);
        }
    }
}