孤独的猫

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

可以用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 }

图形为:

posted on 2011-05-11 21:15  孤独的猫  阅读(4175)  评论(0编辑  收藏  举报