gpt4 book ai didi

wpf - 如何使 WPF 形状完全填充

转载 作者:行者123 更新时间:2023-12-02 10:54:54 27 4
gpt4 key购买 nike

我有一条这样的路,

<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 的图形。将两个放在一起,它们就会抵消。

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

最佳答案

查看你的路径并玩弄 PathGeometry.FillRule我对这两个选项都得到了相同的结果。

这是使用带有单个Path的非零FilRule。

我能够获得我相信您正在寻找的结果的唯一方法是使用Nonzero FillRule 并为问题 PathFigure 创建一个单独的路径。

这是使用 Nonzero FillRule 和单独的 Path 来解决问题 PathFigures

<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>

关于wpf - 如何使 WPF 形状完全填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9627863/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com