C# GDI+简单绘图演示

简介: 就是算坐标要仔细,要不然,就不知道图画到哪里去了。。。 还好,我几何学得不太差。。将六个图合到一个大图,算得出来。。。 1 using System; 2 using System.Collections.

就是算坐标要仔细,要不然,就不知道图画到哪里去了。。。

还好,我几何学得不太差。。将六个图合到一个大图,算得出来。。。

 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.Threading.Tasks;
 9 using System.Windows.Forms;
10 using System.Drawing.Drawing2D;
11 
12 namespace WindowsFormsApplication3
13 {
14     public partial class Form1 : Form
15     {
16         public Form1()
17         {
18             InitializeComponent();
19         }
20 
21         private void button1_Click(object sender, EventArgs e)
22         {
23             Graphics ghs = this.CreateGraphics();
24             Brush mybs = new SolidBrush(Color.Red);
25             Rectangle rt = new Rectangle(12, 40, 100, 100);
26             ghs.FillRectangle(mybs, rt);
27         }
28 
29         private void button2_Click(object sender, EventArgs e)
30         {
31             Graphics ghs = this.CreateGraphics();
32             for (int i = 1; i < 6; i++)
33             {
34                 HatchStyle hs = (HatchStyle)(5 + i);
35                 HatchBrush hb = new HatchBrush(hs, Color.Blue);
36                 Rectangle rtl = new Rectangle(175, 30 * i, 30 * i, 50);
37                 ghs.FillRectangle(hb, rtl);
38             }
39         }
40 
41         private void button3_Click(object sender, EventArgs e)
42         {
43             Point p1 = new Point(300, 30);
44             Point p2 = new Point(350, 50);
45             LinearGradientBrush lgb = new LinearGradientBrush(p1, p2, Color.Brown, Color.Cyan);
46             Graphics ghs = this.CreateGraphics();
47             lgb.WrapMode = WrapMode.TileFlipX;
48             ghs.FillRectangle(lgb, 320, 50, 100, 100);
49         }
50 
51         private void button4_Click(object sender, EventArgs e)
52         {
53             Pen blackPen = new Pen(Color.Black, 3);
54             Point point1 = new Point(12, 300);
55             Point point2 = new Point(100, 300);
56             Graphics g = this.CreateGraphics();
57             g.DrawLine(blackPen, point1, point2);
58         }
59 
60         private void button5_Click(object sender, EventArgs e)
61         {
62             Graphics graphics = this.CreateGraphics();
63             Pen myPen = new Pen(Color.Black, 3);
64             Point point1 = new Point(220, 270);
65             Point point2 = new Point(220, 350);
66             graphics.DrawLine(myPen, point1, point2);
67         }
68 
69         private void button6_Click(object sender, EventArgs e)
70         {
71             Graphics ghs = this.CreateGraphics();
72             Pen myPen = new Pen(Color.Orange, 3);
73             ghs.DrawPie(myPen,300,300,120,100, 210,120);
74         }
75     }
76 }

目录
相关文章
C# GDI+绘图(四)实现网格绘制,并填充相应的表格内容
C# GDI+绘图(四)实现网格绘制,并填充相应的表格内容
C# GDI+绘图(三)GDI+实现QQ截图类似功能
C# GDI+绘图(三)GDI+实现QQ截图类似功能
C# GDI+绘图(二)进阶---Pen/Brush以及坐标轴平移和旋转等
上一篇C# GDI+绘图(一)GDI+介绍及基础,我们介绍了,GDI+的基础,这篇我们对其进阶内容进行学习,分别为Pen/Brush以及坐标轴操作
|
C# 图形学
C# GDI+绘图(一)GDI+介绍及基础
最近,项目中,有一块比较发杂的网格,并在网格上绘有各种颜色和文本,在Dev库中并未找到能实现这种功能的现有或可以二次开发的控件,因此,涉及到GDI+绘图这块陌生的领域。下面即时我在本次学习过程中的笔记,本次内容一共分为4篇,分别都有各自的代码或工程文件提供,有需要的朋友可以下载。
|
程序员 C# 图形学
使用 C# Graphics 绘图来绘制一个足球
2022卡塔尔世界杯是足球爱好者的狂欢,这与我毫无关系,作为一个缺乏运动的人,还是不要去看人家玩命的运动了。虽然不看球,不过这波热度的持续冲击,还是让我在朋友圈刷到了结局 ———— 球王梅西如愿以偿捧得金杯,后起之秀姆巴佩加冕金靴。但作为程序员,为了增加一些参与感我就拿 C# 画个足球图案吧。
264 0
使用 C# Graphics 绘图来绘制一个足球
|
C# 图形学
C#之深入理解GDI+绘制圆弧及圆角矩形等比缩放的绘制
GDI+中对于圆弧的绘制,是以给定的长方形(Rectangle`结构)为边界绘制的椭圆的一部分形成的圆弧。绘制的圆弧的中心为长方形内切椭圆的圆心(如果是正方形,则正方形的...
774 0
C#之深入理解GDI+绘制圆弧及圆角矩形等比缩放的绘制
C#编程-128:GDI绘图基础知识
C#编程-128:GDI绘图基础知识
159 0
C#编程-128:GDI绘图基础知识
|
C# 图形学 Windows
C# GDI+编程之Graphics类
GDI+是GDI的后继者,它是.NET Framework为操作图形提供的应用程序编程接口,主要用在窗体上绘制各种图形图像,可以用于绘制各种数据图像、数学仿真等。 Graphics类是GDI+的核心,它提供将对象绘制到显式设备的方法。Graphics类封装了绘制直线、曲线、圆形、图像和文本的方法,是一切GDI+操作的基础类。在绘图之前,必须在指定的窗体上创建一个Graphics对象,才能调用Graphics类的方法画图。
411 0
C# GDI+编程之Graphics类
C#(三十五)之在滚动窗口中绘图
窗体中的三个属性: Size:窗体大小(包括标题栏和边框) ClientSize:工作区大小(不包括标题栏和边框) AutoScrollMinSize:出现滚动条的最小尺寸
254 0
C#(三十五)之在滚动窗口中绘图
|
小程序 C# 图形学
C#(三十二)之Windows绘图
本篇内容记录了Windows绘图的基本概念、操作和清除刚刚绘制的画像等
243 0
C#(三十二)之Windows绘图