Export (0) Print
Expand All

BezierSegment Class

Represents a cubic Bezier curve drawn between two points.

Namespace: System.Windows.Media
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public sealed class BezierSegment : PathSegment
public final class BezierSegment extends PathSegment
public final class BezierSegment extends PathSegment
<BezierSegment .../>

Use a PathFigure object to store BezierSegment objects and other segments.

A cubic Bezier curve is defined by four points: a start point, an end point (Point3), and two control points (Point1 and Point2). The BezierSegment class does not contain a property for the starting point of the curve; it only defines the end point. The beginning point of the curve is the current point of the PathFigure to which the BezierSegment is added.

The two control points of a cubic Bezier curve behave like magnets, attracting portions of what would otherwise be a straight line toward themselves and producing a curve. The first control point, Point1, affects the beginning portion of the curve; the second control point, Point2, affects the ending portion of the curve. Note that the curve doesn't necessarily pass through either of the control points; each control point moves its portion of the line toward itself, but not through itself.

Freezable Features

A BezierSegment is a type of Freezable object. For information about Freezable features, such as freezing and cloning, see the Freezable Objects Overview.

This example shows how to create a cubic Bezier curve. To create a cubic Bezier curve, use the PathGeometry, PathFigure, and BezierSegment classes. To display the resulting geometry, use a Path element, or use it with a GeometryDrawing or a DrawingContext. In the following examples, a cubic Bezier curve is drawn from (10, 100) to (300, 100). The curve has control points of (100, 0) and (200, 200).

In Extensible Application Markup Language (XAML), you may use abbreviated markup syntax to describe a path.

<Path Stroke="Black" StrokeThickness="1"  
  Data="M 10,100 C 100,0 200,200 300,100" />

In XAML, you can also draw a cubic Bezier curve using object tags. The following is equivalent to the previous XAML example.

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

This example is part of larger sample; for the complete sample, see the Geometries Sample.

More Code

How to: Create a Quadratic Bezier Curve

This example shows how to create a quadratic Bezier curve. To create a quadratic Bezier curve, use the PathGeometry, PathFigure, and QuadraticBezierSegment classes.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft