跟着 伍逸 老师学GDI+
最近在看伍逸 老师著的《C# 二维三维图形绘制工程实例宝典》,感觉这本书太经典了,心想一定要坚持把这本书看完,为了能勉励自己,特注册次博客。在此对伍逸老师表示由衷的感谢。
2.Brush的学习
2.1 SolidBrush: 实心画刷
2.2 HatchBrush: 阴影画刷
2.3 LinerGradientBrush: 线性渐变画刷
用法如下:(与书上同)
- 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;
- using System.Drawing.Drawing2D;
- namespace _002Brush
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Paint(object sender, PaintEventArgs e)
- {
- Graphics g = e.Graphics;
- Brush brSolid = new SolidBrush(Color.Blue);
- Brush brHatch = new HatchBrush(HatchStyle.HorizontalBrick, Color.Red, Color.Yellow);
- Brush brGradient = new LinearGradientBrush(new Rectangle(0,0,200,200),Color.Black,Color.LightGray,45,false);
- g.FillRectangle(brGradient,10,10,200,200);
- g.FillEllipse(brHatch,200,200,150,190);
- g.FillPie(brSolid,0,0,300,300,285,75);
- }
- }
- }
运行结果如下:
转载于:https://blog.51cto.com/lixianhui/784915