PolyBezierSegment 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示一条或多条三次方贝塞尔曲线。
public ref class PolyBezierSegment sealed : System::Windows::Media::PathSegment
public sealed class PolyBezierSegment : System.Windows.Media.PathSegment
type PolyBezierSegment = class
inherit PathSegment
Public NotInheritable Class PolyBezierSegment
Inherits PathSegment
- 继承
示例
以下示例演示如何使用 绘制两个 PolyBezierSegment 立方贝塞尔曲线。
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel>
<Canvas>
<Path Stroke="Black" StrokeThickness="1">
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigureCollection>
<!-- The StartPoint specifies the starting point of the first curve. -->
<PathFigure StartPoint="10,100">
<PathFigure.Segments>
<PathSegmentCollection>
<!-- The PolyBezierSegment specifies two cubic Bezier curves.
The first curve is from 10,100 (start point specified above)
to 300,100 with a control point of 0,0 and another control
point of 200,0. The second curve is from 300,100
(end of the last curve) to 600,100 with a control point of 300,0
and another control point of 400,0. -->
<PolyBezierSegment Points="0,0 200,0 300,100 300,0 400,0 600,100" />
</PathSegmentCollection>
</PathFigure.Segments>
</PathFigure>
</PathFigureCollection>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
</Canvas>
</StackPanel>
</Page>
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
namespace SDKSample
{
public partial class PolyBezierSegmentExample : Page
{
public PolyBezierSegmentExample()
{
// Create a PathFigure to be used for the PathGeometry of myPath.
PathFigure myPathFigure = new PathFigure();
// Set the starting point for the PathFigure specifying that the
// geometry starts at point 10,100.
myPathFigure.StartPoint = new Point(10, 100);
// Create a PointCollection that holds the Points used to specify
// the points of the PolyBezierSegment below.
PointCollection myPointCollection = new PointCollection(6);
myPointCollection.Add(new Point(0, 0));
myPointCollection.Add(new Point(200, 0));
myPointCollection.Add(new Point(300, 100));
myPointCollection.Add(new Point(300, 0));
myPointCollection.Add(new Point(400, 0));
myPointCollection.Add(new Point(600, 100));
// The PolyBezierSegment specifies two cubic Bezier curves.
// The first curve is from 10,100 (start point specified by the PathFigure)
// to 300,100 with a control point of 0,0 and another control point
// of 200,0. The second curve is from 300,100 (end of the last curve) to
// 600,100 with a control point of 300,0 and another control point of 400,0.
PolyBezierSegment myBezierSegment = new PolyBezierSegment();
myBezierSegment.Points = myPointCollection;
PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
myPathSegmentCollection.Add(myBezierSegment);
myPathFigure.Segments = myPathSegmentCollection;
PathFigureCollection myPathFigureCollection = new PathFigureCollection();
myPathFigureCollection.Add(myPathFigure);
PathGeometry myPathGeometry = new PathGeometry();
myPathGeometry.Figures = myPathFigureCollection;
// Create a path to draw a geometry with.
Path myPath = new Path();
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1;
// specify the shape (quadratic Bezier curve) of the path using the StreamGeometry.
myPath.Data = myPathGeometry;
// Add path shape to the UI.
StackPanel mainPanel = new StackPanel();
mainPanel.Children.Add(myPath);
this.Content = mainPanel;
}
}
}
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Media
Imports System.Windows.Shapes
Namespace SDKSample
Partial Public Class PolyBezierSegmentExample
Inherits Page
Public Sub New()
' Create a PathFigure to be used for the PathGeometry of myPath.
Dim myPathFigure As New PathFigure()
' Set the starting point for the PathFigure specifying that the
' geometry starts at point 10,100.
myPathFigure.StartPoint = New Point(10, 100)
' Create a PointCollection that holds the Points used to specify
' the points of the PolyBezierSegment below.
Dim myPointCollection As New PointCollection(6)
myPointCollection.Add(New Point(0, 0))
myPointCollection.Add(New Point(200, 0))
myPointCollection.Add(New Point(300, 100))
myPointCollection.Add(New Point(300, 0))
myPointCollection.Add(New Point(400, 0))
myPointCollection.Add(New Point(600, 100))
' The PolyBezierSegment specifies two cubic Bezier curves.
' The first curve is from 10,100 (start point specified by the PathFigure)
' to 300,100 with a control point of 0,0 and another control point
' of 200,0. The second curve is from 300,100 (end of the last curve) to
' 600,100 with a control point of 300,0 and another control point of 400,0.
Dim myBezierSegment As New PolyBezierSegment()
myBezierSegment.Points = myPointCollection
Dim myPathSegmentCollection As New PathSegmentCollection()
myPathSegmentCollection.Add(myBezierSegment)
myPathFigure.Segments = myPathSegmentCollection
Dim myPathFigureCollection As New PathFigureCollection()
myPathFigureCollection.Add(myPathFigure)
Dim myPathGeometry As New PathGeometry()
myPathGeometry.Figures = myPathFigureCollection
' Create a path to draw a geometry with.
Dim myPath As New Path()
myPath.Stroke = Brushes.Black
myPath.StrokeThickness = 1
' specify the shape (quadratic Bezier curve) of the path using the StreamGeometry.
myPath.Data = myPathGeometry
' Add path shape to the UI.
Dim mainPanel As New StackPanel()
mainPanel.Children.Add(myPath)
Me.Content = mainPanel
End Sub
End Class
End Namespace
注解
PathFigure使用 对象存储PolyBezierSegment对象和其他段。
三次方贝塞尔曲线由四个点定义:一个起点、一个终点和两个控制点。 通过将 PolyBezierSegment 属性设置为 Points 点集合,指定一个或多个三次立方贝塞尔曲线。 对于集合中的每三个点,第一个和第二个点指定曲线的两个控制点,第三个点指定终点。 请注意,没有指定曲线的起点,因为起点与最后一段的终点相同。
三次方贝塞尔曲线的两个控制点的行为类似于磁体,吸引本应是直线的部分,并产生曲线。 第一个控制点影响曲线的起始部分;第二个控制点影响曲线的结束部分。 请注意,曲线不一定通过任一控制点;每个控制点都将其部分的线条向自身移动,但不能通过自身移动。
构造函数
PolyBezierSegment() |
初始化 PolyBezierSegment 类的新实例。 |
PolyBezierSegment(IEnumerable<Point>, Boolean) |
使用指定的 PolyBezierSegment 对象集合和一个指定是否为线段描边的值,来初始化 Point 类的一个新实例。 |
字段
PointsProperty |
标识 Points 依赖项属性。 |
属性
CanFreeze |
获取一个值,该值指示是否可将对象变为不可修改。 (继承自 Freezable) |
DependencyObjectType |
DependencyObjectType获取包装此实例的 CLR 类型的 。 (继承自 DependencyObject) |
Dispatcher |
获取与此 Dispatcher 关联的 DispatcherObject。 (继承自 DispatcherObject) |
HasAnimatedProperties |
获取一个值,该值指示一个或多个 AnimationClock 对象是否与此对象的任何依赖项属性相关联。 (继承自 Animatable) |
IsFrozen |
获取一个值,该值指示对象当前是否可修改。 (继承自 Freezable) |
IsSealed |
获取一个值,该值指示此实例当前是否为密封的(只读)。 (继承自 DependencyObject) |
IsSmoothJoin |
获取或设置一个值,该值指示在用 PathSegment 为此 PathSegment 和上一个 Pen 描边时是否将它们之间的联接视为角。 (继承自 PathSegment) |
IsStroked |
获取或设置一个值,该值指示是否为该段描边。 (继承自 PathSegment) |
Points |
获取或设置定义此 PointCollection 对象的 PolyBezierSegment。 |
方法
事件
Changed |
在修改 Freezable 或其包含的对象时发生。 (继承自 Freezable) |