Export (0) Print
Expand All

GraphicsPath.AddBezier Method (Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)

Adds a cubic Bézier curve to the current figure.

Namespace:  System.Drawing.Drawing2D
Assembly:  System.Drawing (in System.Drawing.dll)

public void AddBezier(
	int x1,
	int y1,
	int x2,
	int y2,
	int x3,
	int y3,
	int x4,
	int y4
)

Parameters

x1
Type: System.Int32

The x-coordinate of the starting point of the curve.

y1
Type: System.Int32

The y-coordinate of the starting point of the curve.

x2
Type: System.Int32

The x-coordinate of the first control point for the curve.

y2
Type: System.Int32

The y-coordinate of the first control point for the curve.

x3
Type: System.Int32

The x-coordinate of the second control point for the curve.

y3
Type: System.Int32

The y-coordinate of the second control point for the curve.

x4
Type: System.Int32

The x-coordinate of the endpoint of the curve.

y4
Type: System.Int32

The y-coordinate of the endpoint of the curve.

The cubic curve is constructed from the first point to the fourth point by using the second and third points as control points.

If there is a previous line or curve segment in the figure, a line is added to connect the endpoint of the previous segment to the starting point of the cubic curve.

The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, an OnPaint event object. The code performs the following actions:

  • Creates a path.

  • Adds a cubic Bézier curve defined by the points (50, 50), (70, 0), (100, 120), and (150, 50) to the path.

  • Closes the curve.

  • Draws the path to screen.

private void AddBezierExample(PaintEventArgs e)
{

    // Create a new Path.
    GraphicsPath myPath = new GraphicsPath();

    // Call AddBezier.
    myPath.StartFigure();
    myPath.AddBezier(50, 50, 70, 0, 100, 120, 150, 50);

    // Close the curve.
    myPath.CloseFigure();

    // Draw the path to screen.
    e.Graphics.DrawPath(new Pen(Color.Red, 2), myPath);
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft