HOW TO:建立合併幾何
本範例示範如何合併幾何。 若要合併兩個幾何,請使用 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>
合併幾何:Exclude
在下列範例中,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>
合併幾何:Intersect
在下列標記中,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>
合併幾何:Union
在下列標記中,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