Nota
El acceso a esta página requiere autorización. Puede intentar iniciar sesión o cambiar directorios.
El acceso a esta página requiere autorización. Puede intentar cambiar los directorios.
En esta introducción se describe cómo usar las clases de Windows Presentation Foundation (WPF) Geometry para describir las formas. En este tema también se contrastan las diferencias entre Geometry los objetos y Shape los elementos.
¿Qué es una geometría?
La Geometry clase y las clases que derivan de ella, como EllipseGeometry, PathGeometryy CombinedGeometry, permiten describir la geometría de una forma 2D. Estas descripciones geométricas tienen muchos usos, como definir una forma para pintar en la pantalla o definir regiones de prueba de impacto y recorte. Incluso puedes usar una geometría para definir una trayectoria de animación.
Geometry Los objetos pueden ser simples, como rectángulos y círculos, o compuestos, creados a partir de dos o más objetos de geometría. Se pueden crear geometrías más complejas mediante las PathGeometry clases y StreamGeometry , que permiten describir arcos y curvas.
Dado que un Geometry es un tipo de Freezable, los objetos Geometry proporcionan varias características especiales: se pueden declarar como recursos, compartidos entre múltiples objetos, hechos solo de lectura para mejorar el rendimiento, clonados y hechos seguros para subprocesos. Para obtener más información sobre las distintas características proporcionadas por Freezable objetos, vea Objetos Freezable: Información General.
Geometrías frente a formas
Las Geometry clases y Shape parecen similares en que describen formas 2D (comparar EllipseGeometry y Ellipse por ejemplo), pero hay diferencias importantes.
Para uno, la Geometry clase hereda de la Freezable clase mientras la Shape clase hereda de FrameworkElement. Dado que son elementos, los Shape objetos se pueden representar y participar en el sistema de diseño, mientras que los Geometry objetos no pueden.
Aunque Shape los objetos son más fáciles de usar que Geometry los objetos, Geometry los objetos son más versátiles. Mientras se usa un Shape objeto para representar gráficos 2D, se puede usar un Geometry objeto para definir la región geométrica para gráficos 2D, definir una región para recortar o definir una región para las pruebas de posicionamiento, por ejemplo.
La forma del trayecto
Una Shape, la clase Path, de hecho, utiliza un Geometry para describir su contenido. Al establecer la propiedad Data de Path con Geometry, y fijar sus propiedades Fill y Stroke, puede representar un Geometry.
Propiedades comunes que toman una geometría
En las secciones anteriores se mencionó que los objetos Geometry se pueden usar con otros objetos con diversos fines, como dibujar formas, animar y recortar. En la tabla siguiente se enumeran varias clases que tienen propiedades que toman un Geometry objeto .
Tipo | Propiedad |
---|---|
DoubleAnimationUsingPath | PathGeometry |
DrawingGroup | ClipGeometry |
GeometryDrawing | Geometry |
Path | Data |
UIElement | Clip |
Tipos de geometría simples
La clase base para todas las geometrías es la clase Geometryabstracta . Las clases que derivan de la Geometry clase se pueden agrupar aproximadamente en tres categorías: geometrías simples, geometrías de ruta y geometrías compuestas.
Las clases de geometría simples incluyen LineGeometry, RectangleGeometryy y EllipseGeometry se usan para crear formas geométricas básicas, como líneas, rectángulos y círculos.
LineGeometry Se define especificando el punto inicial de la línea y el punto final.
RectangleGeometry Se define con una Rect estructura que especifica su posición relativa y su alto y ancho. Puede crear un rectángulo redondeado estableciendo las RadiusX propiedades y RadiusY .
EllipseGeometry Se define mediante un punto central, un radio x y un radio Y. En los ejemplos siguientes se muestra cómo crear geometrías simples para la representación y el recorte.
Estas mismas formas, así como formas más complejas, se pueden crear utilizando una PathGeometry o mediante la combinación de objetos de geometría, pero estas clases proporcionan un medio más sencillo para producir estas formas geométricas básicas.
En el ejemplo siguiente se muestra cómo crear y representar un LineGeometry. Como se indicó anteriormente, un Geometry objeto no se puede dibujar a sí mismo, por lo que en el ejemplo se usa una Path forma para representar la línea. Dado que una línea no tiene área, establecer la propiedad Fill del Path no tendría efecto; en su lugar, solo se especifican las propiedades Stroke y StrokeThickness. En la ilustración siguiente se muestra la salida del ejemplo.
Una geometría de línea se dibuja de (10,20) a (100,130)
<Path Stroke="Black" StrokeThickness="1" >
<Path.Data>
<LineGeometry StartPoint="10,20" EndPoint="100,130" />
</Path.Data>
</Path>
LineGeometry myLineGeometry = new LineGeometry();
myLineGeometry.StartPoint = new Point(10,20);
myLineGeometry.EndPoint = new Point(100,130);
Path myPath = new Path();
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1;
myPath.Data = myLineGeometry;
Dim myLineGeometry As New LineGeometry()
myLineGeometry.StartPoint = New Point(10,20)
myLineGeometry.EndPoint = New Point(100,130)
Dim myPath As New Path()
myPath.Stroke = Brushes.Black
myPath.StrokeThickness = 1
myPath.Data = myLineGeometry
En el ejemplo siguiente se muestra cómo crear y representar un EllipseGeometry. Los ejemplos establecen que el Center de EllipseGeometry se establece en el punto 50,50
, y el radio x y el radio y se establecen en 50
, lo que crea un círculo de 100 de diámetro. El interior de la elipse se pinta asignando un valor a la propiedad Fill del elemento Path, en este caso Gold. En la ilustración siguiente se muestra la salida del ejemplo.
Una
Una EllipseGeometry dibujada en (50,50)
<Path Fill="Gold" Stroke="Black" StrokeThickness="1">
<Path.Data>
<EllipseGeometry Center="50,50" RadiusX="50" RadiusY="50" />
</Path.Data>
</Path>
EllipseGeometry myEllipseGeometry = new EllipseGeometry();
myEllipseGeometry.Center = new Point(50, 50);
myEllipseGeometry.RadiusX = 50;
myEllipseGeometry.RadiusY = 50;
Path myPath = new Path();
myPath.Fill = Brushes.Gold;
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1;
myPath.Data = myEllipseGeometry;
Dim myEllipseGeometry As New EllipseGeometry()
myEllipseGeometry.Center = New Point(50, 50)
myEllipseGeometry.RadiusX = 50
myEllipseGeometry.RadiusY = 50
Dim myPath As New Path()
myPath.Fill = Brushes.Gold
myPath.Stroke = Brushes.Black
myPath.StrokeThickness = 1
myPath.Data = myEllipseGeometry
En el ejemplo siguiente se muestra cómo crear y representar un RectangleGeometry. La posición y las dimensiones del rectángulo se definen mediante una Rect estructura. La posición es 50,50
y la altura y el ancho son ambos 25
, lo que crea un cuadrado. En la ilustración siguiente se muestra la salida del ejemplo.
Un
Un RectangleGeometry dibujado en 50,50
<Path Fill="LemonChiffon" Stroke="Black" StrokeThickness="1">
<Path.Data>
<RectangleGeometry Rect="50,50,25,25" />
</Path.Data>
</Path>
RectangleGeometry myRectangleGeometry = new RectangleGeometry();
myRectangleGeometry.Rect = new Rect(50,50,25,25);
Path myPath = new Path();
myPath.Fill = Brushes.LemonChiffon;
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1;
myPath.Data = myRectangleGeometry;
Dim myRectangleGeometry As New RectangleGeometry()
myRectangleGeometry.Rect = New Rect(50,50,25,25)
Dim myPath As New Path()
myPath.Fill = Brushes.LemonChiffon
myPath.Stroke = Brushes.Black
myPath.StrokeThickness = 1
myPath.Data = myRectangleGeometry
En el ejemplo siguiente se muestra cómo usar un EllipseGeometry como región de recorte para una imagen. Un Image objeto se define con un Width de 200 y un Height de 150. Un EllipseGeometry con un RadiusX valor de 100, un RadiusY valor de 75, y un Center valor de 100,75 se establece en la Clip propiedad de la imagen. Solo se mostrará la parte de la imagen que está dentro del área de la elipse. En la ilustración siguiente se muestra la salida del ejemplo.
Un EllipseGeometry utilizado para recortar un control de imagen
<Image
Source="sampleImages\Waterlilies.jpg"
Width="200" Height="150" HorizontalAlignment="Left">
<Image.Clip>
<EllipseGeometry
RadiusX="100"
RadiusY="75"
Center="100,75"/>
</Image.Clip>
</Image>
// Create the image to clip.
Image myImage = new Image();
Uri imageUri =
new Uri(@"C:\\Documents and Settings\\All Users\\Documents\My Pictures\\Sample Pictures\\Water lilies.jpg", UriKind.Relative);
myImage.Source = new BitmapImage(imageUri);
myImage.Width = 200;
myImage.Height = 150;
myImage.HorizontalAlignment = HorizontalAlignment.Left;
// Use an EllipseGeometry to define the clip region.
EllipseGeometry myEllipseGeometry = new EllipseGeometry();
myEllipseGeometry.Center = new Point(100, 75);
myEllipseGeometry.RadiusX = 100;
myEllipseGeometry.RadiusY = 75;
myImage.Clip = myEllipseGeometry;
' Create the image to clip.
Dim myImage As New Image()
Dim imageUri As New Uri("C:\\Documents and Settings\\All Users\\Documents\My Pictures\\Sample Pictures\\Water lilies.jpg", UriKind.Relative)
myImage.Source = New BitmapImage(imageUri)
myImage.Width = 200
myImage.Height = 150
myImage.HorizontalAlignment = HorizontalAlignment.Left
' Use an EllipseGeometry to define the clip region.
Dim myEllipseGeometry As New EllipseGeometry()
myEllipseGeometry.Center = New Point(100, 75)
myEllipseGeometry.RadiusX = 100
myEllipseGeometry.RadiusY = 75
myImage.Clip = myEllipseGeometry
Geometrías de ruta
La PathGeometry clase y su equivalente ligero, la StreamGeometry clase , proporcionan los medios para describir varias figuras complejas compuestas de arcos, curvas y líneas.
En el corazón de un PathGeometry está una colección de objetos PathFigure, denominada así porque cada figura describe una forma discreta en el PathGeometry. Cada PathFigure está formado por uno o varios objetos PathSegment, cada uno de los cuales describe un segmento de la figura.
Hay muchos tipos de segmentos.
Tipo de segmento | Descripción | Ejemplo |
---|---|---|
ArcSegment | Crea un arco elíptico entre dos puntos. | Cree un arco elíptico. |
BezierSegment | Crea una curva Bezier cúbica entre dos puntos. | Cree una curva Bézier cúbica. |
LineSegment | Crea una línea entre dos puntos. | Crea un SegmentoDeLínea en una GeometríaDeRuta |
PolyBezierSegment | Crea una serie de curvas Bezier cúbicas. | Consulte la PolyBezierSegment página de tipo. |
PolyLineSegment | Crea una serie de líneas. | Consulte la PolyLineSegment página de tipo. |
PolyQuadraticBezierSegment | Crea una serie de curvas Bezier cuadráticas. | Ver la página PolyQuadraticBezierSegment. |
QuadraticBezierSegment | Crea una curva Bezier cuadrática. | Cree una curva bezier cuadrática. |
Los segmentos dentro de un PathFigure se combinan en una sola forma geométrica, donde el punto final de cada segmento es el punto inicial del siguiente segmento. La propiedad StartPoint de un PathFigure especifica el punto desde el que se dibuja el primer segmento. Cada segmento posterior comienza en el punto final del segmento anterior. Por ejemplo, se puede definir una línea vertical de 10,50
a 10,150
estableciendo la propiedad StartPoint en 10,50
y creando un LineSegment con la propiedad Point establecida en 10,150
.
En el siguiente ejemplo se crea un PathGeometry simple que comprende un PathFigure único con un LineSegment y se muestra mediante un elemento Path. El PathFigure objeto StartPoint se establece en 10,20
, y LineSegment se define con un punto final de 100,130
. En la ilustración siguiente se muestra el PathGeometry creado por este ejemplo.
Una PathGeometry que contiene un solo Segmento de Línea
<Path Stroke="Black" StrokeThickness="1">
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigure StartPoint="10,20">
<PathFigure.Segments>
<LineSegment Point="100,130"/>
</PathFigure.Segments>
</PathFigure>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
// Create a figure that describes a
// line from (10,20) to (100,130).
PathFigure myPathFigure = new PathFigure();
myPathFigure.StartPoint = new Point(10,20);
myPathFigure.Segments.Add(
new LineSegment(new Point(100,130),
true /* IsStroked */ ));
/// Create a PathGeometry to contain the figure.
PathGeometry myPathGeometry = new PathGeometry();
myPathGeometry.Figures.Add(myPathFigure);
// Display the PathGeometry.
Path myPath = new Path();
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1;
myPath.Data = myPathGeometry;
' Create a figure that describes a
' line from (10,20) to (100,130).
Dim myPathFigure As New PathFigure()
myPathFigure.StartPoint = New Point(10,20)
myPathFigure.Segments.Add(New LineSegment(New Point(100,130), True)) ' IsStroked
''' Create a PathGeometry to contain the figure.
Dim myPathGeometry As New PathGeometry()
myPathGeometry.Figures.Add(myPathFigure)
' Display the PathGeometry.
Dim myPath As New Path()
myPath.Stroke = Brushes.Black
myPath.StrokeThickness = 1
myPath.Data = myPathGeometry
Vale la pena comparar este ejemplo con el ejemplo anterior LineGeometry . La sintaxis usada para un PathGeometry es mucho más detallada que la usada para un simple LineGeometry, y puede tener más sentido usar la clase LineGeometry en este caso, pero la sintaxis detallada de la PathGeometry permite regiones geométricas extremadamente intrincadas y complejas.
Se pueden crear geometrías más complejas mediante una combinación de PathSegment objetos .
En el ejemplo siguiente se usa un BezierSegment, un LineSegment y un ArcSegment para crear forma. En primer lugar, el ejemplo crea una curva Bezier cúbica mediante la definición de cuatro puntos: un punto de inicio, que es el punto final del segmento anterior, un punto final (Point3) y dos puntos de control (Point1 y Point2). Los dos puntos de control de una curva Bezier cúbica se comportan como imanes, atraer partes de lo que de otro modo sería una línea recta hacia sí mismas, produciendo una curva. El primer punto de control, Point1, afecta a la parte inicial de la curva; el segundo punto de control, Point2, afecta a la parte final de la curva.
A continuación, el ejemplo agrega un objeto LineSegment, que se dibuja entre el punto final del BezierSegment anterior al punto especificado por su propiedad LineSegment.
A continuación, el ejemplo agrega un ArcSegment, que se dibuja desde el punto final del LineSegment anterior hasta el punto que especifica su propiedad Point. En el ejemplo también se especifica el radio x e y del arco (Size), un ángulo de rotación (RotationAngle), una marca que indica el tamaño del ángulo del arco resultante (IsLargeArc) y un valor que indica en qué dirección se dibuja el arco (SweepDirection). En la ilustración siguiente se muestra la forma creada por este ejemplo.
Geometría de camino
<Path Stroke="Black" StrokeThickness="1" >
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigure StartPoint="10,50">
<PathFigure.Segments>
<BezierSegment
Point1="100,0"
Point2="200,200"
Point3="300,100"/>
<LineSegment Point="400,100" />
<ArcSegment
Size="50,50" RotationAngle="45"
IsLargeArc="True" SweepDirection="Clockwise"
Point="200,100"/>
</PathFigure.Segments>
</PathFigure>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
// Create a figure.
PathFigure myPathFigure = new PathFigure();
myPathFigure.StartPoint = new Point(10,50);
myPathFigure.Segments.Add(
new BezierSegment(
new Point(100,0),
new Point(200,200),
new Point(300,100),
true /* IsStroked */ ));
myPathFigure.Segments.Add(
new LineSegment(
new Point(400,100),
true /* IsStroked */ ));
myPathFigure.Segments.Add(
new ArcSegment(
new Point(200,100),
new Size(50,50),
45,
true, /* IsLargeArc */
SweepDirection.Clockwise,
true /* IsStroked */ ));
/// Create a PathGeometry to contain the figure.
PathGeometry myPathGeometry = new PathGeometry();
myPathGeometry.Figures.Add(myPathFigure);
// Display the PathGeometry.
Path myPath = new Path();
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1;
myPath.Data = myPathGeometry;
' Create a figure.
Dim myPathFigure As New PathFigure()
myPathFigure.StartPoint = New Point(10,50)
myPathFigure.Segments.Add(New BezierSegment(New Point(100,0), New Point(200,200), New Point(300,100), True)) ' IsStroked
myPathFigure.Segments.Add(New LineSegment(New Point(400,100), True)) ' IsStroked
myPathFigure.Segments.Add(New ArcSegment(New Point(200,100), New Size(50,50), 45, True, SweepDirection.Clockwise, True)) ' IsStroked - IsLargeArc
''' Create a PathGeometry to contain the figure.
Dim myPathGeometry As New PathGeometry()
myPathGeometry.Figures.Add(myPathFigure)
' Display the PathGeometry.
Dim myPath As New Path()
myPath.Stroke = Brushes.Black
myPath.StrokeThickness = 1
myPath.Data = myPathGeometry
Incluso se pueden crear geometrías más complejas mediante el uso de varios PathFigure objetos dentro de .PathGeometry
En el ejemplo siguiente se crea un PathGeometry objeto con dos PathFigure objetos, cada uno de los cuales contiene varios PathSegment objetos. Se utilizan el PathFigure del ejemplo anterior y un PathFigure con un PolyLineSegment y un QuadraticBezierSegment. PolyLineSegment Se define con una matriz de puntos y QuadraticBezierSegment se define con un punto de control y un punto final. En la ilustración siguiente se muestra la forma creada por este ejemplo.
Un PathGeometry con varias figuras
<Path Stroke="Black" StrokeThickness="1" >
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigure StartPoint="10,50">
<PathFigure.Segments>
<BezierSegment
Point1="100,0"
Point2="200,200"
Point3="300,100"/>
<LineSegment Point="400,100" />
<ArcSegment
Size="50,50" RotationAngle="45"
IsLargeArc="True" SweepDirection="Clockwise"
Point="200,100"/>
</PathFigure.Segments>
</PathFigure>
<PathFigure StartPoint="10,100">
<PathFigure.Segments>
<PolyLineSegment Points="50,100 50,150" />
<QuadraticBezierSegment Point1="200,200" Point2="300,100"/>
</PathFigure.Segments>
</PathFigure>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
PathGeometry myPathGeometry = new PathGeometry();
// Create a figure.
PathFigure pathFigure1 = new PathFigure();
pathFigure1.StartPoint = new Point(10,50);
pathFigure1.Segments.Add(
new BezierSegment(
new Point(100,0),
new Point(200,200),
new Point(300,100),
true /* IsStroked */ ));
pathFigure1.Segments.Add(
new LineSegment(
new Point(400,100),
true /* IsStroked */ ));
pathFigure1.Segments.Add(
new ArcSegment(
new Point(200,100),
new Size(50,50),
45,
true, /* IsLargeArc */
SweepDirection.Clockwise,
true /* IsStroked */ ));
myPathGeometry.Figures.Add(pathFigure1);
// Create another figure.
PathFigure pathFigure2 = new PathFigure();
pathFigure2.StartPoint = new Point(10,100);
Point[] polyLinePointArray =
new Point[]{ new Point(50, 100), new Point(50, 150)};
PolyLineSegment myPolyLineSegment = new PolyLineSegment();
myPolyLineSegment.Points =
new PointCollection(polyLinePointArray);
pathFigure2.Segments.Add(myPolyLineSegment);
pathFigure2.Segments.Add(
new QuadraticBezierSegment(
new Point(200,200),
new Point(300,100),
true /* IsStroked */ ));
myPathGeometry.Figures.Add(pathFigure2);
// Display the PathGeometry.
Path myPath = new Path();
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1;
myPath.Data = myPathGeometry;
Dim myPathGeometry As New PathGeometry()
' Create a figure.
Dim pathFigure1 As New PathFigure()
pathFigure1.StartPoint = New Point(10,50)
pathFigure1.Segments.Add(New BezierSegment(New Point(100,0), New Point(200,200), New Point(300,100), True)) ' IsStroked
pathFigure1.Segments.Add(New LineSegment(New Point(400,100), True)) ' IsStroked
pathFigure1.Segments.Add(New ArcSegment(New Point(200,100), New Size(50,50), 45, True, SweepDirection.Clockwise, True)) ' IsStroked - IsLargeArc
myPathGeometry.Figures.Add(pathFigure1)
' Create another figure.
Dim pathFigure2 As New PathFigure()
pathFigure2.StartPoint = New Point(10,100)
Dim polyLinePointArray() As Point = { New Point(50, 100), New Point(50, 150)}
Dim myPolyLineSegment As New PolyLineSegment()
myPolyLineSegment.Points = New PointCollection(polyLinePointArray)
pathFigure2.Segments.Add(myPolyLineSegment)
pathFigure2.Segments.Add(New QuadraticBezierSegment(New Point(200,200), New Point(300,100), True)) ' IsStroked
myPathGeometry.Figures.Add(pathFigure2)
' Display the PathGeometry.
Dim myPath As New Path()
myPath.Stroke = Brushes.Black
myPath.StrokeThickness = 1
myPath.Data = myPathGeometry
StreamGeometry
Al igual que la PathGeometry clase , StreamGeometry define una forma geométrica compleja que puede contener curvas, arcos y líneas. A diferencia de , PathGeometryel contenido de un StreamGeometry no admite el enlace de datos, la animación o la modificación. Utilice un StreamGeometry cuando necesite describir una geometría compleja, pero no desee la carga adicional de soportar el enlace de datos, la animación o la modificación. Debido a su eficacia, la StreamGeometry clase es una buena opción para describir adornos.
Para obtener un ejemplo, vea Crear una forma mediante streamGeometry.
Sintaxis de marcado de ruta
Los tipos PathGeometry y StreamGeometry soportan una sintaxis de atributo del Lenguaje de Marcas de Aplicación Extensible (XAML) mediante una serie especial de comandos de movimiento y dibujo. Para obtener más información, consulte Sintaxis de marcado de ruta.
Geometrías compuestas
Los objetos de geometría compuestos se pueden crear usando un GeometryGroup, un CombinedGeometry, o llamando al método estático GeometryCombine.
El CombinedGeometry objeto y el Combine método realizan una operación booleana para combinar el área definida por dos geometrías. Geometry los objetos que no tienen área se descartan. Solo se pueden combinar dos Geometry objetos (aunque estas dos geometrías también pueden ser geometrías compuestas).
La GeometryGroup clase crea una amalgama de los Geometry objetos que contiene sin fusionar sus áreas. Cualquier número de Geometry objetos se puede agregar a un GeometryGroup. Para obtener un ejemplo, vea Crear una forma compuesta.
Dado que no realizan una operación de combinación, el uso GeometryGroup de objetos proporciona ventajas de rendimiento sobre el uso CombinedGeometry de objetos o el Combine método .
Geometrías combinadas
La sección anterior mencionó el CombinedGeometry objeto y el Combine método combinan el área definida por las geometrías que contienen. La GeometryCombineMode enumeración especifica cómo se combinan las geometrías. Los valores posibles para la GeometryCombineMode propiedad son: Union, Intersect, Excludey Xor.
En el ejemplo siguiente, se define un CombinedGeometry con un modo de combinación Unión. Tanto Geometry1 como y Geometry2 se definen como círculos del mismo radio, pero con centros desplazados por 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>
En el ejemplo siguiente, se define un CombinedGeometry con un modo de combinar de Xor. Tanto Geometry1 como y Geometry2 se definen como círculos del mismo radio, pero con centros desplazados por 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>
Para obtener ejemplos adicionales, vea Crear una forma compuesta y Crear una geometría combinada.
Características de Freezable
Dado que hereda de la Freezable clase , la clase proporciona varias características especiales: Geometry los objetos se pueden declarar como Geometry, compartidos entre varios objetos, hecho de solo lectura para mejorar el rendimiento, clonado y hecho seguro para subprocesos. Para obtener más información sobre las distintas características proporcionadas por Freezable objetos, vea Objetos Freezable: Información General.
Otras características de geometría
La Geometry clase también proporciona métodos de utilidad útiles, como los siguientes:
FillContains : determina si la geometría contiene otro Geometry.
StrokeContains - Determina si el trazo de un Geometry contiene un punto especificado.
Consulte la Geometry clase para obtener una lista completa de sus métodos.
Consulte también
.NET Desktop feedback