[UWP] [XAML]多边形中的负空间 [英] [UWP][XAML] Negative space in Polygon

查看:70
本文介绍了[UWP] [XAML]多边形中的负空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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)

推荐答案

Hello Oliver9523,

Hello Oliver9523,

据我所知,Polygon并非主要用于绘制这种有孔的形状。最好使用

路径
+ ... +
PolyLineSegment
,您可以使用它来控制
FillRule
。 

As far as I know, Polygon is not primarily designed for drawing such holed-shapes. It would be better to use Path +... + 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]多边形中的负空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆