GDI+ 钢笔和笔刷同时使用

可通过钢笔和笔刷混合 使用绘制出有边框的填充图案,如图:

代码如下:

View Code
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g 
= e.Graphics;
            HatchBrush hb 
= new HatchBrush(HatchStyle.NarrowHorizontal, Color.Blue, Color.White);
            LinearGradientBrush lgb 
= new LinearGradientBrush(new Point(22), new Point(192), Color.Blue, Color.Brown);
            Pen hp 
= new Pen(lgb,10);
            g.DrawRectangle(hp, 
20,20120,120);
            g.FillRectangle(hb,
30,30,100,100);
        }

 因此我们可以通过自己的想象来创建各种东西。

posted on 2011-07-29 21:52  wtq  阅读(400)  评论(0编辑  收藏  举报