如何:创建椭圆弧

更新:2007 年 11 月

此示例演示如何绘制椭圆弧。若要创建椭圆弧,请使用 PathGeometryPathFigureArcSegment 类。

示例

在下面的示例中,椭圆弧是从 (10,100) 到 (200,100) 绘制而成的。该弧的 Size 为 100 x 50 个与设备无关的像素、RotationAngle 为 45 度、IsLargeArc 设置为 true、SweepDirectionCounterclockwise

xaml

在可扩展应用程序标记语言 (XAML) 中,可以使用属性语法来描述路径。

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

xaml

(请注意,此属性语法实际上创建一个 StreamGeometryPathGeometry 的轻量版本)。有关更多信息,请参见路径标记语法页。)

在 XAML 中,还可以通过显式使用对象标记来绘制椭圆弧。下面的内容等效于前面的 XAML 标记。

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

此示例摘自一个更大的示例。有关完整示例,请参见几何图形示例

请参见

任务

如何:创建二次贝塞尔曲线

如何:创建三次方贝塞尔曲线