有一个很好的讨论关于在这个线程上获得一个加宽的路径几何:
就我而言,我希望得到的外线不是“圆的”,而是完全平坦的。那可能吗?
我试图更改线连接属性,但结果视觉没有变化。
这是重现问题的代码:
private void Window_Loaded(object sender, RoutedEventArgs e)
{
StreamGeometry geom = new StreamGeometry();
DrawLines(geom);
Pen p = new Pen(Brushes.Black, 10);
p.LineJoin = PenLineJoin.Miter;
p.EndLineCap = PenLineCap.Flat;
p.StartLineCap = PenLineCap.Flat;
PathGeometry pathGeoWidened = geom.GetWidenedPathGeometry(p);
PathGeometry pathGeom = pathGeoWidened.GetOutlinedPathGeometry();
Path myPath = new Path();
myPath.Stroke = Brushes.Black;
myPath.Data = pathGeom;
myCanvas.Children.Add(myPath);
}
private static void DrawLines(StreamGeometry geom)
{
using (var context = geom.Open())
{
context.BeginFigure(new Point(100, 100), true, true);
context.LineTo(new Point(100, 200), true, true);
context.LineTo(new Point(200, 200), true, true);
context.LineTo(new Point(200, 100), true, true);
}
}
有什么想法吗?
伊戈尔。