您当前的位置: 首页 >  c#

彭世瑜

暂无认证

  • 1浏览

    0关注

    2791博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

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

彭世瑜 发布时间:2017-08-20 13:19:11 ,浏览量:1

C#编程-131:DrawPolygon绘制多边形
  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. }
关注
打赏
1665367115
查看更多评论
立即登录/注册

微信扫码登录

0.2382s