0

有一个很好的讨论关于在这个线程上获得一个加宽的路径几何:

围绕折线创建一个多边形,如缓冲区

就我而言,我希望得到的外线不是“圆的”,而是完全平坦的。那可能吗?

我试图更改线连接属性,但结果视觉没有变化。

这是重现问题的代码:

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);
        }
    }

有什么想法吗?

伊戈尔。

4

1 回答 1

0

使用 aPathGeometry而不是 a StreamGeometry。出于某种原因StreamGeometry,总是有圆线连接。

于 2018-03-13T13:24:19.963 回答