问题描述
我正在使用Polygon类(https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.shapes.polygon)绘制各种形状。如果可能的话,我无法确定是否有办法绘制负空间?
I'm using the Polygon class (https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.shapes.polygon) to drawn various shapes. I can't see if there is a way to draw negative space if it's at all possible?
负空间我的意思是以下示例(https://developers.google.com / maps / documentation / javascript / examples / polygon-hole)
By negative space I mean like the following example (https://developers.google.com/maps/documentation/javascript/examples/polygon-hole)
推荐答案
据我所知,Polygon并非主要用于绘制这种有孔的形状。最好使用
+ ... +
PolyLineSegment ,您可以使用它来控制
FillRule 。
As far as I know, Polygon is not primarily designed for drawing such holed-shapes. It would be better to usePath +... + PolyLineSegment instead, with which you can control FillRule of each polygon if required.
<Canvas>
<Path Fill="#66FFD700" Stroke="Orange" StrokeThickness="2">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="282,18" IsClosed="True">
<PolyLineSegment Points="259,281 19,147"/>
</PathFigure>
<PathFigure StartPoint="236,74" IsClosed="True">
<PolyLineSegment Points="250,117 184,90"/>
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
</Canvas>
附录:如何设法使用多边形+折线绘制多孔形状。
Appendix: How to manage to draw holed-shapes with Polygon + Polylines.
可以通过整合多边形来实现,如下所示。
It might be possible by integrating polygons, as follows.
<Canvas>
<Polygon Fill="#66FFD700" Points="282,18 259,281 19,147 282,18
236,74 184,90 250,117 236,74"/>
<Polyline Stroke="Orange" StrokeThickness="2" Points="282,18 259,281 19,147 282,18"/>
<Polyline Stroke="Orange" StrokeThickness="2" Points="236,74 250,117 184,90 236,74"/>
</Canvas>
这篇关于[UWP] [XAML]多边形中的负空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!