最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#繪制中國(guó)國(guó)旗的方法

 更新時(shí)間:2015年08月13日 09:16:57   作者:北風(fēng)其涼  
這篇文章主要介紹了C#繪制中國(guó)國(guó)旗的方法,以實(shí)例形式較為詳細(xì)的分析了C#圖形繪制的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了C#繪制中國(guó)國(guó)旗的方法。分享給大家供大家參考。具體如下:

程序運(yùn)行截圖:

中國(guó)國(guó)旗被定義在《GB:12982-2004》中,以下是從維基百科條目中華人民共和國(guó)國(guó)旗中截的一張圖,標(biāo)出了五顆星大致的位置。

建立一個(gè)空的C# Windows窗體應(yīng)用程序,窗體取名FormMain,在窗體中放一個(gè)PictureBox,取名為picFlagOfChina,并將Dock屬性設(shè)置為Fill。程序代碼中用到了窗體事件Load和Resize,程序代碼如下:

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 ChineseFlag
{
 public partial class FormMain : Form
 {
  public FormMain()
  {
   InitializeComponent();
  }
  private void FormMain_Load(object sender, EventArgs e)
  {
   PaintFlag();
  }
  //修改窗體大小時(shí)發(fā)生
  private void FormMain_Resize(object sender, EventArgs e)
  {
   PaintFlag();
  }
  /// <summary>
  /// 在圖片框 picFlagOfChina 中繪制國(guó)旗
  /// </summary>
  private void PaintFlag()
  {
   picFlagOfChina.BackColor = Color.Red;
   picFlagOfChina.Image = new Bitmap(
    picFlagOfChina.Width, picFlagOfChina.Height);
   Graphics g = Graphics.FromImage(picFlagOfChina.Image);
   Point[] p = new Point[] { };
   p = PentacleA(this.Width, this.Height);
   g.FillPolygon(Brushes.Yellow, p);
   p = PentacleB(this.Width, this.Height);
   g.FillPolygon(Brushes.Yellow, p);
   p = PentacleC(this.Width, this.Height);
   g.FillPolygon(Brushes.Yellow, p);
   p = PentacleD(this.Width, this.Height);
   g.FillPolygon(Brushes.Yellow, p);
   p = PentacleE(this.Width, this.Height);
   g.FillPolygon(Brushes.Yellow, p);
  }
  //大星
  private Point[] PentacleA(int width, int height)
  {
   return new Point[] 
   { 
    new Point((int)(width / 30.0 * 5), (int)(height / 20.0 * 2)),
    new Point((int)(width / 30.0 * 5.7), (int)(height / 20.0 * 4.1)),
    new Point((int)(width / 30.0 * 8), (int)(height / 20.0 * 4.1)),
    new Point((int)(width / 30.0 * 6), (int)(height / 20.0 * 5.3)),
    new Point((int)(width / 30.0 * 6.8), (int)(height / 20.0 * 7.3)),
    new Point((int)(width / 30.0 * 5), (int)(height / 20.0 * 6.1)),
    new Point((int)(width / 30.0 * 3.2), (int)(height / 20.0 * 7.3)),
    new Point((int)(width / 30.0 * 4), (int)(height / 20.0 * 5.3)),
    new Point((int)(width / 30.0 * 2), (int)(height / 20.0 * 4.1)),
    new Point((int)(width / 30.0 * 4.3), (int)(height / 20.0 * 4.1)),
   };
  }
  //工人星
  private Point[] PentacleB(int width, int height)
  {
   return new Point[] 
   { 
    new Point((int)(width / 30.0 * 9.2), (int)(height / 20.0 * 2.5)),
    new Point((int)(width / 30.0 * 9.6), (int)(height / 20.0 * 2)),
    new Point((int)(width / 30.0 * 9.3), (int)(height / 20.0 * 1.4)),
    new Point((int)(width / 30.0 * 9.95), (int)(height / 20.0 * 1.7)),
    new Point((int)(width / 30.0 * 10.45), (int)(height / 20.0 * 1.1)),
    new Point((int)(width / 30.0 * 10.36), (int)(height / 20.0 * 1.85)),
    new Point((int)(width / 30.0 * 11), (int)(height / 20.0 * 2.1)),
    new Point((int)(width / 30.0 * 10.34), (int)(height / 20.0 * 2.25)),
    new Point((int)(width / 30.0 * 10.3), (int)(height / 20.0 * 2.95)),
    new Point((int)(width / 30.0 * 9.9), (int)(height / 20.0 * 2.3))
   };
  }
  //農(nóng)民星
  private Point[] PentacleC(int width, int height)
  {
   return new Point[] 
   { 
    new Point((int)(width / 30.0 * 11), (int)(height / 20.0 * 4.1)),
    new Point((int)(width / 30.0 * 11.65), (int)(height / 20.0 * 3.8)),
    new Point((int)(width / 30.0 * 11.55), (int)(height / 20.0 * 3.05)),
    new Point((int)(width / 30.0 * 12.05), (int)(height / 20.0 * 3.6)),
    new Point((int)(width / 30.0 * 12.7), (int)(height / 20.0 * 3.3)),
    new Point((int)(width / 30.0 * 12.35), (int)(height / 20.0 * 3.98)),
    new Point((int)(width / 30.0 * 12.9), (int)(height / 20.0 * 4.5)),
    new Point((int)(width / 30.0 * 12.1), (int)(height / 20.0 * 4.3)),
    new Point((int)(width / 30.0 * 11.8), (int)(height / 20.0 * 5)),
    new Point((int)(width / 30.0 * 11.7), (int)(height / 20.0 * 4.2))
   };
  }
  //小資星
  private Point[] PentacleD(int width, int height)
  {
   return new Point[] 
   { 
    new Point((int)(width / 30.0 * 11.1), (int)(height / 20.0 * 6.7)),
    new Point((int)(width / 30.0 * 11.8), (int)(height / 20.0 * 6.7)),
    new Point((int)(width / 30.0 * 12), (int)(height / 20.0 * 6)),
    new Point((int)(width / 30.0 * 12.2), (int)(height / 20.0 * 6.7)),
    new Point((int)(width / 30.0 * 12.9), (int)(height / 20.0 * 6.7)),
    new Point((int)(width / 30.0 * 12.35), (int)(height / 20.0 * 7.1)),
    new Point((int)(width / 30.0 * 12.55), (int)(height / 20.0 * 7.8)),
    new Point((int)(width / 30.0 * 12), (int)(height / 20.0 * 7.4)),
    new Point((int)(width / 30.0 * 11.45), (int)(height / 20.0 * 7.8)),
    new Point((int)(width / 30.0 * 11.65), (int)(height / 20.0 * 7.1))
   };
  }
  //民資星(工人星向下平移7個(gè)單位)
  private Point[] PentacleE(int width, int height)
  {
   return new Point[] 
   { 
    new Point((int)(width / 30.0 * 9.2), (int)(height / 20.0 * 9.5)),
    new Point((int)(width / 30.0 * 9.6), (int)(height / 20.0 * 9)),
    new Point((int)(width / 30.0 * 9.3), (int)(height / 20.0 * 8.4)),
    new Point((int)(width / 30.0 * 9.95), (int)(height / 20.0 * 8.7)),
    new Point((int)(width / 30.0 * 10.45), (int)(height / 20.0 * 8.1)),
    new Point((int)(width / 30.0 * 10.36), (int)(height / 20.0 * 8.85)),
    new Point((int)(width / 30.0 * 11), (int)(height / 20.0 * 9.1)),
    new Point((int)(width / 30.0 * 10.34), (int)(height / 20.0 * 9.25)),
    new Point((int)(width / 30.0 * 10.3), (int)(height / 20.0 * 9.95)),
    new Point((int)(width / 30.0 * 9.9), (int)(height / 20.0 * 9.3))
   };
  }
 }
}

希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • 基于C# wpf 實(shí)現(xiàn)Grid內(nèi)控件拖動(dòng)詳情

    基于C# wpf 實(shí)現(xiàn)Grid內(nèi)控件拖動(dòng)詳情

    這篇文章主要介紹了基于C# wpf 實(shí)現(xiàn)Grid內(nèi)控件拖動(dòng),有一些業(yè)務(wù)場(chǎng)景中我們需要拖動(dòng)控件,在Grid中就可以實(shí)現(xiàn)控件拖動(dòng),通過(guò)設(shè)置Margin屬性即可,下面文章我們來(lái)看看具體的實(shí)現(xiàn)內(nèi)容
    2021-11-11
  • C#反射調(diào)用拓展類方法實(shí)例代碼

    C#反射調(diào)用拓展類方法實(shí)例代碼

    這篇文章主要給大家介紹了關(guān)于C#反射調(diào)用拓展類方法的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2022-01-01
  • C#利用ZXing.Net生成條形碼和二維碼

    C#利用ZXing.Net生成條形碼和二維碼

    這篇文章主要為大家詳細(xì)介紹了C#利用ZXing.Net生成條形碼和二維碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-03-03
  • C#程序最小化到托盤圖標(biāo)操作步驟與實(shí)現(xiàn)代碼

    C#程序最小化到托盤圖標(biāo)操作步驟與實(shí)現(xiàn)代碼

    設(shè)置窗體屬性showinTask=false;加notifyicon控件notifyIcon1,為控件notifyIcon1的屬性Icon添加一個(gè)icon圖標(biāo);添加窗體最小化事件(首先需要添加事件引用)接下來(lái)介紹實(shí)現(xiàn)代碼,感興趣的朋友可以研究下
    2012-12-12
  • C#.NET 圖片水印添加代碼

    C#.NET 圖片水印添加代碼

    這篇文章主要為大家詳細(xì)介紹了C#.NET 圖片水印添加代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-07-07
  • C#插入圖片到Excel表格單元格代碼詳解

    C#插入圖片到Excel表格單元格代碼詳解

    在本篇文章里小編給大家整理了關(guān)于C#插入圖片到Excel表格單元格的具體方法和實(shí)例代碼,需要的朋友們可以學(xué)習(xí)下。
    2019-07-07
  • C#讀寫共享文件夾的方法

    C#讀寫共享文件夾的方法

    這篇文章主要為大家詳細(xì)介紹了C#讀寫共享文件夾的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-05-05
  • C# 利用StringBuilder提升字符串拼接性能的小例子

    C# 利用StringBuilder提升字符串拼接性能的小例子

    一個(gè)項(xiàng)目中有數(shù)據(jù)圖表呈現(xiàn),數(shù)據(jù)量稍大時(shí)顯得很慢,在使用了StringBuilder后效果提升很明顯,下面有例子
    2013-07-07
  • C#中的那些常用加密算法

    C#中的那些常用加密算法

    本文主要講解一下C#常用的那些加密算法,包括MD5加密、SHA1加密、Base64加密、Des加密、RSA加密等,需要的朋友可以參考下
    2020-11-11
  • C#中Timer使用及解決重入問(wèn)題

    C#中Timer使用及解決重入問(wèn)題

    本文主要介紹了C#中Timer使用及解決重入問(wèn)題的相關(guān)知識(shí)。具有很好的參考價(jià)值,下面跟著小編一起來(lái)看下吧
    2017-02-02

最新評(píng)論

桐柏县| 凤冈县| 疏勒县| 长垣县| 寻乌县| 枣庄市| 名山县| 红原县| 乌鲁木齐市| 仁化县| 高邮市| 乐安县| 海淀区| 贵阳市| 泌阳县| 三亚市| 南康市| 石台县| 泸定县| 安达市| 武强县| 宜黄县| 巴青县| 娱乐| 靖西县| 渑池县| 托里县| 吴江市| 景德镇市| 丰城市| 革吉县| 巴马| 大荔县| 百色市| 习水县| 嘉兴市| 南澳县| 廊坊市| 雷波县| 阿坝县| 商河县|