我有这样一条路

<Path Stroke="Black" StrokeThickness="1" Fill="#CCCCFF">
    <Path.Data>
    <PathGeometry>
        <PathFigure StartPoint="6.0,12.5" >
            <LineSegment Point="50.0,6.0"></LineSegment>
            <LineSegment Point="94.0,12.5"></LineSegment>
            <LineSegment Point="60.0,19.0"></LineSegment>
            <LineSegment Point="20.0,19.0"></LineSegment>
            <LineSegment Point="6.0,12.5"></LineSegment>
        </PathFigure>
        <PathFigure StartPoint="7.97852754592896,12.2077178955078">
            <ArcSegment IsLargeArc="True" Point="4.02147245407104,12.7922821044922" RotationAngle="171.59663391113281" Size="2,4" SweepDirection="Counterclockwise"></ArcSegment>
            <ArcSegment IsLargeArc="True" Point="7.97852754592896,12.2077178955078" RotationAngle="171.59663391113281" Size="2,4" SweepDirection="Counterclockwise"></ArcSegment>
        </PathFigure>
        <PathFigure StartPoint="51.9785270690918,6.29228210449219">
            <ArcSegment IsLargeArc="True" Point="48.0214729309082,5.70771789550781" RotationAngle="188.40336608886719" Size="2,4" SweepDirection="Counterclockwise"></ArcSegment>
            <ArcSegment IsLargeArc="True" Point="51.9785270690918,6.29228210449219" RotationAngle="188.40336608886719" Size="2,4" SweepDirection="Counterclockwise"></ArcSegment>
        </PathFigure>
    </PathGeometry>
  </Path.Data>
</Path>


它表示一个在两个角处带有一些圆的多边形。

圈子之一未正确填写。它恰好是覆盖多边形的圆的一部分。

它使我想起使用XOR的图形。将两个放置在彼此的顶部,它们会相互抵消。

如果我删除多边形(线段),那么它将正常工作。

最佳答案

在查看您的Path并使用PathGeometry.FillRule属性时,两个选项的结果相同。

这使用具有单个Path的Nonzero FilRule。


我能获得您所希望的结果的唯一方法是使用Nonzero FillRule并为PathFigure的问题创建单独的路径。

这是对问题Path使用带有单独PathFigures的Nonzero FillRule的方法。


<Path Stroke="Black" StrokeThickness="1" Fill="#CCCCFF">
    <Path.Data>
        <PathGeometry FillRule="Nonzero">
            <PathFigure StartPoint="6.0,12.5" >
                <LineSegment Point="50.0,6.0"></LineSegment>
                <LineSegment Point="94.0,12.5"></LineSegment>
                <LineSegment Point="60.0,19.0"></LineSegment>
                <LineSegment Point="20.0,19.0"></LineSegment>
                <LineSegment Point="6.0,12.5"></LineSegment>
            </PathFigure>
        </PathGeometry>
    </Path.Data>
</Path>
<Path Stroke="Black" StrokeThickness="1" Fill="#CCCCFF">
    <Path.Data >
        <PathGeometry FillRule="Nonzero">
            <PathFigure StartPoint="51.9785270690918,6.29228210449219">
                <ArcSegment IsLargeArc="True" Point="48.0214729309082,5.70771789550781" RotationAngle="188.40336608886719" Size="2,4" SweepDirection="Counterclockwise"></ArcSegment>
                <ArcSegment IsLargeArc="True" Point="51.9785270690918,6.29228210449219" RotationAngle="188.40336608886719" Size="2,4" SweepDirection="Counterclockwise"  ></ArcSegment>
            </PathFigure>
            <PathFigure StartPoint="7.97852754592896,12.2077178955078" >
                <ArcSegment IsLargeArc="True" Point="4.02147245407104,12.7922821044922" RotationAngle="171.59663391113281" Size="2,4" SweepDirection="Counterclockwise"></ArcSegment>
                <ArcSegment IsLargeArc="True" Point="7.97852754592896,12.2077178955078" RotationAngle="171.59663391113281" Size="2,4" SweepDirection="Counterclockwise"></ArcSegment>
            </PathFigure>
        </PathGeometry>
    </Path.Data>
</Path>

09-17 22:49