如何:创建三次方贝塞尔曲线
此示例演示如何创建三次方贝塞尔曲线。 若要创建三次方贝塞尔曲线,请使用 PathGeometry、PathFigure 和 BezierSegment 类。 若要显示所生成的几何图形,请使用 Path 元素,或将该元素与 GeometryDrawing 或 DrawingContext 一起使用。 在下面的示例中,三次方贝塞尔曲线从 (10,100) 绘制到 (300,100)。 该曲线具有 (100,0) 和 (200,200) 两个控制点。
示例
[xaml]
在Extensible Application Markup Language (XAML) 中,可以使用缩写标记语法来描述路径。
<Path Stroke="Black" StrokeThickness="1"
Data="M 10,100 C 100,0 200,200 300,100" />
[xaml]
在XAML 中,还可以使用对象标记来绘制三次方贝塞尔曲线。 下面的示例与前面的 XAML 示例是等效的。
<Path Stroke="Black" StrokeThickness="1">
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigureCollection>
<PathFigure StartPoint="10,100">
<PathFigure.Segments>
<PathSegmentCollection>
<BezierSegment Point1="100,0" Point2="200,200" Point3="300,100" />
</PathSegmentCollection>
</PathFigure.Segments>
</PathFigure>
</PathFigureCollection>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
此示例摘自一个更大的示例;有关完整示例,请参见 Geometries Sample(几何图形示例)。