【问题标题】:Get Widened Path Geometry with flat line joins使用平线连接获得加宽路径几何
【发布时间】:2014-10-18 09:18:32
【问题描述】:

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

Create a polygon around a polyline like a buffer

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

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

这是重现问题的代码:

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

有什么想法吗?

伊戈尔。

【问题讨论】:

  • 你不能用ScaleTransformRenderTransform 绘制相同的多边形吗?
  • 不确定它的外观(所以它被称为完全平坦)?
  • 我在原始线程中添加了一个示例代码。不幸的是,我仍然无法发布图像,但这很容易复制。无论我在 pen line joins 甚至在 Path line joins 中做什么,结果总是一样的。
  • 我得到了一些帮助,似乎我可以解决这个问题,将 LineTo isSmoothJoin 参数更改为 false。谢谢你们!

标签: c# wpf pathgeometry


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-05-13
    • 1970-01-01
    • 1970-01-01
    • 2022-06-14
    • 2011-01-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多