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(2, 2), new Point(19, 2), Color.Blue, Color.Brown);
Pen hp = new Pen(lgb,10);
g.DrawRectangle(hp, 20,20, 120,120);
g.FillRectangle(hb,30,30,100,100);
}
{
Graphics g = e.Graphics;
HatchBrush hb = new HatchBrush(HatchStyle.NarrowHorizontal, Color.Blue, Color.White);
LinearGradientBrush lgb = new LinearGradientBrush(new Point(2, 2), new Point(19, 2), Color.Blue, Color.Brown);
Pen hp = new Pen(lgb,10);
g.DrawRectangle(hp, 20,20, 120,120);
g.FillRectangle(hb,30,30,100,100);
}
因此我们可以通过自己的想象来创建各种东西。