程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> 關於C# >> C#用Graphics繪制雪人

C#用Graphics繪制雪人

編輯:關於C#

在網上看到一段代碼,覺得有意思,就修改了下共享CSDN讀友。

程序運行界面:

private void printDramC(Graphics g)

{

const int MID = 150;

const int Top = 50;

this.Text = "simple graphics snowman";

Font font = new Font("隸書",17);

Pen blue = new Pen(Color.Blue);

Pen yellow = new Pen(Color.Yellow);

Pen white = new Pen(Color.White);

Pen red = new Pen(Color.Red);

  Pen black = new Pen(Color.Black);

Brush brWhite = white.Brush;

Brush brBlack = black.Brush;

Brush brRed = red.Brush;

  g.FillRectangle(brRed, 20, 30, 30, 120);

  g.FillRectangle(brRed, 250, 30, 30, 120);

g.FillRectangle(brRed, 100, 0, 100, 25);

StringFormat format = new StringFormat();

format.FormatFlags = StringFormatFlags.DirectionVertical;

g.DrawString("三杯祝福歌", font, brBlack, 250, 30, format);

  g.DrawString("一曲迎春調", font, brBlack, 20, 30, format);

g.DrawString("迎春祝福", font, brBlack, 100, 0);

   g.DrawRectangle(blue, 0, 175, 300, 50);  //sky

  g.DrawEllipse(yellow, -40, -40, 80, 80); //sun

g.FillEllipse(brWhite, MID - 20, Top, 40, 40); //head

g.FillEllipse(brWhite, MID - 35, Top + 35, 70, 50); //top

 g.FillEllipse(brWhite, MID - 50, Top + 80, 100, 60); //bot

g.FillEllipse(brBlack, MID - 10, Top + 10, 5, 5); //l.eye

g.FillEllipse(brBlack, MID + 5, Top + 10, 5, 5);//r.eye

  g.DrawArc(black, MID - 10, Top + 20, 20, 10, -190, -160);//(:

//arms

g.DrawLine(black, MID - 25, Top + 60, Top - 50, MID + 40);

g.DrawLine(black, MID + 25, Top + 60, MID + 55, Top + 60);

g.DrawLine(black, MID - 20, Top + 5, MID + 20, Top + 5);//hat,brim,top

g.FillRectangle(brBlack, MID - 15, Top - 20, 30, 25);

}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved