画粗线时去掉角
结果:
替代文本 http://lh4.ggpht.com/ _1TPOP7DzY1E/TCyG2pVxi2I/AAAAAAAADSM/TTqZZxh5LR8/s800/Capture4.gif
问题:
我可以对“附录”这一行进行四舍五入或执行某些操作吗?
代码:
private void Form1_Paint(object sender, PaintEventArgs e)
{
Point[] points1 = new Point[] {
new Point(50, 90),
new Point(60, 20),
new Point(70, 120)
};
GraphicsPath path1 = new GraphicsPath();
path1.AddLines(points1);
ControlPaint.DrawGrid(e.Graphics, this.ClientRectangle,
new Size(10, 10), Color.Red);
using (Pen p = Pens.DarkBlue.Clone() as Pen)
{
p.Width = 5;
e.Graphics.DrawPath(p, path1);
e.Graphics.DrawString("Width: " + p.Width,
new Font(this.Font, FontStyle.Bold),
Brushes.DarkBlue, new Point(35, 150));
Matrix m = new Matrix();
m.Translate(50, 0);
e.Graphics.Transform = m;
p.Width = 1;
e.Graphics.DrawPath(p, path1);
e.Graphics.DrawLine(Pens.Red, -40, 20, 150, 20);
e.Graphics.DrawString("Width: " + p.Width,
this.Font, Brushes.DarkBlue, new Point(35, 150));
}
}
Result:
alt text http://lh4.ggpht.com/_1TPOP7DzY1E/TCyG2pVxi2I/AAAAAAAADSM/TTqZZxh5LR8/s800/Capture4.gif
Question:
Can I round or do something with this line "appendix"?
Code:
private void Form1_Paint(object sender, PaintEventArgs e)
{
Point[] points1 = new Point[] {
new Point(50, 90),
new Point(60, 20),
new Point(70, 120)
};
GraphicsPath path1 = new GraphicsPath();
path1.AddLines(points1);
ControlPaint.DrawGrid(e.Graphics, this.ClientRectangle,
new Size(10, 10), Color.Red);
using (Pen p = Pens.DarkBlue.Clone() as Pen)
{
p.Width = 5;
e.Graphics.DrawPath(p, path1);
e.Graphics.DrawString("Width: " + p.Width,
new Font(this.Font, FontStyle.Bold),
Brushes.DarkBlue, new Point(35, 150));
Matrix m = new Matrix();
m.Translate(50, 0);
e.Graphics.Transform = m;
p.Width = 1;
e.Graphics.DrawPath(p, path1);
e.Graphics.DrawLine(Pens.Red, -40, 20, 150, 20);
e.Graphics.DrawString("Width: " + p.Width,
this.Font, Brushes.DarkBlue, new Point(35, 150));
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需更改
Pen.LineJoin
到LineJoin.Round< /代码>
。您还可以降低
Pen.MiterLimit
修剪很长的角。
Just change
Pen.LineJoin
toLineJoin.Round
. You can also lowerPen.MiterLimit
to clip very long corners.