C#编程-131:DrawPolygon绘制多边形

C#编程-131:DrawPolygon绘制多边形_第1张图片


  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10. namespace PolygonTest
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         public Form1()
  15.         {
  16.             InitializeComponent();
  17.         }
  18.  
  19.         private void Form1_Paint(object sender, PaintEventArgs e)
  20.         {
  21.             Graphics g = e.Graphics;
  22.             Pen pen = new Pen(Color.Orange,3);
  23.             //绘制三角形
  24.             Point[] points={
  25.                            new Point(220,176),
  26.                            new Point(320,76),
  27.                            new Point(220,76)
  28.                            };
  29.             g.DrawPolygon(pen,points);
  30.             //绘制五角星
  31.             Point[] ps ={
  32.                        new Point(0,76),
  33.                        new Point(80,76),
  34.                        new Point(106,0),
  35.                        new Point(130,76),
  36.                        new Point(210,76),
  37.                        new Point(146,124),
  38.                        new Point(170,200),
  39.                        new Point(106,152),
  40.                        new Point(40,200),
  41.                        new Point(66,124),
  42.                         
  43.                        };
  44.             g.DrawPolygon(pen,ps);
  45.         }
  46.     }
  47. }

你可能感兴趣的:(C#编程-131:DrawPolygon绘制多边形)