Compartir a través de


Cómo: Crear un arco elíptico

En este ejemplo se muestra cómo dibujar un arco elíptico. Para crear un arco elíptico, use las clases PathGeometry, PathFigure y ArcSegment.

Ejemplo

En los ejemplos siguientes, se dibuja un arco elíptico de (10,100) a (200,100). El arco tiene un valor Size de 100 por 50 píxeles independientes del dispositivo, un valor RotationAngle de 45 grados, un valor IsLargeArc de true y un valor SweepDirection de Counterclockwise.

En el lenguaje XAML, se puede utilizar la sintaxis de atributo para describir un trazado.

<Path Stroke="Black" StrokeThickness="1"  
  Data="M 10,100 A 100,50 45 1 0 200,100" />

Tenga en cuenta que esta sintaxis de atributo crea realmente un elemento StreamGeometry versión más ligera de PathGeometry. Para obtener más información, consulte la página Sintaxis de marcado de trazados.

En XAML, también se puede dibujar un arco elíptico mediante el uso explícito de etiquetas de objeto. A continuación se muestra un equivalente al marcado XAML anterior.

<Path Stroke="Black" StrokeThickness="1">
  <Path.Data>
    <PathGeometry>
      <PathGeometry.Figures>
        <PathFigureCollection>
          <PathFigure StartPoint="10,100">
            <PathFigure.Segments>
              <PathSegmentCollection>
                <ArcSegment Size="100,50" RotationAngle="45" IsLargeArc="True" SweepDirection="CounterClockwise" Point="200,100" />
              </PathSegmentCollection>
            </PathFigure.Segments>
          </PathFigure>
        </PathFigureCollection>
      </PathGeometry.Figures>
    </PathGeometry>
  </Path.Data>
</Path>

Este ejemplo forma parte de un ejemplo mayor. Para ver el ejemplo completo, consulte el ejemplo de geometrías.

Vea también