C# 2.0 Graphics 畫雪人
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Text;
7using System.Windows.Forms;
8using System.Drawing.Printing;
9
10namespace PrintTest
11{
12 /// <summary>
13 /// 列印雪人影像窗體
14 /// 2009-02-16 塗聚文
15 /// summary>
16 public partial class printDram : Form
17 {
18 /// <summary>
19 /// 列印雪人影像窗體
20 /// summary>
21 public printDram()
22 {
23 InitializeComponent();
24 }
25 /// <summary>
26 /// 窗體載入
27 /// summary>
28 /// <param name="sender">param>
29 /// <param name="e">param>
30 private void printDram_Load(object sender, EventArgs e)
31 {
32
33 }
34 /// <summary>
35 /// 列印文件
36 /// summary>
37 /// <param name="sender">param>
38 /// <param name="e">param>
39 private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
40 {
41 const int MID = 150;
42 const int Top = 50;
43 this.BackColor = Color.Cyan;
44 this.Width = 310;
45 this.Height = 260;
46 this.Text = "simple graphics snowman";
47
48 Pen blue = new Pen(Color.Blue);
49 Pen yellow = new Pen(Color.Yellow);
50 Pen white = new Pen(Color.White);
51 Pen red = new Pen(Color.Red);
52 Pen black = new Pen(Color.Black);
53 Brush brWhite = white.Brush;
54 Brush brBlack = black.Brush;
55 Brush brRed = red.Brush;
56 Graphics g = e.Graphics;
57
58 g.DrawRectangle(blue, 0, 175, 300, 50); //sky
59 g.DrawEllipse(yellow, -40, -40, 80, 80); //sun
60 g.FillEllipse(brWhite, MID - 20, Top, 40, 40); //head
61 g.FillEllipse(brRed, MID - 35, Top + 35, 70, 50); //top
62 g.FillEllipse(brRed, MID - 50, Top + 80, 100, 60); //bot
63 g.FillEllipse(brBlack, MID - 10, Top + 10, 5, 5); //l.eye
64 g.FillEllipse(brBlack, MID + 5, Top + 10, 5, 5);//r.eye
65 g.DrawArc(black, MID - 10, Top + 20, 20, 10, -190, -160);//(:
66 //arms
67 g.DrawLine(black, MID - 25, Top + 60, Top - 50, MID + 40);
68 g.DrawLine(black, MID + 25, Top + 60, MID + 55, Top + 60);
69
70 g.DrawLine(black, MID - 20, Top + 5, MID + 20, Top + 5);//hat,brim,top
71 g.FillRectangle(brBlack, MID - 15, Top - 20, 30, 25);
72
73 }
74 /// <summary>
75 /// 列印
76 /// summary>
77 /// <param name="sender">param>
78 /// <param name="e">param>
79 private void btnprint_Click(object sender, EventArgs e)
80 {
81 if (MessageBox.Show("是否列印預覽?", "列印預覽", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
82 {
83 this.printPreviewDialog1.Document = this.printDocument1;
84 printPreviewDialog1.ShowDialog();
85 }
86 else
87 {
88 this.printDocument1.Print();//直接列印
89 }
90 }
91 /// <summary>
92 /// 窗體外觀
93 /// summary>
94 /// <param name="sender">param>
95 /// <param name="e">param>
96 private void printDram_Paint(object sender, PaintEventArgs e)
97 {
98 const int MID = 150;
99 const int Top = 50;
100 this.BackColor = Color.Cyan;
101 this.Width = 310;
102 this.Height = 260;
103 this.Text = "simple graphics snowman";
104
105 Pen blue = new Pen(Color.Blue);
106 Pen yellow = new Pen(Color.Yellow);
107 Pen white = new Pen(Color.White);
108 Pen red = new Pen(Color.Red);
109 Pen black = new Pen(Color.Black);
110 Brush brWhite = white.Brush;
111 Brush brBlack = black.Brush;
112 Brush brRed = red.Brush;
113 Graphics g = e.Graphics;
114
115 g.DrawRectangle(blue, 0, 175, 300, 50); //sky
116 g.DrawEllipse(yellow, -40, -40, 80, 80); //sun
117 g.FillEllipse(brWhite, MID - 20, Top, 40, 40); //head
118 g.FillEllipse(brWhite, MID - 35, Top + 35, 70, 50); //top
119 g.FillEllipse(brWhite, MID - 50, Top + 80, 100, 60); //bot
120 g.FillEllipse(brBlack, MID - 10, Top + 10, 5, 5); //l.eye
121 g.FillEllipse(brBlack, MID + 5, Top + 10, 5, 5);//r.eye
122 g.DrawArc(black, MID - 10, Top + 20, 20, 10, -190, -160);//(:
123 //arms
124 g.DrawLine(black, MID - 25, Top + 60, Top - 50, MID + 40);
125 g.DrawLine(black, MID + 25, Top + 60, MID + 55, Top + 60);
126
127 g.DrawLine(black, MID - 20, Top + 5, MID + 20, Top + 5);//hat,brim,top
128 g.FillRectangle(brBlack, MID - 15, Top - 20, 30, 25);
129 }
130 }
131}
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Text;
7using System.Windows.Forms;
8using System.Drawing.Printing;
9
10namespace PrintTest
11{
12 /// <summary>
13 /// 列印雪人影像窗體
14 /// 2009-02-16 塗聚文
15 /// summary>
16 public partial class printDram : Form
17 {
18 /// <summary>
19 /// 列印雪人影像窗體
20 /// summary>
21 public printDram()
22 {
23 InitializeComponent();
24 }
25 /// <summary>
26 /// 窗體載入
27 /// summary>
28 /// <param name="sender">param>
29 /// <param name="e">param>
30 private void printDram_Load(object sender, EventArgs e)
31 {
32
33 }
34 /// <summary>
35 /// 列印文件
36 /// summary>
37 /// <param name="sender">param>
38 /// <param name="e">param>
39 private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
40 {
41 const int MID = 150;
42 const int Top = 50;
43 this.BackColor = Color.Cyan;
44 this.Width = 310;
45 this.Height = 260;
46 this.Text = "simple graphics snowman";
47
48 Pen blue = new Pen(Color.Blue);
49 Pen yellow = new Pen(Color.Yellow);
50 Pen white = new Pen(Color.White);
51 Pen red = new Pen(Color.Red);
52 Pen black = new Pen(Color.Black);
53 Brush brWhite = white.Brush;
54 Brush brBlack = black.Brush;
55 Brush brRed = red.Brush;
56 Graphics g = e.Graphics;
57
58 g.DrawRectangle(blue, 0, 175, 300, 50); //sky
59 g.DrawEllipse(yellow, -40, -40, 80, 80); //sun
60 g.FillEllipse(brWhite, MID - 20, Top, 40, 40); //head
61 g.FillEllipse(brRed, MID - 35, Top + 35, 70, 50); //top
62 g.FillEllipse(brRed, MID - 50, Top + 80, 100, 60); //bot
63 g.FillEllipse(brBlack, MID - 10, Top + 10, 5, 5); //l.eye
64 g.FillEllipse(brBlack, MID + 5, Top + 10, 5, 5);//r.eye
65 g.DrawArc(black, MID - 10, Top + 20, 20, 10, -190, -160);//(:
66 //arms
67 g.DrawLine(black, MID - 25, Top + 60, Top - 50, MID + 40);
68 g.DrawLine(black, MID + 25, Top + 60, MID + 55, Top + 60);
69
70 g.DrawLine(black, MID - 20, Top + 5, MID + 20, Top + 5);//hat,brim,top
71 g.FillRectangle(brBlack, MID - 15, Top - 20, 30, 25);
72
73 }
74 /// <summary>
75 /// 列印
76 /// summary>
77 /// <param name="sender">param>
78 /// <param name="e">param>
79 private void btnprint_Click(object sender, EventArgs e)
80 {
81 if (MessageBox.Show("是否列印預覽?", "列印預覽", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
82 {
83 this.printPreviewDialog1.Document = this.printDocument1;
84 printPreviewDialog1.ShowDialog();
85 }
86 else
87 {
88 this.printDocument1.Print();//直接列印
89 }
90 }
91 /// <summary>
92 /// 窗體外觀
93 /// summary>
94 /// <param name="sender">param>
95 /// <param name="e">param>
96 private void printDram_Paint(object sender, PaintEventArgs e)
97 {
98 const int MID = 150;
99 const int Top = 50;
100 this.BackColor = Color.Cyan;
101 this.Width = 310;
102 this.Height = 260;
103 this.Text = "simple graphics snowman";
104
105 Pen blue = new Pen(Color.Blue);
106 Pen yellow = new Pen(Color.Yellow);
107 Pen white = new Pen(Color.White);
108 Pen red = new Pen(Color.Red);
109 Pen black = new Pen(Color.Black);
110 Brush brWhite = white.Brush;
111 Brush brBlack = black.Brush;
112 Brush brRed = red.Brush;
113 Graphics g = e.Graphics;
114
115 g.DrawRectangle(blue, 0, 175, 300, 50); //sky
116 g.DrawEllipse(yellow, -40, -40, 80, 80); //sun
117 g.FillEllipse(brWhite, MID - 20, Top, 40, 40); //head
118 g.FillEllipse(brWhite, MID - 35, Top + 35, 70, 50); //top
119 g.FillEllipse(brWhite, MID - 50, Top + 80, 100, 60); //bot
120 g.FillEllipse(brBlack, MID - 10, Top + 10, 5, 5); //l.eye
121 g.FillEllipse(brBlack, MID + 5, Top + 10, 5, 5);//r.eye
122 g.DrawArc(black, MID - 10, Top + 20, 20, 10, -190, -160);//(:
123 //arms
124 g.DrawLine(black, MID - 25, Top + 60, Top - 50, MID + 40);
125 g.DrawLine(black, MID + 25, Top + 60, MID + 55, Top + 60);
126
127 g.DrawLine(black, MID - 20, Top + 5, MID + 20, Top + 5);//hat,brim,top
128 g.FillRectangle(brBlack, MID - 15, Top - 20, 30, 25);
129 }
130 }
131}
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12639172/viewspace-555239/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- C# 2.0 新特性C#
- CSS3雪人程式碼例項CSSS3
- 分享聖誕樹+雪人+全屏動效
- Qt Graphics View 框架QTView框架
- What's new in C# from 2.0 to 5.0C#
- c# winform之繪畫及畫直曲線相關C#ORM
- Android 2D Graphics學習(一)、android.graphics介紹Android
- c# winform旋轉顯示繪畫C#ORM
- Python安裝graphics庫Python
- C# 2.0 套接字程式設計例項初探程式設計
- Qt 之 Graphics View Framework 簡介QTViewFramework
- CorelDRAW Graphics Suite 2022UI
- Simplifying Graphics With Java and Threads (轉)Javathread
- iOS開發——Core Graphics繪圖iOS繪圖
- CPT205 Computer Graphics
- 【C#學習筆記】圖片畫素操作C#筆記
- c#畫圖(橢圓和弧線)Craphics類C#
- 鴻蒙OS 2.0手機開機畫面演示:終於去掉安卓鴻蒙安卓
- Astute Graphics for Mac ai創意外掛合集ASTMacAI
- CorelDRAW Graphics Suite 2022 for MacUIMac
- COMP3811 Computer Graphics
- C#畫線控制元件的示例程式碼C#控制元件
- C# 離線人臉識別 虹軟ArcFace 2.0 demoC#
- C# 離線人臉識別 ArcSoft V2.0 DemoC#
- ASP.NET 2.0(C#)- Profile(儲存使用者配置)ASP.NETC#
- 對C# 2.0中匿名方法的種種懷疑分析(轉)C#
- 用生成對抗網路給雪人上色,探索人工智慧時代的美學人工智慧
- 【C# 程式碼小知識】畫蛇添足的編碼字首C#
- 使用java繪圖類Graphics繪製圓圈Java繪圖
- COMP612 Computer Graphics Programming
- 【webabcd】溫故知新ASP.NET 2.0(C#)(1) - MasterPage(母版頁)WebASP.NETC#AST
- c#影象處理入門(-bitmap類和影象畫素值獲取方法)C#
- Astute Graphics for Mac(ai2021創意外掛合集)ASTMacAI
- Bitmap回收—Canvas: trying to use a recycled bitmap android.graphicsCanvasAndroid
- Core Graphics框架 :仿射變換與齊次座標框架
- 《Pro Android Graphics》讀書筆記之第一節Android筆記
- 《Pro Android Graphics》讀書筆記之第六節Android筆記
- 《Pro Android Graphics》讀書筆記之第三節Android筆記