C# 绘图2 画刷Brush
2017-02-13 08:57
197 查看
画刷
以画一个椭圆为例:
上边代码定义了两个点,startPoint和endPoint,并定义了坐标,之后定义了绘画的地方g,定义画刷brush,并以两个点框出一个矩形,在此矩形中画一个红色填充的椭圆,并释放g的资源
Brush类的派生类:
改变画刷:
比如定义了一个 Brush brush = new SolidBrush(Color.Red);
使其变成实心画刷:brush = new SolidBrush(Color.Green);
使其变成纹理画刷:首先要用imageList添加一张图片,然后brush = new TextureBrush( imageList1.Images[0]);
使其变成渐变画刷:加那边需要用到System.Drawing.Drawing2D;命名空间,添加之后,可以添加如下代码:
Point startPoint = new Point(80,70);
Point endPoint = new Point(310,70);
brush = new LinearGradientBrush(startPoint,endPoint,Color.Red,Color.Yellow);
以画一个椭圆为例:
Point startPoint = new Point(10, 10); Point endPoint = new Point(200, 80); Graphics g = this.CreateGraphics(); SolidBrush brush = new SolidBrush(Color.Red); g.FillEllipse(brush,startPoint.X,startPoint.Y,endPoint.X,endPoint.Y); g.Dispose();
上边代码定义了两个点,startPoint和endPoint,并定义了坐标,之后定义了绘画的地方g,定义画刷brush,并以两个点框出一个矩形,在此矩形中画一个红色填充的椭圆,并释放g的资源
Brush类的派生类:
改变画刷:
比如定义了一个 Brush brush = new SolidBrush(Color.Red);
使其变成实心画刷:brush = new SolidBrush(Color.Green);
使其变成纹理画刷:首先要用imageList添加一张图片,然后brush = new TextureBrush( imageList1.Images[0]);
使其变成渐变画刷:加那边需要用到System.Drawing.Drawing2D;命名空间,添加之后,可以添加如下代码:
Point startPoint = new Point(80,70);
Point endPoint = new Point(310,70);
brush = new LinearGradientBrush(startPoint,endPoint,Color.Red,Color.Yellow);
相关文章推荐
- C# GDI绘图之——画笔和画刷
- MFC学习笔记.day02续-CDC类,绘图区域,CPen画笔,画刷 CBrush,DC设备描述表
- c#线性渐变画刷LinearGradientBrush
- C#线性渐变画刷LinearGradientBrush用法实例
- WinAPI: CreateBrushIndirect - 根据画刷结构建立画刷
- C#用鼠标绘图笔记(一)
- 简述WPF中的画刷(Brush)
- C#中双缓存绘图的实现方法
- 浅谈C#中的绘图!
- C# 绘图--飘带
- c# GDI+简单绘图(一)
- WinAPI: CreateHatchBrush - 建立阴影画刷
- 简单C# DGI绘图:时钟 (透明pictureBox解决抖动问题)
- [导入]c# GDI+简单绘图(一)
- 有关c#GDI绘图的一些方法
- c# GDI+简单绘图(二)
- GDI+ 学习记录(11): 路径渐变画刷 - PathGradientBrush
- C#绘图(可以处理负值)
- WinAPI: CreateSolidBrush - 建立实心画刷
- C# GDI+ 简单绘图 (三)