C#--GDI+的PathGradientBrush类的使用

可以用PathGradientBrush类进行路径的渐变填充,如:

 
  
1 private void Form1_Paint( object sender, PaintEventArgs e)
2 {
3 Graphics g = e.Graphics;
4 GraphicsPath gp = new GraphicsPath();
5
6 gp.AddLine( 10 , 10 , 110 , 15 );
7 gp.AddLine( 110 , 15 , 110 , 96 );
8 gp.AddLine( 100 , 96 , 15 , 110 );
9 gp.CloseFigure();
10
11 g.FillRectangle(Brushes.White, this .ClientRectangle);
12 g.SmoothingMode = SmoothingMode.AntiAlias; // 反锯齿
13  
14 PathGradientBrush pgb = new PathGradientBrush(gp);
15 pgb.CenterColor = Color.White;
16 pgb.SurroundColors = new Color[]
17 {
18 Color.Blue
19 };
20 g.FillPath(pgb,gp);
21 g.DrawPath(Pens.Black,gp);
22 pgb.Dispose();
23 gp.Dispose();
24 }

图形为:

2011051121131094.jpg

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值