在下面的代码中,我们把Pen对象的LineJoin属性设置为值LineJoin.Bevel,然后用它绘制一个矩形:
1 private void Form1_Paint(object sender, PaintEventArgs e)
2 {
3 Graphics g = e.Graphics;
4 g.SmoothingMode = SmoothingMode.AntiAlias;
5 g.FillRectangle(Brushes.White, this.ClientRectangle);
6
7 Pen p = new Pen(Color.Black, 10);
8 p.LineJoin = LineJoin.Bevel;
9 e.Graphics.DrawRectangle(p, 20, 20, 60, 60);
10 p.Dispose();
11 }
显示的图形为:
可以用Brush(画笔)进行填充,如:
1 private void Form1_Paint(object sender, PaintEventArgs e)
2 {
3 Graphics g = e.Graphics;
4 g.SmoothingMode = SmoothingMode.AntiAlias;
5 SolidBrush b = new SolidBrush(Color.Crimson);
6 g.FillRectangle(b,20,20,40,40);
7 b.Dispose();
8 }
填充一个深红色的矩形
联系客服