Share via


Gewusst wie: Erstellen von kombinierten Geometrien

In diesem Beispiel wird gezeigt, wie Geometrien kombiniert werden. Verwenden Sie ein CombinedGeometry-Objekt, um zwei Geometrien zu kombinieren. Legen Sie die Eigenschaften Geometry1 und Geometry2 der beiden Geometrien fest, die kombiniert werden sollen, und legen Sie für die GeometryCombineMode-Eigenschaft, die bestimmt, wie die Geometrien miteinander kombiniert werden, Union, Intersect, Exclude oder Xor fest.

Um eine zusammengesetzte Geometrie aus mindestens zwei Geometrien zu erstellen, verwenden Sie eine GeometryGroup.

Beispiel

Im folgenden Beispiel ist eine CombinedGeometry mit dem Geometrie-Kombinationsmodus Exclude definiert. Sowohl Geometry1 als auch Geometry2 werden als Kreise mit identischem Radius definiert, deren Mittelpunkte jedoch um den Wert 50 versetzt sind.

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

Results of the Exclude combine mode
Kombinierte Geometrie ausschließen

Im folgenden Markup ist eine CombinedGeometry mit dem Kombinationsmodus Intersect definiert. Sowohl Geometry1 als auch Geometry2 werden als Kreise mit identischem Radius definiert, deren Mittelpunkte jedoch um den Wert 50 versetzt sind.

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

Results of the Intersect combine mode
Kombinierte Geometrie überschneiden

Im folgenden Markup ist eine CombinedGeometry mit dem Kombinationsmodus Union definiert. Sowohl Geometry1 als auch Geometry2 werden als Kreise mit identischem Radius definiert, deren Mittelpunkte jedoch um den Wert 50 versetzt sind.

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

Results of the Union combine mode
Kombinierte Geometrieunion

Im folgenden Markup ist eine CombinedGeometry mit dem Kombinationsmodus Xor definiert. Sowohl Geometry1 als auch Geometry2 werden als Kreise mit identischem Radius definiert, deren Mittelpunkte jedoch um den Wert 50 versetzt sind.

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

Results of the Xor combine mode
Kombinierter Geometrie-Xor