Compartir a través de


Cómo: Crear una forma mediante pathGeometry

En este ejemplo se muestra cómo crear una forma mediante la PathGeometry clase . PathGeometry Los objetos se componen de uno o varios PathFigure objetos; cada PathFigure uno representa una "figura" o forma diferente. Cada PathFigure uno se compone de uno o varios PathSegment objetos, cada uno de los cuales representa una parte conectada de la figura o forma. Los tipos de segmento incluyen LineSegment, ArcSegmenty BezierSegment.

Ejemplo

En el ejemplo siguiente se usa un PathGeometry para crear un triángulo. PathGeometry se muestra mediante un Path elemento .

<Path Stroke="Black" StrokeThickness="1">
  <Path.Data>
    <PathGeometry>
      <PathGeometry.Figures>
        <PathFigureCollection>
          <PathFigure IsClosed="True" StartPoint="10,100">
            <PathFigure.Segments>
              <PathSegmentCollection>
                <LineSegment Point="100,100" />
                <LineSegment Point="100,50" />
              </PathSegmentCollection>
            </PathFigure.Segments>
          </PathFigure>
        </PathFigureCollection>
      </PathGeometry.Figures>
    </PathGeometry>
  </Path.Data>
</Path>

En la ilustración siguiente se muestra la forma creada en el ejemplo anterior.

wcpsdk_graphicsmm_pathgeometry_triangleUn
Un triángulo creado con pathGeometry

En el ejemplo anterior se mostró cómo crear una forma relativamente sencilla, un triángulo. PathGeometry También se puede usar para crear formas más complejas, incluidos arcos y curvas. Para obtener ejemplos, vea Crear un arco elíptico, Crear una curva bézier cúbica y Crear una curva bezier cuadrática.

Este ejemplo forma parte del ejemplo más grande; para obtener el ejemplo completo, consulte el ejemplo de geometrías.

Consulte también