如何:建立合併幾何
此範例說明如何合併幾何。 若要合併兩個幾何,請使用 CombinedGeometry 物件。 對要合併的兩個幾何設定其 Geometry1 和 Geometry2 屬性,並設定 GeometryCombineMode 屬性 (決定幾何的合併方式) 設定為 Union
、Intersect
、Exclude
或 Xor
。
若要從兩個或更多幾何建立複合幾何,請使用 GeometryGroup。
範例
在下列範例中,會使用幾何合併模式 CombinedGeometry 來定義 Exclude
。
Geometry1 和 Geometry2 兩者都定義為半徑相同的圓形,但中心點位移 50。
<Path Stroke="Black" StrokeThickness="1" Fill="#CCCCFF">
<Path.Data>
<!-- Combines two geometries using the exclude combine mode. -->
<CombinedGeometry GeometryCombineMode="Exclude">
<CombinedGeometry.Geometry1>
<EllipseGeometry RadiusX="50" RadiusY="50" Center="75,75" />
</CombinedGeometry.Geometry1>
<CombinedGeometry.Geometry2>
<EllipseGeometry RadiusX="50" RadiusY="50" Center="125,75" />
</CombinedGeometry.Geometry2>
</CombinedGeometry>
</Path.Data>
</Path>
合併幾何排除
在下列標記中,會使用合併模式 CombinedGeometry 定義 Intersect
。
Geometry1 和 Geometry2 兩者都定義為半徑相同的圓形,但中心點位移 50。
<Path Stroke="Black" StrokeThickness="1" Fill="#CCCCFF">
<Path.Data>
<!-- Combines two geometries using the intersect combine mode. -->
<CombinedGeometry GeometryCombineMode="Intersect">
<CombinedGeometry.Geometry1>
<EllipseGeometry RadiusX="50" RadiusY="50" Center="75,75" />
</CombinedGeometry.Geometry1>
<CombinedGeometry.Geometry2>
<EllipseGeometry RadiusX="50" RadiusY="50" Center="125,75" />
</CombinedGeometry.Geometry2>
</CombinedGeometry>
</Path.Data>
</Path>
合併幾何交集
在下列標記中,會使用合併模式 CombinedGeometry 定義 Union
。
Geometry1 和 Geometry2 兩者都定義為半徑相同的圓形,但中心點位移 50。
<Path Stroke="Black" StrokeThickness="1" Fill="#CCCCFF">
<Path.Data>
<!-- Combines two geometries using the union combine mode. -->
<CombinedGeometry GeometryCombineMode="Union">
<CombinedGeometry.Geometry1>
<EllipseGeometry RadiusX="50" RadiusY="50" Center="75,75" />
</CombinedGeometry.Geometry1>
<CombinedGeometry.Geometry2>
<EllipseGeometry RadiusX="50" RadiusY="50" Center="125,75" />
</CombinedGeometry.Geometry2>
</CombinedGeometry>
</Path.Data>
</Path>
合併幾何聯集
在下列標記中,會使用合併模式 CombinedGeometry 定義 Xor
。
Geometry1 和 Geometry2 兩者都定義為半徑相同的圓形,但中心點位移 50。
<Path Stroke="Black" StrokeThickness="1" Fill="#CCCCFF">
<Path.Data>
<!-- Combines two geometries using the XOR combine mode. -->
<CombinedGeometry GeometryCombineMode="Xor">
<CombinedGeometry.Geometry1>
<EllipseGeometry RadiusX="50" RadiusY="50" Center="75,75" />
</CombinedGeometry.Geometry1>
<CombinedGeometry.Geometry2>
<EllipseGeometry RadiusX="50" RadiusY="50" Center="125,75" />
</CombinedGeometry.Geometry2>
</CombinedGeometry>
</Path.Data>
</Path>
合併幾何 Xor